uranusjr commented on a change in pull request #17839:
URL: https://github.com/apache/airflow/pull/17839#discussion_r697868482
##########
File path: airflow/api_connexion/openapi/v1.yaml
##########
@@ -604,6 +604,40 @@ paths:
'404':
$ref: '#/components/responses/NotFound'
+ /dags/{dag_id}/dagRuns/updateDagRunState:
Review comment:
This endpoint feels wrong to me. Since the operation only affects one
single DagRun, I feel it should be something like
`/dags/{dag_id}/dagRuns/{dag_run_id}/state`. And it should only take a single
`state` field (not `dag_id` or `dag_run_id`).
##########
File path: airflow/api_connexion/endpoints/dag_run_endpoint.py
##########
@@ -271,3 +273,33 @@ def post_dag_run(dag_id, session):
)
raise AlreadyExists(detail=f"DAGRun with DAG ID: '{dag_id}' and DAGRun ID:
'{run_id}' already exists")
+
+
[email protected]_access(
+ [
+ (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG),
+ (permissions.ACTION_CAN_EDIT, permissions.RESOURCE_DAG_RUN)
+ ]
+)
+@provide_session
+def post_set_dag_run_state(dag_id: str, session) -> dict:
+ """Set a state of a dag run."""
+ try:
+ post_body = dagrun_schema.load(request.json, session=session,
unknown="include")
+ except ValidationError as err:
+ raise BadRequest(detail=str(err))
+ dag_run_id, state = post_body['run_id'], post_body['state']
+ dag_run: Optional[DagRun] = session.query(DagRun).filter(DagRun.dag_id ==
dag_id, DagRun.run_id == dag_run_id).one_or_none()
Review comment:
This should happen before loading `post_body`. If a DAG does not exist,
the endpoint should always fail with 404.
--
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]