1import type * as iotdata from "@distilled.cloud/aws/iot-data-plane";
2import type * as Effect from "effect/Effect";
3import * as Binding from "../../Binding.ts";
4import type { Thing } from "./Thing.ts";
5
6export interface GetThingShadowRequest extends Omit<
7 iotdata.GetThingShadowRequest,
8 "thingName"
9> {}
10
11/**
12 * Runtime binding for the IoT data-plane `GetThingShadow` operation (IAM
13 * action `iot:GetThingShadow`).
14 *
15 * Bind it to a {@link Thing} to read the thing's device shadow — the thing
16 * name is injected automatically. The response `payload` is a byte Stream;
17 * decode it with `Stream.decodeText` + `Stream.mkString`. Provide the
18 * implementation with `Effect.provide(AWS.IoT.GetThingShadowHttp)`.
19 * ### Device Shadows
20 * **Example:** Read the Classic Shadow
21 * ```typescript
22 * const getShadow = yield* AWS.IoT.GetThingShadow(thing);
23 *
24 * const state = yield* getShadow().pipe(
25 * Effect.flatMap((result) =>
26 * Stream.mkString(Stream.decodeText(result.payload!)),
27 * ),
28 * );
29 * ```
30 *
31 * **Example:** Read a Named Shadow
32 * ```typescript
33 * const result = yield* getShadow({ shadowName: "telemetry" });
34 * ```
35 *
36 * @binding
37 */
38export interface GetThingShadow extends Binding.Service<
39 GetThingShadow,
40 "AWS.IoT.GetThingShadow",
41 (
42 thing: Thing,
43 ) => Effect.Effect<
44 (
45 request?: GetThingShadowRequest,
46 ) => Effect.Effect<
47 iotdata.GetThingShadowResponse,
48 iotdata.GetThingShadowError
49 >
50 >
51> {}
52
53export const GetThingShadow = Binding.Service<GetThingShadow>(
54 "AWS.IoT.GetThingShadow",
55);