airbyte-cdk 6.20.0__py3-none-any.whl → 6.21.0.dev0__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.
@@ -1513,6 +1513,7 @@ definitions:
1513
1513
  anyOf:
1514
1514
  - "$ref": "#/definitions/JsonDecoder"
1515
1515
  - "$ref": "#/definitions/XmlDecoder"
1516
+ - "$ref": "#/definitions/CompositeRawDecoder"
1516
1517
  $parameters:
1517
1518
  type: object
1518
1519
  additionalProperties: true
@@ -2067,6 +2068,24 @@ definitions:
2067
2068
  $parameters:
2068
2069
  type: object
2069
2070
  additionalProperties: true
2071
+ ZipfileDecoder:
2072
+ title: Zipfile Decoder
2073
+ description: Decoder for response data that is returned as zipfile(s).
2074
+ type: object
2075
+ additionalProperties: true
2076
+ required:
2077
+ - type
2078
+ - parser
2079
+ properties:
2080
+ type:
2081
+ type: string
2082
+ enum: [ZipfileDecoder]
2083
+ parser:
2084
+ title: Parser
2085
+ description: Parser to parse the decompressed data from the zipfile(s).
2086
+ anyOf:
2087
+ - "$ref": "#/definitions/GzipParser"
2088
+ - "$ref": "#/definitions/JsonParser"
2070
2089
  ListPartitionRouter:
2071
2090
  title: List Partition Router
2072
2091
  description: A Partition router that specifies a list of attributes where each attribute describes a portion of the complete data set for a stream. During a sync, each value is iterated over and can be used as input to outbound API requests.
@@ -2895,6 +2914,7 @@ definitions:
2895
2914
  - "$ref": "#/definitions/XmlDecoder"
2896
2915
  - "$ref": "#/definitions/GzipJsonDecoder"
2897
2916
  - "$ref": "#/definitions/CompositeRawDecoder"
2917
+ - "$ref": "#/definitions/ZipfileDecoder"
2898
2918
  $parameters:
2899
2919
  type: object
2900
2920
  additionalProperties: true
@@ -3093,6 +3113,8 @@ definitions:
3093
3113
  - "$ref": "#/definitions/IterableDecoder"
3094
3114
  - "$ref": "#/definitions/XmlDecoder"
3095
3115
  - "$ref": "#/definitions/GzipJsonDecoder"
3116
+ - "$ref": "#/definitions/CompositeRawDecoder"
3117
+ - "$ref": "#/definitions/ZipfileDecoder"
3096
3118
  download_decoder:
3097
3119
  title: Download Decoder
3098
3120
  description: Component decoding the download response so records can be extracted.
@@ -3103,6 +3125,8 @@ definitions:
3103
3125
  - "$ref": "#/definitions/IterableDecoder"
3104
3126
  - "$ref": "#/definitions/XmlDecoder"
3105
3127
  - "$ref": "#/definitions/GzipJsonDecoder"
3128
+ - "$ref": "#/definitions/CompositeRawDecoder"
3129
+ - "$ref": "#/definitions/ZipfileDecoder"
3106
3130
  $parameters:
3107
3131
  type: object
3108
3132
  additionalProperties: true
@@ -2,7 +2,12 @@
2
2
  # Copyright (c) 2023 Airbyte, Inc., all rights reserved.
3
3
  #
4
4
 
5
- from airbyte_cdk.sources.declarative.decoders.composite_raw_decoder import CompositeRawDecoder
5
+ from airbyte_cdk.sources.declarative.decoders.composite_raw_decoder import (
6
+ CompositeRawDecoder,
7
+ GzipParser,
8
+ JsonParser,
9
+ Parser,
10
+ )
6
11
  from airbyte_cdk.sources.declarative.decoders.decoder import Decoder
7
12
  from airbyte_cdk.sources.declarative.decoders.json_decoder import (
8
13
  GzipJsonDecoder,
@@ -15,15 +20,18 @@ from airbyte_cdk.sources.declarative.decoders.pagination_decoder_decorator impor
15
20
  PaginationDecoderDecorator,
16
21
  )
17
22
  from airbyte_cdk.sources.declarative.decoders.xml_decoder import XmlDecoder
