| 1 | import * as ag from "@distilled.cloud/aws/api-gateway"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | import * as Layer from "effect/Layer"; |
| 4 | import { registerApiGatewayBinding } from "./BindingHttp.ts"; |
| 5 | import { UpdateApiKey, type UpdateApiKeyRequest } from "./UpdateApiKey.ts"; |
| 6 | |
| 7 | /** |
| 8 | * HTTP implementation of the {@link UpdateApiKey} binding. Grants |
| 9 | * `apigateway:PATCH` on `/apikeys/*` and calls the API with the host |
| 10 | * Function's credentials. |
| 11 | */ |
| 12 | export const UpdateApiKeyHttp = Layer.effect( |
| 13 | UpdateApiKey, |
| 14 | Effect.gen(function* () { |
| 15 | const updateApiKey = yield* ag.updateApiKey; |
| 16 | return Effect.fn(function* () { |
| 17 | yield* registerApiGatewayBinding({ |
| 18 | cap: "AWS.ApiGateway.UpdateApiKey", |
| 19 | target: "", |
| 20 | verb: "PATCH", |
| 21 | paths: (region) => [`arn:aws:apigateway:${region}::/apikeys/*`], |
| 22 | }); |
| 23 | return Effect.fn("AWS.ApiGateway.UpdateApiKey")(function* ( |
| 24 | request: UpdateApiKeyRequest, |
| 25 | ) { |
| 26 | return yield* updateApiKey(request); |
| 27 | }); |
| 28 | }); |
| 29 | }), |
| 30 | ); |