Skip to content

Commit

Permalink
Merge pull request #8 from perastov/add-async-chain-page-helper
Browse files Browse the repository at this point in the history
Add async chain page helper
  • Loading branch information
perastov authored Sep 26, 2023
2 parents f1fba13 + 629c875 commit 13c8db0
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 deletions.
5 changes: 5 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Release History
===============

1.0.2 (2023-09-26)
------------------

- Add async page chaining helper

1.0.1 (2023-09-26)
------------------

Expand Down
2 changes: 1 addition & 1 deletion cybsi/__version__.py
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
21 changes: 20 additions & 1 deletion cybsi/cloud/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -40,7 +40,7 @@ extend_skip = ["__init__.py"]
[tool.tbump]

[tool.tbump.version]
current = "1.0.1"
current = "1.0.2"

regex = '''
^
Expand Down

0 comments on commit 13c8db0

Please sign in to comment.