| 1 | import * as S3 from "@distilled.cloud/aws/s3"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | |
| 4 | import * as Binding from "../../Binding.ts"; |
| 5 | import type { Bucket } from "./Bucket.ts"; |
| 6 | |
| 7 | export interface PutObjectLegalHoldRequest extends Omit< |
| 8 | S3.PutObjectLegalHoldRequest, |
| 9 | "Bucket" |
| 10 | > {} |
| 11 | |
| 12 | /** |
| 13 | * Runtime binding for `s3:PutObjectLegalHold`. |
| 14 | * |
| 15 | * Bind this operation to a bucket to get a callable that applies or removes |
| 16 | * a legal hold on an object — the bucket name is injected automatically and |
| 17 | * `s3:PutObjectLegalHold` is granted on the bucket's objects. Requires a |
| 18 | * bucket created with `objectLockEnabled: true`. Provide the implementation |
| 19 | * with `Effect.provide(AWS.S3.PutObjectLegalHoldHttp)`. |
| 20 | * ### Object Lock |
| 21 | * **Example:** Place and Release a Legal Hold |
| 22 | * ```typescript |
| 23 | * const putObjectLegalHold = yield* AWS.S3.PutObjectLegalHold(bucket); |
| 24 | * |
| 25 | * yield* putObjectLegalHold({ |
| 26 | * Key: "records/1.json", |
| 27 | * LegalHold: { Status: "ON" }, |
| 28 | * }); |
| 29 | * // … later, release it so the object can be deleted |
| 30 | * yield* putObjectLegalHold({ |
| 31 | * Key: "records/1.json", |
| 32 | * LegalHold: { Status: "OFF" }, |
| 33 | * }); |
| 34 | * ``` |
| 35 | * |
| 36 | * @binding |
| 37 | */ |
| 38 | export interface PutObjectLegalHold extends Binding.Service< |
| 39 | PutObjectLegalHold, |
| 40 | "AWS.S3.PutObjectLegalHold", |
| 41 | ( |
| 42 | bucket: Bucket, |
| 43 | ) => Effect.Effect< |
| 44 | ( |
| 45 | request: PutObjectLegalHoldRequest, |
| 46 | ) => Effect.Effect<S3.PutObjectLegalHoldOutput, S3.PutObjectLegalHoldError> |
| 47 | > |
| 48 | > {} |
| 49 | export const PutObjectLegalHold = Binding.Service<PutObjectLegalHold>( |
| 50 | "AWS.S3.PutObjectLegalHold", |
| 51 | ); |