sailfork / t3code-github / .repos/ alchemy-effect/ packages/ aws/ src/ InternetMonitor/ StartQuery.ts

import * as im from "@distilled.cloud/aws/internetmonitor";
import * as Binding from "alchemy/Binding";
import * as Effect from "effect/Effect";
import type { Monitor } from "./Monitor.ts";

export interface StartQueryRequest extends Omit<im.StartQueryInput, "MonitorName"> {}

/**
 * Runtime binding for `internetmonitor:StartQuery` — start a query against
 * the bound {@link Monitor}'s measurement data with the Internet Monitor
 * query interface; the monitor name is injected automatically.
 *
 * Provide `InternetMonitor.StartQueryHttp` on the hosting Lambda Function to
 * satisfy the requirement.
 * ### Querying Measurements
 * **Example:** Start a Measurements Query
 * ```typescript
 * // init — grants internetmonitor:StartQuery on the monitor
 * const startQuery = yield* AWS.InternetMonitor.StartQuery(monitor);
 *
 * // runtime
 * const { QueryId } = yield* startQuery({
 *   StartTime: new Date(Date.now() - 3_600_000),
 *   EndTime: new Date(),
 *   QueryType: "MEASUREMENTS",
 * });
 * ```
 *
 * @binding
 */
export interface StartQuery extends Binding.Service<
  StartQuery,
  "AWS.InternetMonitor.StartQuery",
  (
    monitor: Monitor,
  ) => Effect.Effect<
    (request: StartQueryRequest) => Effect.Effect<im.StartQueryOutput, im.StartQueryError>
  >
> {}

export const StartQuery = Binding.Service<StartQuery>("AWS.InternetMonitor.StartQuery");