[api]
auth_backend = airflow.api.auth.backend.basic_auth
docker-compose.yaml์๋ ์ด๋ฏธ ์ค์ ์ด ๋์ด ์์ (environments)
AIRFLOWAPIAUTH_BACKENDS: 'airflow.api.auth.backend.basic_auth,airflow.api.auth.backend.session'
์๋ ๋ช
๋ น์ผ๋ก ํ์ธํด๋ณด๊ธฐ
$ docker exec -it learn-airflow-airflow-scheduler-1 airflow config get-value api auth_backend
airflow.api.auth.backend.basic_auth,airflow.api.auth.backend.session
Airflow Web UI์์ ์๋ก์ด ์ฌ์ฉ์ ์ถ๊ฐ (API ์ฌ์ฉ์)

{
"metadatabase": {
"status": "healthy"
},
"scheduler": {
"status": "healthy",
"latest_scheduler_heartbeat": "2022-03-12T06:02:38.067178+00:00"
}
}
curl -X POST --user "airflow:airflow" -H 'Content-Type: application/json' -d
'{"execution_date":"2023-05-24T00:00:00Z"}'
"http://localhost:8080/api/v1/dags/HelloWorld/dagRuns"
{
"detail": "DAGRun with DAG ID: 'HelloWorld' and DAGRun logical date: '2023-05-24 00:00:00+00:00'
already exists",
"status": 409,
"title": "Conflict",
"type":
"https://airflow.apache.org/docs/apache-airflow/2.5.1/stable-rest-api-ref.html#section/Errors/AlreadyExists"
}
curl -X GET --user "airflow:airflow" http://localhost:8080/api/v1/dags
curl -X GET --user "airflow:airflow" http://localhost:8080/api/v1/variables
{
"total_entries": 7,
"variables": [
{
"description": null,
"key": "api_token",
"value": "12345667"
},
{
"description": null,
"key": "csv_url",
"value": "https://s3-geospatial.s3-us-west-2.amazonaws.com/name_gender.csv"
},
curl -X GET --user "airflow:airflow" http://localhost:8080/api/v1/config
{
"detail": "Your Airflow administrator chose not to expose the configuration, most likely for security
reasons.",
"status": 403,
"title": "Forbidden",
"type":
"https://airflow.apache.org/docs/apache-airflow/2.5.1/stable-rest-api-ref.html#section/Errors/PermissionDe
nied"
}
import requests
def get_active_dags():
url = "http://localhost:8080/api/v1/dags"
username, password = "airflow", "airflow"
try:
response = requests.get(url, auth=(username, password))
response_json = response.json()
for dag in response_json["dags"]:
if dag["is_paused"] is False:
print(f"Active DAG: {dag['dag_id']}")
except requests.exceptions.RequestException as e:
print(f"Error: {e}")
get_active_dags()
dockr-compose.yml ํ์ผ์์๋ x-airflow-common -> environment ์น์ ์์ AIRFLOW_WEBSERVER_EXPOSE_CONFIG: 'true'๋ก ์์ฑํด์ฃผ๋ฉด ๋๋ค.
export
Connections successfully exported to connections.json.
import
[2024-06-04 09:46:03,316] {crypto.py:83} WARNING - empty cryptography key - values will not be stored encrypted.
Could not import connection aws_conn_id: connection already exists.
Could not import connection redshift_dev_db: connection already exists.
connections API๋ ํ๊ฒฝ๋ณ์๋ก ์ง์ ๋ ๊ฒ์ ๋ฐํํ์ง ์๋๋ค.