bugraoz93 commented on code in PR #43102:
URL: https://github.com/apache/airflow/pull/43102#discussion_r1807420546


##########
airflow/api_fastapi/core_api/routes/public/connections.py:
##########
@@ -104,3 +105,36 @@ async def get_connections(
         ],
         total_entries=total_entries,
     )
+
+
+@connections_router.patch(
+    "/{connection_id}",
+    responses=create_openapi_http_exception_doc([400, 401, 403, 404]),
+)
+async def patch_connection(
+    connection_id: str,
+    patch_body: ConnectionBody,
+    session: Annotated[Session, Depends(get_session)],
+    update_mask: list[str] | None = Query(None),
+) -> ConnectionResponse:
+    """Update a connection entry."""
+    if patch_body.connection_id != connection_id:
+        raise HTTPException(400, "The connection_id in the request body does 
not match the URL parameter")
+
+    non_update_fields = ["connection_id", "conn_id"]
+    connection = 
session.scalar(select(Connection).filter_by(conn_id=connection_id).limit(1))
+
+    if connection is None:
+        raise HTTPException(404, f"The Connection with connection_id: 
`{connection_id}` was not found")
+
+    if update_mask:
+        data = patch_body.model_dump(include=set(update_mask) - 
set(non_update_fields))
+    else:
+        data = patch_body.model_dump(exclude=set(non_update_fields))
+
+    for key, val in data.items():
+        setattr(connection, key, val)
+    session.add(connection)
+    session.commit()

Review Comment:
   Yes, I missed the scope and added these. I also deleted the same part in 
Variable Patch.



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