| 1 | import type * as budgets from "@distilled.cloud/aws/budgets"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { Budget } from "./Budget.ts"; |
| 5 | |
| 6 | /** |
| 7 | * Request for {@link DescribeNotificationsForBudget} — the bound budget's |
| 8 | * `AccountId` and `BudgetName` are injected automatically. |
| 9 | */ |
| 10 | export interface DescribeNotificationsForBudgetRequest extends Omit< |
| 11 | budgets.DescribeNotificationsForBudgetRequest, |
| 12 | "AccountId" | "BudgetName" |
| 13 | > {} |
| 14 | |
| 15 | /** |
| 16 | * Runtime binding for `budgets:ViewBudget` via |
| 17 | * `DescribeNotificationsForBudget`. |
| 18 | * |
| 19 | * Bind this operation to a {@link Budget} to list its alert thresholds and |
| 20 | * their alarm state (`NotificationState` is `ALARM` once a threshold has been |
| 21 | * crossed) — e.g. to gate expensive work on whether any budget alert has |
| 22 | * fired. Provide the implementation with |
| 23 | * `Effect.provide(AWS.Budgets.DescribeNotificationsForBudgetHttp)`. |
| 24 | * ### Reading Budget Alerts |
| 25 | * **Example:** Check Whether Any Alert Is in Alarm |
| 26 | * ```typescript |
| 27 | * // init — bind the operation to the budget |
| 28 | * const notifications = yield* AWS.Budgets.DescribeNotificationsForBudget(budget); |
| 29 | * |
| 30 | * // runtime |
| 31 | * const result = yield* notifications(); |
| 32 | * const inAlarm = (result.Notifications ?? []).some( |
| 33 | * (n) => n.NotificationState === "ALARM", |
| 34 | * ); |
| 35 | * ``` |
| 36 | * |
| 37 | * @binding |
| 38 | */ |
| 39 | export interface DescribeNotificationsForBudget extends Binding.Service< |
| 40 | DescribeNotificationsForBudget, |
| 41 | "AWS.Budgets.DescribeNotificationsForBudget", |
| 42 | ( |
| 43 | budget: Budget, |
| 44 | ) => Effect.Effect< |
| 45 | ( |
| 46 | request?: DescribeNotificationsForBudgetRequest, |
| 47 | ) => Effect.Effect< |
| 48 | budgets.DescribeNotificationsForBudgetResponse, |
| 49 | budgets.DescribeNotificationsForBudgetError |
| 50 | > |
| 51 | > |
| 52 | > {} |
| 53 | |
| 54 | export const DescribeNotificationsForBudget = |
| 55 | Binding.Service<DescribeNotificationsForBudget>( |
| 56 | "AWS.Budgets.DescribeNotificationsForBudget", |
| 57 | ); |