airbyte-cdk 6.48.4__py3-none-any.whl → 6.48.6__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.
@@ -2,9 +2,10 @@
2
2
  # Copyright (c) 2023 Airbyte, Inc., all rights reserved.
3
3
  #
4
4
 
5
+ import logging
5
6
  from dataclasses import InitVar, dataclass, field
6
7
  from datetime import datetime, timedelta
7
- from typing import Any, List, Mapping, MutableMapping, Optional, Union
8
+ from typing import Any, List, Mapping, Optional, Union
8
9
 
9
10
  from airbyte_cdk.sources.declarative.auth.declarative_authenticator import DeclarativeAuthenticator
10
11
  from airbyte_cdk.sources.declarative.interpolation.interpolated_boolean import InterpolatedBoolean
@@ -19,6 +20,8 @@ from airbyte_cdk.sources.streams.http.requests_native_auth.oauth import (
19
20
  )
20
21
  from airbyte_cdk.utils.datetime_helpers import AirbyteDateTime, ab_datetime_now, ab_datetime_parse
21
22
 
23
+ logger = logging.getLogger("airbyte")
24
+
22
25
 
23
26
  @dataclass
24
27
  class DeclarativeOauth2Authenticator(AbstractOauth2Authenticator, DeclarativeAuthenticator):
