| 1 | import * as amp from "@distilled.cloud/aws/amp"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | import * as Layer from "effect/Layer"; |
| 4 | import * as Binding from "../../Binding.ts"; |
| 5 | import { isBindingHost } from "../Lambda/Function.ts"; |
| 6 | import { |
| 7 | ListWorkspaces, |
| 8 | type ListWorkspacesRequest, |
| 9 | } from "./ListWorkspaces.ts"; |
| 10 | |
| 11 | export const ListWorkspacesHttp = Layer.effect( |
| 12 | ListWorkspaces, |
| 13 | Effect.gen(function* () { |
| 14 | const listWorkspaces = yield* amp.listWorkspaces; |
| 15 | |
| 16 | return Effect.fn(function* () { |
| 17 | if (!globalThis.__ALCHEMY_RUNTIME__) { |
| 18 | const host = yield* Binding.Host; |
| 19 | if (isBindingHost(host)) { |
| 20 | yield* host.bind`Allow(${host}, AWS.AMP.ListWorkspaces())`({ |
| 21 | policyStatements: [ |
| 22 | { |
| 23 | Effect: "Allow", |
| 24 | Action: ["aps:ListWorkspaces"], |
| 25 | Resource: ["*"], |
| 26 | }, |
| 27 | ], |
| 28 | }); |
| 29 | } |
| 30 | } |
| 31 | return Effect.fn("AWS.AMP.ListWorkspaces")(function* ( |
| 32 | request?: ListWorkspacesRequest, |
| 33 | ) { |
| 34 | return yield* listWorkspaces(request ?? {}); |
| 35 | }); |
| 36 | }); |
| 37 | }), |
| 38 | ); |