23
+ from airbyte_cdk.sources.declarative.decoders.zipfile_decoder import ZipfileDecoder
18
24
 
19
25
  __all__ = [
20
26
  "Decoder",
21
27
  "CompositeRawDecoder",
22
28
  "JsonDecoder",
29
+ "JsonParser",
23
30
  "JsonlDecoder",
24
31
  "IterableDecoder",
25
32
  "GzipJsonDecoder",
26
33
  "NoopDecoder",
27
34
  "PaginationDecoderDecorator",
28
35
  "XmlDecoder",
36
+ "ZipfileDecoder",
29
37
  ]
@@ -0,0 +1,50 @@
1
+ #
2
+ # Copyright (c) 2024 Airbyte, Inc., all rights reserved.
3
+ #
4
+
5
+ import logging
6
+ import zipfile
7
+ from dataclasses import dataclass
8
+ from io import BytesIO
9
+ from typing import Any, Generator, MutableMapping
10
+
11
+ import orjson
12
+ import requests
13
+
14
+ from airbyte_cdk.models import FailureType
15
+ from airbyte_cdk.sources.declarative.decoders import Decoder
16
+ from airbyte_cdk.sources.declarative.decoders.composite_raw_decoder import (
17
+ Parser,
18
+ )
19
+ from airbyte_cdk.utils import AirbyteTracedException
20
+
21
+ logger = logging.getLogger("airbyte")
22
+
23
+
24
+ @dataclass
25
+ class ZipfileDecoder(Decoder):
26
+ parser: Parser
27
+
28
+ def is_stream_response(self) -> bool:
29
+ return False
30
+
31
+ def decode(
32
+ self, response: requests.Response
33
+ ) -> Generator[MutableMapping[str, Any], None, None]:
34
+ try:
35
+ zip_file = zipfile.ZipFile(BytesIO(response.content))
36
+ except zipfile.BadZipFile as e:
37
+ logger.error(
38
+ f"Received an invalid zip file in response to URL: {response.request.url}. "
39
+ f"The size of the response body is: {len(response.content)}"
40
+ )
41
+ raise AirbyteTracedException(
42
+ message="Received an invalid zip file in response.",
43
+ internal_message=f"Received an invalid zip file in response to URL: {response.request.url}.",
44
+ failure_type=FailureType.system_error,
45
+ ) from e
46
+
47
+ for file_name in zip_file.namelist():
48
+ unzipped_content = zip_file.read(file_name)
49
+ buffered_content = BytesIO(unzipped_content)
50
+ yield from self.parser.parse(buffered_content)
@@ -1222,9 +1222,6 @@ class LegacySessionTokenAuthenticator(BaseModel):
1222
1222
 
1223
1223
 
1224
1224
  class JsonParser(BaseModel):
1225
- class Config:
1226
- extra = Extra.allow
1227
-
1228
1225
  type: Literal["JsonParser"]
1229
1226
  encoding: Optional[str] = "utf-8"
1230
1227
 
@@ -1660,6 +1657,18 @@ class CompositeErrorHandler(BaseModel):
1660
1657
  parameters: Optional[Dict[str, Any]] = Field(None, alias="$parameters")
1661
1658
 
1662
1659
 
1660
+ class ZipfileDecoder(BaseModel):
1661
+ class Config:
1662
+ extra = Extra.allow
1663
+
1664
+ type: Literal["ZipfileDecoder"]
1665
+ parser: Union[GzipParser, JsonParser] = Field(
1666
+ ...,
1667
+ description="Parser to parse the decompressed data from the zipfile(s).",
1668
+ title="Parser",
1669
+ )
1670
+
1671
+
1663
1672
  class CompositeRawDecoder(BaseModel):
1664
1673
  type: Literal["CompositeRawDecoder"]
1665
1674
  parser: Union[GzipParser, JsonParser, JsonLineParser, CsvParser]
@@ -1865,7 +1874,7 @@ class SessionTokenAuthenticator(BaseModel):
1865
1874
  description="Authentication method to use for requests sent to the API, specifying how to inject the session token.",
1866
1875
  title="Data Request Authentication",
1867
1876
  )
