airbyte_cdk.sources.declarative.spec
@dataclass
class
Spec:
28@dataclass 29class Spec: 30 """ 31 Returns a connection specification made up of information about the connector and how it can be configured 32 33 Attributes: 34 connection_specification (Mapping[str, Any]): information related to how a connector can be configured 35 documentation_url (Optional[str]): The link the Airbyte documentation about this connector 36 """ 37 38 connection_specification: Mapping[str, Any] 39 parameters: InitVar[Mapping[str, Any]] 40 documentation_url: Optional[str] = None 41 advanced_auth: Optional[AuthFlow] = None 42 config_migrations: List[ConfigMigration] = field(default_factory=list) 43 config_transformations: List[ConfigTransformation] = field(default_factory=list) 44 config_validations: List[Validator] = field(default_factory=list) 45 46 def generate_spec(self) -> ConnectorSpecification: 47 """ 48 Returns the connector specification according the spec block defined in the low code connector manifest. 49 """ 50 51 obj: dict[str, Mapping[str, Any] | str | AdvancedAuth] = { 52 "connectionSpecification": self.connection_specification 53 } 54 55 if self.documentation_url: 56 obj["documentationUrl"] = self.documentation_url 57 if self.advanced_auth: 58 self.advanced_auth.auth_flow_type = self.advanced_auth.auth_flow_type.value # type: ignore # We know this is always assigned to an AuthFlow which has the auth_flow_type field 59 # Map CDK AuthFlow model to protocol AdvancedAuth model 60 obj["advanced_auth"] = self.advanced_auth.dict() 61 62 # We remap these keys to camel case because that's the existing format expected by the rest of the platform 63 return ConnectorSpecificationSerializer.load(obj) 64 65 def migrate_config(self, config: MutableMapping[str, Any]) -> None: 66 """ 67 Apply all specified config transformations to the provided config and emit a control message. 68 69 :param config: The user-provided config to migrate 70 """ 71 for migration in self.config_migrations: 72 for transformation in migration.transformations: 73 transformation.transform(config) 74 75 def transform_config(self, config: MutableMapping[str, Any]) -> None: 76 """ 77 Apply all config transformations to the provided config. 78 79 :param config: The user-provided configuration 80 """ 81 for transformation in self.config_transformations: 82 transformation.transform(config) 83 84 def validate_config(self, config: Mapping[str, Any]) -> None: 85 """ 86 Apply all config validations to the provided config. 87 88 :param config: The user-provided configuration 89 """ 90 for validator in self.config_validations: 91 validator.validate(config)
Returns a connection specification made up of information about the connector and how it can be configured
Attributes:
- connection_specification (Mapping[str, Any]): information related to how a connector can be configured
- documentation_url (Optional[str]): The link the Airbyte documentation about this connector
Spec( connection_specification: Mapping[str, Any], parameters: dataclasses.InitVar[typing.Mapping[str, typing.Any]], documentation_url: Optional[str] = None, advanced_auth: Optional[airbyte_cdk.sources.declarative.models.declarative_component_schema.AuthFlow] = None, config_migrations: List[ConfigMigration] = <factory>, config_transformations: List[airbyte_cdk.sources.declarative.transformations.config_transformations.config_transformation.ConfigTransformation] = <factory>, config_validations: List[airbyte_cdk.sources.declarative.validators.Validator] = <factory>)
advanced_auth: Optional[airbyte_cdk.sources.declarative.models.declarative_component_schema.AuthFlow] =
None
config_migrations: List[ConfigMigration]
config_transformations: List[airbyte_cdk.sources.declarative.transformations.config_transformations.config_transformation.ConfigTransformation]
config_validations: List[airbyte_cdk.sources.declarative.validators.Validator]
def
generate_spec( self) -> airbyte_protocol_dataclasses.models.airbyte_protocol.ConnectorSpecification:
46 def generate_spec(self) -> ConnectorSpecification: 47 """ 48 Returns the connector specification according the spec block defined in the low code connector manifest. 49 """ 50 51 obj: dict[str, Mapping[str, Any] | str | AdvancedAuth] = { 52 "connectionSpecification": self.connection_specification 53 } 54 55 if self.documentation_url: 56 obj["documentationUrl"] = self.documentation_url 57 if self.advanced_auth: 58 self.advanced_auth.auth_flow_type = self.advanced_auth.auth_flow_type.value # type: ignore # We know this is always assigned to an AuthFlow which has the auth_flow_type field 59 # Map CDK AuthFlow model to protocol AdvancedAuth model 60 obj["advanced_auth"] = self.advanced_auth.dict() 61 62 # We remap these keys to camel case because that's the existing format expected by the rest of the platform 63 return ConnectorSpecificationSerializer.load(obj)
Returns the connector specification according the spec block defined in the low code connector manifest.
def
migrate_config(self, config: MutableMapping[str, Any]) -> None:
65 def migrate_config(self, config: MutableMapping[str, Any]) -> None: 66 """ 67 Apply all specified config transformations to the provided config and emit a control message. 68 69 :param config: The user-provided config to migrate 70 """ 71 for migration in self.config_migrations: 72 for transformation in migration.transformations: 73 transformation.transform(config)
Apply all specified config transformations to the provided config and emit a control message.
Parameters
- config: The user-provided config to migrate
def
transform_config(self, config: MutableMapping[str, Any]) -> None:
75 def transform_config(self, config: MutableMapping[str, Any]) -> None: 76 """ 77 Apply all config transformations to the provided config. 78 79 :param config: The user-provided configuration 80 """ 81 for transformation in self.config_transformations: 82 transformation.transform(config)
Apply all config transformations to the provided config.
Parameters
- config: The user-provided configuration
def
validate_config(self, config: Mapping[str, Any]) -> None:
84 def validate_config(self, config: Mapping[str, Any]) -> None: 85 """ 86 Apply all config validations to the provided config. 87 88 :param config: The user-provided configuration 89 """ 90 for validator in self.config_validations: 91 validator.validate(config)
Apply all config validations to the provided config.
Parameters
- config: The user-provided configuration
@dataclass
class
ConfigMigration:
22@dataclass 23class ConfigMigration: 24 transformations: List[ConfigTransformation] 25 description: Optional[str] = None
ConfigMigration( transformations: List[airbyte_cdk.sources.declarative.transformations.config_transformations.config_transformation.ConfigTransformation], description: Optional[str] = None)