| 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 PutKeyRequest extends Omit<kvs.PutKeyRequest, "KvsARN"> {} |
| 7 | |
| 8 | /** |
| 9 | * Runtime binding for `cloudfront-keyvaluestore:PutKey`. |
| 10 | * |
| 11 | * Creates or replaces a single key in the bound KeyValueStore's data plane. |
| 12 | * Writes use optimistic concurrency: pass the store's current `ETag` as |
| 13 | * `IfMatch` (from {@link DescribeKeyValueStore} or a previous write's |
| 14 | * response). Provide the implementation with |
| 15 | * `Effect.provide(AWS.CloudFront.PutKeyHttp)`. |
| 16 | * ### Writing KeyValueStore Data |
| 17 | * **Example:** Put a Key |
| 18 | * ```typescript |
| 19 | * // init — bind the operations to the store |
| 20 | * const describeStore = yield* CloudFront.DescribeKeyValueStore(store); |
| 21 | * const putKey = yield* CloudFront.PutKey(store); |
| 22 | * |
| 23 | * // runtime |
| 24 | * const meta = yield* describeStore({}); |
| 25 | * const res = yield* putKey({ |
| 26 | * Key: "routes:/about", |
| 27 | * Value: "/about.html", |
| 28 | * IfMatch: meta.ETag, |
| 29 | * }); |
| 30 | * // res.ETag is the store's new entity tag |
| 31 | * ``` |
| 32 | * |
| 33 | * @binding |
| 34 | */ |
| 35 | export interface PutKey extends Binding.Service< |
| 36 | PutKey, |
| 37 | "AWS.CloudFront.PutKey", |
| 38 | ( |
| 39 | store: KeyValueStore, |
| 40 | ) => Effect.Effect< |
| 41 | ( |
| 42 | request: PutKeyRequest, |
| 43 | ) => Effect.Effect<kvs.PutKeyResponse, kvs.PutKeyError> |
| 44 | > |
| 45 | > {} |
| 46 | |
| 47 | export const PutKey = Binding.Service<PutKey>("AWS.CloudFront.PutKey"); |