Skip to main content

OpenMetadata Airflow Managed DAGS Api

This is a plugin for Apache Airflow >= 1.10 and Airflow >=2.x that exposes REST APIs to deploy an OpenMetadata workflow definition and manage DAGS and tasks.

Development

The file development/airflow/airflow.cfg contains configuration which runs based on the airflow server deployed by the quick-start and development compose files.

You ca run the following command to start the development environment:

export AIRFLOW_HOME=$(pwd)/openmetadata-airflow-managed-api/development/airflow
airflow webserver

Requirements

First, make sure that Airflow is properly installed with the latest version 2.3.3. From the docs:

Then, install following packages in your scheduler and webserver python env.

pip install openmetadata-airflow-managed-apis       

Configuration

Add the following section to airflow.cfg

[openmetadata_airflow_apis]
dag_generated_configs = {AIRFLOW_HOME}/dag_generated_configs

substitute AIRFLOW_HOME with your airflow installation home

Deploy

pip install "apache-airflow==2.3.3" --constraint "https://raw.githubusercontent.com/apache/airflow/constraints-2.3.3/constraints-3.9.txt"
  1. Install the package

  2. mkdir -p {AIRFLOW_HOME}/dag_generated_configs

  3. (re)start the airflow webserver and scheduler

    airflow webserver
    airflow scheduler
    

Validate

You can check that the plugin is correctly loaded by going to http://{AIRFLOW_HOST}:{AIRFLOW_PORT}/restapi, or accessing the REST_API_PLUGIN view through the Admin dropdown.

APIs

Enable JWT Auth tokens

Plugin enables JWT Token based authentication for Airflow versions 1.10.4 or higher when RBAC support is enabled.

Generating the JWT access token
curl -XPOST http://localhost:8080/api/v1/security/login -H "Content-Type: application/json" -d '{"username":"admin", "password":"admin", "refresh":true, "provider": "db"}'
Examples:
curl -X POST http://localhost:8080/api/v1/security/login -H "Content-Type: application/json" -d '{"username":"admin", "password":"admin", "refresh":true, "provider": "db"}'
Sample response which includes access_token and refresh_token.
{
 "access_token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2MDQyMTc4MzgsIm5iZiI6MTYwNDIxNzgzOCwianRpIjoiMTI4ZDE2OGQtMTZiOC00NzU0LWJiY2EtMTEyN2E2ZTNmZWRlIiwiZXhwIjoxNjA0MjE4NzM4LCJpZGVudGl0eSI6MSwiZnJlc2giOnRydWUsInR5cGUiOiJhY2Nlc3MifQ.xSWIE4lR-_0Qcu58OiSy-X0XBxuCd_59ic-9TB7cP9Y",
 "refresh_token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2MDQyMTc4MzgsIm5iZiI6MTYwNDIxNzgzOCwianRpIjoiZjA5NTNkODEtNWY4Ni00YjY0LThkMzAtYzg5NTYzMmFkMTkyIiwiZXhwIjoxNjA2ODA5ODM4LCJpZGVudGl0eSI6MSwidHlwZSI6InJlZnJlc2gifQ.VsiRr8_ulCoQ-3eAbcFz4dQm-y6732QR6OmYXsy4HLk"
}

By default, JWT access token is valid for 15 mins and refresh token is valid for 30 days. You can renew the access token with the help of refresh token as shown below.

Renewing the Access Token
curl -X POST "http://{AIRFLOW_HOST}:{AIRFLOW_PORT}/api/v1/security/refresh" -H 'Authorization: Bearer <refresh_token>'
Examples:
curl -X POST "http://localhost:8080/api/v1/security/refresh" -H 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2MDQyMTc4MzgsIm5iZiI6MTYwNDIxNzgzOCwianRpIjoiZjA5NTNkODEtNWY4Ni00YjY0LThkMzAtYzg5NTYzMmFkMTkyIiwiZXhwIjoxNjA2ODA5ODM4LCJpZGVudGl0eSI6MSwidHlwZSI6InJlZnJlc2gifQ.VsiRr8_ulCoQ-3eAbcFz4dQm-y6732QR6OmYXsy4HLk'
sample response returns the renewed access token as shown below.
{
 "access_token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2MDQyODQ2OTksIm5iZiI6MTYwNDI4NDY5OSwianRpIjoiZDhhN2IzMmYtMWE5Zi00Y2E5LWFhM2ItNDEwMmU3ZmMyMzliIiwiZXhwIjoxNjA0Mjg1NTk5LCJpZGVudGl0eSI6MSwiZnJlc2giOmZhbHNlLCJ0eXBlIjoiYWNjZXNzIn0.qY2e-bNSgOY-YboinOoGqLfKX9aQkdRjo025mZwBadA"
}

