You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
977 B
Python

from airflow import DAG
from airflow.operators.http_operator import SimpleHttpOperator
from datetime import datetime, timedelta
from airflow.utils.dates import days_ago
default_args = {
'owner': 'airflow',
'depends_on_past': False,
'email_on_failure': False,
'email_on_retry': False,
'retries': 1,
'retry_delay': timedelta(minutes=5),
}
with DAG(
'daily_efficiency_api_calls',
default_args=default_args,
description='Efficiency API calls at specific times',
# schedule_interval='30 0,8,15 * * *', # 07:30, 15:30, 22:30 GMT+7
schedule_interval='30 19,3,11 * * *', # 19:30, 03:30, 11:30 UTC
start_date=days_ago(1),
tags=['api', 'efficiency'],
) as dag:
# Morning call at 07:30 GMT+7 (00:30 UTC)
morning_api_call = SimpleHttpOperator(
task_id='morning_api_call',
http_conn_id='efficiency_api',
endpoint='efficiency/data/auto', # No need to include the base URL
method='GET',
)