From 2a120279a4c0948751c5e33ce26e94636dc9bd88 Mon Sep 17 00:00:00 2001 From: Petr Erastov Date: Tue, 26 Sep 2023 14:42:24 +0300 Subject: [PATCH 1/2] Add async page chaining helper --- cybsi/cloud/pagination.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/cybsi/cloud/pagination.py b/cybsi/cloud/pagination.py index 269d56f..f2044b3 100644 --- a/cybsi/cloud/pagination.py +++ b/cybsi/cloud/pagination.py @@ -5,7 +5,17 @@ See :ref:`pagination-example` for complete examples of pagination usage. """ -from typing import Callable, Coroutine, Generic, Iterator, List, Optional, TypeVar, cast +from typing import ( + AsyncIterator, + Callable, + Coroutine, + Generic, + Iterator, + List, + Optional, + TypeVar, + cast, +) from urllib.parse import parse_qs, urlparse import httpx @@ -134,3 +144,12 @@ def chain_pages(start_page: Page[T]) -> Iterator[T]: while page: yield from page page = page.next_page() + + +async def chain_pages_async(start_page: AsyncPage[T]) -> AsyncIterator[T]: + """Get chain of collection objects asynchronously.""" + page: Optional[AsyncPage[T]] = start_page + while page: + for elem in page: + yield elem + page = await page.next_page() From 629c8756aeec8f423032c6567fdb336107a1bf73 Mon Sep 17 00:00:00 2001 From: Petr Erastov Date: Tue, 26 Sep 2023 14:44:47 +0300 Subject: [PATCH 2/2] Bump to 1.0.2 version --- HISTORY.md | 5 +++++ cybsi/__version__.py | 2 +- pyproject.toml | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 906862e..c0a6b99 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,6 +1,11 @@ Release History =============== +1.0.2 (2023-09-26) +------------------ + +- Add async page chaining helper + 1.0.1 (2023-09-26) ------------------ diff --git a/cybsi/__version__.py b/cybsi/__version__.py index d2ac860..ddc70fc 100644 --- a/cybsi/__version__.py +++ b/cybsi/__version__.py @@ -1,4 +1,4 @@ -__version__ = "1.0.1" +__version__ = "1.0.2" __title__ = "cybsi-cloud-sdk" __description__ = "Cybsi Cloud development kit" __license__ = "Apache License 2.0" diff --git a/pyproject.toml b/pyproject.toml index 3d74724..7913b3a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "cybsi-cloud-sdk" -version = "1.0.1" +version = "1.0.2" description = "Cybsi Cloud development kit" authors = ["Cybsi Cloud developers"] license = "Apache License 2.0" @@ -40,7 +40,7 @@ extend_skip = ["__init__.py"] [tool.tbump] [tool.tbump.version] -current = "1.0.1" +current = "1.0.2" regex = ''' ^