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