1import type * as ag from "@distilled.cloud/aws/api-gateway";
2import type * as Effect from "effect/Effect";
3import * as Binding from "../../Binding.ts";
4import type { UsagePlan } from "./UsagePlan.ts";
5
6export interface UpdateUsageRequest extends Omit<
7 ag.UpdateUsageRequest,
8 "usagePlanId"
9> {}
10
11/**
12 * Runtime binding for granting a temporary quota extension to an API key
13 * on a {@link UsagePlan} (`apigateway:PATCH` on
14 * `/usageplans/{id}/keys/{keyId}/usage`).
15 *
16 * Provide `ApiGateway.UpdateUsageHttp` on the Function effect to implement
17 * the binding.
18 *
19 * ### Metering usage
20 * **Example:** Extend a key's remaining quota
21 * ```typescript
22 * // init
23 * const updateUsage = yield* ApiGateway.UpdateUsage(plan);
24 *
25 * // runtime
26 * yield* updateUsage({
27 * keyId,
28 * patchOperations: [
29 * { op: "replace", path: "/remaining", value: "500" },
30 * ],
31 * });
32 * ```
33 *
34 * @binding
35 */
36export interface UpdateUsage extends Binding.Service<
37 UpdateUsage,
38 "AWS.ApiGateway.UpdateUsage",
39 <P extends UsagePlan>(
40 usagePlan: P,
41 ) => Effect.Effect<
42 (
43 request: UpdateUsageRequest,
44 ) => Effect.Effect<ag.Usage, ag.UpdateUsageError>
45 >
46> {}
47export const UpdateUsage = Binding.Service<UpdateUsage>(
48 "AWS.ApiGateway.UpdateUsage",
49);