1import type * as mwaa from "@distilled.cloud/aws/mwaa";
2import type * as Effect from "effect/Effect";
3import * as Binding from "../../Binding.ts";
4import type { Environment } from "./Environment.ts";
5
6/**
7 * Runtime binding for `airflow:CreateCliToken`.
8 *
9 * Bind an {@link Environment} inside a function runtime to mint short-lived
10 * (60-second) Apache Airflow CLI tokens — exchange the token against
11 * `https://{WebServerHostname}/aws_mwaa/cli` to run Airflow CLI commands.
12 * The `CliToken` is `Redacted` — unwrap it with `Redacted.value` when
13 * building the request. Provide the implementation with
14 * `Effect.provide(AWS.MWAA.CreateCliTokenHttp)`.
15 * ### Creating CLI Tokens
16 * **Example:** Mint a CLI Token and Run an Airflow Command
17 * ```typescript
18 * // init — bind the operation to the environment
19 * const createCliToken = yield* AWS.MWAA.CreateCliToken(environment);
20 *
21 * // runtime — mint a token and POST a CLI command to the webserver
22 * const token = yield* createCliToken();
23 * const response = yield* HttpClient.execute(
24 * HttpClientRequest.post(
25 * `https://${token.WebServerHostname}/aws_mwaa/cli`,
26 * ).pipe(
27 * HttpClientRequest.setHeader(
28 * "Authorization",
29 * `Bearer ${Redacted.value(token.CliToken!)}`,
30 * ),
31 * HttpClientRequest.bodyText("dags list -o json"),
32 * ),
33 * );
34 * ```
35 *
36 * @binding
37 */
38export interface CreateCliToken extends Binding.Service<
39 CreateCliToken,
40 "AWS.MWAA.CreateCliToken",
41 (
42 environment: Environment,
43 ) => Effect.Effect<
44 () => Effect.Effect<mwaa.CreateCliTokenResponse, mwaa.CreateCliTokenError>
45 >
46> {}
47
48export const CreateCliToken = Binding.Service<CreateCliToken>(
49 "AWS.MWAA.CreateCliToken",
50);