1import type * as iotw from "@distilled.cloud/aws/iot-wireless";
2import type * as Effect from "effect/Effect";
3import * as Binding from "../../Binding.ts";
4import type { WirelessDevice } from "./WirelessDevice.ts";
5
6/**
7 * Request for {@link GetResourcePosition}. The bound device's id and the
8 * `WirelessDevice` resource type are injected automatically, leaving
9 * nothing else to supply.
10 */
11export interface GetResourcePositionRequest extends Omit<
12 iotw.GetResourcePositionRequest,
13 "ResourceIdentifier" | "ResourceType"
14> {}
15
16/**
17 * Runtime binding for `iotwireless:GetResourcePosition` — read the bound
18 * wireless device's position (WGS84, returned as a GeoJSON payload stream)
19 * from a deployed Lambda or Task.
20 *
21 * ### Reading Device Position
22 * Provide the `GetResourcePositionHttp` implementation layer on the
23 * Function effect, bind the device in the init phase, then call the
24 * returned client at runtime. The `GeoJsonPayload` is a byte `Stream` —
25 * decode it to a string with `Stream.mkString(Stream.decodeText(...))`.
26 *
27 * **Example:** Read the Device's GeoJSON Position
28 * ```typescript
29 * // init
30 * const getPosition = yield* AWS.IoTWireless.GetResourcePosition(device);
31 *
32 * // runtime
33 * const { GeoJsonPayload } = yield* getPosition();
34 * const geoJson = GeoJsonPayload === undefined
35 * ? undefined
36 * : yield* Stream.mkString(Stream.decodeText(GeoJsonPayload));
37 * // on the Function effect:
38 * // .pipe(Effect.provide(AWS.IoTWireless.GetResourcePositionHttp))
39 * ```
40 *
41 * @binding
42 */
43export interface GetResourcePosition extends Binding.Service<
44 GetResourcePosition,
45 "AWS.IoTWireless.GetResourcePosition",
46 (
47 device: WirelessDevice,
48 ) => Effect.Effect<
49 (
50 request?: GetResourcePositionRequest,
51 ) => Effect.Effect<
52 iotw.GetResourcePositionResponse,
53 iotw.GetResourcePositionError
54 >
55 >
56> {}
57export const GetResourcePosition = Binding.Service<GetResourcePosition>(
58 "AWS.IoTWireless.GetResourcePosition",
59);