1
0
mirror of synced 2025-12-26 14:02:10 -05:00
Files
airbyte/airbyte-cdk/python/airbyte_cdk/test/catalog_builder.py
2023-12-11 09:20:45 -05:00

30 lines
963 B
Python

# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
from typing import Any, Dict, List
from airbyte_protocol.models import ConfiguredAirbyteCatalog, SyncMode
class CatalogBuilder:
def __init__(self) -> None:
self._streams: List[Dict[str, Any]] = []
def with_stream(self, name: str, sync_mode: SyncMode) -> "CatalogBuilder":
self._streams.append(
{
"stream": {
"name": name,
"json_schema": {},
"supported_sync_modes": ["full_refresh", "incremental"],
"source_defined_primary_key": [["id"]],
},
"primary_key": [["id"]],
"sync_mode": sync_mode.name,
"destination_sync_mode": "overwrite",
}
)
return self
def build(self) -> ConfiguredAirbyteCatalog:
return ConfiguredAirbyteCatalog.parse_obj({"streams": self._streams})