sailfork / t3code-github / .repos/ alchemy-effect/ packages/ aws/ src/ Synthetics/ GetCanary.ts

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

export interface GetCanaryRequest extends Omit<synthetics.GetCanaryRequest, "Name"> {}

/**
 * Runtime binding for `synthetics:GetCanary` — read the full configuration
 * and current status (state, last run, timeline) of the bound
 * {@link Canary}; the canary name is injected automatically.
 *
 * Provide `Synthetics.GetCanaryHttp` on the hosting Lambda Function to
 * satisfy the requirement.
 * ### Reading Canary Status
 * **Example:** Read the Canary's Current State
 * ```typescript
 * // init — grants synthetics:GetCanary on the canary
 * const getCanary = yield* AWS.Synthetics.GetCanary(canary);
 *
 * // runtime
 * const { Canary } = yield* getCanary();
 * const state = Canary?.Status?.State;
 * ```
 *
 * @binding
 */
export interface GetCanary extends Binding.Service<
  GetCanary,
  "AWS.Synthetics.GetCanary",
  (
    canary: Canary,
  ) => Effect.Effect<
    (
      request?: GetCanaryRequest,
    ) => Effect.Effect<synthetics.GetCanaryResponse, synthetics.GetCanaryError>
  >
> {}

export const GetCanary = Binding.Service<GetCanary>("AWS.Synthetics.GetCanary");