sailfork / t3code-github / .repos/ alchemy-effect/ packages/ gcp/ src/ Spanner/ GetInstance.ts

import type * as spanner from "@distilled.cloud/gcp/spanner_v1";
import * as Binding from "alchemy/Binding";
import type { RuntimeContext } from "alchemy/RuntimeContext";
import type * as Effect from "effect/Effect";
import type { Instance } from "./Instance.ts";

export interface GetInstanceRequest extends Omit<spanner.GetProjectsInstancesRequest, "name"> {}

/**
 * Runtime binding for Cloud Spanner `instances.get`.
 *
 * Bind this operation to an {@link Instance} in a Function/Action init
 * phase. Provide {@link GetInstanceHttp}.
 *
 * ### Observing Instances
 * **Example:** Read the bound instance
 * ```typescript
 * const getInstance = yield* GCP.Spanner.GetInstance(instance);
 * const live = yield* getInstance();
 * ```
 *
 * @binding
 * @category Spanner
 */
export interface GetInstance extends Binding.Service<
  GetInstance,
  "GCP.Spanner.GetInstance",
  (
    instance: Instance,
  ) => Effect.Effect<
    (
      request?: GetInstanceRequest,
    ) => Effect.Effect<spanner.Instance, spanner.GetProjectsInstancesError, RuntimeContext>
  >
> {}

export const GetInstance = Binding.Service<GetInstance>("GCP.Spanner.GetInstance");