pagi

exception sanhe_confluence_sdk.pagi.PaginationError[source]

Base exception for pagination errors.

exception sanhe_confluence_sdk.pagi.MissingLinksError[source]

Raised when response doesn’t have expected ‘_links’ structure for pagination.

This indicates the API response format doesn’t match the expected pagination pattern (response should have ‘_links.next’ for more pages).

sanhe_confluence_sdk.pagi.paginate(client: Confluence, request: T_REQUEST, response_type: type[T_RESPONSE], page_size: int, max_items: int, max_pages: int = 100, limit_field: str = 'limit', results_field: str = 'results') Iterator[T_RESPONSE][source]

Generic paginator for Confluence API list endpoints.

Parameters:
  • client – Confluence client instance.

  • request – Initial request object (must have query_params).

  • response_type – Response class type for deserialization.

  • page_size – Number of items per page (API’s limit parameter).

  • max_items – Stop fetching when total items >= this value. If less than page_size, it will be adjusted to page_size.

  • max_pages – Maximum number of pages to fetch (default 100). This is a safeguard against infinite loops.

  • limit_field – Name of the limit query parameter (default “limit”).

  • results_field – Name of the results field in response (default “results”).

Yields:

Response objects, one per page.

Raises:

MissingLinksError – If response doesn’t have expected ‘_links’ structure.