| 1 | import * as cloudwatch from "@distilled.cloud/aws/cloudwatch"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { AlarmResource } from "./binding-common.ts"; |
| 5 | |
| 6 | export interface DescribeAlarmContributorsRequest extends Omit< |
| 7 | cloudwatch.DescribeAlarmContributorsInput, |
| 8 | "AlarmName" |
| 9 | > {} |
| 10 | |
| 11 | /** |
| 12 | * Runtime binding for `cloudwatch:DescribeAlarmContributors` — list the |
| 13 | * time-series contributors currently in ALARM for a contributor-enabled |
| 14 | * metric-math alarm. Bind it to the {@link Alarm}; the alarm name is |
| 15 | * injected automatically. |
| 16 | * |
| 17 | * Provide `CloudWatch.DescribeAlarmContributorsHttp` on the hosting Lambda |
| 18 | * Function to satisfy the requirement. |
| 19 | * ### Reading Alarm State |
| 20 | * **Example:** List an Alarm's Contributors |
| 21 | * ```typescript |
| 22 | * // init — grants cloudwatch:DescribeAlarmContributors on the alarm |
| 23 | * const describeAlarmContributors = |
| 24 | * yield* AWS.CloudWatch.DescribeAlarmContributors(alarm); |
| 25 | * |
| 26 | * // runtime — plain metric alarms have no contributor data; the typed |
| 27 | * // errors let you treat that as an empty result |
| 28 | * const contributors = yield* describeAlarmContributors().pipe( |
| 29 | * Effect.map((r) => r.AlarmContributors ?? []), |
| 30 | * Effect.catchTag( |
| 31 | * ["ResourceNotFoundException", "ValidationException"], |
| 32 | * () => Effect.succeed([]), |
| 33 | * ), |
| 34 | * ); |
| 35 | * ``` |
| 36 | * |
| 37 | * @binding |
| 38 | */ |
| 39 | export interface DescribeAlarmContributors extends Binding.Service< |
| 40 | DescribeAlarmContributors, |
| 41 | "AWS.CloudWatch.DescribeAlarmContributors", |
| 42 | ( |
| 43 | alarm: AlarmResource, |
| 44 | ) => Effect.Effect< |
| 45 | ( |
| 46 | request?: DescribeAlarmContributorsRequest, |
| 47 | ) => Effect.Effect< |
| 48 | cloudwatch.DescribeAlarmContributorsOutput, |
| 49 | cloudwatch.DescribeAlarmContributorsError |
| 50 | > |
| 51 | > |
| 52 | > {} |
| 53 | |
| 54 | export const DescribeAlarmContributors = |
| 55 | Binding.Service<DescribeAlarmContributors>( |
| 56 | "AWS.CloudWatch.DescribeAlarmContributors", |
| 57 | ); |