I have created a DAG which to get JSON data from an API. After getting the data from the API it uploads the data into S3. The data from the API is paginated and I can only get 100 records at a time. Depending on the data created I might have to loop a couple of times getting the data. I only know how many pages to loop after picking the first data from API.
So my tasks are
initialize_env = DummyOperator(task_id='initialize_env')
get_data = SimpleHttpOperator(task_id='get_data',
url=url,
endpoint='users?page={page_id}') #this task loops number of times
upload_to_s3 = MyOperator(task_id='upload_to_s3') #this task loops number of times
read_data = PythonOperator(task_id='upload_to_s3',
python_callable=function_reading_data) #this task should stop the loop
send_email = DummyOperator(task_id='send_email') #send email at the end of looping
I would like to find out how I can do looping in Airflow so that I go through all the pages?