The best way to control Claude Code, Codex and more from any computer or phone

main
ts 40 lines 1.24 KB
Raw
1 import type * as ag from "@distilled.cloud/aws/api-gateway";
2 import * as Binding from "alchemy/Binding";
3 import type * as Effect from "effect/Effect";
4 import type { UsagePlan } from "./UsagePlan.ts";
5
6 export interface GetUsageRequest extends Omit<ag.GetUsageRequest, "usagePlanId"> {}
7
8 /**
9 * Runtime binding for reading usage data of a {@link UsagePlan}
10 * (`apigateway:GET` on `/usageplans/{id}/usage`).
11 *
12 * Bind a usage plan inside a function runtime to meter per-key API
13 * consumption — the primitive for building billing or quota dashboards.
14 * Provide `ApiGateway.GetUsageHttp` on the Function effect to implement
15 * the binding.
16 *
17 * ### Metering usage
18 * **Example:** Read this month's usage for a key
19 * ```typescript
20 * // init
21 * const getUsage = yield* ApiGateway.GetUsage(plan);
22 *
23 * // runtime
24 * const usage = yield* getUsage({
25 * keyId,
26 * startDate: "2026-07-01",
27 * endDate: "2026-07-14",
28 * });
29 * ```
30 *
31 * @binding
32 */
33 export interface GetUsage extends Binding.Service<
34 GetUsage,
35 "AWS.ApiGateway.GetUsage",
36 <P extends UsagePlan>(
37 usagePlan: P,
38 ) => Effect.Effect<(request: GetUsageRequest) => Effect.Effect<ag.Usage, ag.GetUsageError>>
39 > {}
40 export const GetUsage = Binding.Service<GetUsage>("AWS.ApiGateway.GetUsage");