Skip to content

Commit

Permalink
AirbyteLib: Add 'get_available_connectors()' option (#34982)
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronsteers authored Feb 8, 2024
1 parent e98d88e commit b11a29e
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
2 changes: 2 additions & 0 deletions airbyte-lib/airbyte_lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from airbyte_lib._factories.connector_factories import get_source
from airbyte_lib.caches import DuckDBCache, DuckDBCacheConfig
from airbyte_lib.datasets import CachedDataset
from airbyte_lib.registry import get_available_connectors
from airbyte_lib.results import ReadResult
from airbyte_lib.secrets import SecretSource, get_secret
from airbyte_lib.source import Source
Expand All @@ -14,6 +15,7 @@
"CachedDataset",
"DuckDBCache",
"DuckDBCacheConfig",
"get_available_connectors",
"get_source",
"get_default_cache",
"get_secret",
Expand Down
10 changes: 10 additions & 0 deletions airbyte-lib/airbyte_lib/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,13 @@ def get_connector_metadata(name: str) -> ConnectorMetadata:
},
)
return cache[name]


def get_available_connectors() -> list[str]:
"""Return a list of all available connectors.
Connectors will be returned in alphabetical order, with the standard prefix "source-".
"""
return sorted(
conn.name for conn in _get_registry_cache().values() if conn.pypi_package_name is not None
)
17 changes: 17 additions & 0 deletions airbyte-lib/docs/generated/airbyte_lib.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ def test_registry_get():
assert metadata.latest_available_version == "0.0.1"


def test_registry_list() -> None:
assert registry.get_available_connectors() == ["source-test"]


def test_list_streams(expected_test_stream_data: dict[str, list[dict[str, str | int]]]):
source = ab.get_source(
"source-test", config={"apiKey": "test"}, install_if_missing=False
Expand Down

0 comments on commit b11a29e

Please sign in to comment.