sailfork / t3code-github / .repos/ alchemy-effect/ packages/ aws/ src/ CloudMap/ GetInstance.ts

import type * as SD from "@distilled.cloud/aws/servicediscovery";
import * as Binding from "alchemy/Binding";
import type * as Effect from "effect/Effect";
import type { Service } from "./Service.ts";

/**
 * `GetInstance` request with `ServiceId` injected from the bound
 * {@link Service}.
 */
export interface GetInstanceRequest extends Omit<SD.GetInstanceRequest, "ServiceId"> {}

/**
 * Runtime binding for `servicediscovery:GetInstance` — reads a single
 * registered instance of the bound {@link Service} by its instance ID,
 * returning its full attribute map. Provide the implementation with
 * `Effect.provide(AWS.CloudMap.GetInstanceHttp)`.
 * ### Reading Instances
 * **Example:** Read an Instance's Attributes
 * ```typescript
 * const getInstance = yield* AWS.CloudMap.GetInstance(service);
 *
 * const { Instance } = yield* getInstance({ InstanceId: "worker-1" });
 * console.log(Instance?.Attributes?.AWS_INSTANCE_IPV4);
 * ```
 *
 * @binding
 */
export interface GetInstance extends Binding.Service<
  GetInstance,
  "AWS.CloudMap.GetInstance",
  <S extends Service>(
    service: S,
  ) => Effect.Effect<
    (request: GetInstanceRequest) => Effect.Effect<SD.GetInstanceResponse, SD.GetInstanceError>
  >
> {}
export const GetInstance = Binding.Service<GetInstance>("AWS.CloudMap.GetInstance");