| 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 { DeleteApiKey, type DeleteApiKeyRequest } from "./DeleteApiKey.ts"; |
| 6 | |
| 7 | /** |
| 8 | * HTTP implementation of the {@link DeleteApiKey} binding. Grants |
| 9 | * `apigateway:DELETE` on `/apikeys/*` and calls the API with the host |
| 10 | * Function's credentials. |
| 11 | */ |
| 12 | export const DeleteApiKeyHttp = Layer.effect( |
| 13 | DeleteApiKey, |
| 14 | Effect.gen(function* () { |
| 15 | const deleteApiKey = yield* ag.deleteApiKey; |
| 16 | return Effect.fn(function* () { |
| 17 | yield* registerApiGatewayBinding({ |
| 18 | cap: "AWS.ApiGateway.DeleteApiKey", |
| 19 | target: "", |
| 20 | verb: "DELETE", |
| 21 | paths: (region) => [`arn:aws:apigateway:${region}::/apikeys/*`], |
| 22 | }); |
| 23 | return Effect.fn("AWS.ApiGateway.DeleteApiKey")(function* ( |
| 24 | request: DeleteApiKeyRequest, |
| 25 | ) { |
| 26 | return yield* deleteApiKey(request); |
| 27 | }); |
| 28 | }); |
| 29 | }), |
| 30 | ); |