ibmcloudant.features.pagination

Feature for paginating requests.

Import :class:~ibmcloudant.Pagination and :class:~ibmcloudant.PagerType from :mod:ibmcloudant. Use :meth:Pagination.new_pagination to create a :class:Pagination for the specific :class:PagerType operation and options.

Module Contents

Classes

Pager

Protocol for pagination of Cloudant operations.

PagerType

Enumeration of the available Pager types

Pagination

Entry point for the pagination features.

Data

I

K

R

API

ibmcloudant.features.pagination.I = 'TypeVar(...)'
ibmcloudant.features.pagination.K = 'TypeVar(...)'
class ibmcloudant.features.pagination.Pager

Bases: typing.Protocol[ibmcloudant.features.pagination.I]

Protocol for pagination of Cloudant operations.

Use Pager.new_pager to create a new pager for one of the operation types in PagerType.

abstractmethod get_all() collections.abc.Sequence[ibmcloudant.features.pagination.I]

returns all the pages of results in single list

abstractmethod get_next() collections.abc.Sequence[ibmcloudant.features.pagination.I]

returns the next page of results

abstractmethod has_next() bool

returns False if there are no more pages

class ibmcloudant.features.pagination.PagerType(*args, **kwds)

Bases: enum.Enum

Enumeration of the available Pager types

Initialization

POST_ALL_DOCS = 'auto(...)'
POST_DESIGN_DOCS = 'auto(...)'
POST_FIND = 'auto(...)'
POST_PARTITION_ALL_DOCS = 'auto(...)'
POST_PARTITION_FIND = 'auto(...)'
POST_PARTITION_VIEW = 'auto(...)'
POST_VIEW = 'auto(...)'
class ibmcloudant.features.pagination.Pagination(client: ibmcloudant.cloudant_v1.CloudantV1, type: ibmcloudant.features.pagination.PagerType, opts: dict)

Entry point for the pagination features.

Use :meth:Pagination.new_pagination to create a :class:Pagination instance for the specific :class:PagerType operation and options.

Then create a Pager or Iterable using one of the functions:

  • meth:

    pager - for an IBM Cloud SDK style Pager

    • meth:

      pages - for a page Iterable

      • meth:

        rows - for a row Iterable

Initialization

classmethod new_pagination(client: ibmcloudant.cloudant_v1.CloudantV1, type: ibmcloudant.features.pagination.PagerType, **kwargs)

Create a new Pagination. client: CloudantV1 - the Cloudant service client type: PagerType - the operation type to paginate kwargs: dict - the options for the operation

pager() ibmcloudant.features.pagination.Pager[ibmcloudant.features.pagination.I]

Create a new IBM Cloud SDK style Pager. This type is useful for retrieving one page at a time from a function call.

pages() collections.abc.Iterable[collections.abc.Sequence[ibmcloudant.features.pagination.I]]

Create a new Iterable for all the pages. This type is useful for handling pages in a for loop.

for page in Pagination.new_pagination(client, **opts).pages(): …

rows() collections.abc.Iterable[ibmcloudant.features.pagination.I]

Create a new Iterable for all the rows from all the pages. This type is useful for handling rows in a for loop.

for row in Pagination.new_pagination(client, **opts).rows(): …

ibmcloudant.features.pagination.R = 'TypeVar(...)'