@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 28 lines 1.07 KB
Raw
1 import * as apigee from "@distilled.cloud/gcp/apigee_v1";
2 import * as Effect from "effect/Effect";
3 import * as Stream from "effect/Stream";
4 import { GcpEnvironment } from "../Environment.ts";
5 import { orgParent, organizationOf } from "./names.ts";
6 import { hasOwnershipMarker } from "./ownership.ts";
7
8 export const currentOrganization = (explicit: string | undefined, existing?: string) =>
9 Effect.gen(function* () {
10 const env = yield* GcpEnvironment.current;
11 return organizationOf(explicit, existing, env.project);
12 });
13
14 export const listOwnedInstances = (organization: string) =>
15 apigee.listOrganizationsInstances
16 .pages({
17 parent: orgParent(organization),
18 pageSize: 1000,
19 })
20 .pipe(
21 Stream.flatMap((page) => Stream.fromIterable(page.instances ?? [])),
22 Stream.filter((instance) => hasOwnershipMarker(instance.description)),
23 Stream.runCollect,
24 Effect.map((chunk) => Array.from(chunk)),
25 Effect.catchTag(["NotFound", "ApigeeResourceNotFound"], () =>
26 Effect.succeed([] as apigee.GoogleCloudApigeeV1Instance[]),
27 ),
28 );