You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2018/12/04 09:22:55 UTC
[GitHub] SaumyaRackspace closed pull request #4271: Adding better json return
SaumyaRackspace closed pull request #4271: Adding better json return
URL: https://github.com/apache/incubator-airflow/pull/4271
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/airflow/api/common/experimental/get_dag_runs.py b/airflow/api/common/experimental/get_dag_runs.py
index 63b1f993d3..4dd1306039 100644
--- a/airflow/api/common/experimental/get_dag_runs.py
+++ b/airflow/api/common/experimental/get_dag_runs.py
@@ -53,3 +53,16 @@ def get_dag_runs(dag_id, state=None):
})
return dag_runs
+
+def format_dag_run(run):
+ return {
+ 'id': run.id,
+ 'run_id': run.run_id,
+ 'state': run.state,
+ 'dag_id': run.dag_id,
+ 'execution_date': run.execution_date.isoformat(),
+ 'start_date': ((run.start_date or '') and
+ run.start_date.isoformat()),
+ 'dag_run_url': url_for('airflow.graph', dag_id=run.dag_id,
+ execution_date=run.execution_date)
+ }
diff --git a/airflow/www/api/experimental/endpoints.py b/airflow/www/api/experimental/endpoints.py
index f0bc319eb6..675ff6c062 100644
--- a/airflow/www/api/experimental/endpoints.py
+++ b/airflow/www/api/experimental/endpoints.py
@@ -26,6 +26,7 @@
from airflow.api.common.experimental import trigger_dag as trigger
from airflow.api.common.experimental.get_task import get_task
from airflow.api.common.experimental.get_task_instance import get_task_instance
+from airflow.api.common.experimental.get_dag_runs import format_dag_run
from airflow.exceptions import AirflowException
from airflow.utils import timezone
from airflow.utils.log.logging_mixin import LoggingMixin
@@ -52,6 +53,10 @@ def trigger_dag(dag_id):
if 'run_id' in data:
run_id = data['run_id']
+ detailed_output = None
+ if 'detailed_output' in data:
+ detailed_output = data['detailed_output']
+
conf = None
if 'conf' in data:
conf = data['conf']
@@ -84,8 +89,11 @@ def trigger_dag(dag_id):
if getattr(g, 'user', None):
_log.info("User {} created {}".format(g.user, dr))
-
- response = jsonify(message="Created {}".format(dr))
+ if detailed_output :
+ dr = format_dag_run(dr)
+ response = jsonify(**dr)
+ else:
+ response = jsonify(message="Created {}".format(dr))
return response
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services