| 1 | import * as cloudbuild from "@distilled.cloud/gcp/cloudbuild_v2"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | import * as Layer from "effect/Layer"; |
| 4 | import { AccessReadToken } from "./AccessReadToken.ts"; |
| 5 | import { makeRepositoryHttpBinding } from "./BindingHttp.ts"; |
| 6 | |
| 7 | /** |
| 8 | * HTTP implementation of {@link AccessReadToken}. |
| 9 | * |
| 10 | * @layer |
| 11 | * @provides GCP.CloudBuild.AccessReadToken |
| 12 | */ |
| 13 | export const AccessReadTokenHttp = Layer.effect( |
| 14 | AccessReadToken, |
| 15 | Effect.gen(function* () { |
| 16 | const access = |
| 17 | yield* cloudbuild.accessReadTokenProjectsLocationsConnectionsRepositories; |
| 18 | return yield* makeRepositoryHttpBinding< |
| 19 | cloudbuild.AccessReadTokenProjectsLocationsConnectionsRepositoriesRequest, |
| 20 | cloudbuild.FetchReadTokenResponse, |
| 21 | cloudbuild.AccessReadTokenProjectsLocationsConnectionsRepositoriesError |
| 22 | >({ |
| 23 | tag: "GCP.CloudBuild.AccessReadToken", |
| 24 | iam: { role: "roles/cloudbuild.readTokenAccessor" }, |
| 25 | operation: (input) => |
| 26 | access({ |
| 27 | ...input, |
| 28 | body: input.body ?? {}, |
| 29 | }), |
| 30 | }); |
| 31 | }), |
| 32 | ); |