| 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 { ResumeJob } from "./ResumeJob.ts"; |
| 7 | |
| 8 | /** |
| 9 | * HTTP implementation of {@link ResumeJob}. |
| 10 | * |
| 11 | * Grants `roles/cloudscheduler.admin` on the project because it is the |
| 12 | * only predefined role with `cloudscheduler.jobs.enable`, and Cloud Scheduler |
| 13 | * supports neither per-job IAM policies nor IAM Conditions on |
| 14 | * `resource.name`. |
| 15 | * |
| 16 | * @layer |
| 17 | * @provides GCP.CloudScheduler.ResumeJob |
| 18 | */ |
| 19 | export const ResumeJobHttp: Layer.Layer< |
| 20 | ResumeJob, |
| 21 | never, |
| 22 | Credentials | HttpClient.HttpClient |
| 23 | > = Layer.effect( |
| 24 | ResumeJob, |
| 25 | makeJobHttpBinding< |
| 26 | scheduler.ResumeProjectsLocationsJobsRequest, |
| 27 | scheduler.Job, |
| 28 | scheduler.ResumeProjectsLocationsJobsError |
| 29 | >({ |
| 30 | tag: "GCP.CloudScheduler.ResumeJob", |
| 31 | iam: { role: "roles/cloudscheduler.admin" }, |
| 32 | operation: scheduler.resumeProjectsLocationsJobs, |
| 33 | }), |
| 34 | ); |