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