sinch.core.pagination module

class sinch.core.pagination.Paginator(sinch, endpoint, result: RM | None = None)[source]

Bases: ABC, Generic[RM, BM]

Public interface for paginated list responses.

Parameters:
  • RM – Result model is the server response wrapper can be accessed by result.

  • BM – Body model is the type of a single item yielded by content()/iterator().

  • result (RM | None)

Use content(), next_page() and iterator() to traverse the result set without dealing with the underlying pagination scheme.

content() list[BM][source]

Return the items contained in the current page.

Returns:

The list of items in the current page.

Return type:

list[BM]

next_page() Paginator[RM, BM] | None[source]

Advance to the next page of results.

Returns:

This paginator positioned on the next page, or None if there is no further page.

Return type:

Paginator | None

iterator() Iterator[BM][source]

Iterate over individual items across all pages, fetching each page on demand.

Returns:

An iterator over every item in the result set.

Return type:

Iterator[BM]