The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 06:00 UTC
| 1 | import type * as mwaa from "@distilled.cloud/aws/mwaa"; |
| 2 | import * as Binding from "alchemy/Binding"; |
| 3 | import type * as Effect from "effect/Effect"; |
| 4 | import type { AirflowRoleOptions } from "./BindingHttp.ts"; |
| 5 | import type { Environment } from "./Environment.ts"; |
| 6 | |
| 7 | export interface InvokeRestApiRequest extends Omit<mwaa.InvokeRestApiRequest, "Name"> {} |
| 8 | |
| 9 | /** |
| 10 | * Runtime binding for `airflow:InvokeRestApi` (Airflow 2.4.3+). |
| 11 | * |
| 12 | * Bind an {@link Environment} inside a function runtime to call the Apache |
| 13 | * Airflow REST API on the environment's webserver — trigger DAG runs, list |
| 14 | * DAGs, inspect task instances, manage variables and connections — without |
| 15 | * minting tokens yourself. The IAM grant is scoped to the Airflow RBAC role |
| 16 | * the call is mapped to (`Admin` by default — pass `{ airflowRole }` to |
| 17 | * scope it down). Provide the implementation with |
| 18 | * `Effect.provide(AWS.MWAA.InvokeRestApiHttp)`. |
| 19 | * ### Invoking the Airflow REST API |
| 20 | * **Example:** List DAGs |
| 21 | * ```typescript |
| 22 | * // init — bind the operation to the environment |
| 23 | * const invokeRestApi = yield* AWS.MWAA.InvokeRestApi(environment); |
| 24 | * |
| 25 | * // runtime — GET /dags through the Airflow REST API |
| 26 | * const result = yield* invokeRestApi({ |
| 27 | * Method: "GET", |
| 28 | * Path: "/dags", |
| 29 | * QueryParameters: { paused: false }, |
| 30 | * }); |
| 31 | * const dags = result.RestApiResponse as { dags: { dag_id: string }[] }; |
| 32 | * ``` |
| 33 | * |
| 34 | * **Example:** Trigger a DAG Run |
| 35 | * ```typescript |
| 36 | * const run = yield* invokeRestApi({ |
| 37 | * Method: "POST", |
| 38 | * Path: "/dags/my_dag/dagRuns", |
| 39 | * Body: { conf: { source: "lambda" } }, |
| 40 | * }); |
| 41 | * ``` |
| 42 | * |
| 43 | * @binding |
| 44 | */ |
| 45 | export interface InvokeRestApi extends Binding.Service< |
| 46 | InvokeRestApi, |
| 47 | "AWS.MWAA.InvokeRestApi", |
| 48 | ( |
| 49 | environment: Environment, |
| 50 | options?: AirflowRoleOptions, |
| 51 | ) => Effect.Effect< |
| 52 | ( |
| 53 | request: InvokeRestApiRequest, |
| 54 | ) => Effect.Effect<mwaa.InvokeRestApiResponse, mwaa.InvokeRestApiError> |
| 55 | > |
| 56 | > {} |
| 57 | |
| 58 | export const InvokeRestApi = Binding.Service<InvokeRestApi>("AWS.MWAA.InvokeRestApi"); |