| 1 | import type * as cur from "@distilled.cloud/aws/cost-and-usage-report-service"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | |
| 5 | /** |
| 6 | * Request for {@link DescribeReportDefinitions} — pagination knobs only. |
| 7 | */ |
| 8 | export interface DescribeReportDefinitionsRequest |
| 9 | extends cur.DescribeReportDefinitionsRequest {} |
| 10 | |
| 11 | /** |
| 12 | * Runtime binding for `cur:DescribeReportDefinitions`. |
| 13 | * |
| 14 | * Lists the Cost and Usage Report definitions in the account — each entry |
| 15 | * carries the report's delivery bucket/prefix, granularity, format, and last |
| 16 | * delivery status, so a Lambda can discover where its billing data lands |
| 17 | * before reading the report files from S3. Account-level operation (the API |
| 18 | * enumerates every definition), so the binding takes no resource argument. |
| 19 | * Provide the implementation with |
| 20 | * `Effect.provide(AWS.CostAndUsageReport.DescribeReportDefinitionsHttp)`. |
| 21 | * ### Reading Report Definitions |
| 22 | * **Example:** Find a report's delivery location |
| 23 | * ```typescript |
| 24 | * // init — account-level binding, no resource argument |
| 25 | * const describeReportDefinitions = |
| 26 | * yield* AWS.CostAndUsageReport.DescribeReportDefinitions(); |
| 27 | * |
| 28 | * // runtime |
| 29 | * const { ReportDefinitions } = yield* describeReportDefinitions(); |
| 30 | * const report = ReportDefinitions?.find((r) => r.ReportName === "costs"); |
| 31 | * yield* Effect.log(`delivered to s3://${report?.S3Bucket}/${report?.S3Prefix}`); |
| 32 | * ``` |
| 33 | * |
| 34 | * @binding |
| 35 | */ |
| 36 | export interface DescribeReportDefinitions extends Binding.Service< |
| 37 | DescribeReportDefinitions, |
| 38 | "AWS.CostAndUsageReport.DescribeReportDefinitions", |
| 39 | () => Effect.Effect< |
| 40 | ( |
| 41 | request?: DescribeReportDefinitionsRequest, |
| 42 | ) => Effect.Effect< |
| 43 | cur.DescribeReportDefinitionsResponse, |
| 44 | cur.DescribeReportDefinitionsError |
| 45 | > |
| 46 | > |
| 47 | > {} |
| 48 | |
| 49 | export const DescribeReportDefinitions = |
| 50 | Binding.Service<DescribeReportDefinitions>( |
| 51 | "AWS.CostAndUsageReport.DescribeReportDefinitions", |
| 52 | ); |