| 1 | import * as scheduler from "@distilled.cloud/gcp/cloudscheduler_v1"; |
| 2 | import { Credentials } from "@distilled.cloud/gcp/Credentials"; |
| 3 | import * as Layer from "effect/Layer"; |
| 4 | import * as HttpClient from "effect/http/HttpClient"; |
| 5 | import { makeJobHttpBinding } from "./BindingHttp.ts"; |
| 6 | import { RunJob } from "./RunJob.ts"; |
| 7 | |
| 8 | /** |
| 9 | * HTTP implementation of {@link RunJob}. |
| 10 | * |
| 11 | * @layer |
| 12 | * @provides GCP.CloudScheduler.RunJob |
| 13 | */ |
| 14 | export const RunJobHttp: Layer.Layer< |
| 15 | RunJob, |
| 16 | never, |
| 17 | Credentials | HttpClient.HttpClient |
| 18 | > = Layer.effect( |
| 19 | RunJob, |
| 20 | makeJobHttpBinding< |
| 21 | scheduler.RunProjectsLocationsJobsRequest, |
| 22 | scheduler.Job, |
| 23 | scheduler.RunProjectsLocationsJobsError |
| 24 | >({ |
| 25 | tag: "GCP.CloudScheduler.RunJob", |
| 26 | // Cloud Scheduler has no resource-level IAM. |
| 27 | iam: { role: "roles/cloudscheduler.jobRunner" }, |
| 28 | operation: scheduler.runProjectsLocationsJobs, |
| 29 | }), |
| 30 | ); |