1import * as cloudwatch from "@distilled.cloud/aws/cloudwatch";
2import * as Effect from "effect/Effect";
3import * as Binding from "../../Binding.ts";
4import type { AlarmResource } from "./binding-common.ts";
5
6export interface DescribeAlarmsRequest extends Omit<
7 cloudwatch.DescribeAlarmsInput,
8 "AlarmNames"
9> {}
10
11type AlarmResources = [AlarmResource, ...AlarmResource[]];
12
13/**
14 * Runtime binding for `cloudwatch:DescribeAlarms` — read the current state
15 * and configuration of the bound alarms. Bind it to one or more
16 * {@link Alarm} / {@link CompositeAlarm} resources; the alarm names are
17 * injected automatically.
18 *
19 * Provide `CloudWatch.DescribeAlarmsHttp` on the hosting Lambda Function to
20 * satisfy the requirement.
21 * ### Reading Alarm State
22 * **Example:** Read the State of a Bound Alarm
23 * ```typescript
24 * const alarm = yield* CloudWatch.Alarm("HighErrors", {
25 * MetricName: "Errors",
26 * Namespace: "AWS/Lambda",
27 * Statistic: "Sum",
28 * Period: 60,
29 * EvaluationPeriods: 1,
30 * Threshold: 1,
31 * ComparisonOperator: "GreaterThanOrEqualToThreshold",
32 * });
33 *
34 * // init — grants cloudwatch:DescribeAlarms on the alarm
35 * const describeAlarms = yield* AWS.CloudWatch.DescribeAlarms(alarm);
36 *
37 * // runtime
38 * const result = yield* describeAlarms();
39 * const state = result.MetricAlarms?.[0]?.StateValue; // "OK" | "ALARM" | ...
40 * ```
41 *
42 * @binding
43 */
44export interface DescribeAlarms extends Binding.Service<
45 DescribeAlarms,
46 "AWS.CloudWatch.DescribeAlarms",
47 (
48 ...alarms: AlarmResources
49 ) => Effect.Effect<
50 (
51 request?: DescribeAlarmsRequest,
52 ) => Effect.Effect<cloudwatch.DescribeAlarmsOutput, any>
53 >
54> {}
55
56export const DescribeAlarms = Binding.Service<DescribeAlarms>(
57 "AWS.CloudWatch.DescribeAlarms",
58);