| 1 | import type * as sqladmin from "@distilled.cloud/gcp/sqladmin_v1"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { RuntimeContext } from "../../RuntimeContext.ts"; |
| 5 | import type { Instance } from "./Instance.ts"; |
| 6 | |
| 7 | export interface GetInstanceRequest extends Omit< |
| 8 | sqladmin.GetInstancesRequest, |
| 9 | "instance" | "project" |
| 10 | > {} |
| 11 | |
| 12 | /** |
| 13 | * Runtime binding for Cloud SQL `instances.get`. |
| 14 | * |
| 15 | * Bind this operation to an {@link Instance} in a Function/Action init |
| 16 | * phase. Provide {@link GetInstanceHttp}. |
| 17 | * |
| 18 | * Grants `roles/cloudsql.viewer` on the project under an IAM Condition |
| 19 | * naming only this instance (Cloud SQL has no instance-level IAM policy). |
| 20 | * |
| 21 | * ### Observing Instances |
| 22 | * **Example:** Read the bound instance |
| 23 | * ```typescript |
| 24 | * const getInstance = yield* GCP.SQL.GetInstance(db); |
| 25 | * const live = yield* getInstance(); |
| 26 | * ``` |
| 27 | * |
| 28 | * @binding |
| 29 | * @category SQL |
| 30 | */ |
| 31 | export interface GetInstance extends Binding.Service< |
| 32 | GetInstance, |
| 33 | "GCP.SQL.GetInstance", |
| 34 | ( |
| 35 | instance: Instance, |
| 36 | ) => Effect.Effect< |
| 37 | ( |
| 38 | request?: GetInstanceRequest, |
| 39 | ) => Effect.Effect< |
| 40 | sqladmin.DatabaseInstance, |
| 41 | sqladmin.GetInstancesError, |
| 42 | RuntimeContext |
| 43 | > |
| 44 | > |
| 45 | > {} |
| 46 | |
| 47 | export const GetInstance = Binding.Service<GetInstance>("GCP.SQL.GetInstance"); |