| 1 | import type * as sitewise from "@distilled.cloud/aws/iotsitewise"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | |
| 5 | /** |
| 6 | * Request for {@link ExecuteQuery}. |
| 7 | */ |
| 8 | export interface ExecuteQueryRequest extends sitewise.ExecuteQueryRequest {} |
| 9 | |
| 10 | /** |
| 11 | * Runtime binding for `iotsitewise:ExecuteQuery` — run a SiteWise SQL |
| 12 | * query across all asset models, assets, measurements, metrics, and |
| 13 | * transforms in the account from a deployed Lambda or Task. |
| 14 | * |
| 15 | * The query surface is account-wide, so the binding grants the action on |
| 16 | * `Resource: ["*"]` and takes no bound resource. |
| 17 | * |
| 18 | * ### Querying Asset Data with SQL |
| 19 | * Provide the `ExecuteQueryHttp` implementation layer on the Function |
| 20 | * effect, bind in the init phase (no resource argument), then call the |
| 21 | * returned client at runtime. |
| 22 | * |
| 23 | * **Example:** Find an Asset by Name |
| 24 | * ```typescript |
| 25 | * // init — account-level binding takes no resource |
| 26 | * const executeQuery = yield* AWS.IoTSiteWise.ExecuteQuery(); |
| 27 | * |
| 28 | * // runtime |
| 29 | * const { rows } = yield* executeQuery({ |
| 30 | * queryStatement: |
| 31 | * "SELECT asset_id, asset_name FROM asset WHERE asset_name = 'Pump1'", |
| 32 | * }); |
| 33 | * // on the Function effect: |
| 34 | * // .pipe(Effect.provide(AWS.IoTSiteWise.ExecuteQueryHttp)) |
| 35 | * ``` |
| 36 | * |
| 37 | * @binding |
| 38 | */ |
| 39 | export interface ExecuteQuery extends Binding.Service< |
| 40 | ExecuteQuery, |
| 41 | "AWS.IoTSiteWise.ExecuteQuery", |
| 42 | () => Effect.Effect< |
| 43 | ( |
| 44 | request: ExecuteQueryRequest, |
| 45 | ) => Effect.Effect< |
| 46 | sitewise.ExecuteQueryResponse, |
| 47 | sitewise.ExecuteQueryError |
| 48 | > |
| 49 | > |
| 50 | > {} |
| 51 | export const ExecuteQuery = Binding.Service<ExecuteQuery>( |
| 52 | "AWS.IoTSiteWise.ExecuteQuery", |
| 53 | ); |