aito.client.v2.responses
Response classes returned by the AitoClientV2
The v2 envelope (core/docs/v2-response-format.md §3) is:
{"kind": "<rows|estimate|aggregate|evaluation|batch|error>",
<payload>, # `hits` (+ offset, total) for rows; `data` otherwise
"meta": {...}, # opt-in, see AitoClientV2(meta=True)
"warnings": [...]} # non-fatal notes, always additive
Two things about that envelope are worth knowing before reading this module.
`rows` is bare. For v1 compatibility a rows response carries no kind at
all — {offset, total, hits}. The documented client rule is kind ?? "rows".
…but an absent `kind` does not prove `rows`. The non-rows envelopes are
built by the rep2-native code paths only. A legacy type: table answered
through a v2 endpoint falls to the rep1 compatibility shim, which returns the
flat v1 shape — so POST /api/v2/_estimate returns {"estimate": ..., "why":
...} for a legacy table and {"kind": "estimate", "data": {"value": ...}}
for a collection, on the same build. Applying kind ?? "rows" to the first
one classifies a scalar as a page of rows.
unwrap_payload() is the single place that copes with this: the caller says
which kind it asked for, an envelope of that kind is unwrapped, a bare body is
passed through, and a different kind raises. When the engine unifies the two
shapes, that one function is the only thing to delete.
Module Attributes
result kind -> the response class that parses it |
Functions
|
return the response class for a result kind, defaulting to |
|
return the payload of a v2 response, whether or not it is enveloped |
Classes
|
An |
|
A |
|
An |
|
An |
|
A single hit of a |
|
The base class of a v2 API response |
|
A |
|
A non-fatal note attached to a v2 response |