bbovenzi commented on code in PR #76458:
URL: https://github.com/apache/airflow/pull/76458#discussion_r4530018993


##########
airflow-core/newsfragments/76458.significant.rst:
##########


Review Comment:
   This is a new newsfragment. Not replacing an older one like the PR 
description said



##########
airflow-core/src/airflow/api_fastapi/core_api/datamodels/connections.py:
##########
@@ -288,6 +288,58 @@ def validate_team_name(self) -> ConnectionBody:
 ConnectionBodyPartial = make_partial_model(ConnectionBody)
 
 
+def _contains_mask(value: Any) -> bool:
+    if isinstance(value, dict):
+        return any(_contains_mask(item) for item in value.values())
+    if isinstance(value, list):
+        return any(_contains_mask(item) for item in value)
+    return value == _MASK
+
+
+class ConnectionTestBody(ConnectionBody):
+    """
+    Connection to test.
+
+    Either only ``connection_id``, to test the stored connection as it is, or 
a complete
+    connection, tested exactly as given. A stored connection's secrets are 
never
+    combined with a connection supplied in the request.
+    """
+
+    conn_type: str | None = None  # type: ignore[assignment]
+
+    def is_stored_connection(self) -> bool:
+        """Return True when the request only names the stored connection to 
test."""
+        return self.model_fields_set == {"connection_id"}
+
+    @model_validator(mode="after")
+    def validate_complete_connection(self) -> ConnectionTestBody:
+        if self.is_stored_connection():
+            return self
+        missing = {
+            "conn_type",
+            "host",
+            "login",
+            "schema_",
+            "port",
+            "password",
+            "extra",
+        } - self.model_fields_set

Review Comment:
   Do we want to force users to have to explicitly set all of these fields as 
null if they don't want to include them? If its not included it would be none 
by default



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