airbyte.sources.registry

Backwards compatibility shim for airbyte.sources.registry.

This module re-exports symbols from airbyte.registry for backwards compatibility. New code should import from airbyte.registry directly.

 1# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
 2"""Backwards compatibility shim for airbyte.sources.registry.
 3
 4This module re-exports symbols from airbyte.registry for backwards compatibility.
 5New code should import from airbyte.registry directly.
 6"""
 7
 8from __future__ import annotations
 9
10from airbyte.registry import (
11    ConnectorMetadata,
12    InstallType,
13    Language,
14    get_available_connectors,
15    get_connector_metadata,
16)
17
18
19__all__ = [
20    "ConnectorMetadata",
21    "InstallType",
22    "Language",
23    "get_available_connectors",
24    "get_connector_metadata",
25]
class ConnectorMetadata(pydantic.main.BaseModel):
 78class ConnectorMetadata(BaseModel):
 79    """Metadata for a connector."""
 80
 81    name: str
 82    """Connector name. For example, "source-google-sheets"."""
 83
 84    display_name: str | None = None
 85    """Human-readable connector name."""
 86
 87    connector_type: str | None = None
 88    """Connector type: `source` or `destination`."""
 89
 90    definition_id: str | None = None
 91    """Source or destination definition ID."""
 92
 93    docker_repository: str | None = None
 94    """Docker repository for the connector image."""
 95
 96    latest_available_version: str | None
 97    """The latest available version of the connector."""
 98
 99    pypi_package_name: str | None
100    """The name of the PyPI package for the connector, if it exists."""
101
102    language: Language | None
103    """The language of the connector."""
104
105    install_types: set[InstallType]
106    """The supported install types for the connector."""
107
108    suggested_streams: list[str] | None = None
109    """A list of suggested streams for the connector, if available."""
110
111    support_level: str | None = None
112    """Connector support level."""
113
114    release_stage: str | None = None
115    """Connector release stage."""
116
117    source_type: str | None = None
118    """Connector subtype."""
119
120    documentation_url: str | None = None
121    """Connector documentation URL."""
122
123    release_date: str | None = None
124    """Connector release date."""
125
126    github_issue_label: str | None = None
127    """GitHub issue label for the connector."""
128
129    @property
130    def default_install_type(self) -> InstallType:
131        """Return the default install type for the connector."""
132        if self.language == Language.MANIFEST_ONLY and InstallType.YAML in self.install_types:
133            return InstallType.YAML
134
135        if InstallType.PYTHON in self.install_types:
136            return InstallType.PYTHON
137
138        # Else: Java or Docker
139        return InstallType.DOCKER

Metadata for a connector.

name: str = PydanticUndefined

Connector name. For example, "source-google-sheets".

display_name: str | None = None

Human-readable connector name.

connector_type: str | None = None

Connector type: source or destination.

definition_id: str | None = None

Source or destination definition ID.

docker_repository: str | None = None

Docker repository for the connector image.

latest_available_version: str | None = PydanticUndefined

The latest available version of the connector.

pypi_package_name: str | None = PydanticUndefined

The name of the PyPI package for the connector, if it exists.

language: Language | None = PydanticUndefined

The language of the connector.

install_types: set[InstallType] = PydanticUndefined

The supported install types for the connector.

suggested_streams: list[str] | None = None

A list of suggested streams for the connector, if available.

support_level: str | None = None

Connector support level.

release_stage: str | None = None

Connector release stage.

source_type: str | None = None

Connector subtype.

documentation_url: str | None = None

Connector documentation URL.

release_date: str | None = None

Connector release date.

github_issue_label: str | None = None

GitHub issue label for the connector.

default_install_type: InstallType
129    @property
130    def default_install_type(self) -> InstallType:
131        """Return the default install type for the connector."""
132        if self.language == Language.MANIFEST_ONLY and InstallType.YAML in self.install_types:
133            return InstallType.YAML
134
135        if InstallType.PYTHON in self.install_types:
136            return InstallType.PYTHON
137
138        # Else: Java or Docker
139        return InstallType.DOCKER

Return the default install type for the connector.

class InstallType(builtins.str, enum.Enum):
49class InstallType(str, Enum):
50    """The type of installation for a connector."""
51
52    YAML = "yaml"
53    """Manifest-only connectors that can be run without Docker."""
54    PYTHON = "python"
55    """Python-based connectors available via PyPI."""
56    DOCKER = "docker"
57    """Docker-based connectors (returns all connectors for backward compatibility)."""
58    JAVA = "java"
59    """Java-based connectors."""
60
61    INSTALLABLE = "installable"
62    """Connectors installable in the current environment (environment-sensitive).
63
64    Returns all connectors if Docker is installed, otherwise only Python and YAML.
65    """
66    ANY = "any"
67    """All connectors in the registry (environment-independent)."""

