@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 06:00 UTC

main
ts 41 lines 1.42 KB
Raw
1 import * as privateca from "@distilled.cloud/gcp/privateca_v1";
2 import * as Effect from "effect/Effect";
3 import * as Layer from "effect/Layer";
4 import * as GCPBindings from "../GCPBindings.ts";
5 import { grantFor } from "../HttpBinding.ts";
6 import type { CaPool } from "./CaPool.ts";
7 import { FetchCaCerts, type FetchCaCertsRequest } from "./FetchCaCerts.ts";
8
9 /**
10 * HTTP implementation of {@link FetchCaCerts}.
11 *
12 * @layer
13 * @provides GCP.PrivateCA.FetchCaCerts
14 */
15 export const FetchCaCertsHttp = Layer.effect(
16 FetchCaCerts,
17 Effect.gen(function* () {
18 const bind = yield* GCPBindings.Bind;
19 const fetchCaCertsProjectsLocationsCaPools = yield* GCPBindings.withCredentials(
20 privateca.fetchCaCertsProjectsLocationsCaPools,
21 );
22 return Effect.fn(function* <P extends CaPool>(pool: P) {
23 if (!globalThis.__ALCHEMY_RUNTIME__) {
24 yield* bind`GCP.PrivateCA.FetchCaCerts(${pool})`({
25 iam: [
26 grantFor({ role: "roles/privateca.poolReader", on: "privateca.caPool" }, pool.name),
27 ],
28 });
29 }
30 const name = yield* pool.name;
31 return Effect.fn(`GCP.PrivateCA.FetchCaCerts(${pool.LogicalId})`)(function* (
32 request?: FetchCaCertsRequest,
33 ) {
34 return yield* fetchCaCertsProjectsLocationsCaPools({
35 caPool: yield* name,
36 body: request?.requestId !== undefined ? { requestId: request.requestId } : {},
37 });
38 });
39 });
40 }),
41 );