1868
- decoder: Optional[Union[JsonDecoder, XmlDecoder]] = Field(
1877
+ decoder: Optional[Union[JsonDecoder, XmlDecoder, CompositeRawDecoder]] = Field(
1869
1878
  None, description="Component used to decode the response.", title="Decoder"
1870
1879
  )
1871
1880
  parameters: Optional[Dict[str, Any]] = Field(None, alias="$parameters")
@@ -2070,6 +2079,7 @@ class SimpleRetriever(BaseModel):
2070
2079
  XmlDecoder,
2071
2080
  GzipJsonDecoder,
2072
2081
  CompositeRawDecoder,
2082
+ ZipfileDecoder,
2073
2083
  ]
2074
2084
  ] = Field(
2075
2085
  None,
@@ -2146,6 +2156,8 @@ class AsyncRetriever(BaseModel):
2146
2156
  IterableDecoder,
2147
2157
  XmlDecoder,
2148
2158
  GzipJsonDecoder,
2159
+ CompositeRawDecoder,
2160
+ ZipfileDecoder,
2149
2161
  ]
2150
2162
  ] = Field(
2151
2163
  None,
@@ -2160,6 +2172,8 @@ class AsyncRetriever(BaseModel):
2160
2172
  IterableDecoder,
2161
2173
  XmlDecoder,
2162
2174
  GzipJsonDecoder,
2175
+ CompositeRawDecoder,
2176
+ ZipfileDecoder,
2163
2177
  ]
2164
2178
  ] = Field(
2165
2179
  None,
@@ -66,6 +66,7 @@ from airbyte_cdk.sources.declarative.decoders import (
66
66
  JsonlDecoder,
67
67
  PaginationDecoderDecorator,
68
68
  XmlDecoder,
69
+ ZipfileDecoder,
69
70
  )
70
71
  from airbyte_cdk.sources.declarative.decoders.composite_raw_decoder import (
71
72
  CompositeRawDecoder,
@@ -356,6 +357,9 @@ from airbyte_cdk.sources.declarative.models.declarative_component_schema import
356
357
  from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
357
358
  XmlDecoder as XmlDecoderModel,
358
359
  )
360
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
361
+ ZipfileDecoder as ZipfileDecoderModel,
362
+ )
359
363
  from airbyte_cdk.sources.declarative.partition_routers import (
360
364
  CartesianProductStreamSlicer,
361
365
  ListPartitionRouter,
@@ -571,6 +575,7 @@ class ModelToComponentFactory:
571
575
  ConfigComponentsResolverModel: self.create_config_components_resolver,
572
576
  StreamConfigModel: self.create_stream_config,
573
577
  ComponentMappingDefinitionModel: self.create_components_mapping_definition,
578
+ ZipfileDecoderModel: self.create_zipfile_decoder,
574
579
  }
575
580
 
576
581
  # Needed for the case where we need to perform a second parse on the fields of a custom component
@@ -1796,6 +1801,12 @@ class ModelToComponentFactory:
1796
1801
  ) -> GzipJsonDecoder:
1797
1802
  return GzipJsonDecoder(parameters={}, encoding=model.encoding)
1798
1803
 
1804
+ def create_zipfile_decoder(
1805
+ self, model: ZipfileDecoderModel, config: Config, **kwargs: Any
1806
+ ) -> ZipfileDecoder:
1807
+ parser = self._create_component_from_model(model=model.parser, config=config)
1808
+ return ZipfileDecoder(parser=parser)
1809
+
1799
1810
  def create_gzip_parser(
1800
1811
  self, model: GzipParserModel, config: Config, **kwargs: Any
1801
1812
  ) -> GzipParser:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: airbyte-cdk
3
- Version: 6.20.0
3
+ Version: 6.21.0.dev0
4
4
  Summary: A framework for writing Airbyte Connectors.
5
5
  License: MIT
6
6
  Keywords: airbyte,connector-development-kit,cdk
@@ -67,16 +67,17 @@ airbyte_cdk/sources/declarative/concurrent_declarative_source.py,sha256=tSTCSmyM
67
67
  airbyte_cdk/sources/declarative/datetime/__init__.py,sha256=l9LG7Qm6e5r_qgqfVKnx3mXYtg1I9MmMjomVIPfU4XA,177