The type of installation for a connector.

YAML = <InstallType.YAML: 'yaml'>

Manifest-only connectors that can be run without Docker.

PYTHON = <InstallType.PYTHON: 'python'>

Python-based connectors available via PyPI.

DOCKER = <InstallType.DOCKER: 'docker'>

Docker-based connectors (returns all connectors for backward compatibility).

JAVA = <InstallType.JAVA: 'java'>

Java-based connectors.

INSTALLABLE = <InstallType.INSTALLABLE: 'installable'>

Connectors installable in the current environment (environment-sensitive).

Returns all connectors if Docker is installed, otherwise only Python and YAML.

ANY = <InstallType.ANY: 'any'>

All connectors in the registry (environment-independent).

class Language(builtins.str, enum.Enum):
70class Language(str, Enum):
71    """The language of a connector."""
72
73    PYTHON = InstallType.PYTHON.value
74    JAVA = InstallType.JAVA.value
75    MANIFEST_ONLY = _MANIFEST_ONLY_LANGUAGE

The language of a connector.

PYTHON = <Language.PYTHON: 'python'>
JAVA = <Language.JAVA: 'java'>
MANIFEST_ONLY = <Language.MANIFEST_ONLY: 'manifest-only'>
def get_available_connectors( install_type: InstallType | str | None = <InstallType.INSTALLABLE: 'installable'>) -> list[str]:
293def get_available_connectors(
294    install_type: InstallType | str | None = InstallType.INSTALLABLE,
295) -> list[str]:
296    """Return a list of all available connectors.
297
298    Connectors will be returned in alphabetical order, with the standard prefix "source-".
299
300    Args:
301        install_type: The type of installation for the connector.
302            Defaults to `InstallType.INSTALLABLE`.
303    """
304    if install_type is None or install_type == InstallType.INSTALLABLE:
305        # Filter for installable connectors (default behavior).
306        if is_docker_installed():
307            logger.info("Docker is detected. Returning all connectors.")
308            return sorted(_get_registry_cache().keys())
309
310        logger.info("Docker was not detected. Returning only Python and Manifest-only connectors.")
311        return sorted(
312            [
313                connector_name
314                for connector_name, conn_info in _get_registry_cache().items()
315                if conn_info.language in {Language.PYTHON, Language.MANIFEST_ONLY}
316            ]
317        )
318
319    if not isinstance(install_type, InstallType):
320        install_type = InstallType(install_type)
321
322    if install_type == InstallType.PYTHON:
323        return sorted(
324            connector_name
325            for connector_name, conn_info in _get_registry_cache().items()
326            if conn_info.pypi_package_name is not None
327        )
328
329    if install_type == InstallType.JAVA:
330        warnings.warn(
331            message="Java connectors are not yet supported.",
332            stacklevel=2,
333        )
334        return sorted(
335            connector_name
336            for connector_name, conn_info in _get_registry_cache().items()
337            if conn_info.language == Language.JAVA
338        )
339
340    if install_type in {InstallType.DOCKER, InstallType.ANY}:
341        return sorted(_get_registry_cache().keys())
342
343    if install_type == InstallType.YAML:
344        return sorted(
345            conn.name
346            for conn in _get_registry_cache().values()
347            if InstallType.YAML in conn.install_types
348        )
349
350    # pragma: no cover  # Should never be reached.
351    raise exc.PyAirbyteInputError(
352        message="Invalid install type.",
353        context={
354            "install_type": install_type,
355        },
356    )

Return a list of all available connectors.

Connectors will be returned in alphabetical order, with the standard prefix "source-".

Arguments:
def get_connector_metadata(name: str) -> ConnectorMetadata | None:
263def get_connector_metadata(name: str) -> ConnectorMetadata | None:
264    """Check the cache for the connector.
265
266    If the cache is empty, populate by calling update_cache.
267    """
268    registry_url = _get_registry_url()
269
270    if _is_registry_disabled(registry_url):
271        return None
272
273    cache = copy(_get_registry_cache())
274
275    if not cache:
276        raise exc.PyAirbyteInternalError(
277            message="Connector registry could not be loaded.",
278            context={
279                "registry_url": _get_registry_url(),
280            },
281        )
282    if name not in cache:
283        raise exc.AirbyteConnectorNotRegisteredError(
284            connector_name=name,
285            context={
286                "registry_url": _get_registry_url(),
287                "available_connectors": get_available_connectors(),
288            },
289        )
290    return cache[name]

Check the cache for the connector.

If the cache is empty, populate by calling update_cache.