| 1 | import type * as appsignals from "@distilled.cloud/aws/application-signals"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { ServiceLevelObjective } from "./ServiceLevelObjective.ts"; |
| 5 | |
| 6 | /** |
| 7 | * `BatchGetServiceLevelObjectiveBudgetReport` request with `SloIds` |
| 8 | * injected from the bound {@link ServiceLevelObjective}. |
| 9 | */ |
| 10 | export interface GetBudgetReportRequest extends Omit< |
| 11 | appsignals.BatchGetServiceLevelObjectiveBudgetReportInput, |
| 12 | "SloIds" |
| 13 | > {} |
| 14 | |
| 15 | /** |
| 16 | * Runtime binding for |
| 17 | * `application-signals:BatchGetServiceLevelObjectiveBudgetReport`, scoped |
| 18 | * to one {@link ServiceLevelObjective}. |
| 19 | * |
| 20 | * Retrieves the bound SLO's error-budget report — health indicator, |
| 21 | * attainment, and remaining budget — at the requested timestamp. Provide |
| 22 | * the implementation with |
| 23 | * `Effect.provide(AWS.ApplicationSignals.BatchGetServiceLevelObjectiveBudgetReportHttp)`. |
| 24 | * ### Reading SLOs |
| 25 | * **Example:** Check the SLO's Error Budget |
| 26 | * ```typescript |
| 27 | * // init — bind the operation to the SLO |
| 28 | * const getBudgetReport = |
| 29 | * yield* AWS.ApplicationSignals.BatchGetServiceLevelObjectiveBudgetReport(slo); |
| 30 | * |
| 31 | * // runtime — the SLO's ARN is injected as SloIds |
| 32 | * const result = yield* getBudgetReport({ Timestamp: new Date() }); |
| 33 | * const report = result.Reports[0]; |
| 34 | * yield* Effect.log(`${report?.BudgetStatus}: ${report?.Attainment}%`); |
| 35 | * ``` |
| 36 | * |
| 37 | * @binding |
| 38 | */ |
| 39 | export interface BatchGetServiceLevelObjectiveBudgetReport extends Binding.Service< |
| 40 | BatchGetServiceLevelObjectiveBudgetReport, |
| 41 | "AWS.ApplicationSignals.BatchGetServiceLevelObjectiveBudgetReport", |
| 42 | ( |
| 43 | slo: ServiceLevelObjective, |
| 44 | ) => Effect.Effect< |
| 45 | ( |
| 46 | request: GetBudgetReportRequest, |
| 47 | ) => Effect.Effect< |
| 48 | appsignals.BatchGetServiceLevelObjectiveBudgetReportOutput, |
| 49 | appsignals.BatchGetServiceLevelObjectiveBudgetReportError |
| 50 | > |
| 51 | > |
| 52 | > {} |
| 53 | |
| 54 | export const BatchGetServiceLevelObjectiveBudgetReport = |
| 55 | Binding.Service<BatchGetServiceLevelObjectiveBudgetReport>( |
| 56 | "AWS.ApplicationSignals.BatchGetServiceLevelObjectiveBudgetReport", |
| 57 | ); |