1import type * as dataproc from "@distilled.cloud/gcp/dataproc_v1";
2import type * as Effect from "effect/Effect";
3import * as Binding from "../../Binding.ts";
4import type { RuntimeContext } from "../../RuntimeContext.ts";
5import type { Cluster } from "./Cluster.ts";
6
7export interface SubmitJobRequest extends Omit<
8 dataproc.SubmitProjectsRegionsJobsRequest,
9 "projectId" | "region"
10> {}
11
12/**
13 * Runtime binding for Dataproc `jobs.submit`.
14 *
15 * Bind this operation to a {@link Cluster} in a Function/Action init
16 * phase. Provide {@link SubmitJobHttp}. The bound cluster is injected as
17 * `job.placement.clusterName` unless the request already sets one.
18 *
19 * ### Submitting Jobs
20 * **Example:** Run SparkPi on the bound cluster
21 * ```typescript
22 * const submitJob = yield* GCP.Dataproc.SubmitJob(cluster);
23 * const job = yield* submitJob({
24 * body: {
25 * job: {
26 * sparkJob: {
27 * mainClass: "org.apache.spark.examples.SparkPi",
28 * jarFileUris: [
29 * "file:///usr/lib/spark/examples/jars/spark-examples.jar",
30 * ],
31 * args: ["10"],
32 * },
33 * },
34 * },
35 * });
36 * ```
37 *
38 * @binding
39 * @category Dataproc
40 */
41export interface SubmitJob extends Binding.Service<
42 SubmitJob,
43 "GCP.Dataproc.SubmitJob",
44 (
45 cluster: Cluster,
46 ) => Effect.Effect<
47 (
48 request: SubmitJobRequest,
49 ) => Effect.Effect<
50 dataproc.Job,
51 dataproc.SubmitProjectsRegionsJobsError,
52 RuntimeContext
53 >
54 >
55> {}
56
57export const SubmitJob = Binding.Service<SubmitJob>("GCP.Dataproc.SubmitJob");