anishgirianish commented on code in PR #62343:
URL: https://github.com/apache/airflow/pull/62343#discussion_r3316030532


##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/connections.py:
##########
@@ -259,6 +321,78 @@ def test_connection(test_body: ConnectionBody) -> 
ConnectionTestResponse:
         os.environ.pop(conn_env_var, None)
 
 
+@connections_router.post(
+    "/enqueue-test",
+    status_code=status.HTTP_202_ACCEPTED,
+    responses=create_openapi_http_exception_doc(
+        [
+            status.HTTP_403_FORBIDDEN,
+            status.HTTP_409_CONFLICT,
+            status.HTTP_422_UNPROCESSABLE_ENTITY,
+        ]
+    ),
+    dependencies=[Depends(action_logging())],
+)
+def enqueue_connection_test(
+    test_body: ConnectionTestRequestBody,
+    session: SessionDep,
+    user: GetUserDep,
+) -> ConnectionTestQueuedResponse:
+    """Enqueue a connection test for deferred execution on a worker; returns a 
polling token."""
+    _ensure_test_connection_enabled()
+    _ensure_executor_is_configured(test_body.executor)
+
+    existing = 
session.scalar(select(Connection).filter_by(conn_id=test_body.connection_id))
+    if existing is not None:
+        effective_team = existing.team_name
+        if test_body.team_name is not None and test_body.team_name != 
effective_team:
+            raise HTTPException(
+                status.HTTP_403_FORBIDDEN,
+                f"team_name `{test_body.team_name}` does not match the team of 
connection "
+                f"`{test_body.connection_id}`.",
+            )
+    else:
+        effective_team = test_body.team_name

Review Comment:
   Done thank you



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