Skip to content

Commit 75c39fe

Browse files
committed
Add detailed connection testing to connectors documentation and implementation
- Introduced a new method `test_connection_detailed` in `ConnectorsResource` to return detailed connection test results, including elapsed time. - Updated documentation to include examples for both basic and detailed connection testing.
1 parent d4bec33 commit 75c39fe

3 files changed

Lines changed: 27 additions & 4 deletions

File tree

docs/guides/connectors.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ Test connection (basic):
3737
ok = client.connectors.test_connection(conn.id)
3838
```
3939

40+
Test connection (detailed):
41+
```python
42+
details = client.connectors.test_connection_detailed(conn.id)
43+
# {'ok': True, 'elapsed_ms': 123}
44+
```
45+
4046
Filter by type:
4147
```python
4248
pg = client.connectors.list_by_type("postgres")
@@ -64,4 +70,5 @@ snowflake_conn = client.connectors.create(
6470

6571
# Optional: test the connection
6672
ok = client.connectors.test_connection(snowflake_conn.id)
73+
details = client.connectors.test_connection_detailed(snowflake_conn.id)
6774
```

documentation/docs/guides/connectors.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ Test connection (basic):
3737
ok = client.connectors.test_connection(conn.id)
3838
```
3939

40+
Test connection (detailed):
41+
```python
42+
details = client.connectors.test_connection_detailed(conn.id)
43+
# {'ok': True, 'elapsed_ms': 123}
44+
```
45+
4046
Filter by type:
4147
```python
4248
pg = client.connectors.list_by_type("postgres")
@@ -64,6 +70,7 @@ snowflake_conn = client.connectors.create(
6470

6571
# Optional: test the connection
6672
ok = client.connectors.test_connection(snowflake_conn.id)
73+
details = client.connectors.test_connection_detailed(snowflake_conn.id)
6774
```
6875

6976

resources/connectors.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,12 +267,21 @@ def test_connection(self, connector_id: str) -> bool:
267267
```
268268
"""
269269
try:
270-
# This would typically be a separate endpoint, but for now we'll use get
271-
# In a real implementation, there might be a POST /connectors/{id}/test endpoint
272-
connector = self.get(connector_id)
273-
return True
270+
resp = self._client.post(f"/connectors/{connector_id}/test")
271+
return bool(resp.get("ok", False))
274272
except Exception as e:
275273
raise ValidationError(f"Connection test failed: {str(e)}")
274+
275+
def test_connection_detailed(self, connector_id: str) -> dict:
276+
"""Test a connector and return detailed response (e.g., elapsed_ms).
277+
278+
Args:
279+
connector_id: The connector ID to test
280+
281+
Returns:
282+
Dict with fields like { ok: bool, elapsed_ms: int }
283+
"""
284+
return self._client.post(f"/connectors/{connector_id}/test")
276285

277286
def list_by_type(self, db_type: str) -> List[Connector]:
278287
"""List connectors by database type.

0 commit comments

Comments
 (0)