You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@airflow.apache.org by Ayush Goel <ay...@gmail.com> on 2020/07/07 14:06:40 UTC

How to validate the input conf parameters sent through Rest api in airflow and send response back to the api?

Hi,

I am triggering the dag using the following command:
curl -kX POST
https://smtca01379.rd.corpintra.net:8081/api/experimental/dags/api_test/dag_runs
-H 'Cache-Control: no-cache' -H 'Content-Type: application/json' -d
'{"conf":"{\"input_path\":\"/mapr/ayush\",
\"output_path\":\"/mapr/output\", \"output_format\":\"/mapr/type\",
\"path_desc_file\":\"/mapr/path_desc_file\"}"}'

I am able to get access to parameters inside my code using:
params['dag_run'].conf['input_path']

After running the curl command I am getting the response as:
{"execution_date":"2020-07-07T13:00:02+00:00","message":"Created <DagRun
api_test @ 2020-07-07 13:00:02+00:00: manual__2020-07-07T13:00:02+00:00,
externally triggered: True>","run_id":"manual__2020-07-07T13:00:02+00:00"}

Is there any way in which I can validate the conf parameters which are sent
through rest api?

for example: I want to check whether input path given exists on the cluster
or not. If it does not exist, we should get an error and the dag should
not trigger.

If the validation fails, the response should be sent back to the api.


Thanks and Regards,
Ayush Goel