1import type * as ce from "@distilled.cloud/aws/cost-explorer";
2import type * as Effect from "effect/Effect";
3import * as Binding from "../../Binding.ts";
4
5/**
6 * Request for {@link GetCostAndUsage}.
7 */
8export interface GetCostAndUsageRequest extends ce.GetCostAndUsageRequest {}
9
10/**
11 * Runtime binding for `ce:GetCostAndUsage`.
12 *
13 * Query cost and usage metrics (`UnblendedCost`, `UsageQuantity`, …)
14 * filtered and grouped by dimension over a time range — the core Cost
15 * Explorer query. Provide the implementation with
16 * `Effect.provide(AWS.CostExplorer.GetCostAndUsageHttp)`.
17 * ### Querying Cost and Usage
18 * **Example:** Query Last Month's Unblended Cost
19 * ```typescript
20 * // init — account-level binding takes no resource
21 * const getCostAndUsage = yield* AWS.CostExplorer.GetCostAndUsage();
22 *
23 * // runtime
24 * const result = yield* getCostAndUsage({
25 * TimePeriod: { Start: "2026-06-01", End: "2026-07-01" },
26 * Granularity: "MONTHLY",
27 * Metrics: ["UnblendedCost"],
28 * });
29 * const total = result.ResultsByTime?.[0]?.Total?.UnblendedCost?.Amount;
30 * ```
31 *
32 * @binding
33 */
34export interface GetCostAndUsage extends Binding.Service<
35 GetCostAndUsage,
36 "AWS.CostExplorer.GetCostAndUsage",
37 () => Effect.Effect<
38 (
39 request: GetCostAndUsageRequest,
40 ) => Effect.Effect<ce.GetCostAndUsageResponse, ce.GetCostAndUsageError>
41 >
42> {}
43
44export const GetCostAndUsage = Binding.Service<GetCostAndUsage>(
45 "AWS.CostExplorer.GetCostAndUsage",
46);