roboto.http.response
Module Contents
BatchResponse
Bases: pydantic.BaseModel, Generic[Model]
The response to a batch request, holding one element per request element, in the order the request sent them.
Every element of a batch is applied or refused on its own, so a batch can come back partly applied. succeeded and failed split the outcomes for a caller that does not care which request element produced which; read responses to trace an outcome back to the request element at its position.
Parameters
data AnyProperties
BatchResponse.failed
The exception the platform reported for each element it refused, in request order.
BatchResponse.map_data()
Convert what each applied element carries, leaving positions and failures untouched.
A batch call parses the platform’s answer into records and uses this to hand the caller domain objects instead: a SessionRecord becomes a Session. transform runs only on elements carrying data; a refused element keeps its exception, and every element keeps its position.
Parameters
transform collections.Builds the domain object an applied element’s record stands for.
Returns
A batch holding one element per element of this one, in the same order.
Attributes
BatchResponse.responses
BatchResponse.single()
The result carried by the only element of a one-element batch.
A singular call such as create_session() sends its one element through the plural counterpart and unwraps the answer with this, so its caller gets a raised exception rather than a batch to inspect.
Raises
Whatever the platform refused the element with.
The batch does not hold exactly one element, or holds one carrying neither a result nor an error.
Return type
BatchResponseElement
Bases: pydantic.BaseModel, Generic[Model]
One element of a response to a batch request, holding data when the operation succeeded and error when it failed, never both. An element holding neither reports an operation that returns no content, the batch equivalent of a 204 answer to a singular call.
Parameters
data AnyAttributes
BatchResponseElement.error
BatchResponseElement.model_config
model_config #Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
BatchResponseElement.serialize_error()
Parameters
value Optional[roboto.info pydantic.Return type
BatchResponseElement.validate_error()
Build the exception an element was refused with, in whichever form the failure arrived.
Three forms reach this: an exception object, which is what an element copied from another batch carries; the envelope RobotoDomainException.to_dict() produces; and that envelope as JSON text, which is what RobotoDomainException declares to pydantic. Only a literal None yields None, which is how an element the platform applied or answered with no content arrives.
Any other value is a refusal, whatever shape it has. An envelope naming an exception class this release does not define, one missing its code or message, JSON that is not an envelope, and text that is not JSON all read as a RobotoUnrecognizedErrorException carrying whatever code and message could be recovered, with the value’s own text as the message when no message could be. That way a refused element is always in BatchResponse.failed, so a caller checking failed before treating a batch as done cannot mistake a garbled refusal for success.
plain mode replaces the validation the error annotation would otherwise apply. That annotation reads JSON text, so it would reject the exception object returned here.
Parameters
value AnyReturn type
DEFAULT_RESPONSE_JSONPATH
HttpResponse
Parameters
response urllib.HttpResponse.to_dict()
Parameters
json_path Optional[collections.Return type
HttpResponse.to_int()
Return type
HttpResponse.to_paginated_list()
Parameters
record_type Type[PydanticModel]Return type
HttpResponse.to_record()
Parameters
record_type Type[PydanticModel]json_path Optional[collections.Return type
HttpResponse.to_record_list()
Parameters
record_type Type[PydanticModel]json_path Optional[collections.Return type
HttpResponse.to_string()
HttpResponse.to_string_list()
Return type
InvalidPaginationTokenError
Bases: ValueError
Raised when a pagination token cannot be parsed.
A pagination token is opaque to clients, so one that fails to decode or carries an unsupported scheme reflects bad caller input — a fabricated, truncated, or stale token — rather than a server fault. Subclasses ValueError so existing callers that catch ValueError around PaginationToken.from_token() keep working unchanged, while callers that want to distinguish this recoverable input error (e.g. to surface an actionable message instead of a generic 500 or runtime exception) can catch it specifically.
MappedModel
Model
PaginatedList
Bases: pydantic.BaseModel, Generic[Model]
A list of records pulled from a paginated result set. It may be a subset of that result set, in which case next_token will be set and can be used to fetch the next page.
Parameters
data AnyAttributes
PaginatedList.next_token
Opaque token to fetch the next page of results.
If None, then this is the last page of results.
PaginationToken
A pagination token that can be treated as a truly opaque token by clients, with support for evolving the token format over time.
Parameters
Properties
PaginationToken.decode()
Base64 decode the data, adding back any trailing padding (“=”) as necessary to make data properly Base64.
Parameters
data strReturn type
PaginationToken.empty()
Return type
PaginationToken.encode()
Base64 encode the data and strip all trailing padding (“=”).
Parameters
data strReturn type
PaginationToken.from_token()
Parameters
token Optional[str]Return type
PaginationToken.json_token()
Parameters
data AnyReturn type
PaginationToken.to_token()
Return type
PaginationTokenEncoding
PaginationTokenScheme
PydanticModel
StreamedList
Bases: pydantic.BaseModel, Generic[Model]
A StreamedList differs from a PaginatedList in that it represents a stream of data that is in process of being written to. Unlike a result set, which is finite and complete, a stream may be infinite, and it is unknown when or if it will complete.
Parameters
data Any