The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import * as binaryauthorization from "@distilled.cloud/gcp/binaryauthorization_v1"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | import * as Layer from "effect/Layer"; |
| 4 | import * as GCPBindings from "../GCPBindings.ts"; |
| 5 | import { GetPlatformsPolicy, type GetPlatformsPolicyRequest } from "./GetPlatformsPolicy.ts"; |
| 6 | import type { PlatformsPolicy } from "./PlatformsPolicy.ts"; |
| 7 | |
| 8 | /** |
| 9 | * HTTP implementation of {@link GetPlatformsPolicy}. |
| 10 | * |
| 11 | * @layer |
| 12 | * @provides GCP.BinaryAuthorization.GetPlatformsPolicy |
| 13 | */ |
| 14 | export const GetPlatformsPolicyHttp = Layer.effect( |
| 15 | GetPlatformsPolicy, |
| 16 | Effect.gen(function* () { |
| 17 | const bind = yield* GCPBindings.Bind; |
| 18 | const getPolicy = yield* GCPBindings.withCredentials( |
| 19 | binaryauthorization.getProjectsPlatformsPolicies, |
| 20 | ); |
| 21 | return Effect.fn(function* (policy: PlatformsPolicy) { |
| 22 | if (!globalThis.__ALCHEMY_RUNTIME__) { |
| 23 | yield* bind`GCP.BinaryAuthorization.GetPlatformsPolicy(${policy})`({ |
| 24 | // Platform policies have no resource-level IAM. |
| 25 | iam: [{ role: "roles/binaryauthorization.policyViewer" }], |
| 26 | }); |
| 27 | } |
| 28 | const name = yield* policy.name; |
| 29 | return Effect.fn(`GCP.BinaryAuthorization.GetPlatformsPolicy(${policy.LogicalId})`)( |
| 30 | function* (request?: GetPlatformsPolicyRequest) { |
| 31 | return yield* getPolicy({ |
| 32 | ...request, |
| 33 | name: yield* name, |
| 34 | }); |
| 35 | }, |
| 36 | ); |
| 37 | }); |
| 38 | }), |
| 39 | ); |