| 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 { User } from "./User.ts"; |
| 6 | |
| 7 | export interface GetUserRequest extends Omit< |
| 8 | sqladmin.GetUsersRequest, |
| 9 | "instance" | "project" | "name" |
| 10 | > {} |
| 11 | |
| 12 | /** |
| 13 | * Runtime binding for Cloud SQL `users.get`. |
| 14 | * |
| 15 | * Bind this operation to a {@link User} in a Function/Action init phase. |
| 16 | * Provide {@link GetUserHttp}. |
| 17 | * |
| 18 | * Grants `roles/cloudsql.viewer` on the project, unconditioned: Cloud SQL |
| 19 | * has no instance-level IAM policy, `cloudsql.users.get` is not matched by |
| 20 | * an IAM Condition on the instance name, and no narrower predefined role |
| 21 | * carries it. |
| 22 | * |
| 23 | * ### Observing Users |
| 24 | * **Example:** Read the bound user |
| 25 | * ```typescript |
| 26 | * const getUser = yield* GCP.SQL.GetUser(appUser); |
| 27 | * const live = yield* getUser(); |
| 28 | * ``` |
| 29 | * |
| 30 | * @binding |
| 31 | * @category SQL |
| 32 | */ |
| 33 | export interface GetUser extends Binding.Service< |
| 34 | GetUser, |
| 35 | "GCP.SQL.GetUser", |
| 36 | ( |
| 37 | user: User, |
| 38 | ) => Effect.Effect< |
| 39 | ( |
| 40 | request?: GetUserRequest, |
| 41 | ) => Effect.Effect<sqladmin.User, sqladmin.GetUsersError, RuntimeContext> |
| 42 | > |
| 43 | > {} |
| 44 | |
| 45 | export const GetUser = Binding.Service<GetUser>("GCP.SQL.GetUser"); |