pdstools.infinity.internal._pagination

Attributes

T

Classes

_Slice

A lazy slice view over a PaginatedList.

PaginatedList

Abstracts pagination of Pega API

AsyncPaginatedList

Async variant of PaginatedList.

Module Contents

T
class _Slice(the_list: PaginatedList[T], the_slice: slice)

Bases: Generic[T]

A lazy slice view over a PaginatedList.

Parameters:
_list
_start
_stop
_step
__iter__() collections.abc.Iterator[T]
Return type:

collections.abc.Iterator[T]

__getitem__(index: int) T | None
Parameters:

index (int)

Return type:

T | None

_finished(index: int) bool
Parameters:

index (int)

Return type:

bool

as_df() polars.DataFrame
Return type:

polars.DataFrame

class PaginatedList(content_class: Any, client: Any, request_method: str, url: str, extra_attribs: dict[str, Any] | None = None, _root: str | None = None, **kwargs: Any)

Bases: Generic[T]

Abstracts pagination of Pega API

Currently supports format where a ‘nextToken’ is supplied and the next page is retrieved by supplying that token as the ‘pageToken’ of the next call to the same URL.

Can be iterated, indexed or sliced.

Parameters:
  • content_class (Any)

  • client (Any)

  • request_method (str)

  • url (str)

  • extra_attribs (dict[str, Any] | None)

  • _root (str | None)

  • kwargs (Any)

_elements: list[T] = []
_client
_content_class
_url
_first_params
_next_token: str | bool | None = True
_next_params
_extra_attribs
_request_method
_root = None
__getitem__(key: str | int) T
__getitem__(index: slice) _Slice[T]
get(__key: int | str, __default: str | None) T
get(__key: slice, __default: str | None) _Slice[T]

Returns the specified key or default.

If string type provided as key, the content_class needs to be a Pydantic class, with an attribute called ‘id’.

Parameters:
  • __key (int | slice | str) – Can be a int (index), slice (start:end), or string (id attribute)

  • __default (str | None, optional) – The value to return if none found, by default None

Returns:

The element, or slice of elements. If not found, returns default

Return type:

Any

__iter__() collections.abc.Iterator[T]
Return type:

collections.abc.Iterator[T]

__repr__() str
Return type:

str

_get_next_page() list[T]
Return type:

list[T]

_get_up_to_index(index: int) None
Parameters:

index (int)

Return type:

None

_grow() list[T]
Return type:

list[T]

_has_next() bool
Return type:

bool

_is_larger_than(index: int) bool
Parameters:

index (int)

Return type:

bool

class AsyncPaginatedList(content_class: Any, client: Any, request_method: str, url: str, extra_attribs: dict[str, Any] | None = None, _root: str | None = None, **kwargs: Any)

Bases: Generic[T]

Async variant of PaginatedList.

Same constructor interface. Uses await client.request(...) and exposes async for iteration via __aiter__.

Parameters:
  • content_class (Any)

  • client (Any)

  • request_method (str)

  • url (str)

  • extra_attribs (dict[str, Any] | None)

  • _root (str | None)

  • kwargs (Any)

_elements: list[T] = []
_client
_content_class
_url
_first_params
_next_token: str | bool | None = True
_next_params
_extra_attribs
_request_method
_root = None
async __aiter__() collections.abc.AsyncIterator[T]
Return type:

collections.abc.AsyncIterator[T]

__repr__() str
Return type:

str

async _get_next_page() list[T]
Return type:

list[T]

async _get_up_to_index(index: int) None
Parameters:

index (int)

Return type:

None

async _grow() list[T]
Return type:

list[T]

_has_next() bool
Return type:

bool

_is_larger_than(index: int) bool
Parameters:

index (int)

Return type:

bool

async collect() list[T]

Eagerly fetch all pages and return as a plain list.

Return type:

list[T]

async get(__key: int | slice | str | None = None, __default: str | None = None, **kwargs: Any) T | None

Async version of PaginatedList.get().

Parameters:
  • __key (int | slice | str | None)

  • __default (str | None)

  • kwargs (Any)

Return type:

T | None

async as_df() polars.DataFrame

Collect all pages into a polars DataFrame.

Return type:

polars.DataFrame