airbyte-cdk 6.19.1__py3-none-any.whl → 6.20.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,24 @@
1
1
  #
2
- # Copyright (c) 2023 Airbyte, Inc., all rights reserved.
2
+ # Copyright (c) 2025 Airbyte, Inc., all rights reserved.
3
3
  #
4
4
 
5
+ from typing import Mapping
6
+
7
+ from pydantic.v1 import BaseModel
8
+
9
+ from airbyte_cdk.sources.declarative.checks.check_dynamic_stream import CheckDynamicStream
5
10
  from airbyte_cdk.sources.declarative.checks.check_stream import CheckStream
6
11
  from airbyte_cdk.sources.declarative.checks.connection_checker import ConnectionChecker
12
+ from airbyte_cdk.sources.declarative.models import (
13
+ CheckDynamicStream as CheckDynamicStreamModel,
14
+ )
15
+ from airbyte_cdk.sources.declarative.models import (
16
+ CheckStream as CheckStreamModel,
17
+ )
18
+
19
+ COMPONENTS_CHECKER_TYPE_MAPPING: Mapping[str, type[BaseModel]] = {
20
+ "CheckStream": CheckStreamModel,
21
+ "CheckDynamicStream": CheckDynamicStreamModel,
22
+ }
7
23
 
8
- __all__ = ["CheckStream", "ConnectionChecker"]
24
+ __all__ = ["CheckStream", "CheckDynamicStream", "ConnectionChecker"]
@@ -0,0 +1,51 @@
1
+ #
2
+ # Copyright (c) 2025 Airbyte, Inc., all rights reserved.
3
+ #
4
+
5
+ import logging
6
+ import traceback
7
+ from dataclasses import InitVar, dataclass
8
+ from typing import Any, List, Mapping, Tuple
9
+
10
+ from airbyte_cdk import AbstractSource
11
+ from airbyte_cdk.sources.declarative.checks.connection_checker import ConnectionChecker
12
+ from airbyte_cdk.sources.streams.http.availability_strategy import HttpAvailabilityStrategy
13
+
14
+
15
+ @dataclass
16
+ class CheckDynamicStream(ConnectionChecker):
17
+ """
18
+ Checks the connections by checking availability of one or many dynamic streams
19
+
20
+ Attributes:
21
+ stream_count (int): numbers of streams to check
22
+ """
23
+
24
+ stream_count: int
25
+ parameters: InitVar[Mapping[str, Any]]
26
+
27
+ def __post_init__(self, parameters: Mapping[str, Any]) -> None:
28
+ self._parameters = parameters
29
+
30
+ def check_connection(
31
+ self, source: AbstractSource, logger: logging.Logger, config: Mapping[str, Any]
32
+ ) -> Tuple[bool, Any]:
33
+ streams = source.streams(config=config)
34
+ if len(streams) == 0:
35
+ return False, f"No streams to connect to from source {source}"
36
+
37
+ for stream_index in range(min(self.stream_count, len(streams))):
38
+ stream = streams[stream_index]
39
+ availability_strategy = HttpAvailabilityStrategy()
40
+ try:
41
+ stream_is_available, reason = availability_strategy.check_availability(
42
+ stream, logger
43
+ )
44
+ if not stream_is_available:
45
+ return False, reason
46
+ except Exception as error:
47
+ logger.error(
48
+ f"Encountered an error trying to connect to stream {stream.name}. Error: \n {traceback.format_exc()}"
49
+ )
50
+ return False, f"Unable to connect to stream {stream.name} - {error}"
51
+ return True, None
@@ -18,7 +18,9 @@ properties:
18
18
  type: string
19
19
  enum: [DeclarativeSource]
20
20
  check:
21
- "$ref": "#/definitions/CheckStream"
21
+ anyOf:
22
+ - "$ref": "#/definitions/CheckStream"
23
+ - "$ref": "#/definitions/CheckDynamicStream"
22
24
  streams:
23
25
  type: array
24
26
  items:
@@ -303,6 +305,21 @@ definitions:
303
305
  examples:
304
306
  - ["users"]
305
307
  - ["users", "contacts"]
308
+ CheckDynamicStream:
309
+ title: Dynamic Streams to Check
310
+ description: (This component is experimental. Use at your own risk.) Defines the dynamic streams to try reading when running a check operation.
311
+ type: object
312
+ required:
313
+ - type
314
+ - stream_count
315
+ properties:
316
+ type:
317
+ type: string
318
+ enum: [CheckDynamicStream]
319
+ stream_count:
320
+ title: Stream Count
321
+ description: Numbers of the streams to try reading from when running a check operation.
322
+ type: integer
306
323
  CompositeErrorHandler:
