| 1 | import type * as location from "@distilled.cloud/aws/location"; |
| 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 | * `StartJob` request with `ExecutionRoleArn` injected from the bound |
| 8 | * execution role. |
| 9 | */ |
| 10 | export interface StartJobRequest extends Omit< |
| 11 | location.StartJobRequest, |
| 12 | "ExecutionRoleArn" |
| 13 | > {} |
| 14 | |
| 15 | /** |
| 16 | * Starts a Location batch metadata job (e.g. batch address validation over |
| 17 | * an S3 input file). |
| 18 | * |
| 19 | * Runtime binding for the `StartJob` operation (IAM action `geo:StartJob`). |
| 20 | * Bind the IAM {@link Role} Location assumes to read the S3 input and write |
| 21 | * the S3 output — its ARN is injected as `ExecutionRoleArn` and the host is |
| 22 | * additionally granted `iam:PassRole` on it. Jobs are named at runtime so |
| 23 | * the `geo:StartJob` grant is on `*`. Provide the implementation with |
| 24 | * `Effect.provide(AWS.Location.StartJobHttp)`. |
| 25 | * |
| 26 | * ### Managing Batch Jobs |
| 27 | * **Example:** Start a Batch Job |
| 28 | * ```typescript |
| 29 | * const startJob = yield* Location.StartJob(jobsRole); |
| 30 | * |
| 31 | * const job = yield* startJob({ |
| 32 | * Action: "ValidateAddress", |
| 33 | * InputOptions: { Format: "CSV", Location: "s3://my-bucket/addresses.csv" }, |
| 34 | * OutputOptions: { Format: "CSV", Location: "s3://my-bucket/results/" }, |
| 35 | * }); |
| 36 | * // job.JobId → poll with Location.GetJob |
| 37 | * ``` |
| 38 | * |
| 39 | * @binding |
| 40 | */ |
| 41 | export interface StartJob extends Binding.Service< |
| 42 | StartJob, |
| 43 | "AWS.Location.StartJob", |
| 44 | ( |
| 45 | executionRole: Role, |
| 46 | ) => Effect.Effect< |
| 47 | ( |
| 48 | request: StartJobRequest, |
| 49 | ) => Effect.Effect<location.StartJobResponse, location.StartJobError> |
| 50 | > |
| 51 | > {} |
| 52 | export const StartJob = Binding.Service<StartJob>("AWS.Location.StartJob"); |