graflo.data_source.api_response¶
API response envelope parsing and optional first-response auto-detection.
Attributes¶
CARRY_TOKEN_CANDIDATES = ('results_id', 'scroll_id', 'pit_id', 'search_id')
module-attribute
¶
CURSOR_CANDIDATES = ('next_cursor', 'cursor', 'next_page_token')
module-attribute
¶
HAS_MORE_CANDIDATES = ('has_more', 'hasMore')
module-attribute
¶
NEXT_OFFSET_CANDIDATES = ('next_offset', 'nextOffset')
module-attribute
¶
OFFSET_CANDIDATES = ('offset', 'skip')
module-attribute
¶
RECORDS_CANDIDATES = ('results', 'data', 'items', 'records', 'entries', 'rows')
module-attribute
¶
TOTAL_COUNT_CANDIDATES = ('count', 'total', 'total_count')
module-attribute
¶
logger = logging.getLogger(__name__)
module-attribute
¶
Classes¶
ResolvedApiResponse
¶
Bases: ApiResponseStructure
Response paths resolved after optional auto-detection on the first body.
Source code in graflo/data_source/api_response.py
Methods:¶
resolve(config, body)
classmethod
¶
Source code in graflo/data_source/api_response.py
Functions:¶
detect_carry_params(body)
¶
Infer session-token carry map from known response field names.
Returns a query-param-name -> response-path map. Looks at top-level object
keys first, then at 0.<key> when the body is a non-empty list of
objects (e.g. BMC Discovery kind envelopes). Does not treat singular
result_id as a carry token.
Source code in graflo/data_source/api_response.py
detect_response_shape(body)
¶
Infer unset response path keys from a top-level response envelope.
Source code in graflo/data_source/api_response.py
extract_records(body, resolved)
¶
Extract record dicts from a parsed JSON body.
Source code in graflo/data_source/api_response.py
get_at_path(obj, path)
¶
Resolve a dot-separated path against a JSON-like object.
Source code in graflo/data_source/api_response.py
get_batch_metadata(body, resolved)
¶
Read batch-level metadata from the response envelope.
Source code in graflo/data_source/api_response.py
has_more_pages(body, resolved, items, *, strategy)
¶
Return whether another HTTP page should be fetched.
Source code in graflo/data_source/api_response.py
next_cursor_value(body, resolved)
¶
Read the next cursor token from the response when configured.
Source code in graflo/data_source/api_response.py
next_offset_value(body, resolved)
¶
Read the next offset from the response when configured.
Source code in graflo/data_source/api_response.py
update_carried_params(body, carry_params, carried)
¶
Refresh carried query params from the latest response body.