|
3 | 3 |
|
4 | 4 | from __future__ import annotations |
5 | 5 |
|
6 | | -from typing import TYPE_CHECKING |
| 6 | +from typing import TYPE_CHECKING, Any |
7 | 7 |
|
8 | 8 | from airbyte._util import api_util |
9 | 9 | from airbyte.cloud.connectors import CloudDestination, CloudSource |
@@ -280,6 +280,48 @@ def get_sync_result( |
280 | 280 | job_id=job_id, |
281 | 281 | ) |
282 | 282 |
|
| 283 | + # Artifacts |
| 284 | + |
| 285 | + def get_state_artifacts(self) -> list[dict[str, Any]] | None: |
| 286 | + """Get the connection state artifacts. |
| 287 | +
|
| 288 | + Returns the persisted state for this connection, which can be used |
| 289 | + when debugging incremental syncs. |
| 290 | +
|
| 291 | + Uses the Config API endpoint: POST /v1/state/get |
| 292 | +
|
| 293 | + Returns: |
| 294 | + List of state objects for each stream, or None if no state is set. |
| 295 | + """ |
| 296 | + state_response = api_util.get_connection_state( |
| 297 | + connection_id=self.connection_id, |
| 298 | + api_root=self.workspace.api_root, |
| 299 | + client_id=self.workspace.client_id, |
| 300 | + client_secret=self.workspace.client_secret, |
| 301 | + ) |
| 302 | + if state_response.get("stateType") == "not_set": |
| 303 | + return None |
| 304 | + return state_response.get("streamState", []) |
| 305 | + |
| 306 | + def get_catalog_artifact(self) -> dict[str, Any] | None: |
| 307 | + """Get the configured catalog for this connection. |
| 308 | +
|
| 309 | + Returns the full configured catalog (syncCatalog) for this connection, |
| 310 | + including stream schemas, sync modes, cursor fields, and primary keys. |
| 311 | +
|
| 312 | + Uses the Config API endpoint: POST /v1/web_backend/connections/get |
| 313 | +
|
| 314 | + Returns: |
| 315 | + Dictionary containing the configured catalog, or `None` if not found. |
| 316 | + """ |
| 317 | + connection_response = api_util.get_connection_catalog( |
| 318 | + connection_id=self.connection_id, |
| 319 | + api_root=self.workspace.api_root, |
| 320 | + client_id=self.workspace.client_id, |
| 321 | + client_secret=self.workspace.client_secret, |
| 322 | + ) |
| 323 | + return connection_response.get("syncCatalog") |
| 324 | + |
283 | 325 | def rename(self, name: str) -> CloudConnection: |
284 | 326 | """Rename the connection. |
285 | 327 |
|
|
0 commit comments