Skip to content
Merged
24 changes: 21 additions & 3 deletions airbyte/_util/api_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,17 @@ def get_workspace(
# List resources


def list_connections(
def list_connections( # noqa: PLR0913
workspace_id: str,
*,
api_root: str,
client_id: SecretString,
client_secret: SecretString,
name: str | None = None,
name_filter: Callable[[str], bool] | None = None,
limit: int | None = 20,
offset: int | None = 0,
include_deleted: bool | None = False,
) -> list[models.ConnectionResponse]:
"""List connections."""
if name and name_filter:
Expand All @@ -153,6 +156,9 @@ def list_connections(
response = airbyte_instance.connections.list_connections(
api.ListConnectionsRequest(
workspace_ids=[workspace_id],
limit=limit,
offset=offset,
include_deleted=include_deleted,
),
)

Expand Down Expand Up @@ -212,14 +218,17 @@ def list_workspaces(
]


def list_sources(
def list_sources( # noqa: PLR0913
workspace_id: str,
*,
api_root: str,
client_id: SecretString,
client_secret: SecretString,
name: str | None = None,
name_filter: Callable[[str], bool] | None = None,
limit: int | None = 20,
offset: int | None = 0,
include_deleted: bool | None = False,
) -> list[models.SourceResponse]:
"""List sources."""
if name and name_filter:
Expand All @@ -236,6 +245,9 @@ def list_sources(
response: api.ListSourcesResponse = airbyte_instance.sources.list_sources(
api.ListSourcesRequest(
workspace_ids=[workspace_id],
limit=limit,
offset=offset,
include_deleted=include_deleted,
),
)

Expand All @@ -250,14 +262,17 @@ def list_sources(
return [source for source in response.sources_response.data if name_filter(source.name)]


def list_destinations(
def list_destinations( # noqa: PLR0913
workspace_id: str,
*,
api_root: str,
client_id: SecretString,
client_secret: SecretString,
name: str | None = None,
name_filter: Callable[[str], bool] | None = None,
limit: int | None = 20,
offset: int | None = 0,
include_deleted: bool | None = False,
) -> list[models.DestinationResponse]:
"""List destinations."""
if name and name_filter:
Expand All @@ -274,6 +289,9 @@ def list_destinations(
response = airbyte_instance.destinations.list_destinations(
api.ListDestinationsRequest(
workspace_ids=[workspace_id],
limit=limit,
offset=offset,
include_deleted=include_deleted,
),
)

Expand Down
48 changes: 45 additions & 3 deletions airbyte/cloud/workspaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,13 +374,27 @@ def list_connections(
name: str | None = None,
*,
name_filter: Callable | None = None,
limit: int | None = 20,
offset: int | None = 0,
include_deleted: bool | None = False,
) -> list[CloudConnection]:
"""List connections by name in the workspace."""
"""List connections by name in the workspace.

Args:
name: Optional name filter for connections.
name_filter: Optional callable to filter connections by name.
limit: Maximum number of connections to return (default: 20).
offset: Number of connections to skip (default: 0).
include_deleted: Whether to include deleted connections (default: False).
"""
connections = api_util.list_connections(
api_root=self.api_root,
workspace_id=self.workspace_id,
name=name,
name_filter=name_filter,
limit=limit,
offset=offset,
include_deleted=include_deleted,
client_id=self.client_id,
client_secret=self.client_secret,
)
Expand All @@ -400,13 +414,27 @@ def list_sources(
name: str | None = None,
*,
name_filter: Callable | None = None,
limit: int | None = 20,
offset: int | None = 0,
include_deleted: bool | None = False,
) -> list[CloudSource]:
"""List all sources in the workspace."""
"""List all sources in the workspace.

Args:
name: Optional name filter for sources.
name_filter: Optional callable to filter sources by name.
limit: Maximum number of sources to return (default: 20).
offset: Number of sources to skip (default: 0).
include_deleted: Whether to include deleted sources (default: False).
"""
sources = api_util.list_sources(
api_root=self.api_root,
workspace_id=self.workspace_id,
name=name,
name_filter=name_filter,
limit=limit,
offset=offset,
include_deleted=include_deleted,
client_id=self.client_id,
client_secret=self.client_secret,
)
Expand All @@ -424,13 +452,27 @@ def list_destinations(
name: str | None = None,
*,
name_filter: Callable | None = None,
limit: int | None = 20,
offset: int | None = 0,
include_deleted: bool | None = False,
) -> list[CloudDestination]:
"""List all destinations in the workspace."""
"""List all destinations in the workspace.

Args:
name: Optional name filter for destinations.
name_filter: Optional callable to filter destinations by name.
limit: Maximum number of destinations to return (default: 20).
offset: Number of destinations to skip (default: 0).
include_deleted: Whether to include deleted destinations (default: False).
"""
destinations = api_util.list_destinations(
api_root=self.api_root,
workspace_id=self.workspace_id,
name=name,
name_filter=name_filter,
limit=limit,
offset=offset,
include_deleted=include_deleted,
client_id=self.client_id,
client_secret=self.client_secret,
)
Expand Down
Loading