1
0
mirror of synced 2026-01-06 06:04:16 -05:00
Files
airbyte/airbyte-cdk/python/airbyte_cdk/sources/declarative/spec/spec.py
Lake Mossman 63ff3d75b4 Make documentation_url optional in a declarative connector spec (#21347)
* Make documentation_url optional in a declarative connector spec

* simplify if statement

* bump patch version of cdk

* Revert "bump patch version of cdk"

This reverts commit 1854bf3be1.

* 🤖 Bump patch version of Airbyte CDK

* Revert "🤖 Bump patch version of Airbyte CDK"

This reverts commit 85d5a989e2.

* 🤖 Bump patch version of Airbyte CDK

Co-authored-by: lmossman <lmossman@users.noreply.github.com>
2023-01-12 14:23:04 -08:00

38 lines
1.3 KiB
Python

#
# Copyright (c) 2022 Airbyte, Inc., all rights reserved.
#
from dataclasses import InitVar, dataclass
from typing import Any, Mapping, Optional
from airbyte_cdk.models.airbyte_protocol import ConnectorSpecification
from dataclasses_jsonschema import JsonSchemaMixin
@dataclass
class Spec(JsonSchemaMixin):
"""
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
"""
connection_specification: Mapping[str, Any]
options: InitVar[Mapping[str, Any]]
documentation_url: Optional[str] = None
def generate_spec(self) -> ConnectorSpecification:
"""
Returns the connector specification according the spec block defined in the low code connector manifest.
"""
obj = {"connectionSpecification": self.connection_specification}
if self.documentation_url:
obj["documentationUrl"] = self.documentation_url
# We remap these keys to camel case because that's the existing format expected by the rest of the platform
return ConnectorSpecification.parse_obj(obj)