Enable API requests with JWT

If the Authorization header is not added in the api request,response error:
{"msg":"Missing Authorization Header"}
Pass the additional Authorization:Bearer <access_token> header in the rest API request.

Examples:

curl -X GET -H 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2MDQyODQ2OTksIm5iZiI6MTYwNDI4NDY5OSwianRpIjoiZDhhN2IzMmYtMWE5Zi00Y2E5LWFhM2ItNDEwMmU3ZmMyMzliIiwiZXhwIjoxNjA0Mjg1NTk5LCJpZGVudGl0eSI6MSwiZnJlc2giOmZhbHNlLCJ0eXBlIjoiYWNjZXNzIn0.qY2e-bNSgOY-YboinOoGqLfKX9aQkdRjo025mZwBadA' http://localhost:8080/rest_api/api\?api\=dag_state\&dag_id\=dag_test\&run_id\=manual__2020-10-28T17%3A36%3A28.838356%2B00%3A00

Using the API

Once you deploy the plugin and restart the webserver, you can start to use the REST API. Bellow you will see the endpoints that are supported.

Note: If enable RBAC, http://{AIRFLOW_HOST}:{AIRFLOW_PORT}/rest_api/
This web page will show the Endpoints supported and provide a form for you to test submitting to them.

deploy_dag

Description:
  • Deploy a new dag, and refresh dag to session.
Endpoint:
http://{AIRFLOW_HOST}:{AIRFLOW_PORT}/rest_api/api?api=deploy_dag
Method:
  • POST