307
324
  title: Composite Error Handler
308
325
  description: Error handler that sequentially iterates over a list of error handlers.
@@ -22,6 +22,7 @@ from airbyte_cdk.models import (
22
22
  ConnectorSpecification,
23
23
  FailureType,
24
24
  )
25
+ from airbyte_cdk.sources.declarative.checks import COMPONENTS_CHECKER_TYPE_MAPPING
25
26
  from airbyte_cdk.sources.declarative.checks.connection_checker import ConnectionChecker
26
27
  from airbyte_cdk.sources.declarative.declarative_source import DeclarativeSource
27
28
  from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
@@ -107,7 +108,7 @@ class ManifestDeclarativeSource(DeclarativeSource):
107
108
  if "type" not in check:
108
109
  check["type"] = "CheckStream"
109
110
  check_stream = self._constructor.create_component(
110
- CheckStreamModel,
111
+ COMPONENTS_CHECKER_TYPE_MAPPING[check["type"]],
111
112
  check,
112
113
  dict(),
113
114
  emit_connector_builder_messages=self._emit_connector_builder_messages,
@@ -52,6 +52,15 @@ class CheckStream(BaseModel):
52
52
  )
53
53
 
54
54
 
55
+ class CheckDynamicStream(BaseModel):
56
+ type: Literal["CheckDynamicStream"]
57
+ stream_count: int = Field(
58
+ ...,
59
+ description="Numbers of the streams to try reading from when running a check operation.",
60
+ title="Stream Count",
61
+ )
62
+
63
+
55
64
  class ConcurrencyLevel(BaseModel):
56
65
  type: Optional[Literal["ConcurrencyLevel"]] = None
57
66
  default_concurrency: Union[int, str] = Field(
@@ -1661,7 +1670,7 @@ class DeclarativeSource1(BaseModel):
1661
1670
  extra = Extra.forbid
1662
1671
 
1663
1672
  type: Literal["DeclarativeSource"]
1664
- check: CheckStream
1673
+ check: Union[CheckStream, CheckDynamicStream]
1665
1674
  streams: List[DeclarativeStream]
1666
1675
  dynamic_streams: Optional[List[DynamicDeclarativeStream]] = None
1667
1676
  version: str = Field(
@@ -1687,7 +1696,7 @@ class DeclarativeSource2(BaseModel):
1687
1696
  extra = Extra.forbid
1688
1697
 
1689
1698
  type: Literal["DeclarativeSource"]
1690
- check: CheckStream
1699
+ check: Union[CheckStream, CheckDynamicStream]
1691
1700
  streams: Optional[List[DeclarativeStream]] = None
1692
1701
  dynamic_streams: List[DynamicDeclarativeStream]
1693
1702
  version: str = Field(
@@ -54,7 +54,7 @@ from airbyte_cdk.sources.declarative.auth.token_provider import (
54
54
  SessionTokenProvider,
55
55
  TokenProvider,
56
56
  )
57
- from airbyte_cdk.sources.declarative.checks import CheckStream
57
+ from airbyte_cdk.sources.declarative.checks import CheckDynamicStream, CheckStream
58
58
  from airbyte_cdk.sources.declarative.concurrency_level import ConcurrencyLevel
59
59
  from airbyte_cdk.sources.declarative.datetime import MinMaxDatetime
60
60
  from airbyte_cdk.sources.declarative.declarative_stream import DeclarativeStream
@@ -123,6 +123,9 @@ from airbyte_cdk.sources.declarative.models.declarative_component_schema import
123
123
  from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
124
124
  BearerAuthenticator as BearerAuthenticatorModel,
125
125
  )
126
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
127
+ CheckDynamicStream as CheckDynamicStreamModel,
128
+ )
126
129
  from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
127
130
  CheckStream as CheckStreamModel,
128
131
  )
@@ -493,6 +496,7 @@ class ModelToComponentFactory:
493
496
  BasicHttpAuthenticatorModel: self.create_basic_http_authenticator,
494
497
  BearerAuthenticatorModel: self.create_bearer_authenticator,
495
498
  CheckStreamModel: self.create_check_stream,
499
+ CheckDynamicStreamModel: self.create_check_dynamic_stream,
496
500
  CompositeErrorHandlerModel: self.create_composite_error_handler,
497
501
  CompositeRawDecoderModel: self.create_composite_raw_decoder,
498
502
  ConcurrencyLevelModel: self.create_concurrency_level,
