1import * as S3 from "@distilled.cloud/aws/s3";
2import * as Effect from "effect/Effect";
3
4import * as Binding from "../../Binding.ts";
5import type { Bucket } from "./Bucket.ts";
6
7export interface PutObjectRetentionRequest extends Omit<
8 S3.PutObjectRetentionRequest,
9 "Bucket"
10> {}
11
12/**
13 * Runtime binding for `s3:PutObjectRetention`.
14 *
15 * Bind this operation to a bucket to get a callable that places an Object
16 * Lock retention configuration on an object — the bucket name is injected
17 * automatically and `s3:PutObjectRetention` is granted on the bucket's
18 * objects. Requires a bucket created with `objectLockEnabled: true`;
19 * bypassing a GOVERNANCE retention additionally requires
20 * `s3:BypassGovernanceRetention`. Provide the implementation with
21 * `Effect.provide(AWS.S3.PutObjectRetentionHttp)`.
22 * ### Object Lock
23 * **Example:** Retain an Object in GOVERNANCE Mode
24 * ```typescript
25 * const putObjectRetention = yield* AWS.S3.PutObjectRetention(bucket);
26 *
27 * yield* putObjectRetention({
28 * Key: "records/1.json",
29 * Retention: {
30 * Mode: "GOVERNANCE",
31 * RetainUntilDate: new Date(Date.now() + 24 * 60 * 60 * 1000),
32 * },
33 * });
34 * ```
35 *
36 * @binding
37 */
38export interface PutObjectRetention extends Binding.Service<
39 PutObjectRetention,
40 "AWS.S3.PutObjectRetention",
41 (
42 bucket: Bucket,
43 ) => Effect.Effect<
44 (
45 request: PutObjectRetentionRequest,
46 ) => Effect.Effect<S3.PutObjectRetentionOutput, S3.PutObjectRetentionError>
47 >
48> {}
49export const PutObjectRetention = Binding.Service<PutObjectRetention>(
50 "AWS.S3.PutObjectRetention",
51);