benchling_sdk.helpers.pagination_helpers module¶
- class LengthExtractor¶
- Bases: - Protocol- Extract estimated size information if available. - __init__(*args, **kwargs)¶
 
- class PageIterator¶
- Bases: - Iterable[- List[- benchling_sdk.helpers.pagination_helpers.Model]]- Paginate arbitrary Benchling API endpoints which support the concept of a next_token. - next_token points to subsequent pages of results. Supporting API endpoints typically return a “results body” object which contains a key for next_token, as well as a key for a collection of results representing the current page. - Any API errors encountered during retrieval of a page will be marshaled to - benchling_sdk.errors.BenchlingError.- __init__(api_call: PagedApiCall, results_extractor: ResultsExtractor, token_extractor: TokenExtractor = _default_token_extractor, length_extractor: LengthExtractor = _default_length_extractor) None¶
- Initialize a PageIterator. - Parameters
- api_call – A Callable that accepts a str for the next_token 
- results_extractor – A Callable that can extract a list of models from a results body 
- token_extractor – A Callable that can extract the next_token str value from a results body 
- length_extractor – A Callable that can extract the approximated available results count from a response 
 
 
 - property estimated_count: int¶
- Return the value of the Result-Count header provided by the API, if applicable. - Some endpoints may not implement this header. In that case, NotImplementedError is raised. 
 - first() Optional[benchling_sdk.helpers.pagination_helpers.Model]¶
- Return the first item from the first page. - Will return None if the page had zero results. Operates independent of iteration - calls to first after starting iteration will still return the first item from the first page and not the current page. 
 
- class PagedApiCall¶
- Bases: - Protocol- Make an HTTP call which implemented pagination. - __init__(*args, **kwargs)¶
 
