| 1 | import type * as emrc from "@distilled.cloud/aws/emr-containers"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { VirtualCluster } from "./VirtualCluster.ts"; |
| 5 | |
| 6 | /** |
| 7 | * Runtime binding for `emr-containers:StartJobRun`. |
| 8 | * |
| 9 | * Submits a Spark job run to the bound {@link VirtualCluster}. The virtual |
| 10 | * cluster ID is injected from the binding; pass a `jobDriver` + |
| 11 | * `executionRoleArn` + `releaseLabel` directly, or a `jobTemplateId` (+ |
| 12 | * `jobTemplateParameters`) to start from a {@link JobTemplate}. Returns the |
| 13 | * new job run's `id`/`arn` for use with `DescribeJobRun` / `CancelJobRun`. |
| 14 | * Provide the implementation with |
| 15 | * `Effect.provide(AWS.EMRContainers.StartJobRunHttp)`. |
| 16 | * ### Running Jobs |
| 17 | * **Example:** Start A Templated Spark Job |
| 18 | * ```typescript |
| 19 | * // init — bind the operation to the virtual cluster |
| 20 | * const startJobRun = yield* AWS.EMRContainers.StartJobRun(virtualCluster); |
| 21 | * |
| 22 | * // runtime |
| 23 | * const { id } = yield* startJobRun({ |
| 24 | * jobTemplateId: templateId, |
| 25 | * jobTemplateParameters: { EntryPoint: "s3://my-bucket/etl.py" }, |
| 26 | * }); |
| 27 | * yield* Effect.log(`job run started: ${id}`); |
| 28 | * ``` |
| 29 | * |
| 30 | * @binding |
| 31 | */ |
| 32 | export interface StartJobRun extends Binding.Service< |
| 33 | StartJobRun, |
| 34 | "AWS.EMRContainers.StartJobRun", |
| 35 | (virtualCluster: VirtualCluster) => Effect.Effect< |
| 36 | ( |
| 37 | request: Omit< |
| 38 | emrc.StartJobRunRequest, |
| 39 | "virtualClusterId" | "clientToken" |
| 40 | > & { |
| 41 | /** |
| 42 | * Idempotency token for the job run submission. |
| 43 | * @default auto-generated per call |
| 44 | */ |
| 45 | clientToken?: string; |
| 46 | }, |
| 47 | ) => Effect.Effect<emrc.StartJobRunResponse, emrc.StartJobRunError> |
| 48 | > |
| 49 | > {} |
| 50 | export const StartJobRun = Binding.Service<StartJobRun>( |
| 51 | "AWS.EMRContainers.StartJobRun", |
| 52 | ); |