| 1 | import type * as translate from "@distilled.cloud/aws/translate"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { Role } from "../IAM/Role.ts"; |
| 5 | |
| 6 | /** |
| 7 | * `StartTextTranslationJob` request with `DataAccessRoleArn` defaulting to |
| 8 | * the role the binding was constructed with. |
| 9 | */ |
| 10 | export interface StartTextTranslationJobRequest extends Omit< |
| 11 | translate.StartTextTranslationJobRequest, |
| 12 | "DataAccessRoleArn" | "ClientToken" |
| 13 | > { |
| 14 | /** |
| 15 | * IAM role Amazon Translate assumes to read the input documents from S3 |
| 16 | * and write the translated results. |
| 17 | * @default the data-access role bound via `StartTextTranslationJob(role)` |
| 18 | */ |
| 19 | DataAccessRoleArn?: string; |
| 20 | /** |
| 21 | * Idempotency token for the job. |
| 22 | * @default an auto-generated token |
| 23 | */ |
| 24 | ClientToken?: string; |
| 25 | } |
| 26 | |
| 27 | /** |
| 28 | * Runtime binding for `translate:StartTextTranslationJob` — start an |
| 29 | * asynchronous batch translation job over a collection of documents in S3. |
| 30 | * |
| 31 | * The binding is constructed with the **data-access role** (the IAM role |
| 32 | * Amazon Translate assumes to read the input documents and write results; |
| 33 | * its trust policy must allow `translate.amazonaws.com`). The role's ARN is |
| 34 | * injected as `DataAccessRoleArn` on every runtime request and the host is |
| 35 | * granted `iam:PassRole` on it alongside |
| 36 | * `translate:StartTextTranslationJob` (which has no resource-level IAM). |
| 37 | * Track the job with {@link DescribeTextTranslationJob} and stop it with |
| 38 | * {@link StopTextTranslationJob}. |
| 39 | * |
| 40 | * ### Batch Translation Jobs |
| 41 | * **Example:** Start a batch translation job |
| 42 | * ```typescript |
| 43 | * // deploy time — bind the Translate data-access role |
| 44 | * const startJob = yield* AWS.Translate.StartTextTranslationJob(dataAccessRole); |
| 45 | * |
| 46 | * // runtime |
| 47 | * const job = yield* startJob({ |
| 48 | * InputDataConfig: { S3Uri: "s3://my-bucket/input/", ContentType: "text/plain" }, |
| 49 | * OutputDataConfig: { S3Uri: "s3://my-bucket/output/" }, |
| 50 | * SourceLanguageCode: "en", |
| 51 | * TargetLanguageCodes: ["es"], |
| 52 | * }); |
| 53 | * // job.JobId, job.JobStatus === "SUBMITTED" |
| 54 | * ``` |
| 55 | * |
| 56 | * @binding |
| 57 | */ |
| 58 | export interface StartTextTranslationJob extends Binding.Service< |
| 59 | StartTextTranslationJob, |
| 60 | "AWS.Translate.StartTextTranslationJob", |
| 61 | <R extends Role>( |
| 62 | dataAccessRole: R, |
| 63 | ) => Effect.Effect< |
| 64 | ( |
| 65 | request: StartTextTranslationJobRequest, |
| 66 | ) => Effect.Effect< |
| 67 | translate.StartTextTranslationJobResponse, |
| 68 | translate.StartTextTranslationJobError |
| 69 | > |
| 70 | > |
| 71 | > {} |
| 72 | export const StartTextTranslationJob = Binding.Service<StartTextTranslationJob>( |
| 73 | "AWS.Translate.StartTextTranslationJob", |
| 74 | ); |