sailfork / t3code-github / .repos/ alchemy-effect/ packages/ aws/ src/ CostExplorer/ GetAnomalies.ts

import type * as ce from "@distilled.cloud/aws/cost-explorer";
import * as Binding from "alchemy/Binding";
import type * as Effect from "effect/Effect";
import type { AnomalyMonitor } from "./AnomalyMonitor.ts";

/**
 * Request for {@link GetAnomalies} — the bound monitor's ARN is
 * injected automatically.
 */
export interface GetAnomaliesRequest extends Omit<ce.GetAnomaliesRequest, "MonitorArn"> {}

/**
 * Runtime binding for `ce:GetAnomalies`.
 *
 * Retrieve the cost anomalies a monitor detected during a date
 * interval (available for up to 90 days). Provide the implementation with
 * `Effect.provide(AWS.CostExplorer.GetAnomaliesHttp)`.
 * ### Anomaly Detection at Runtime
 * **Example:** List a Monitor's Anomalies
 * ```typescript
 * // init — bind the operation to the monitor
 * const getAnomalies = yield* AWS.CostExplorer.GetAnomalies(monitor);
 *
 * // runtime
 * const result = yield* getAnomalies({
 *   DateInterval: { StartDate: "2026-06-01" },
 * });
 * const anomalies = result.Anomalies;
 * ```
 *
 * @binding
 */
export interface GetAnomalies extends Binding.Service<
  GetAnomalies,
  "AWS.CostExplorer.GetAnomalies",
  (
    monitor: AnomalyMonitor,
  ) => Effect.Effect<
    (request: GetAnomaliesRequest) => Effect.Effect<ce.GetAnomaliesResponse, ce.GetAnomaliesError>
  >
> {}

export const GetAnomalies = Binding.Service<GetAnomalies>("AWS.CostExplorer.GetAnomalies");