-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathhttp_call.py
43 lines (34 loc) · 1.06 KB
/
http_call.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
"""
DAG file for auto labelling job.
"""
from datetime import timedelta, datetime
import os
from airflow.decorators import task, dag
from airflow.models import DAG
from airflow.providers.http.operators.http import SimpleHttpOperator
import logging
import json
DAG_NAME = "data_api_call"
TASK_DATA_API_CALL = "data_api_call"
CONNECTION_ID="data_api_connection"
@dag(
schedule_interval="0 0 * * *",
start_date=datetime.today() - timedelta(days=2),
dagrun_timeout=timedelta(minutes=60),
)
def collaboration_with_data_api():
@task
def read_from_rest():
return SimpleHttpOperator(
task_id=TASK_DATA_API_CALL,
http_conn_id=CONNECTION_ID,
method="GET",
endpoint="/",
# data="{\"id\":111333222}",
headers={"Content-Type": "application/json"},
# response will be pushed to xcom with COLLABORATION_TASK_ID
xcom_push=True,
log_response=True,
)
read_from_rest()
dag=collaboration_with_data_api()