@@ -30,7 +33,7 @@ class DeclarativeOauth2Authenticator(AbstractOauth2Authenticator, DeclarativeAut
30
33
  Attributes:
31
34
  token_refresh_endpoint (Union[InterpolatedString, str]): The endpoint to refresh the access token
32
35
  client_id (Union[InterpolatedString, str]): The client id
33
- client_secret (Union[InterpolatedString, str]): Client secret
36
+ client_secret (Union[InterpolatedString, str]): Client secret (can be empty for APIs that support this)
34
37
  refresh_token (Union[InterpolatedString, str]): The token used to refresh the access token
35
38
  access_token_name (Union[InterpolatedString, str]): THe field to extract access token from in the response
36
39
  expires_in_name (Union[InterpolatedString, str]): The field to extract expires_in from in the response
@@ -201,8 +204,11 @@ class DeclarativeOauth2Authenticator(AbstractOauth2Authenticator, DeclarativeAut
201
204
  self._client_secret.eval(self.config) if self._client_secret else self._client_secret
202
205
  )
203
206
  if not client_secret:
204
- raise ValueError("OAuthAuthenticator was unable to evaluate client_secret parameter")
205
- return client_secret # type: ignore # value will be returned as a string, or an error will be raised
207
+ # We've seen some APIs allowing empty client_secret so we will only log here
208
+ logger.warning(
209
+ "OAuthAuthenticator was unable to evaluate client_secret parameter hence it'll be empty"
210
+ )
211
+ return client_secret # type: ignore # value will be returned as a string, which might be empty
206
212
 
207
213
  def get_refresh_token_name(self) -> str:
208
214
  return self._refresh_token_name.eval(self.config) # type: ignore # eval returns a string in this context
@@ -16,6 +16,7 @@ import click
16
16
  from airbyte_cdk.models.connector_metadata import ConnectorLanguage, MetadataFile
17
17
  from airbyte_cdk.utils.docker_image_templates import (
18
18
  DOCKERIGNORE_TEMPLATE,
19
+ JAVA_CONNECTOR_DOCKERFILE_TEMPLATE,
19
20
  MANIFEST_ONLY_DOCKERFILE_TEMPLATE,
20
21
  PYTHON_CONNECTOR_DOCKERFILE_TEMPLATE,
21
22
  )
@@ -197,6 +198,22 @@ def build_connector_image(
197
198
 
198
199
  base_tag = f"{metadata.data.dockerRepository}:{tag}"
199
200
  arch_images: list[str] = []
201
+
202
+ if metadata.data.language == ConnectorLanguage.JAVA:
203
+ # This assumes that the repo root ('airbyte') is three levels above the
204
+ # connector directory (airbyte/airbyte-integrations/connectors/source-foo).
205
+ repo_root = connector_directory.parent.parent.parent
206
+ # For Java connectors, we need to build the connector tar file first.
207
+ subprocess.run(
208
+ [
209
+ "./gradlew",
210
+ f":airbyte-integrations:connectors:{connector_name}:distTar",
211
+ ],
212
+ cwd=repo_root,
213
+ text=True,
214
+ check=True,
215
+ )
216
+
200
217
  for arch in [ArchEnum.AMD64, ArchEnum.ARM64]:
201
218
  docker_tag = f"{base_tag}-{arch.value}"
202
219
  docker_tag_parts = docker_tag.split("/")
@@ -248,10 +265,7 @@ def get_dockerfile_template(
248
265
  return MANIFEST_ONLY_DOCKERFILE_TEMPLATE
249
266
 
250
267
  if metadata.data.language == ConnectorLanguage.JAVA:
251
- raise ValueError(
252
- f"Java and Kotlin connectors are not yet supported. "
253
- "Please use airbyte-ci or gradle to build your image."
254
- )
268
+ return JAVA_CONNECTOR_DOCKERFILE_TEMPLATE
255
269
 
256
270
  raise ValueError(
257
271
  f"Unsupported connector language: {metadata.data.language}. "
@@ -322,10 +336,20 @@ def verify_connector_image(
322
336
  )
323
337
  # check that the output is valid JSON
324
338
  if result.stdout:
325
- try:
326
- json.loads(result.stdout)
327
- except json.JSONDecodeError:
328
- logger.error("Invalid JSON output from spec command.")
339
+ found_spec_output = False
340
+ for line in result.stdout.split("\n"):
341
+ if line.strip():
342
+ try:
343
+ # Check if the line is a valid JSON object
344
+ msg = json.loads(line)
345
+ if isinstance(msg, dict) and "type" in msg and msg["type"] == "SPEC":
346
+ found_spec_output = True
347
+
348
+ except json.JSONDecodeError as e:
349
+ logger.warning(f"Invalid JSON output from spec command: {e}: {line}")
350
+
351
+ if not found_spec_output:
352
+ logger.error("No valid JSON output found for spec command.")
329
353
  return False
330
354
  else:
331
355
  logger.error("No output from spec command.")
@@ -14,8 +14,9 @@ These templates are used to generate connector images.
14
14
  DOCKERIGNORE_TEMPLATE: str = "\n".join(
15
15
  [
16
16
  "# This file is auto-generated. Do not edit.",
17
- # "*,"
17
+ "*," # Ignore everything not explicitly allowed below
18
18
  "build/",
19
+ "!build/distributions/*.tar",
19
20
  ".venv/",
20
21
  "secrets/",
21
22
  "!setup.py",
@@ -36,7 +37,7 @@ DOCKERIGNORE_TEMPLATE: str = "\n".join(
36
37
  # PYTHON CONNECTOR IMAGE ##
37
38
  ###########################
38
39
 
39
- PYTHON_CONNECTOR_DOCKERFILE_TEMPLATE = """
40
+ PYTHON_CONNECTOR_DOCKERFILE_TEMPLATE = r"""
40
41
  # syntax=docker/dockerfile:1
41
42
  # check=skip=all
42
43
  ARG BASE_IMAGE
@@ -99,3 +100,37 @@ COPY . ./
99
100
  ENV AIRBYTE_ENTRYPOINT="python ./main.py"
100
101
  ENTRYPOINT ["python", "./main.py"]
101
102
  """
103
+
104
+ #########################
105
+ # JAVA CONNECTOR IMAGE ##
106
+ #########################
107
+
108
+ JAVA_CONNECTOR_DOCKERFILE_TEMPLATE = """
109
+ # Java connector Dockerfile for Airbyte
110
+
111
+ # Build arguments
112
+ ARG BASE_IMAGE
113
+
114
+ # Base image - using Amazon Corretto (Amazon's distribution of OpenJDK)
115
+ FROM ${BASE_IMAGE}
116
+ ARG CONNECTOR_KEBAB_NAME
117
+
118
+ # Set permissions for downloaded files
119
+ RUN chmod +x /airbyte/base.sh /airbyte/javabase.sh && \
120
+ chown airbyte:airbyte /airbyte/base.sh /airbyte/javabase.sh /airbyte/dd-java-agent.jar
121
+
122
+ ENV AIRBYTE_ENTRYPOINT="/airbyte/base.sh"
123
+ ENV APPLICATION="${CONNECTOR_KEBAB_NAME}"
124
+
125
+ # Add the connector TAR file and extract it
126
+ COPY ./build/distributions/${CONNECTOR_KEBAB_NAME}.tar /tmp/${CONNECTOR_KEBAB_NAME}.tar
127
+ RUN tar xf /tmp/${CONNECTOR_KEBAB_NAME}.tar --strip-components=1 -C /airbyte && \
128
+ rm -rf /tmp/${CONNECTOR_KEBAB_NAME}.tar && \
129
+ chown -R airbyte:airbyte /airbyte
130
+
131
+ # Set the non-root user
132
+ USER airbyte
133
+
134
+ # Set entrypoint
135
+ ENTRYPOINT ["/airbyte/base.sh"]
136
+ """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: airbyte-cdk
3
- Version: 6.48.4
3
+ Version: 6.48.6
4
4
  Summary: A framework for writing Airbyte Connectors.
5
5
  Home-page: https://airbyte.com
6
6
  License: MIT
@@ -75,7 +75,7 @@ airbyte_cdk/sources/declarative/async_job/timer.py,sha256=Fb8P72CQ7jIzJyzMSSNuBf
75
75
  airbyte_cdk/sources/declarative/auth/__init__.py,sha256=e2CRrcBWGhz3sQu3Oh34d1riEIwXipGS8hrSB1pu0Oo,284
76
76
  airbyte_cdk/sources/declarative/auth/declarative_authenticator.py,sha256=nf-OmRUHYG4ORBwyb5CANzuHEssE-oNmL-Lccn41Td8,1099
77
77
  airbyte_cdk/sources/declarative/auth/jwt.py,sha256=SICqNsN2Cn_EgKadIgWuZpQxuMHyzrMZD_2-Uwy10rY,8539
78
- airbyte_cdk/sources/declarative/auth/oauth.py,sha256=Uxh3EpIV0noe23e1j8efoegjk1d5B7xyVAFSaFtbwoQ,14127
78
+ airbyte_cdk/sources/declarative/auth/oauth.py,sha256=bCwf3f3Td_CA8DZ6CXMVPNiImM9QEGDxkcLKzSo3-f0,14339
79
79
  airbyte_cdk/sources/declarative/auth/selective_authenticator.py,sha256=qGwC6YsCldr1bIeKG6Qo-A9a5cTdHw-vcOn3OtQrS4c,1540
80
80
  airbyte_cdk/sources/declarative/auth/token.py,sha256=2EnE78EhBOY9hbeZnQJ9AuFaM-G7dccU-oKo_LThRQk,11070
81
81
  airbyte_cdk/sources/declarative/auth/token_provider.py,sha256=Jzuxlmt1_-_aFC_n0OmP8L1nDOacLzbEVVx3kjdX_W8,3104
@@ -395,8 +395,8 @@ airbyte_cdk/utils/analytics_message.py,sha256=bi3uugQ2NjecnwTnz63iD5D1M8ZR8mXPbd
395
395
  airbyte_cdk/utils/constants.py,sha256=QzCi7j5SqpI5I06uRvQ8FC73JVJi7rXaRnR3E_gro5c,108
396
396
  airbyte_cdk/utils/datetime_format_inferrer.py,sha256=Ne2cpk7Tx3eZDEW2Q3O7jnNOY9g-w-AUMt3Ltvwg1tY,3989
397
397
  airbyte_cdk/utils/datetime_helpers.py,sha256=8mqzZ67Or2PBp7tLtrhh6XFv4wFzYsjCL_DOQJRaftI,17751
398
- airbyte_cdk/utils/docker.py,sha256=tLetbEzcC5xBPsFFcPrUzN3mNsutm0_8Vy7a6grFm60,10033
399
- airbyte_cdk/utils/docker_image_templates.py,sha256=KCilUF-tab4aDJxsgWqywafMg5OUkixuXFsThuVi1VU,2352
398
+ airbyte_cdk/utils/docker.py,sha256=kM8DmRsA5a4_kJmZYwlAIaSjHeTfkVV-Gmp10ADkh80,11062
399
+ airbyte_cdk/utils/docker_image_templates.py,sha256=X8f_aRgt_x8yIbrTfsSWw_oIERu65a8hNttcgXA7hlw,3417
400
400
  airbyte_cdk/utils/event_timing.py,sha256=aiuFmPU80buLlNdKq4fDTEqqhEIelHPF6AalFGwY8as,2557
401
401
  airbyte_cdk/utils/is_cloud_environment.py,sha256=DayV32Irh-SdnJ0MnjvstwCJ66_l5oEsd8l85rZtHoc,574
402
402
  airbyte_cdk/utils/mapping_helpers.py,sha256=nWjOpnz_5QE9tY9-GtSWMPvYQL95kDD6k8KwwjUmrh0,6526
@@ -408,9 +408,9 @@ airbyte_cdk/utils/slice_hasher.py,sha256=EDxgROHDbfG-QKQb59m7h_7crN1tRiawdf5uU7G
408
408
  airbyte_cdk/utils/spec_schema_transformations.py,sha256=-5HTuNsnDBAhj-oLeQXwpTGA0HdcjFOf2zTEMUTTg_Y,816
409
409
  airbyte_cdk/utils/stream_status_utils.py,sha256=ZmBoiy5HVbUEHAMrUONxZvxnvfV9CesmQJLDTAIWnWw,1171
410
410
  airbyte_cdk/utils/traced_exception.py,sha256=C8uIBuCL_E4WnBAOPSxBicD06JAldoN9fGsQDp463OY,6292
411
- airbyte_cdk-6.48.4.dist-info/LICENSE.txt,sha256=Wfe61S4BaGPj404v8lrAbvhjYR68SHlkzeYrg3_bbuM,1051
412
- airbyte_cdk-6.48.4.dist-info/LICENSE_SHORT,sha256=aqF6D1NcESmpn-cqsxBtszTEnHKnlsp8L4x9wAh3Nxg,55
413
- airbyte_cdk-6.48.4.dist-info/METADATA,sha256=hXMMplkbvREua_CfMKw1NaOIGbD43pmoz1tURhdTUWg,6343
414
- airbyte_cdk-6.48.4.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
415
- airbyte_cdk-6.48.4.dist-info/entry_points.txt,sha256=AKWbEkHfpzzk9nF9tqBUaw1MbvTM4mGtEzmZQm0ZWvM,139
416
- airbyte_cdk-6.48.4.dist-info/RECORD,,
411
+ airbyte_cdk-6.48.6.dist-info/LICENSE.txt,sha256=Wfe61S4BaGPj404v8lrAbvhjYR68SHlkzeYrg3_bbuM,1051
412
+ airbyte_cdk-6.48.6.dist-info/LICENSE_SHORT,sha256=aqF6D1NcESmpn-cqsxBtszTEnHKnlsp8L4x9wAh3Nxg,55
413
+ airbyte_cdk-6.48.6.dist-info/METADATA,sha256=ukLCWdp4GYARrBEW7wQubufsruhncIeEhAvMFweXs9Y,6343
414
+ airbyte_cdk-6.48.6.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
415
+ airbyte_cdk-6.48.6.dist-info/entry_points.txt,sha256=AKWbEkHfpzzk9nF9tqBUaw1MbvTM4mGtEzmZQm0ZWvM,139
416
+ airbyte_cdk-6.48.6.dist-info/RECORD,,