Lee-W commented on code in PR #52868:
URL: https://github.com/apache/airflow/pull/52868#discussion_r2193881157


##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/hitl.py:
##########
@@ -0,0 +1,144 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from __future__ import annotations
+
+from uuid import UUID
+
+import structlog
+from fastapi import Depends, HTTPException, status
+from sqlalchemy import select
+
+from airflow.api_fastapi.auth.managers.models.resource_details import 
DagAccessEntity
+from airflow.api_fastapi.common.db.common import SessionDep, paginated_select
+from airflow.api_fastapi.common.router import AirflowRouter
+from airflow.api_fastapi.core_api.datamodels.hitl import (
+    HITLResponseContentDetail,
+    HITLResponseDetail,
+    HITLResponseDetailCollection,
+    UpdateHITLResponsePayload,
+)
+from airflow.api_fastapi.core_api.openapi.exceptions import 
create_openapi_http_exception_doc
+from airflow.api_fastapi.core_api.security import GetUserDep, 
ReadableTIFilterDep, requires_access_dag
+from airflow.models.hitl import HITLResponseModel
+from airflow.models.taskinstance import TaskInstance as TI
+from airflow.utils import timezone
+
+hitl_router = AirflowRouter(tags=["HumanInTheLoop"], prefix="/hitl-responses")
+
+log = structlog.get_logger(__name__)
+
+
+@hitl_router.patch(
+    "/{task_instance_id}",
+    responses=create_openapi_http_exception_doc(
+        [
+            status.HTTP_404_NOT_FOUND,
+            status.HTTP_409_CONFLICT,
+        ]
+    ),
+    dependencies=[
+        Depends(requires_access_dag(method="GET", 
access_entity=DagAccessEntity.TASK_INSTANCE)),
+    ],
+)
+def update_hitl_response(
+    task_instance_id: UUID,
+    update_hitl_response_payload: UpdateHITLResponsePayload,
+    user: GetUserDep,
+    session: SessionDep,
+) -> HITLResponseContentDetail:
+    """Update a Human-in-the-loop response."""
+    ti_id_str = str(task_instance_id)
+    hitl_response_model = session.scalar(
+        select(HITLResponseModel).where(HITLResponseModel.ti_id == ti_id_str)
+    )
+    if not hitl_response_model:
+        raise HTTPException(
+            status.HTTP_404_NOT_FOUND,
+            f"Human-in-the-loop Response does not exist for Task Instance with 
id {ti_id_str}",
+        )
+
+    if hitl_response_model.response_received:

Review Comment:
   Probably let's handle it in another PR. I feel this one might need more 
discussion 



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