davidavdav commented on issue #20063:
URL: https://github.com/apache/airflow/issues/20063#issuecomment-991916475


   I think it is possible to include `dag_id` and/or `dag_run_id` filtering in 
the `/dags` GET api using parameters, see this minimal example server: 
   
   ```python
   #!/usr/bin/env python3
   
   ## See if we can find way to send ath/to/mediafile like arguments to a 
restful api
   
   from flask import Flask
   from flask_restful import reqparse, Resource, Api
   import logging
   
   app = Flask(__name__)
   
   api = Api(app)
   
   parser = reqparse.RequestParser()
   parser.add_argument("dag_id", required=False)
   parser.add_argument("dag_run_id", required=False)
   
   class Dag(Resource):
       def get(self):
           args = parser.parse_args()
           ## do clever DB access and filtering here, for now we just return 
the dag_run_id (default None)
           return args.dag_run_id
   
   api.add_resource(Dag, "/dags")
   
   if __name__ == "__main__":
       logging.basicConfig(level=logging.INFO, format='%(asctime)s 
%(levelname)s %(message)s')
       app.run(host='0.0.0.0', port=4000, debug=True)
   ```
   Test using `curl 'http://localhost:4000/dags?dag_run_id=path/to/mediafile'`
   
   This could keep the current Api routes.  Adding parameters like 
`details=true` or `tasks=true`, or `task_id=$task_id` could even be added to 
cover other parts of the DAG access api, in cases where identifiers would 
otherwise conflict with Flask routing. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to