| 1 | import type * as codeconnections from "@distilled.cloud/aws/codeconnections"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { Connection } from "./Connection.ts"; |
| 5 | |
| 6 | /** |
| 7 | * Runtime binding for `codeconnections:GetConnection`. |
| 8 | * |
| 9 | * Bind this operation to a {@link Connection} to read the connection's live |
| 10 | * state — status (`PENDING`/`AVAILABLE`/`ERROR`), provider type, and owner — |
| 11 | * from inside a function runtime. Useful for workloads that gate work on the |
| 12 | * connection's OAuth handshake having been completed. Provide the |
| 13 | * implementation with `Effect.provide(AWS.CodeConnections.GetConnectionHttp)`. |
| 14 | * ### Inspecting a Connection |
| 15 | * **Example:** Gate on the Connection Being AVAILABLE |
| 16 | * ```typescript |
| 17 | * // init — bind the operation to the connection |
| 18 | * const getConnection = yield* AWS.CodeConnections.GetConnection(connection); |
| 19 | * |
| 20 | * // runtime |
| 21 | * const { Connection: live } = yield* getConnection(); |
| 22 | * if (live?.ConnectionStatus !== "AVAILABLE") { |
| 23 | * return yield* HttpServerResponse.text("handshake pending", { status: 409 }); |
| 24 | * } |
| 25 | * ``` |
| 26 | * |
| 27 | * @binding |
| 28 | */ |
| 29 | export interface GetConnection extends Binding.Service< |
| 30 | GetConnection, |
| 31 | "AWS.CodeConnections.GetConnection", |
| 32 | ( |
| 33 | connection: Connection, |
| 34 | ) => Effect.Effect< |
| 35 | () => Effect.Effect< |
| 36 | codeconnections.GetConnectionOutput, |
| 37 | codeconnections.GetConnectionError |
| 38 | > |
| 39 | > |
| 40 | > {} |
| 41 | |
| 42 | export const GetConnection = Binding.Service<GetConnection>( |
| 43 | "AWS.CodeConnections.GetConnection", |
| 44 | ); |