| 1 | import type * as TSW from "@distilled.cloud/aws/timestream-write"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { Table } from "./Table.ts"; |
| 5 | |
| 6 | export interface CreateBatchLoadTaskRequest extends Omit< |
| 7 | TSW.CreateBatchLoadTaskRequest, |
| 8 | "TargetDatabaseName" | "TargetTableName" |
| 9 | > {} |
| 10 | |
| 11 | /** |
| 12 | * Runtime binding for `timestream-write:CreateBatchLoadTask` — start a bulk |
| 13 | * CSV import from S3 into a Timestream {@link Table}. |
| 14 | * |
| 15 | * Bind the operation to the target table to get a callable with |
| 16 | * `TargetDatabaseName` and `TargetTableName` injected automatically; you |
| 17 | * supply the S3 data source, the report location, and the data model. The |
| 18 | * binding grants `timestream:CreateBatchLoadTask` on the table and its |
| 19 | * database; grant the host S3 read on the source bucket and write on the |
| 20 | * report bucket separately (e.g. via the S3 capability bindings). |
| 21 | * |
| 22 | * Provide `Timestream.CreateBatchLoadTaskHttp` on the Function to implement |
| 23 | * the binding. |
| 24 | * |
| 25 | * ### Batch Loading |
| 26 | * **Example:** Start a bulk CSV import |
| 27 | * ```typescript |
| 28 | * // init — bind the operation to the target table |
| 29 | * const createBatchLoadTask = yield* Timestream.CreateBatchLoadTask(table); |
| 30 | * |
| 31 | * // runtime — import CSV rows from S3 |
| 32 | * const task = yield* createBatchLoadTask({ |
| 33 | * DataSourceConfiguration: { |
| 34 | * DataSourceS3Configuration: { BucketName: "my-ingest-bucket", ObjectKeyPrefix: "metrics/" }, |
| 35 | * DataFormat: "CSV", |
| 36 | * }, |
| 37 | * ReportConfiguration: { |
| 38 | * ReportS3Configuration: { BucketName: "my-report-bucket" }, |
| 39 | * }, |
| 40 | * DataModelConfiguration: { DataModel: { TimeColumn: "time", TimeUnit: "MILLISECONDS", DimensionMappings: [{ SourceColumn: "host" }], MeasureNameColumn: "measure" } }, |
| 41 | * }); |
| 42 | * // task.TaskId identifies the import for Describe/Resume |
| 43 | * ``` |
| 44 | * |
| 45 | * @binding |
| 46 | */ |
| 47 | export interface CreateBatchLoadTask extends Binding.Service< |
| 48 | CreateBatchLoadTask, |
| 49 | "AWS.Timestream.CreateBatchLoadTask", |
| 50 | ( |
| 51 | table: Table, |
| 52 | ) => Effect.Effect< |
| 53 | ( |
| 54 | request: CreateBatchLoadTaskRequest, |
| 55 | ) => Effect.Effect< |
| 56 | TSW.CreateBatchLoadTaskResponse, |
| 57 | TSW.CreateBatchLoadTaskError | TSW.DescribeEndpointsError |
| 58 | > |
| 59 | > |
| 60 | > {} |
| 61 | |
| 62 | export const CreateBatchLoadTask = Binding.Service<CreateBatchLoadTask>( |
| 63 | "AWS.Timestream.CreateBatchLoadTask", |
| 64 | ); |