anishgirianish commented on code in PR #62343:
URL: https://github.com/apache/airflow/pull/62343#discussion_r3029232752
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/connections.py:
##########
@@ -257,6 +286,84 @@ def test_connection(test_body: ConnectionBody) ->
ConnectionTestResponse:
os.environ.pop(conn_env_var, None)
+@connections_router.post(
+ "/test-async",
+ status_code=status.HTTP_202_ACCEPTED,
+ responses=create_openapi_http_exception_doc([status.HTTP_403_FORBIDDEN,
status.HTTP_409_CONFLICT]),
+ dependencies=[Depends(requires_access_connection(method="POST")),
Depends(action_logging())],
+)
+def test_connection_async(
+ test_body: ConnectionTestRequestBody,
+ session: SessionDep,
+) -> ConnectionTestQueuedResponse:
+ """
+ Queue an async connection test to be executed on a worker.
+
+ The connection data is stored in the test request table and the worker
+ reads from there. Returns a token to poll for the result via
+ GET /connections/test-async/{token}.
+ """
+ _ensure_test_connection_enabled()
+
+ # Only one active test per connection_id at a time.
+ _check_no_active_test(test_body.connection_id, session)
+
+ connection_test = ConnectionTestRequest(
+ connection_id=test_body.connection_id,
+ conn_type=test_body.conn_type,
+ host=test_body.host,
+ login=test_body.login,
+ password=test_body.password,
+ schema=test_body.schema_,
+ port=test_body.port,
+ extra=test_body.extra,
+ commit_on_success=test_body.commit_on_success,
+ executor=test_body.executor,
+ queue=test_body.queue,
+ )
+ session.add(connection_test)
+ session.flush()
Review Comment:
removed thanks
##########
airflow-ctl/src/airflowctl/api/datamodels/generated.py:
##########
@@ -245,15 +245,58 @@ class ConnectionResponse(BaseModel):
team_name: Annotated[str | None, Field(title="Team Name")] = None
+class ConnectionTestQueuedResponse(BaseModel):
+ """
+ Response returned when an async connection test is queued.
+ """
+
+ token: Annotated[str, Field(title="Token")]
+ connection_id: Annotated[str, Field(title="Connection Id")]
+ state: Annotated[str, Field(title="State")]
+
+
+class ConnectionTestRequestBody(BaseModel):
+ """
+ Request body for async connection test.
+ """
+
+ model_config = ConfigDict(
+ extra="forbid",
+ )
+ connection_id: Annotated[str, Field(title="Connection Id")]
+ conn_type: Annotated[str, Field(title="Conn Type")]
+ host: Annotated[str | None, Field(title="Host")] = None
+ login: Annotated[str | None, Field(title="Login")] = None
+ schema_: Annotated[str | None, Field(alias="schema", title="Schema")] =
None
+ port: Annotated[int | None, Field(title="Port")] = None
+ password: Annotated[str | None, Field(title="Password")] = None
+ extra: Annotated[str | None, Field(title="Extra")] = None
+ commit_on_success: Annotated[bool | None, Field(title="Commit On
Success")] = False
+ executor: Annotated[str | None, Field(title="Executor")] = None
+ queue: Annotated[str | None, Field(title="Queue")] = None
+
+
class ConnectionTestResponse(BaseModel):
"""
- Connection Test serializer for responses.
+ Connection Test serializer for synchronous test responses.
"""
status: Annotated[bool, Field(title="Status")]
message: Annotated[str, Field(title="Message")]
+class ConnectionTestStatusResponse(BaseModel):
Review Comment:
updated thanks
--
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]