| 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 GetObjectAttributesRequest extends Omit< |
| 8 | S3.GetObjectAttributesRequest, |
| 9 | "Bucket" |
| 10 | > {} |
| 11 | |
| 12 | /** |
| 13 | * Runtime binding for `s3:GetObjectAttributes`. |
| 14 | * |
| 15 | * Bind this operation to a bucket to get a callable that reads object |
| 16 | * metadata (size, ETag, checksum, storage class, object parts) without |
| 17 | * fetching the body — the bucket name is injected automatically and the |
| 18 | * object-read attribute actions are granted on the bucket's objects. Provide |
| 19 | * the implementation with `Effect.provide(AWS.S3.GetObjectAttributesHttp)`. |
| 20 | * ### Reading Objects |
| 21 | * **Example:** Read Object Size and ETag |
| 22 | * ```typescript |
| 23 | * const getObjectAttributes = yield* AWS.S3.GetObjectAttributes(bucket); |
| 24 | * |
| 25 | * const attrs = yield* getObjectAttributes({ |
| 26 | * Key: "reports/q3.csv", |
| 27 | * ObjectAttributes: ["ObjectSize", "ETag", "StorageClass"], |
| 28 | * }); |
| 29 | * ``` |
| 30 | * |
| 31 | * @binding |
| 32 | */ |
| 33 | export interface GetObjectAttributes extends Binding.Service< |
| 34 | GetObjectAttributes, |
| 35 | "AWS.S3.GetObjectAttributes", |
| 36 | ( |
| 37 | bucket: Bucket, |
| 38 | ) => Effect.Effect< |
| 39 | ( |
| 40 | request: GetObjectAttributesRequest, |
| 41 | ) => Effect.Effect< |
| 42 | S3.GetObjectAttributesOutput, |
| 43 | S3.GetObjectAttributesError |
| 44 | > |
| 45 | > |
| 46 | > {} |
| 47 | export const GetObjectAttributes = Binding.Service<GetObjectAttributes>( |
| 48 | "AWS.S3.GetObjectAttributes", |
| 49 | ); |