| 1 | import type * as kvs from "@distilled.cloud/aws/cloudfront-keyvaluestore"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { KeyValueStore } from "./KeyValueStore.ts"; |
| 5 | |
| 6 | export interface UpdateKeysRequest extends Omit< |
| 7 | kvs.UpdateKeysRequest, |
| 8 | "KvsARN" |
| 9 | > {} |
| 10 | |
| 11 | /** |
| 12 | * Runtime binding for `cloudfront-keyvaluestore:UpdateKeys`. |
| 13 | * |
| 14 | * Puts and/or deletes multiple keys in the bound KeyValueStore's data plane |
| 15 | * as a single all-or-nothing batch. Writes use optimistic concurrency: pass |
| 16 | * the store's current `ETag` as `IfMatch` (from |
| 17 | * {@link DescribeKeyValueStore} or a previous write's response). Provide the |
| 18 | * implementation with `Effect.provide(AWS.CloudFront.UpdateKeysHttp)`. |
| 19 | * ### Writing KeyValueStore Data |
| 20 | * **Example:** Batch Put + Delete |
| 21 | * ```typescript |
| 22 | * // init — bind the operations to the store |
| 23 | * const describeStore = yield* CloudFront.DescribeKeyValueStore(store); |
| 24 | * const updateKeys = yield* CloudFront.UpdateKeys(store); |
| 25 | * |
| 26 | * // runtime |
| 27 | * const meta = yield* describeStore({}); |
| 28 | * yield* updateKeys({ |
| 29 | * IfMatch: meta.ETag, |
| 30 | * Puts: [{ Key: "routes:/", Value: "/index.html" }], |
| 31 | * Deletes: [{ Key: "routes:/legacy" }], |
| 32 | * }); |
| 33 | * ``` |
| 34 | * |
| 35 | * @binding |
| 36 | */ |
| 37 | export interface UpdateKeys extends Binding.Service< |
| 38 | UpdateKeys, |
| 39 | "AWS.CloudFront.UpdateKeys", |
| 40 | ( |
| 41 | store: KeyValueStore, |
| 42 | ) => Effect.Effect< |
| 43 | ( |
| 44 | request: UpdateKeysRequest, |
| 45 | ) => Effect.Effect<kvs.UpdateKeysResponse, kvs.UpdateKeysError> |
| 46 | > |
| 47 | > {} |
| 48 | |
| 49 | export const UpdateKeys = Binding.Service<UpdateKeys>( |
| 50 | "AWS.CloudFront.UpdateKeys", |
| 51 | ); |