@@ -846,6 +850,12 @@ class ModelToComponentFactory:
846
850
  def create_check_stream(model: CheckStreamModel, config: Config, **kwargs: Any) -> CheckStream:
847
851
  return CheckStream(stream_names=model.stream_names, parameters={})
848
852
 
853
+ @staticmethod
854
+ def create_check_dynamic_stream(
855
+ model: CheckDynamicStreamModel, config: Config, **kwargs: Any
856
+ ) -> CheckDynamicStream:
857
+ return CheckDynamicStream(stream_count=model.stream_count, parameters={})
858
+
849
859
  def create_composite_error_handler(
850
860
  self, model: CompositeErrorHandlerModel, config: Config, **kwargs: Any
851
861
  ) -> CompositeErrorHandler:
@@ -3,13 +3,12 @@
3
3
  - Components marked as optional are not required and can be ignored.
4
4
  - if `url_requester` is not provided, `urls_extractor` will get urls from the `polling_job_response`
5
5
  - interpolation_context, e.g. `create_job_response` or `polling_job_response` can be obtained from stream_slice
6
-
7
6
 
8
7
  ```mermaid
9
8
  ---
10
9
  title: AsyncHttpJobRepository Sequence Diagram
11
10
  ---
12
- sequenceDiagram
11
+ sequenceDiagram
13
12
  participant AsyncHttpJobRepository as AsyncOrchestrator
14
13
  participant CreationRequester as creation_requester
15
14
  participant PollingRequester as polling_requester
@@ -54,4 +53,4 @@ sequenceDiagram
54
53
  DeleteRequester -->> AsyncHttpJobRepository: Confirmation
55
54
 
56
55
 
57
- ```
56
+ ```
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: airbyte-cdk
3
- Version: 6.19.1
3
+ Version: 6.20.0
4
4
  Summary: A framework for writing Airbyte Connectors.
5
5
  License: MIT
6
6
  Keywords: airbyte,connector-development-kit,cdk
@@ -57,7 +57,8 @@ airbyte_cdk/sources/declarative/auth/oauth.py,sha256=GhXWheC5GkKV7req3jBCY0aTbFw
57
57
  airbyte_cdk/sources/declarative/auth/selective_authenticator.py,sha256=qGwC6YsCldr1bIeKG6Qo-A9a5cTdHw-vcOn3OtQrS4c,1540
58
58
  airbyte_cdk/sources/declarative/auth/token.py,sha256=r4u3WXyVa7WmiSZ9-eZXlrUI-pS0D4YWJnwjLzwV-Fk,11210
59
59
  airbyte_cdk/sources/declarative/auth/token_provider.py,sha256=9oq3dcBPAPwXSfkISjhA05dMhIzxaDQTmwOydBrnsMk,3028
60
- airbyte_cdk/sources/declarative/checks/__init__.py,sha256=WWXMfvKkndqwAUZdgSr7xVHVXDFTKCUQ9EubqT7H4QE,274
60
+ airbyte_cdk/sources/declarative/checks/__init__.py,sha256=nsVV5Bo0E_tBNd8A4Xdsdb-75PpcLo5RQu2RQ_Gv-ME,806
61
+ airbyte_cdk/sources/declarative/checks/check_dynamic_stream.py,sha256=aXKL1YSAB-0T_eZiavb7e5rprf-DdXG77Fy81FtlcWk,1843
61
62
  airbyte_cdk/sources/declarative/checks/check_stream.py,sha256=dAA-UhmMj0WLXCkRQrilWCfJmncBzXCZ18ptRNip3XA,2139
62
63
  airbyte_cdk/sources/declarative/checks/connection_checker.py,sha256=MBRJo6WJlZQHpIfOGaNOkkHUmgUl_4wDM6VPo41z5Ss,1383
63
64
  airbyte_cdk/sources/declarative/concurrency_level/__init__.py,sha256=5XUqrmlstYlMM0j6crktlKQwALek0uiz2D3WdM46MyA,191
@@ -66,7 +67,7 @@ airbyte_cdk/sources/declarative/concurrent_declarative_source.py,sha256=tSTCSmyM
66
67
  airbyte_cdk/sources/declarative/datetime/__init__.py,sha256=l9LG7Qm6e5r_qgqfVKnx3mXYtg1I9MmMjomVIPfU4XA,177
67
68
  airbyte_cdk/sources/declarative/datetime/datetime_parser.py,sha256=SX9JjdesN1edN2WVUVMzU_ptqp2QB1OnsnjZ4mwcX7w,2579
68
69
  airbyte_cdk/sources/declarative/datetime/min_max_datetime.py,sha256=0BHBtDNQZfvwM45-tY5pNlTcKAFSGGNxemoi0Jic-0E,5785
69
- airbyte_cdk/sources/declarative/declarative_component_schema.yaml,sha256=k_al8qcF6DSsm51IsZoUI8LCOlfZE141u2Iq5WEkfiI,135419
70
+ airbyte_cdk/sources/declarative/declarative_component_schema.yaml,sha256=fdrKoQkRUSJwS_k2xRxWTiXqwQv7jmM8mdEfdrnmdnc,136006
70
71
  airbyte_cdk/sources/declarative/declarative_source.py,sha256=nF7wBqFd3AQmEKAm4CnIo29CJoQL562cJGSCeL8U8bA,1531
71
72
  airbyte_cdk/sources/declarative/declarative_stream.py,sha256=JRyNeOIpsFu4ztVZsN6sncqUEIqIE-bUkD2TPgbMgk0,10375
72
73
  airbyte_cdk/sources/declarative/decoders/__init__.py,sha256=edGj4fGxznBk4xzRQyCA1rGfbpqe7z-RE0K3kQQWbgA,858
@@ -101,17 +102,17 @@ airbyte_cdk/sources/declarative/interpolation/interpolated_string.py,sha256=LYEZ
101
102
  airbyte_cdk/sources/declarative/interpolation/interpolation.py,sha256=-V5UddGm69UKEB6o_O1EIES9kfY8FV_X4Ji8w1yOuSA,981
102
103
  airbyte_cdk/sources/declarative/interpolation/jinja.py,sha256=BtsY_jtT4MihFqeQgc05HXj3Ndt-e2ESQgGwbg3Sdxc,6430
103
104
  airbyte_cdk/sources/declarative/interpolation/macros.py,sha256=Y5AWYxbJTUtJ_Jm7DV9qrZDiymFR9LST7fBt4piT2-U,4585
104
- airbyte_cdk/sources/declarative/manifest_declarative_source.py,sha256=wX_dQ401siuwh3zHgSHRnSN1vIojI4Nufg3BwzZAzk0,16239
105
+ airbyte_cdk/sources/declarative/manifest_declarative_source.py,sha256=_xCg7CfWQCDXVQx8ZRzcS6yuocfWzqLvOMLkgwEK5vw,16352
105
106
  airbyte_cdk/sources/declarative/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
106
107
  airbyte_cdk/sources/declarative/migrations/legacy_to_per_partition_state_migration.py,sha256=iemy3fKLczcU0-Aor7tx5jcT6DRedKMqyK7kCOp01hg,3924
107
108
  airbyte_cdk/sources/declarative/migrations/state_migration.py,sha256=KWPjealMLKSMtajXgkdGgKg7EmTLR-CqqD7UIh0-eDU,794
108
109
  airbyte_cdk/sources/declarative/models/__init__.py,sha256=nUFxNCiKeYRVXuZEKA7GD-lTHxsiKcQ8FitZjKhPIvE,100
109
- airbyte_cdk/sources/declarative/models/declarative_component_schema.py,sha256=2UabGD45tpF_5YzjpFKcQ4PiVfCvYSa7RbrUPW7M_ZQ,95465
110
+ airbyte_cdk/sources/declarative/models/declarative_component_schema.py,sha256=vdFgGfWWLGU9aQ9NK0f_g8r0FUkhV76kj3MsmDSzBT4,95776
110
111
  airbyte_cdk/sources/declarative/parsers/__init__.py,sha256=ZnqYNxHsKCgO38IwB34RQyRMXTs4GTvlRi3ImKnIioo,61
111
112
  airbyte_cdk/sources/declarative/parsers/custom_exceptions.py,sha256=Rir9_z3Kcd5Es0-LChrzk-0qubAsiK_RSEnLmK2OXm8,553
112
113
  airbyte_cdk/sources/declarative/parsers/manifest_component_transformer.py,sha256=CXwTfD3wSQq3okcqwigpprbHhSURUokh4GK2OmOyKC8,9132
113
114
  airbyte_cdk/sources/declarative/parsers/manifest_reference_resolver.py,sha256=IWUOdF03o-aQn0Occo1BJCxU0Pz-QILk5L67nzw2thw,6803
114
- airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py,sha256=9hSAdPJFG_ZUkIbdBuxj_IUKARNRsRi8a7xX82UqTQ8,111726
115
+ airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py,sha256=2GL54eoIQUvZbQVTnFED42dLdSfu6zYM1eMcOzImCyk,112189
115
116
  airbyte_cdk/sources/declarative/partition_routers/__init__.py,sha256=HJ-Syp3p7RpyR_OK0X_a2kSyISfu3W-PKrRI16iY0a8,957
116
117
  airbyte_cdk/sources/declarative/partition_routers/async_job_partition_router.py,sha256=n82J15S8bjeMZ5uROu--P3hnbQoxkY5v7RPHYx7g7ro,2929
117
118
  airbyte_cdk/sources/declarative/partition_routers/cartesian_product_stream_slicer.py,sha256=c5cuVFM6NFkuQqG8Z5IwkBuwDrvXZN1CunUOM_L0ezg,6892
@@ -119,7 +120,7 @@ airbyte_cdk/sources/declarative/partition_routers/list_partition_router.py,sha25
119
120
  airbyte_cdk/sources/declarative/partition_routers/partition_router.py,sha256=YyEIzdmLd1FjbVP3QbQ2VFCLW_P-OGbVh6VpZShp54k,2218
120
121
  airbyte_cdk/sources/declarative/partition_routers/single_partition_router.py,sha256=SKzKjSyfccq4dxGIh-J6ejrgkCHzaiTIazmbmeQiRD4,1942
121
122
  airbyte_cdk/sources/declarative/partition_routers/substream_partition_router.py,sha256=5bgXoJfBg_6i53krQMptAGb50XB5XoVfqQxKQhlLtBA,15383
122
- airbyte_cdk/sources/declarative/requesters/README.md,sha256=WabtHlwHg_J34aL1Kwm8vboYqBaSgsFjq10qR-P2sx8,2658
123
+ airbyte_cdk/sources/declarative/requesters/README.md,sha256=eL1I4iLkxaw7hJi9S9d18_XcRl-R8lUSjqBVJJzvXmg,2656
123
124
  airbyte_cdk/sources/declarative/requesters/__init__.py,sha256=d7a3OoHbqaJDyyPli3nqqJ2yAW_SLX6XDaBAKOwvpxw,364
124
125
  airbyte_cdk/sources/declarative/requesters/error_handlers/__init__.py,sha256=SkEDcJxlT1683rNx93K9whoS0OyUukkuOfToGtgpF58,776
125
126
  airbyte_cdk/sources/declarative/requesters/error_handlers/backoff_strategies/__init__.py,sha256=1WZdpFmWL6W_Dko0qjflTaKIWeqt8jHT-D6HcujIp3s,884
@@ -343,8 +344,8 @@ airbyte_cdk/utils/slice_hasher.py,sha256=-pHexlNYoWYPnXNH-M7HEbjmeJe9Zk7SJijdQ7d
343
344
  airbyte_cdk/utils/spec_schema_transformations.py,sha256=-5HTuNsnDBAhj-oLeQXwpTGA0HdcjFOf2zTEMUTTg_Y,816
344
345
  airbyte_cdk/utils/stream_status_utils.py,sha256=ZmBoiy5HVbUEHAMrUONxZvxnvfV9CesmQJLDTAIWnWw,1171
345
346
  airbyte_cdk/utils/traced_exception.py,sha256=C8uIBuCL_E4WnBAOPSxBicD06JAldoN9fGsQDp463OY,6292
346
- airbyte_cdk-6.19.1.dist-info/LICENSE.txt,sha256=Wfe61S4BaGPj404v8lrAbvhjYR68SHlkzeYrg3_bbuM,1051
347
- airbyte_cdk-6.19.1.dist-info/METADATA,sha256=vZseMtnWdaQvyzb3uh3Egn-ahu7vHW0mijR0meswMDk,6000
348
- airbyte_cdk-6.19.1.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
349
- airbyte_cdk-6.19.1.dist-info/entry_points.txt,sha256=fj-e3PAQvsxsQzyyq8UkG1k8spunWnD4BAH2AwlR6NM,95
350
- airbyte_cdk-6.19.1.dist-info/RECORD,,
347
+ airbyte_cdk-6.20.0.dist-info/LICENSE.txt,sha256=Wfe61S4BaGPj404v8lrAbvhjYR68SHlkzeYrg3_bbuM,1051
348
+ airbyte_cdk-6.20.0.dist-info/METADATA,sha256=mJ9CtFNvum2UmCz2OOr9aMcPRFbtgCsYiD5siTNUgnU,6000
349
+ airbyte_cdk-6.20.0.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
350
+ airbyte_cdk-6.20.0.dist-info/entry_points.txt,sha256=fj-e3PAQvsxsQzyyq8UkG1k8spunWnD4BAH2AwlR6NM,95
351
+ airbyte_cdk-6.20.0.dist-info/RECORD,,