| 1 | import * as im from "@distilled.cloud/aws/internetmonitor"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { Monitor } from "./Monitor.ts"; |
| 5 | |
| 6 | export interface GetQueryStatusRequest extends Omit< |
| 7 | im.GetQueryStatusInput, |
| 8 | "MonitorName" |
| 9 | > {} |
| 10 | |
| 11 | /** |
| 12 | * Runtime binding for `internetmonitor:GetQueryStatus` — check whether a |
| 13 | * query started on the bound {@link Monitor} is `QUEUED`, `RUNNING`, |
| 14 | * `SUCCEEDED`, `FAILED`, or `CANCELED`; the monitor name is injected |
| 15 | * automatically. |
| 16 | * |
| 17 | * Provide `InternetMonitor.GetQueryStatusHttp` on the hosting Lambda |
| 18 | * Function to satisfy the requirement. |
| 19 | * ### Querying Measurements |
| 20 | * **Example:** Poll a Query Until It Completes |
| 21 | * ```typescript |
| 22 | * // init — grants internetmonitor:GetQueryStatus on the monitor |
| 23 | * const getQueryStatus = yield* AWS.InternetMonitor.GetQueryStatus(monitor); |
| 24 | * |
| 25 | * // runtime |
| 26 | * const { Status } = yield* getQueryStatus({ QueryId: queryId }).pipe( |
| 27 | * Effect.repeat({ |
| 28 | * schedule: Schedule.spaced("2 seconds"), |
| 29 | * until: (r) => r.Status !== "QUEUED" && r.Status !== "RUNNING", |
| 30 | * times: 10, |
| 31 | * }), |
| 32 | * ); |
| 33 | * ``` |
| 34 | * |
| 35 | * @binding |
| 36 | */ |
| 37 | export interface GetQueryStatus extends Binding.Service< |
| 38 | GetQueryStatus, |
| 39 | "AWS.InternetMonitor.GetQueryStatus", |
| 40 | ( |
| 41 | monitor: Monitor, |
| 42 | ) => Effect.Effect< |
| 43 | ( |
| 44 | request: GetQueryStatusRequest, |
| 45 | ) => Effect.Effect<im.GetQueryStatusOutput, im.GetQueryStatusError> |
| 46 | > |
| 47 | > {} |
| 48 | |
| 49 | export const GetQueryStatus = Binding.Service<GetQueryStatus>( |
| 50 | "AWS.InternetMonitor.GetQueryStatus", |
| 51 | ); |