Skip to main content

FastAPI plugin to pause/unpause Airflow DAGs in bulk.

Project description

🧩 Bulk Pause / Unpause API Plugin

The Bulk Pause / Unpause API provides REST endpoints to manage DAGs programmatically — enabling bulk control over DAGs using prefix or tag-based filters.


⚙️ Overview

  • Built using FastAPI
  • Communicates with Airflow’s core REST API
  • Provides endpoints to pause, unpause, or list DAGs
  • Integrated authentication via Airflow’s /auth/token

🔧 Features

  • Centralized API client (AirflowClient) for REST API interaction
  • Built-in authentication support using /auth/token
  • Simplified connection management via Airflow’s conn_id
  • Consistent response formatting and error handling

Connection Setup (Required)

Before using the client, create a connection in the Airflow UI → Admin → Connections.

Field Description Example
Conn Id Used in code airflow_api_conn
Conn Type http or https http
Host Airflow Webserver http://localhost:8080
Login Username / Service Account admin
Password Password or API token mysecret

🧱 High-Level Architecture

flowchart TD
    U[User or Script] --> X[Airflow Xtra API]
    subgraph Airflow Webserver
      X --> A[Auth Token Endpoint]
      X --> R[Airflow REST API v2]
    end
    R --> S[Scheduler or Executor]
    S --> D[DAGs and Tasks]

    subgraph Airflow Connection
      C1[Conn Type http or https]
      C2[Host webserver]
      C3[Port optional]
      C4[Login Password]
      C5[Conn id airflow_api_conn]
    end
    X -. uses .-> C1
    X -. uses .-> C2
    X -. uses .-> C3
    X -. uses .-> C4
    X -. uses .-> C5

🧩 Component View

flowchart LR
    subgraph Plugin
      H[Helpers AirflowClient<br/>resolve conn id<br/>token auth<br/>REST calls]
      F[FastAPI Routes<br/>pause unpause list]
    end

    UI[React UI optional] --> F
    S[Scripts or CLI] --> F

    F --> H
    H --> AR[Airflow REST API v2]
    H --> AT[Auth Token Endpoint]

    AR --> SCH[Scheduler or Executor]
    SCH --> DAG[DAGs and Tasks]

🧩 Example Endpoints

Endpoint Method Description
/api/airflow_bulk_pause_api/pause POST Pause matching DAGs
/api/airflow_bulk_pause_api/unpause POST Unpause matching DAGs
/api/airflow_bulk_pause_api/list GET List all active DAGs

🧪 Example Usage

curl -X POST http://localhost:8080/api/airflow_bulk_pause_api/pause -d '{"name_prefix": "etl_"}'

Response:

{
  "paused": ["etl_orders", "etl_customers"],
  "skipped": ["daily_cleanup"]
}

🧱 Architecture

  • FastAPI routes registered through the Airflow plugin manager
  • Uses AirflowClient (from helpers) for backend communication
  • Returns structured JSON responses for UI or automation scripts

🧾 License

MIT © Rahul Rajasekharan

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

air_labs_bulk_pause_api-0.1.1.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

air_labs_bulk_pause_api-0.1.1-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file air_labs_bulk_pause_api-0.1.1.tar.gz.

File metadata

  • Download URL: air_labs_bulk_pause_api-0.1.1.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for air_labs_bulk_pause_api-0.1.1.tar.gz
Algorithm Hash digest
SHA256 fb24f2280a057f102e29262522c117907e6f9e64733be4a0808b3c206880dcc6
MD5 5ee62867c674c95c58956340aa60401c
BLAKE2b-256 8efd0197184f45f016ed9870068efdef11da4221789053b43f2188af9181d2c3

See more details on using hashes here.

File details

Details for the file air_labs_bulk_pause_api-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for air_labs_bulk_pause_api-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 915281163fa039f627832969d20831035757ddb47f80fe92cc13d9cfc4587efd
MD5 8ae30b10fb005817ca5ba54d48e7a04a
BLAKE2b-256 7d9b3008af70e24db0f1132bc251c21154724f292477a7cdfdf6eab20bbb503d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page