sailfork / t3code-github / .repos/ alchemy-effect/ packages/ gcp/ src/ Compute/ StopInstance.ts

import type * as compute from "@distilled.cloud/gcp/compute_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 StopInstanceRequest extends Omit<
  compute.StopInstancesRequest,
  "instance" | "zone" | "project"
> {}

/**
 * Runtime binding for Compute Engine `instances.stop`.
 *
 * Bind this operation to an {@link Instance} in a Function/Action init phase.
 * Provide {@link StopInstanceHttp}.
 *
 * ### Instance Lifecycle Control
 * **Example:** Stop the bound instance
 * ```typescript
 * const stopInstance = yield* GCP.Compute.StopInstance(vm);
 * yield* stopInstance();
 * ```
 *
 * @binding
 * @category Compute
 */
export interface StopInstance extends Binding.Service<
  StopInstance,
  "GCP.Compute.StopInstance",
  (
    instance: Instance,
  ) => Effect.Effect<
    (
      request?: StopInstanceRequest,
    ) => Effect.Effect<compute.Operation, compute.StopInstancesError, RuntimeContext>
  >
> {}

export const StopInstance = Binding.Service<StopInstance>("GCP.Compute.StopInstance");