Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Airflow API getting started #47

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/_sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
- [Notifications - Send Slack notifications](/how-tos/airflow/send-slack-notifications.md)
- [Worker - Custom Worker Environment](/how-tos/airflow/customize-worker-environment.md)
- [Worker - Request Memory and CPU](/how-tos/airflow/request-resources-on-workers.md)
- [API - Getting Started](/how-tos/airflow/api-getting-started.md)
sconley-datacoves marked this conversation as resolved.
Show resolved Hide resolved
- [Datacoves](/how-tos/datacoves/)
- [Configure Connection Templates](/how-tos/datacoves/how_to_connection_template.md)
- [Configure Environments](/how-tos/datacoves/how_to_environments.md)
Expand Down
63 changes: 63 additions & 0 deletions docs/how-tos/airflow/api-getting-started.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Airflow API - Getting Started

## Requirements

1. Airflow API enabled.
2. Valid credentials: `username` and `password`.
3. Environment slug.
3. **Authentication URL**: https://api.<domain\>
4. **Airflow API URL**: https://api-airflow-<environment-slug\>.<domain\>/api/v1 E.g: `https://api-airflow-dev123.datacoves.com`

## Authentication

### Request

```bash
curl --location 'https://<authentication-url>/api/token/' \
--header 'Content-Type: application/json' \
--data-raw '{
"email": "<username>",
"password": "<password>"
}'
```

### Response

```bash
{
"refresh": "eyJ0eXAiOiJKV1QiLCJhbGc...",
"access": "eyJ0eXAiOiJKV1QiLCJhbGci..."
}
```

The `exp` field in the payload will have the token expiration time.

![JWT](assets/api-airflow-jwt-min.png)

## Refresh token

Once the token expires you can generate a new token or use the `refresh token` to get a new one. Please note that the refresh token also has an expiration time.

```bash
curl --location 'https://<authentication-url>/api/token/refresh/' \
--header 'Content-Type: application/json' \
--header 'Cookie: csrftoken=yKEcHY5X7IT4IZOjJLbX4tGLH06I2AKK' \
--data '{
"refresh": "eyJ0eXAiOiJKV1QiLCJhbGc..."
}'
```

## Airflow API Documentation

You can consult the Airflow API documentation in your environment with `Swagger UI` or `Redoc`.

![Airflow API docs](assets/api-airflow-doc-min.png)

## Example

Getting Dags

```bash
curl --location 'https://<airflow-api-url>.datacoveslocal.com/api/v1/dags' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGci...'
```
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.