POST request Arguments:
{
	"workflow": {
		"name": "test_ingestion_x_35",
		"force": "true",
		"pause": "false",
		"unpause": "true",
		"dag_config": {
			"test_ingestion_x_35": {
				"default_args": {
					"owner": "harsha",
					"start_date": "2021-10-29T00:00:00.000Z",
					"end_date": "2021-11-05T00:00:00.000Z",
					"retries": 1,
					"retry_delay_sec": 300
				},
				"schedule_interval": "0 3 * * *",
				"concurrency": 1,
				"max_active_runs": 1,
				"dagrun_timeout_sec": 60,
				"default_view": "tree",
				"orientation": "LR",
				"description": "this is an example dag!",
				"tasks": {
					"task_1": {
						"operator": "airflow.operators.python_operator.PythonOperator",
						"python_callable_name": "metadata_ingestion_workflow",
						"python_callable_file": "metadata_ingestion.py",
						"op_kwargs": {
							"workflow_config": {
								"metadata_server": {
									"config": {
										"api_endpoint": "http://localhost:8585/api",
										"auth_provider_type": "no-auth"
									},
									"type": "metadata-server"
								},
								"sink": {
									"config": {
										"es_host": "localhost",
										"es_port": 9200,
										"index_dashboards": "true",
										"index_tables": "true",
										"index_topics": "true"
									},
									"type": "elasticsearch"
								},
								"source": {
									"config": {
										"include_dashboards": "true",
										"include_tables": "true",
										"include_topics": "true",
										"limit_records": 10
									},
									"type": "metadata"
								}
							}
						}
					}
				}
			}
		}
	}
}
Examples:
curl -H  'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2MzU2NTE1MDAsIm5iZiI6MTYzNTY1MTUwMCwianRpIjoiNWQyZTM3ZDYtNjdiYS00NGZmLThjOWYtMDM0ZTQyNGE3MTZiIiwiZXhwIjoxNjM1NjUyNDAwLCJpZGVudGl0eSI6MSwiZnJlc2giOnRydWUsInR5cGUiOiJhY2Nlc3MifQ.DRUYCAiMh5h2pk1MZZJ4asyVFC20pu35DuAANQ5GxGw' -H 'Content-Type: application/json' -d "@test_ingestion_config.json" -X POST http://localhost:8080/rest_api/api\?api\=deploy_dag```
##### response:
```json
{"message": "Workflow [test_ingestion_x_35] has been created", "status": "success"}

delete_dag

Description:
  • Delete dag based on dag_id.
Endpoint:
http://{AIRFLOW_HOST}:{AIRFLOW_PORT}/rest_api/api?api=delete_dag&dag_id=value
Method:
  • GET
GET request Arguments:
  • dag_id - string - The id of dag.
Examples:
curl -X GET http://localhost:8080/rest_api/api?api=delete_dag&dag_id=dag_test
response:
{
  "message": "DAG [dag_test] deleted",
  "status": "success"
}

Download files

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

Source Distribution

openmetadata_managed_apis-2.0.0.0.tar.gz (48.4 kB view details)

Uploaded Source

Built Distribution

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

openmetadata_managed_apis-2.0.0.0-py3-none-any.whl (88.5 kB view details)

Uploaded Python 3

File details

Details for the file openmetadata_managed_apis-2.0.0.0.tar.gz.

File metadata

File hashes

Hashes for openmetadata_managed_apis-2.0.0.0.tar.gz
Algorithm Hash digest
SHA256 f425ebde16c6bc777abb3864c91266ae9fd2e961552f30312250b4e6b229bfdc
MD5 06c4dcb55bd04629a2c2e70c7430dd42
BLAKE2b-256 4cef35b9731c45e22ec84e324b4e5873abce31a99e2d1c801800efab5c63e077

See more details on using hashes here.

File details

Details for the file openmetadata_managed_apis-2.0.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for openmetadata_managed_apis-2.0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f6cfd05628c75be70d80e054a82ccbe2f04aad9e2308d2e2139a96faffaa6607
MD5 91581f430330f735a476ab40bd8aa8d0
BLAKE2b-256 37275ed6dd4c3fa94f0f62507464e6153450007bb97cf04292a8549b345336bc

See more details on using hashes here.

Release history Release notifications | RSS feed

2.0.1.0

2 files

This release

2.0.0.0 This release

2 files

1.13.6.0

2 files

1.13.5.0

2 files

1.13.4.1

2 files

1.13.4.0

2 files

1.13.3.3

2 files

1.13.3.2

2 files

1.13.3.1

2 files

1.13.3.0

2 files

1.13.2.0

2 files

1.13.1.1

2 files

1.13.1.0

2 files

1.13.0.0

2 files

1.12.14.2

2 files

1.12.14.1

2 files

1.12.14.0

2 files

1.12.13.0

2 files

1.12.12.0

2 files

1.12.11.2

2 files

1.12.11.1

2 files

1.12.11.0

2 files

1.12.10.1

2 files

1.12.10.0

2 files

1.12.9.0

2 files

1.12.8.10

2 files

1.12.8.9

2 files

1.12.8.8

2 files

1.12.8.7

2 files

1.12.8.6

2 files

1.12.8.4

2 files

1.12.8.3

2 files

1.12.8.2

2 files

1.12.8.1

2 files

1.12.8.0

2 files

1.12.7.0

2 files

1.12.6.4

2 files

1.12.6.3

2 files

1.12.6.2

2 files

1.12.6.1

2 files

1.12.6.0

2 files

1.12.5.6

2 files

1.12.5.5

2 files

1.12.5.4

2 files

1.12.5.3

2 files

1.12.5.2

2 files

1.12.5.1

2 files

1.12.5.0

2 files

1.12.4.1

2 files

1.12.4.0

2 files

1.12.3.0

2 files

1.12.2.0

2 files

1.12.1.0

2 files

1.12.0.0

2 files

1.11.14.0

2 files

1.11.13.0

2 files

1.11.12.2

2 files

1.11.12.1

2 files

1.11.12.0

2 files

1.11.11.3

2 files

1.11.11.2

2 files

1.11.11.1

2 files

1.11.11.0

2 files

1.11.10.0

2 files

1.11.9.2

2 files

1.11.9.1

2 files

1.11.9.0

2 files

1.11.8.1

2 files

1.11.8.0

2 files

1.11.7.2

2 files

1.11.7.1

2 files

1.11.7.0

2 files

1.11.6.3

2 files

1.11.6.2

2 files

1.11.6.1

2 files

1.11.6.0

2 files

1.11.5.1

2 files

1.11.5.0

2 files

1.11.4.0

2 files

1.11.3.0

2 files

1.11.2.0

2 files

1.11.1.0

2 files

1.11.0.0

2 files

1.10.14.7

2 files

1.10.14.6

2 files

1.10.14.5

2 files

1.10.14.4

2 files

1.10.14.3

2 files

1.10.14.2

2 files

1.10.14.1

2 files

1.10.14.0

2 files

1.10.13.0

2 files

1.10.12.0

2 files

1.10.11.2

2 files

1.10.11.1

2 files

1.10.11.0

2 files

1.10.10.0

2 files

1.10.9.1

2 files

1.10.9.0

2 files

1.10.8.0

2 files

1.10.7.0

2 files

1.10.6.0

2 files

1.10.5.0

2 files

1.10.4.1

2 files

1.10.4.0

2 files

1.10.3.0

2 files

1.10.2.0

2 files

1.10.1.0

2 files

1.10.0.0

2 files

1.9.17.6

2 files

1.9.17.5

2 files

1.9.17.4

2 files

1.9.17.3

2 files

1.9.17.2

2 files

1.9.17.1

2 files

1.9.17.0

2 files

1.9.16.2

2 files

1.9.16.1

2 files

1.9.16.0

2 files

1.9.15.0

2 files

1.9.14.1

2 files

1.9.14.0

2 files

1.9.13.1

2 files

1.9.13.0

2 files

1.9.12.0

2 files

1.9.11.9

2 files

1.9.11.8.1

2 files

1.9.11.8.0

2 files

1.9.11.7.0

2 files

1.9.11.6

2 files

1.9.11.5

2 files

1.9.11.4

2 files

1.9.11.3

2 files

1.9.11.2

2 files

1.9.11.1

2 files

1.9.11.0

2 files

1.9.10.0

2 files

1.9.9.1

2 files

1.9.9.0

2 files

1.9.8.0

2 files

1.9.7.1

2 files

1.9.7.0

2 files

1.9.6.0

2 files

1.9.5.0

2 files

1.9.4.0

2 files

1.9.3.0

2 files

1.9.2.1

2 files

1.9.2.0

2 files

1.9.1.0

2 files

1.9.0.0

2 files

1.8.12.0

2 files

1.8.11.0

2 files

1.8.10.0

2 files

1.8.9.0

2 files

1.8.8.1

2 files

1.8.8.0

2 files

1.8.7.5

2 files

1.8.7.4

2 files

1.8.7.3

2 files

1.8.7.2

2 files

1.8.7.1

2 files

1.8.7.0

2 files

1.8.6.1

2 files

1.8.6.0

2 files

1.8.5.0

2 files

1.8.4.0

2 files

1.8.3.1

2 files

1.8.3.0

2 files

1.8.2.0

2 files

1.8.1.0

2 files

1.8.0.0

2 files

1.7.7.4

2 files

1.7.7.3

2 files

1.7.7.2

2 files

1.7.7.1

2 files

1.7.7.0

2 files

1.7.6.0

2 files

1.7.5.4

2 files

1.7.5.3

2 files

1.7.5.2

2 files

1.7.5.1

2 files

1.7.5.0

2 files

1.7.4.2

2 files

1.7.4.1

2 files

1.7.4.0

2 files

1.7.3.0

2 files

1.7.2.1

2 files

1.7.2.0

2 files

1.7.1.5

2 files

1.7.1.4

2 files

1.7.1.3

2 files

1.7.1.2

2 files

1.7.1.1

2 files

1.7.1.0

2 files

1.7.0.1

2 files

1.7.0.0

2 files

1.6.13.2

2 files

1.6.13.1

2 files

1.6.13.0

2 files

1.6.12.0

2 files

1.6.11.1

2 files

1.6.11.0

2 files

1.6.10.0

2 files

1.6.9.0

2 files

1.6.8.0

2 files

1.6.7.3

2 files

1.6.7.2

2 files

1.6.7.1

2 files

1.6.7.0

2 files

1.6.6.9

2 files

1.6.6.8

2 files

1.6.6.7

2 files

1.6.6.6

2 files

1.6.6.5

2 files

1.6.6.4

2 files

1.6.6.3

2 files

1.6.6.2

2 files

1.6.6.1

2 files

1.6.6.0

2 files

1.6.5.2

2 files

1.6.5.1

2 files

1.6.5.0

2 files

1.6.4.0

2 files

1.6.3.3

2 files

1.6.3.2

2 files

1.6.3.1

2 files

1.6.3.0

2 files

1.6.2.2

2 files

1.6.2.1

2 files

1.6.2.0

2 files

1.6.1.0

2 files

1.6.0.0

2 files

1.5.15.2

2 files

1.5.15.1

2 files

1.5.15.0

2 files

1.5.14.1

2 files

1.5.14.0

2 files

1.5.13.2

2 files

1.5.13.1

2 files

1.5.13.0

2 files

1.5.12.1

2 files

1.5.12.0

2 files

1.5.11.0

2 files

1.5.10.0

2 files

1.5.9.0

2 files

1.5.8.0

2 files

1.5.7.1

2 files

1.5.7.0

2 files

1.5.6.0

2 files

1.5.5.0

2 files

1.5.4.1

2 files

1.5.4.0

2 files

1.5.3.1

2 files

1.5.3.0

2 files

1.5.2.0

2 files

1.5.1.0

2 files

1.5.0.0

2 files

1.4.8.1

2 files

1.4.8.0

2 files

1.4.7.2

2 files

1.4.7.1

2 files

1.4.7.0

2 files

1.4.6.0

2 files

1.4.5.0

2 files

1.4.4.2

2 files

1.4.4.1

2 files

1.4.4.0

2 files

1.4.3.3

2 files

1.4.3.2

2 files

1.4.3.1

2 files

1.4.3.0

2 files

1.4.2.0

2 files

1.4.1.0

2 files

1.4.0.1

2 files

1.4.0.0

2 files

1.3.4.0

2 files

1.3.3.0

2 files

1.3.2.0

2 files

1.3.1.3

2 files

1.3.1.2

2 files

1.3.1.1

2 files

1.3.1.0

2 files

1.3.0.1

2 files

1.3.0.0

2 files

1.2.5.3

2 files

1.2.5.2

2 files

1.2.5.1

2 files

1.2.5.0

2 files

1.2.4.7

2 files

1.2.4.6

2 files

1.2.4.5

2 files

1.2.4.4

2 files

1.2.4.2

2 files

1.2.4.1

2 files

1.2.4.0

2 files

1.2.3.3

2 files

1.2.3.2

2 files

1.2.3.1

2 files

1.2.3.0

2 files

1.2.2.2

2 files

1.2.2.1

2 files

1.2.2.0

2 files

1.2.1.1

2 files

1.2.1.0

2 files

1.2.0.1

2 files

1.2.0.0

2 files

1.1.7.5

2 files

1.1.7.4

2 files

1.1.7.3

2 files

1.1.7.2

2 files

1.1.7.1

2 files

1.1.7.0

2 files

1.1.6.1

2 files

1.1.6.0

2 files

1.1.5.0

2 files

1.1.4.0

2 files

1.1.3.0

2 files

1.1.2.0

1 file

1.1.1.1

2 files

1.1.1.0

1 file

1.1.0.4

3 files

1.1.0.3

3 files

1.1.0.2

3 files

1.1.0.1

3 files

1.1.0.0

3 files

1.0.5.1

3 files

1.0.5.0

3 files

1.0.4.4

3 files

1.0.4.3

3 files

1.0.4.2

3 files

1.0.4.1

3 files

1.0.4.0

3 files

1.0.3.0

3 files

1.0.2.0

3 files

1.0.1.3

3 files

1.0.1.2

1.0.1.1

3 files

1.0.1.0

3 files

1.0.0.2

3 files

1.0.0.1

3 files

1.0.0.0

3 files

0.13.4.0

3 files

0.13.3.1

3 files

0.13.3.0

3 files

0.13.2.8

3 files

0.13.2.7

3 files

0.13.2.6

3 files

0.13.2.5

3 files

0.13.2.4

3 files

0.13.2.3

3 files

0.13.2.2

3 files

0.13.2.1

3 files

0.13.2.0

3 files

0.13.1.9

3 files

0.13.1.8

3 files

0.13.1.7

3 files

0.13.1.6

3 files

0.13.1.4

3 files

0.13.1.3

3 files

0.13.1.2

3 files

0.13.1.1

3 files

0.13.1.0

3 files

0.13.0.3

3 files

0.13.0.1

3 files

0.13.0.0

3 files

0.12.3.2

3 files

0.12.3.1

3 files

0.12.3.0

3 files

0.12.2.4

3 files

0.12.2.3

3 files

0.12.2.2

3 files

0.12.2.1

3 files

0.12.2.0

3 files

0.12.1.3

3 files

0.12.1.2

3 files

0.12.1.1

3 files

0.12.1.0

3 files

0.12.0.0

3 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page