query
Query objects for Fount API queries based on pydantic
.
Query
¶
Base WPPBAV Fount query.
Attributes:
Name | Type | Description |
---|---|---|
item_id |
(int, optional)
|
Get specific resource by ID, default None Can also be set with |
filters |
FountFilters instance or dict of filter values, optional
|
Filters to apply to the query, default None |
fields |
(str or list[str], optional)
|
Specific fields to retrieve from the query, default None |
include |
(str or list[str], optional)
|
Additional resources to retrieve from the query, default None |
metric_keys |
(str or list[str], optional)
|
Key or list of keys for the metrics included in the response, default None Currently, this parameter is only available for the |
metric_group_keys |
(str or list[str], optional)
|
Key or list of keys for the metric groups included in the response, default None Currently, this parameter is only available for the |
sort |
(str, optional)
|
Sort response by field, default None To sort in descending (highest first) order, use a Sorts by item ID default. |
page |
(int, optional)
|
Get specific page from paginated response, default None When None, the default value in the Fount is 1 Must be greater than 0 |
per_page |
(int, optional)
|
Number of items per page, default None When None, the default value in the Fount is 25 When performing paged queries, Client uses 100 as the default Must be greater than 0 |
max_pages |
(int, optional)
|
Maximum number of pages to retrieve, default None When None, all pages will be retrieved with a Must be greater than 0 |
ensure(query=None, **kwargs)
classmethod
¶
Ensure Query
instance with possible additional parameters.
Defaults to parameters passed in query
instance when any additional
parameters overlap.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
query |
Query
|
Query object to combine with additional parameters, default None |
None
|
**kwargs |
SequenceOrValues
|
Additional parameters to add to the new |
{}
|
Returns:
Type | Description |
---|---|
Query
|
|
Source code in bavapi/query.py
is_single_page()
¶
Returns True if the query only would request a single page
Otherwise the query will perform multiple paginated requests
Conditions for being a single page:
- self.max_pages is
1
OR - self.per_page is not
None
or0
AND (self.max_pages OR self.per_page) are notNone
or0
Returns:
Type | Description |
---|---|
bool
|
Whether the query would perform a single page request |
Source code in bavapi/query.py
paginated(n_pages, per_page=None)
¶
Yield Query
instances with page parameters for each page in n_pages
.
For performing multiple paginated requests.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n_pages |
int
|
Number of pages for which to generate paginated |
required |
per_page |
int
|
Number of results per page, default None |
None
|
Yields:
Type | Description |
---|---|
Query
|
Query instances with page parameters set. |
Source code in bavapi/query.py
to_params(endpoint)
¶
Return Fount-compatible dictionary of the query.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
endpoint |
str
|
The endpoint for which to format the query |
required |
Returns:
Type | Description |
---|---|
dict[str, Any]
|
Fount-compatible dictionary of the query. |
Source code in bavapi/query.py
with_page(page=None, per_page=None, max_pages=None)
¶
Create new instance of Query
with overridden page parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
page |
int
|
Current page number, default None |
None
|
per_page |
int
|
Number of results per page, default None |
None
|
max_pages |
int
|
Max number of pages requested, default None |
None
|
Returns:
Type | Description |
---|---|
Query
|
New |