Skip to content

Commit 12043e5

Browse files
committed
chore: format
1 parent e36067a commit 12043e5

File tree

4 files changed

+179
-155
lines changed

4 files changed

+179
-155
lines changed

airbyte_cdk/sources/declarative/models/declarative_component_schema.py

Lines changed: 40 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -618,9 +618,7 @@ class OAuthAuthenticator(BaseModel):
618618
scopes: Optional[List[str]] = Field(
619619
None,
620620
description="List of scopes that should be granted to the access token.",
621-
examples=[
622-
["crm.list.read", "crm.objects.contacts.read", "crm.schema.contacts.read"]
623-
],
621+
examples=[["crm.list.read", "crm.objects.contacts.read", "crm.schema.contacts.read"]],
624622
title="Scopes",
625623
)
626624
token_expiry_date: Optional[str] = Field(
@@ -1126,28 +1124,24 @@ class OAuthConfigSpecification(BaseModel):
11261124
class Config:
11271125
extra = Extra.allow
11281126

1129-
oauth_user_input_from_connector_config_specification: Optional[Dict[str, Any]] = (
1130-
Field(
1131-
None,
1132-
description="OAuth specific blob. This is a Json Schema used to validate Json configurations used as input to OAuth.\nMust be a valid non-nested JSON that refers to properties from ConnectorSpecification.connectionSpecification\nusing special annotation 'path_in_connector_config'.\nThese are input values the user is entering through the UI to authenticate to the connector, that might also shared\nas inputs for syncing data via the connector.\nExamples:\nif no connector values is shared during oauth flow, oauth_user_input_from_connector_config_specification=[]\nif connector values such as 'app_id' inside the top level are used to generate the API url for the oauth flow,\n oauth_user_input_from_connector_config_specification={\n app_id: {\n type: string\n path_in_connector_config: ['app_id']\n }\n }\nif connector values such as 'info.app_id' nested inside another object are used to generate the API url for the oauth flow,\n oauth_user_input_from_connector_config_specification={\n app_id: {\n type: string\n path_in_connector_config: ['info', 'app_id']\n }\n }",
1133-
examples=[
1134-
{"app_id": {"type": "string", "path_in_connector_config": ["app_id"]}},
1135-
{
1136-
"app_id": {
1137-
"type": "string",
1138-
"path_in_connector_config": ["info", "app_id"],
1139-
}
1140-
},
1141-
],
1142-
title="OAuth user input",
1143-
)
1127+
oauth_user_input_from_connector_config_specification: Optional[Dict[str, Any]] = Field(
1128+
None,
1129+
description="OAuth specific blob. This is a Json Schema used to validate Json configurations used as input to OAuth.\nMust be a valid non-nested JSON that refers to properties from ConnectorSpecification.connectionSpecification\nusing special annotation 'path_in_connector_config'.\nThese are input values the user is entering through the UI to authenticate to the connector, that might also shared\nas inputs for syncing data via the connector.\nExamples:\nif no connector values is shared during oauth flow, oauth_user_input_from_connector_config_specification=[]\nif connector values such as 'app_id' inside the top level are used to generate the API url for the oauth flow,\n oauth_user_input_from_connector_config_specification={\n app_id: {\n type: string\n path_in_connector_config: ['app_id']\n }\n }\nif connector values such as 'info.app_id' nested inside another object are used to generate the API url for the oauth flow,\n oauth_user_input_from_connector_config_specification={\n app_id: {\n type: string\n path_in_connector_config: ['info', 'app_id']\n }\n }",
1130+
examples=[
1131+
{"app_id": {"type": "string", "path_in_connector_config": ["app_id"]}},
1132+
{
1133+
"app_id": {
1134+
"type": "string",
1135+
"path_in_connector_config": ["info", "app_id"],
1136+
}
1137+
},
1138+
],
1139+
title="OAuth user input",
11441140
)
1145-
oauth_connector_input_specification: Optional[OauthConnectorInputSpecification] = (
1146-
Field(
1147-
None,
1148-
description='The DeclarativeOAuth specific blob.\nPertains to the fields defined by the connector relating to the OAuth flow.\n\nInterpolation capabilities:\n- The variables placeholders are declared as `{{my_var}}`.\n- The nested resolution variables like `{{ {{my_nested_var}} }}` is allowed as well.\n\n- The allowed interpolation context is:\n + base64Encoder - encode to `base64`, {{ {{my_var_a}}:{{my_var_b}} | base64Encoder }}\n + base64Decorer - decode from `base64` encoded string, {{ {{my_string_variable_or_string_value}} | base64Decoder }}\n + urlEncoder - encode the input string to URL-like format, {{ https://test.host.com/endpoint | urlEncoder}}\n + urlDecorer - decode the input url-encoded string into text format, {{ urlDecoder:https%3A%2F%2Fairbyte.io | urlDecoder}}\n + codeChallengeS256 - get the `codeChallenge` encoded value to provide additional data-provider specific authorisation values, {{ {{state_value}} | codeChallengeS256 }}\n\nExamples:\n - The TikTok Marketing DeclarativeOAuth spec:\n {\n "oauth_connector_input_specification": {\n "type": "object",\n "additionalProperties": false,\n "properties": {\n "consent_url": "https://ads.tiktok.com/marketing_api/auth?{{client_id_key}}={{client_id_value}}&{{redirect_uri_key}}={{ {{redirect_uri_value}} | urlEncoder}}&{{state_key}}={{state_value}}",\n "access_token_url": "https://business-api.tiktok.com/open_api/v1.3/oauth2/access_token/",\n "access_token_params": {\n "{{ auth_code_key }}": "{{ auth_code_value }}",\n "{{ client_id_key }}": "{{ client_id_value }}",\n "{{ client_secret_key }}": "{{ client_secret_value }}"\n },\n "access_token_headers": {\n "Content-Type": "application/json",\n "Accept": "application/json"\n },\n "extract_output": ["data.access_token"],\n "client_id_key": "app_id",\n "client_secret_key": "secret",\n "auth_code_key": "auth_code"\n }\n }\n }',
1149-
title="DeclarativeOAuth Connector Specification",
1150-
)
1141+
oauth_connector_input_specification: Optional[OauthConnectorInputSpecification] = Field(
1142+
None,
1143+
description='The DeclarativeOAuth specific blob.\nPertains to the fields defined by the connector relating to the OAuth flow.\n\nInterpolation capabilities:\n- The variables placeholders are declared as `{{my_var}}`.\n- The nested resolution variables like `{{ {{my_nested_var}} }}` is allowed as well.\n\n- The allowed interpolation context is:\n + base64Encoder - encode to `base64`, {{ {{my_var_a}}:{{my_var_b}} | base64Encoder }}\n + base64Decorer - decode from `base64` encoded string, {{ {{my_string_variable_or_string_value}} | base64Decoder }}\n + urlEncoder - encode the input string to URL-like format, {{ https://test.host.com/endpoint | urlEncoder}}\n + urlDecorer - decode the input url-encoded string into text format, {{ urlDecoder:https%3A%2F%2Fairbyte.io | urlDecoder}}\n + codeChallengeS256 - get the `codeChallenge` encoded value to provide additional data-provider specific authorisation values, {{ {{state_value}} | codeChallengeS256 }}\n\nExamples:\n - The TikTok Marketing DeclarativeOAuth spec:\n {\n "oauth_connector_input_specification": {\n "type": "object",\n "additionalProperties": false,\n "properties": {\n "consent_url": "https://ads.tiktok.com/marketing_api/auth?{{client_id_key}}={{client_id_value}}&{{redirect_uri_key}}={{ {{redirect_uri_value}} | urlEncoder}}&{{state_key}}={{state_value}}",\n "access_token_url": "https://business-api.tiktok.com/open_api/v1.3/oauth2/access_token/",\n "access_token_params": {\n "{{ auth_code_key }}": "{{ auth_code_value }}",\n "{{ client_id_key }}": "{{ client_id_value }}",\n "{{ client_secret_key }}": "{{ client_secret_value }}"\n },\n "access_token_headers": {\n "Content-Type": "application/json",\n "Accept": "application/json"\n },\n "extract_output": ["data.access_token"],\n "client_id_key": "app_id",\n "client_secret_key": "secret",\n "auth_code_key": "auth_code"\n }\n }\n }',
1144+
title="DeclarativeOAuth Connector Specification",
11511145
)
11521146
complete_oauth_output_specification: Optional[Dict[str, Any]] = Field(
11531147
None,
@@ -1165,9 +1159,7 @@ class Config:
11651159
complete_oauth_server_input_specification: Optional[Dict[str, Any]] = Field(
11661160
None,
11671161
description="OAuth specific blob. This is a Json Schema used to validate Json configurations persisted as Airbyte Server configurations.\nMust be a valid non-nested JSON describing additional fields configured by the Airbyte Instance or Workspace Admins to be used by the\nserver when completing an OAuth flow (typically exchanging an auth code for refresh token).\nExamples:\n complete_oauth_server_input_specification={\n client_id: {\n type: string\n },\n client_secret: {\n type: string\n }\n }",
1168-
examples=[
1169-
{"client_id": {"type": "string"}, "client_secret": {"type": "string"}}
1170-
],
1162+
examples=[{"client_id": {"type": "string"}, "client_secret": {"type": "string"}}],
11711163
title="OAuth input specification",
11721164
)
11731165
complete_oauth_server_output_specification: Optional[Dict[str, Any]] = Field(
@@ -1964,9 +1956,7 @@ class RecordSelector(BaseModel):
19641956
description="Responsible for filtering records to be emitted by the Source.",
19651957
title="Record Filter",
19661958
)
1967-
schema_normalization: Optional[
1968-
Union[SchemaNormalization, CustomSchemaNormalization]
1969-
] = Field(
1959+
schema_normalization: Optional[Union[SchemaNormalization, CustomSchemaNormalization]] = Field(
19701960
None,
19711961
description="Responsible for normalization according to the schema.",
19721962
title="Schema Normalization",
@@ -2107,9 +2097,7 @@ class ConfigMigration(BaseModel):
21072097
description: Optional[str] = Field(
21082098
None, description="The description/purpose of the config migration."
21092099
)
2110-
transformations: List[
2111-
Union[ConfigRemapField, ConfigAddFields, ConfigRemoveFields]
2112-
] = Field(
2100+
transformations: List[Union[ConfigRemapField, ConfigAddFields, ConfigRemoveFields]] = Field(
21132101
...,
21142102
description="The list of transformations that will attempt to be applied on an incoming unmigrated config. The transformations will be applied in the order they are defined.",
21152103
title="Transformations",
@@ -2307,9 +2295,7 @@ class Config:
23072295
extra = Extra.allow
23082296

23092297
type: Literal["DeclarativeStream"]
2310-
name: Optional[str] = Field(
2311-
"", description="The stream name.", example=["Users"], title="Name"
2312-
)
2298+
name: Optional[str] = Field("", description="The stream name.", example=["Users"], title="Name")
23132299
retriever: Union[SimpleRetriever, AsyncRetriever, CustomRetriever] = Field(
23142300
...,
23152301
description="Component used to coordinate how records are extracted across stream slices and request pages.",
@@ -2487,20 +2473,18 @@ class HttpRequester(BaseModelWithDeprecations):
24872473
description="Allows for retrieving a dynamic set of properties from an API endpoint which can be injected into outbound request using the stream_partition.extra_fields.",
24882474
title="Fetch Properties from Endpoint",
24892475
)
2490-
request_parameters: Optional[Union[Dict[str, Union[str, QueryProperties]], str]] = (
2491-
Field(
2492-
None,
2493-
description="Specifies the query parameters that should be set on an outgoing HTTP request given the inputs.",
2494-
examples=[
2495-
{"unit": "day"},
2496-
{
2497-
"query": 'last_event_time BETWEEN TIMESTAMP "{{ stream_interval.start_time }}" AND TIMESTAMP "{{ stream_interval.end_time }}"'
2498-
},
2499-
{"searchIn": "{{ ','.join(config.get('search_in', [])) }}"},
2500-
{"sort_by[asc]": "updated_at"},
2501-
],
2502-
title="Query Parameters",
2503-
)
2476+
request_parameters: Optional[Union[Dict[str, Union[str, QueryProperties]], str]] = Field(
2477+
None,
2478+
description="Specifies the query parameters that should be set on an outgoing HTTP request given the inputs.",
2479+
examples=[
2480+
{"unit": "day"},
2481+
{
2482+
"query": 'last_event_time BETWEEN TIMESTAMP "{{ stream_interval.start_time }}" AND TIMESTAMP "{{ stream_interval.end_time }}"'
2483+
},
2484+
{"searchIn": "{{ ','.join(config.get('search_in', [])) }}"},
2485+
{"sort_by[asc]": "updated_at"},
2486+
],
2487+
title="Query Parameters",
25042488
)
25052489
request_headers: Optional[Union[Dict[str, str], str]] = Field(
25062490
None,
@@ -2690,9 +2674,7 @@ class QueryProperties(BaseModel):
26902674

26912675
class StateDelegatingStream(BaseModel):
26922676
type: Literal["StateDelegatingStream"]
2693-
name: str = Field(
2694-
..., description="The stream name.", example=["Users"], title="Name"
2695-
)
2677+
name: str = Field(..., description="The stream name.", example=["Users"], title="Name")
26962678
full_refresh_stream: DeclarativeStream = Field(
26972679
...,
26982680
description="Component used to coordinate how records are extracted across stream slices and request pages when the state is empty or not provided.",
@@ -2781,9 +2763,7 @@ class AsyncRetriever(BaseModel):
27812763
)
27822764
download_extractor: Optional[
27832765
Union[DpathExtractor, CustomRecordExtractor, ResponseToFileExtractor]
2784-
] = Field(
2785-
None, description="Responsible for fetching the records from provided urls."
2786-
)
2766+
] = Field(None, description="Responsible for fetching the records from provided urls.")
27872767
creation_requester: Union[HttpRequester, CustomRequester] = Field(
27882768
...,
27892769
description="Requester component that describes how to prepare HTTP requests to send to the source API to create the async server-side job.",
@@ -2923,12 +2903,10 @@ class DynamicDeclarativeStream(BaseModel):
29232903
stream_template: DeclarativeStream = Field(
29242904
..., description="Reference to the stream template.", title="Stream Template"
29252905
)
2926-
components_resolver: Union[HttpComponentsResolver, ConfigComponentsResolver] = (
2927-
Field(
2928-
...,
2929-
description="Component resolve and populates stream templates with components values.",
2930-
title="Components Resolver",
2931-
)
2906+
components_resolver: Union[HttpComponentsResolver, ConfigComponentsResolver] = Field(
2907+
...,
2908+
description="Component resolve and populates stream templates with components values.",
2909+
title="Components Resolver",
29322910
)
29332911

29342912

airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -820,8 +820,9 @@ def _collect_model_deprecations(self, model: BaseModelWithDeprecations) -> None:
820820
if log not in self._collected_deprecation_logs:
821821
self._collected_deprecation_logs.append(log)
822822

823-
824-
def create_config_migration(self, model: ConfigMigrationModel, config: Config) -> ConfigMigration:
823+
def create_config_migration(
824+
self, model: ConfigMigrationModel, config: Config
825+
) -> ConfigMigration:
825826
transformations = []
826827
for transformation in model.transformations:
827828
transformations.append(self._create_component_from_model(transformation, config))
@@ -831,7 +832,9 @@ def create_config_migration(self, model: ConfigMigrationModel, config: Config) -
831832
transformations=transformations,
832833
)
833834

834-
def create_config_add_fields(self, model: ConfigAddFieldsModel, config: Config) -> ConfigAddFields:
835+
def create_config_add_fields(
836+
self, model: ConfigAddFieldsModel, config: Config
837+
) -> ConfigAddFields:
835838
fields = [self._create_component_from_model(field, config) for field in model.fields]
836839
return ConfigAddFields(
837840
fields=fields,
@@ -854,17 +857,17 @@ def create_config_remap_field(model: ConfigRemapFieldModel, config: Config) -> C
854857
config=config,
855858
)
856859

857-
858860
def create_dpath_validator(self, model: DpathValidatorModel, config: Config) -> DpathValidator:
859-
860861
strategy = self._create_component_from_model(model.validation_strategy, config)
861862

862863
return DpathValidator(
863864
field_path=model.field_path,
864865
strategy=strategy,
865866
)
866867

867-
def create_predicate_validator(self, model: PredicateValidatorModel, config: Config) -> PredicateValidator:
868+
def create_predicate_validator(
869+
self, model: PredicateValidatorModel, config: Config
870+
) -> PredicateValidator:
868871
strategy = self._create_component_from_model(model.validation_strategy, config)
869872

870873
return PredicateValidator(
@@ -873,7 +876,9 @@ def create_predicate_validator(self, model: PredicateValidatorModel, config: Con
873876
)
874877

875878
@staticmethod
876-
def create_validate_adheres_to_schema(model: ValidateAdheresToSchemaModel) -> ValidateAdheresToSchema:
879+
def create_validate_adheres_to_schema(
880+
model: ValidateAdheresToSchemaModel,
881+
) -> ValidateAdheresToSchema:
877882
base_schema = cast(Mapping[str, Any], model.base_schema)
878883
return ValidateAdheresToSchema(
879884
schema=base_schema,

0 commit comments

Comments
 (0)