flip_api.utils.paging_utils

Attributes

T

Classes

PagingInfo

FilterInfo

IPagedResponse

Abstract base class for generic types.

IPagedData

Abstract base class for generic types.

Functions

get_paging_details(→ PagingInfo)

Parses query string parameters for pagination details.

get_filter_details(→ FilterInfo)

Parses query string parameters for filter details.

get_total_pages(→ int)

Calculates the total number of pages.

Module Contents

flip_api.utils.paging_utils.T
class flip_api.utils.paging_utils.PagingInfo

Bases: pydantic.BaseModel

offset: int
page_number: int
page_size: int
search_str: str
model_config
class flip_api.utils.paging_utils.FilterInfo

Bases: pydantic.BaseModel

owner: uuid.UUID | None
model_config
class flip_api.utils.paging_utils.IPagedResponse

Bases: pydantic.BaseModel, Generic[T]

Abstract base class for generic types.

A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as:

class Mapping(Generic[KT, VT]):
    def __getitem__(self, key: KT) -> VT:
        ...
    # Etc.

This class can then be used as follows:

def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT:
    try:
        return mapping[key]
    except KeyError:
        return default
data: list[T]
total_rows: int
class flip_api.utils.paging_utils.IPagedData

Bases: pydantic.BaseModel, Generic[T]

Abstract base class for generic types.

A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as:

class Mapping(Generic[KT, VT]):
    def __getitem__(self, key: KT) -> VT:
        ...
    # Etc.

This class can then be used as follows:

def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT:
    try:
        return mapping[key]
    except KeyError:
        return default
page: int
page_size: int
total_pages: int
total_records: int
data: list[T]
model_config
flip_api.utils.paging_utils.get_paging_details(query_string_parameters: dict[str, str | int | float] | None = None) PagingInfo

Parses query string parameters for pagination details.

Parameters:

query_string_parameters – A dictionary of query parameters.

Returns:

An object containing offset, page number, page size, and search string.

Return type:

PagingInfo

flip_api.utils.paging_utils.get_filter_details(query_string_parameters: dict[str, str | uuid.UUID] | None = None) FilterInfo

Parses query string parameters for filter details.

Parameters:

query_string_parameters – A dictionary of query parameters.

Returns:

An object containing filter criteria (e.g., owner_id).

Return type:

FilterInfo

flip_api.utils.paging_utils.get_total_pages(total_records: int, page_size_int: int) int

Calculates the total number of pages.

Parameters:
  • total_records – The total number of records.

  • page_size_int – The number of records per page.

Returns:

The total number of pages.

Return type:

int