Skip to content

Fd 45 sift client calc channels and rules #262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion python/lib/sift_client/_internal/low_level_wrappers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
from sift_client._internal.low_level_wrappers.assets import AssetsLowLevelClient
from sift_client._internal.low_level_wrappers.calculated_channels import (
CalculatedChannelsLowLevelClient,
)
from sift_client._internal.low_level_wrappers.channels import ChannelsLowLevelClient
from sift_client._internal.low_level_wrappers.ping import PingLowLevelClient
from sift_client._internal.low_level_wrappers.rules import RulesLowLevelClient
from sift_client._internal.low_level_wrappers.runs import RunsLowLevelClient

__all__ = ["AssetsLowLevelClient", "PingLowLevelClient"]
__all__ = [
"AssetsLowLevelClient",
"CalculatedChannelsLowLevelClient",
"ChannelsLowLevelClient",
"PingLowLevelClient",
"RulesLowLevelClient",
"RunsLowLevelClient",
]
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ async def list_all_assets(
"""
return await self._handle_pagination(
self.list_assets,
kwargs={"query_filter": query_filter},
page_size=page_size,
query_filter=query_filter,
order_by=order_by,
max_results=max_results,
)
Expand Down
18 changes: 16 additions & 2 deletions python/lib/sift_client/_internal/low_level_wrappers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,26 @@ class LowLevelClientBase(ABC):
@staticmethod
async def _handle_pagination(
func: Callable,
kwargs: dict[str, Any] = {},
page_size: int | None = None,
page_token: str | None = None,
query_filter: str | None = None,
order_by: str | None = None,
max_results: int | None = None,
) -> list[Any]:
"""
Handle pagination for a given function by calling the function until all results are retrieved or the max_results is reached.

Args:
func: The function to call.
kwargs: Keyword arguments to pass to the function.
page_size: The number of results to return per page.
page_token: The token to use for the next page.
order_by: How to order the retrieved results.
max_results: Maximum number of results to return. Will be in increments of page_size or default page size defined by the call if no page_size is provided.

Returns:
A list of all matching results.
"""
results: list[Any] = []
if page_token is None:
page_token = ""
Expand All @@ -23,8 +37,8 @@ async def _handle_pagination(
response, page_token = await func(
page_size=page_size,
page_token=page_token,
query_filter=query_filter,
order_by=order_by,
**kwargs,
)
results.extend(response)
if page_token == "":
Expand Down
Loading
Loading