Code Monkey home page Code Monkey logo

airflow-extended-api-plugin's Introduction

Airflow Plugin - Airflow Extended API

Airflow Extended API, which export airflow CLI command as RESTful API to extend the ability of airflow official API.

Deploy plugin

  1. Download plugins zip from:
https://github.com/caoergou/airflow-extended-api/archive/master.zip
  1. Check the plugins_floder configuration in airflow.cfg.
    If not, consider use airflow default plugin dir path {AIRFLOW_HOME}/plugins as plugin floder.
  2. Unzip the plugins zip, move folder /plugins/extended_api/ to plugins_floder directory.
unzip airflow-extended-api-plugin.zip

cp -r airflow-rest-api-plugin/plugins/extended_api/* {AIRFLOW_PLUGINS_FOLDER}
  1. Start services of the airflow webserver and the airflow scheduler.
airflow webserver -p 8080
airflow scheduler

Directory structure

  • /plugins
    • /extended_api
      • /extended_api.py - Airflow plugins, expose functions as RESTful API.
      • /utils.py - API DTO class and function to execute CLI command.
      • /index.html - Airflow Extended API specification static front-end page.
      • /openapi.yaml - Airflow Extended API specification yaml file in OpenAPI Specification style.

Authentication And Security Warning

For convenience, these APIs does NOT require any authentication!

Therefore, if these APIs is directly exposed to the public network environment, it is equivalent to exposing the command line execution authority to public, which is a huge security risk.

So it For safety reasons, please think carefully about whether you need to keep this @csrf.exempt annotation.

Using the REST API

clear_task

Description:
  • use CLI command to clear a task for rerun.
Endpoint:
https://{AIRFLOW_HOST}:{AIRFLOW_PORT}/api/extended/clear
Method:
  • POST
POST request Arguments:

Args for Airflow CLI command airflow tasks clear.

Parameter Type Description Required
dagName String Name of DAG to clear True
downstream boolean Whether to recursively clear downstream tasks. default value is false False
startDate String Start of the time range for task instance to clear True
endDate String End of the time range for task instance to clear True
jobName String Regex of operator to clear True
username String Username who call this api False
Examples:
curl -X POST https://localhost:8080/api/extended/clear -H "Content-Type: application/json" -d '{"dagName": "string","downstream": true,"endDate": "2019-08-24T14:15:22Z","jobName": "string","startDate": "2019-08-24T14:15:22Z","username": "Knowhere API"}'
response:
{
  "executed_command": "string",
  "exit_code": 0,
  "output_info": [
    "string"
  ],
  "error_info": [
    "string"
  ]
}

links

airflow-extended-api-plugin's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.