uranusjr commented on a change in pull request #19758:
URL: https://github.com/apache/airflow/pull/19758#discussion_r756612051



##########
File path: airflow/api_connexion/endpoints/dag_endpoint.py
##########
@@ -88,25 +88,68 @@ def get_dags(limit, session, offset=0, only_active=True, 
tags=None, dag_id_patte
 @provide_session
 def patch_dag(session, dag_id, update_mask=None):
     """Update the specific DAG"""
+    try:
+        patch_body = dag_schema.load(request.json, session=session)
+    except ValidationError as err:
+        raise BadRequest("Invalid Dag schema", detail=str(err.messages))
+    if update_mask:
+        patch_body_ = {}
+        if update_mask != ['is_paused']:
+            raise BadRequest(detail="Only `is_paused` field can be updated 
through the REST API")
+        update_mask = update_mask[0]
+        patch_body_[update_mask] = patch_body[update_mask]
+        patch_body = patch_body_
     dag = session.query(DagModel).filter(DagModel.dag_id == 
dag_id).one_or_none()
     if not dag:
         raise NotFound(f"Dag with id: '{dag_id}' not found")
+    setattr(dag, 'is_paused', patch_body['is_paused'])

Review comment:
       Any reason why this is not
   
   ```suggestion
       dag.is_paused = patch_body['is_paused']
   ```
   
   instead?




-- 
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