68
68
  airbyte_cdk/sources/declarative/datetime/datetime_parser.py,sha256=SX9JjdesN1edN2WVUVMzU_ptqp2QB1OnsnjZ4mwcX7w,2579
69
69
  airbyte_cdk/sources/declarative/datetime/min_max_datetime.py,sha256=0BHBtDNQZfvwM45-tY5pNlTcKAFSGGNxemoi0Jic-0E,5785
70
- airbyte_cdk/sources/declarative/declarative_component_schema.yaml,sha256=fdrKoQkRUSJwS_k2xRxWTiXqwQv7jmM8mdEfdrnmdnc,136006
70
+ airbyte_cdk/sources/declarative/declarative_component_schema.yaml,sha256=7gJ3TfTU5m4WkBw_KOooYPfegjvuGhIwyuCXSEhpMZo,136842
71
71
  airbyte_cdk/sources/declarative/declarative_source.py,sha256=nF7wBqFd3AQmEKAm4CnIo29CJoQL562cJGSCeL8U8bA,1531
72
72
  airbyte_cdk/sources/declarative/declarative_stream.py,sha256=JRyNeOIpsFu4ztVZsN6sncqUEIqIE-bUkD2TPgbMgk0,10375
73
- airbyte_cdk/sources/declarative/decoders/__init__.py,sha256=edGj4fGxznBk4xzRQyCA1rGfbpqe7z-RE0K3kQQWbgA,858
73
+ airbyte_cdk/sources/declarative/decoders/__init__.py,sha256=KSpQetKGqPCv-38QgcVJ5kzM5nzbFldTSsYDCS3Xf0Y,1035
74
74
  airbyte_cdk/sources/declarative/decoders/composite_raw_decoder.py,sha256=kQfUVMVhChKe5OngwIQrs0F9KGnRUN-CKVFakCU23DQ,4354
75
75
  airbyte_cdk/sources/declarative/decoders/decoder.py,sha256=sl-Gt8lXi7yD2Q-sD8je5QS2PbgrgsYjxRLWsay7DMc,826
76
76
  airbyte_cdk/sources/declarative/decoders/json_decoder.py,sha256=qdbjeR6RffKaah_iWvMsOcDolYuxJY5DaI3b9AMTZXg,3327
77
77
  airbyte_cdk/sources/declarative/decoders/noop_decoder.py,sha256=iZh0yKY_JzgBnJWiubEusf5c0o6Khd-8EWFWT-8EgFo,542
78
78
  airbyte_cdk/sources/declarative/decoders/pagination_decoder_decorator.py,sha256=ZVBZhAOl0I0MymXN5CKTC-kIXG4GuUQAEyn0XpUDuSE,1081
79
79
  airbyte_cdk/sources/declarative/decoders/xml_decoder.py,sha256=EU-7t-5vIGRHZ14h-f0GUE4V5-eTM9Flux-A8xgI1Rc,3117
80
+ airbyte_cdk/sources/declarative/decoders/zipfile_decoder.py,sha256=zF1Zu1hhjbLvrCl69z0v-j8FPnfHX1KLK3KgyxnTb78,1607
80
81
  airbyte_cdk/sources/declarative/exceptions.py,sha256=kTPUA4I2NV4J6HDz-mKPGMrfuc592akJnOyYx38l_QM,176
81
82
  airbyte_cdk/sources/declarative/extractors/__init__.py,sha256=RmV-IkO1YLj0PSOrrqC9AV1gO8-90t8UTDVfJGshN9E,754
82
83
  airbyte_cdk/sources/declarative/extractors/dpath_extractor.py,sha256=wR4Ol4MG2lt5UlqXF5EU_k7qa5cN4_-luu3PJ1PlO3A,3131
@@ -107,12 +108,12 @@ airbyte_cdk/sources/declarative/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW
107
108
  airbyte_cdk/sources/declarative/migrations/legacy_to_per_partition_state_migration.py,sha256=iemy3fKLczcU0-Aor7tx5jcT6DRedKMqyK7kCOp01hg,3924
