sailfork / t3code-github / .repos/ alchemy-effect/ packages/ aws/ src/ EMRServerless/ StartSession.ts

import type * as emr from "@distilled.cloud/aws/emr-serverless";
import * as Binding from "alchemy/Binding";
import type * as Effect from "effect/Effect";
import type { Application } from "./Application.ts";

/**
 * Request accepted by the {@link StartSession} runtime callable. The
 * `applicationId` is injected from the bound {@link Application}; the
 * idempotency `clientToken` is auto-generated when omitted.
 */
export type StartSessionInput = Omit<emr.StartSessionRequest, "applicationId" | "clientToken"> & {
  /**
   * Idempotency token deduplicating retried submissions.
   * @default a generated UUID per call
   */
  clientToken?: string;
};

/**
 * Runtime binding for `emr-serverless:StartSession`.
 *
 * Starts an interactive session on the bound {@link Application} (the
 * application must enable `interactiveConfiguration`). The session assumes
 * the given execution role; grants `iam:PassRole` (conditioned to
 * `emr-serverless.amazonaws.com`) accordingly. Provide the implementation
 * with `Effect.provide(AWS.EMRServerless.StartSessionHttp)`.
 * ### Interactive Sessions
 * **Example:** Start A Session
 * ```typescript
 * // init
 * const startSession = yield* AWS.EMRServerless.StartSession(app);
 *
 * // runtime
 * const session = yield* startSession({ executionRoleArn: sessionRoleArn });
 * yield* Effect.log(`started ${session.sessionId}`);
 * ```
 *
 * @binding
 */
export interface StartSession extends Binding.Service<
  StartSession,
  "AWS.EMRServerless.StartSession",
  (
    application: Application,
  ) => Effect.Effect<
    (request: StartSessionInput) => Effect.Effect<emr.StartSessionResponse, emr.StartSessionError>
  >
> {}
export const StartSession = Binding.Service<StartSession>("AWS.EMRServerless.StartSession");