108
109
  airbyte_cdk/sources/declarative/migrations/state_migration.py,sha256=KWPjealMLKSMtajXgkdGgKg7EmTLR-CqqD7UIh0-eDU,794
109
110
  airbyte_cdk/sources/declarative/models/__init__.py,sha256=nUFxNCiKeYRVXuZEKA7GD-lTHxsiKcQ8FitZjKhPIvE,100
110
- airbyte_cdk/sources/declarative/models/declarative_component_schema.py,sha256=vdFgGfWWLGU9aQ9NK0f_g8r0FUkhV76kj3MsmDSzBT4,95776
111
+ airbyte_cdk/sources/declarative/models/declarative_component_schema.py,sha256=CDcYWVUIQoT50X1j1Zb_bejerg1rMxZjVcNa6rJ5JMA,96194
111
112
  airbyte_cdk/sources/declarative/parsers/__init__.py,sha256=ZnqYNxHsKCgO38IwB34RQyRMXTs4GTvlRi3ImKnIioo,61
112
113
  airbyte_cdk/sources/declarative/parsers/custom_exceptions.py,sha256=Rir9_z3Kcd5Es0-LChrzk-0qubAsiK_RSEnLmK2OXm8,553
113
114
  airbyte_cdk/sources/declarative/parsers/manifest_component_transformer.py,sha256=CXwTfD3wSQq3okcqwigpprbHhSURUokh4GK2OmOyKC8,9132
114
115
  airbyte_cdk/sources/declarative/parsers/manifest_reference_resolver.py,sha256=IWUOdF03o-aQn0Occo1BJCxU0Pz-QILk5L67nzw2thw,6803
115
- airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py,sha256=2GL54eoIQUvZbQVTnFED42dLdSfu6zYM1eMcOzImCyk,112189
116
+ airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py,sha256=L8iHeRywEPZ4mDUK8oh3A7Vn6-d-6MHyLBWxlLyKVTc,112659
116
117
  airbyte_cdk/sources/declarative/partition_routers/__init__.py,sha256=HJ-Syp3p7RpyR_OK0X_a2kSyISfu3W-PKrRI16iY0a8,957
117
118
  airbyte_cdk/sources/declarative/partition_routers/async_job_partition_router.py,sha256=n82J15S8bjeMZ5uROu--P3hnbQoxkY5v7RPHYx7g7ro,2929
118
119
  airbyte_cdk/sources/declarative/partition_routers/cartesian_product_stream_slicer.py,sha256=c5cuVFM6NFkuQqG8Z5IwkBuwDrvXZN1CunUOM_L0ezg,6892
@@ -344,8 +345,8 @@ airbyte_cdk/utils/slice_hasher.py,sha256=-pHexlNYoWYPnXNH-M7HEbjmeJe9Zk7SJijdQ7d
344
345
  airbyte_cdk/utils/spec_schema_transformations.py,sha256=-5HTuNsnDBAhj-oLeQXwpTGA0HdcjFOf2zTEMUTTg_Y,816
345
346
  airbyte_cdk/utils/stream_status_utils.py,sha256=ZmBoiy5HVbUEHAMrUONxZvxnvfV9CesmQJLDTAIWnWw,1171
346
347
  airbyte_cdk/utils/traced_exception.py,sha256=C8uIBuCL_E4WnBAOPSxBicD06JAldoN9fGsQDp463OY,6292
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,,
348
+ airbyte_cdk-6.21.0.dev0.dist-info/LICENSE.txt,sha256=Wfe61S4BaGPj404v8lrAbvhjYR68SHlkzeYrg3_bbuM,1051
349
+ airbyte_cdk-6.21.0.dev0.dist-info/METADATA,sha256=dv48GD8Zw_hcpqCpeJZsMd2pKjnSVxtT0S4z3JcAb84,6005
350
+ airbyte_cdk-6.21.0.dev0.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
351
+ airbyte_cdk-6.21.0.dev0.dist-info/entry_points.txt,sha256=fj-e3PAQvsxsQzyyq8UkG1k8spunWnD4BAH2AwlR6NM,95
352
+ airbyte_cdk-6.21.0.dev0.dist-info/RECORD,,