Skip to content
Roboto
Esc
↑↓navigate↵open⌘Jpreview
On this page

roboto.http

Submodules

Package Contents

BEARER_TOKEN_HEADER

roboto.http.BEARER_TOKEN_HEADER = 'X-Roboto-Bearer-Token'#View Source

Bearer token which is parsed as a JWT to provide additional request context for invocations

BatchRequest

class roboto.http.BatchRequest(/, **data)#View Source

Bases: pydantic.BaseModel, Generic[Model]

Batched HTTP requests

Parameters

data Any

Attributes

BatchRequest.requests

requests list[Model] #

BatchResponse

class roboto.http.BatchResponse(/, **data)#View Source

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 Any

Properties

BatchResponse.failed

The exception the platform reported for each element it refused, in request order.

BatchResponse.map_data()

map_data(transform)#View Source

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.abc.Callable[[Model], MappedModel]

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

responses list[BatchResponseElement[Model]] #

BatchResponse.single()

single()#View Source

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

Properties

BatchResponse.succeeded

succeeded list[Model] #

The result the platform returned for each element it applied, in request order.

Return type: list[Model]

BatchResponseElement

class roboto.http.BatchResponseElement(/, **data)#View Source

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 Any

Attributes

BatchResponseElement.data

data Model | None = None #

BatchResponseElement.error

BatchResponseElement.model_config

model_config #

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

BatchResponseElement.serialize_error()

serialize_error(value, info)#View Source

Parameters

info pydantic.SerializationInfo

Return type

Optional[dict[str, Any]]

BatchResponseElement.validate_error()

validate_error(value)#View Source

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 Any

BearerTokenDecorator

class roboto.http.BearerTokenDecorator(token)#View Source

Decorates requests with a static, unchanging bearer token.

Parameters

token str

CONNECTION_CONSISTENCY_HEADER

roboto.http.CONNECTION_CONSISTENCY_HEADER = 'X-Roboto-Connection-Consistency'#View Source

Header to control database read consistency for query/search endpoints.

Set to ‘strongly_consistent’ to force strongly consistent reads, or ‘eventually_consistent’ to force eventually consistent reads. Omission defaults to the API version’s default.

Only applies to query and search endpoints (e.g., /v1/query/*, /v1/datasets/query, /v1/files/query). Has no effect on other endpoints.

For API versions >= 2026-03-13, query endpoints default to eventually consistent reads. For older API versions, they default to strongly consistent reads for backward compatibility.

CONTENT_TYPE_JSON_HEADER

roboto.http.CONTENT_TYPE_JSON_HEADER#View Source

ClientError

exception roboto.http.ClientError(exc)#View Source

Bases: HttpError

Common base class for all non-exit exceptions.

Parameters

exc urllib.error.HTTPError

DEFAULT_HTTP_TIMEOUT

roboto.http.DEFAULT_HTTP_TIMEOUT = 30.0#View Source

HttpClient

class roboto.http.HttpClient(base_headers=None, default_endpoint=None, default_auth=None, requester=None, extra_headers_provider=None, default_timeout=None, options=None)#View Source

Parameters

base_headers Optional[dict[str, str]]
default_endpoint Optional[str]
extra_headers_provider Optional[Callable[[], dict[str, str]]]
default_timeout Optional[float]

Properties

HttpClient.auth_decorator

HttpClient.delete()

delete(url, data=None, headers=None, idempotent=True, retry_wait=None, timeout=NotSet)#View Source

Parameters

url str
data Any
headers Optional[dict]
idempotent bool
retry_wait Optional[roboto.http.request.RetryWaitFn]

HttpClient.get()

get(url, headers=None, retry_wait=None, idempotent=True, timeout=NotSet)#View Source

Parameters

url str
headers Optional[dict]
retry_wait Optional[roboto.http.request.RetryWaitFn]
idempotent bool

HttpClient.patch()

patch(url, data=None, headers=None, idempotent=True, retry_wait=None, timeout=NotSet)#View Source

Parameters

url str
data Any
headers Optional[dict]
idempotent bool
retry_wait Optional[roboto.http.request.RetryWaitFn]

HttpClient.post()

post(url, data=None, headers=None, idempotent=False, retry_wait=None, timeout=NotSet)#View Source

Parameters

url str
data Any
headers Optional[dict]
idempotent bool
retry_wait Optional[roboto.http.request.RetryWaitFn]

HttpClient.put()

put(url, data=None, headers=None, idempotent=True, retry_wait=None, timeout=NotSet)#View Source

Parameters

url str
data Any
headers Optional[dict]
idempotent bool
retry_wait Optional[roboto.http.request.RetryWaitFn]

HttpClient.set_requester()

set_requester(requester)#View Source

HttpClient.url()

url(path)#View Source

Parameters

path str

Return type

str

HttpClientOptions

class roboto.http.HttpClientOptions#View Source

Behavior of a HttpClient, applied to every request it makes.

Attributes

HttpClientOptions.logging

HttpClientOptions.retry

HttpError

exception roboto.http.HttpError(exc)#View Source

Bases: Exception

Common base class for all non-exit exceptions.

Parameters

exc urllib.error.HTTPError

Properties

HttpError.headers

headers dict #
Return type: dict

HttpError.msg

msg Any #
Return type: Any

HttpError.status

status http.HTTPStatus | None #
Return type: Optional[http.HTTPStatus]

HttpLoggingOptions

class roboto.http.HttpLoggingOptions#View Source

How a HttpClient renders requests into its logs.

Attributes

HttpLoggingOptions.scrub_headers

scrub_headers Sequence[str] = () #

Header names, compared case-insensitively, whose values are replaced with * in every rendered form of a request the client produces. Authorization is always scrubbed, with or without an entry here.

HttpRequest

class roboto.http.HttpRequest(url, method='GET', headers=None, data=None, retry_wait=None, idempotent=False)#View Source

Parameters

url str
method str
headers Optional[dict[str, str]]
data Any
retry_wait Optional[roboto.http.retry.RetryWaitFn]
idempotent bool

HttpRequest.append_headers()

append_headers(headers)#View Source

Parameters

headers dict[str, str]

Return type

None

Properties

HttpRequest.body

body bytes | None #
Return type: Optional[bytes]

Attributes

HttpRequest.data

data Any = None #

HttpRequest.describe()

describe(scrub_headers=())#View Source

Render the request for logging, with sensitive header values replaced by *.

Parameters

scrub_headers Collection[str]

Header names, compared case-insensitively, to scrub in addition to ALWAYS_SCRUBBED_HEADERS.

Return type

str

Attributes

HttpRequest.headers

headers dict #

Properties

HttpRequest.hostname

hostname str #
Return type: str

Attributes

HttpRequest.idempotent

idempotent bool = False #

HttpRequest.method

method str #

HttpRequest.retry_wait

HttpRequest.url

url str #

HttpRetryOptions

class roboto.http.HttpRetryOptions#View Source

Whether and how many times a HttpClient retries a failed request.

Attributes

HttpRetryOptions.max_attempts

max_attempts int = 10 #

Total attempts per request, first try included. Values below 1 behave as 1: the first attempt always runs.

HttpRetryOptions.predicate

predicate RetryPredicate | None = None #

Called with the request and the exception a failed attempt raised; True means try again. None keeps the default, is_expected_to_be_transient(), which retries failures expected to be transient: DNS resolution failures unconditionally; connection errors, timeouts, and retryable HTTP statuses according to the request’s idempotency.

InvalidPaginationTokenError

exception roboto.http.InvalidPaginationTokenError#View Source

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.

ORG_OVERRIDE_HEADER

roboto.http.ORG_OVERRIDE_HEADER = 'X-Roboto-Org-Id'#View Source

Header to specify the organization that the user is acting on behalf of.

ORG_OVERRIDE_QUERY_PARAM

roboto.http.ORG_OVERRIDE_QUERY_PARAM = 'robotoOrgId'#View Source

Query parameter to specify the organization that the user is acting on behalf of.

PaginatedList

class roboto.http.PaginatedList(/, **data)#View Source

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 Any

Attributes

PaginatedList.items

items list[Model] #

Roboto entities in this page of results.

PaginatedList.next_token

next_token str | None = None #

Opaque token to fetch the next page of results.

If None, then this is the last page of results.

PaginatedList.total_count

total_count int | None = None #

Total result set size, if available.

PaginationToken

class roboto.http.PaginationToken(scheme, encoding, data)#View Source

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.data

data Any #
Return type: Any

PaginationToken.decode()

static decode(data)#View Source

Base64 decode the data, adding back any trailing padding (“=”) as necessary to make data properly Base64.

Parameters

data str

Return type

str

PaginationToken.empty()

static empty()#View Source

Return type

PaginationToken.encode()

static encode(data)#View Source

Base64 encode the data and strip all trailing padding (“=”).

Parameters

data str

Return type

str

PaginationToken.from_token()

classmethod from_token(token)#View Source

Parameters

token Optional[str]

Return type

PaginationToken.json_token()

classmethod json_token(data)#View Source

Parameters

data Any

Return type

PaginationToken.to_token()

to_token()#View Source

Return type

str

PaginationTokenEncoding

class roboto.http.PaginationTokenEncoding(*args, **kwds)#View Source

Bases: enum.Enum

Pagination token encoding enum

Attributes

PaginationTokenEncoding.Json

Json = 'json' #

PaginationTokenEncoding.Raw

Raw = 'raw' #

PaginationTokenScheme

class roboto.http.PaginationTokenScheme(*args, **kwds)#View Source

Bases: enum.Enum

Pagination token scheme enum

Attributes

PaginationTokenScheme.V1

V1 = 'v1' #

RESOURCE_OWNER_OVERRIDE_HEADER

roboto.http.RESOURCE_OWNER_OVERRIDE_HEADER = 'X-Roboto-Resource-Owner-Id'#View Source

Header to specify the organization that owns the resource being accessed.

RESOURCE_OWNER_OVERRIDE_QUERY_PARAM

roboto.http.RESOURCE_OWNER_OVERRIDE_QUERY_PARAM = 'robotoResourceOwnerId'#View Source

Query parameter to specify the organization that owns the resource being accessed.

ROBOTO_REQUESTER_HEADER

roboto.http.ROBOTO_REQUESTER_HEADER = 'X-Roboto-Requester'#View Source

A JSON serialized RobotoRequester representing the entity making a request to Roboto.

RetryPredicate

roboto.http.RetryPredicate#View Source

Decides whether the exception warrants another attempt at the request.

RobotoClient

class roboto.http.RobotoClient(endpoint, auth_decorator, http_client_kwargs=None)#View Source

A client for making HTTP requests against Roboto service

Parameters

endpoint str
http_client_kwargs Optional[dict[str, Any]]

RobotoClient.defaulted()

classmethod defaulted(client=None)#View Source

Parameters

client Optional[RobotoClient]

Return type

RobotoClient.delete()

delete(path, caller_org_id=None, data=None, headers=None, idempotent=True, owner_org_id=None, query=None, retry_wait_fn=None, timeout=NotSet)#View Source

Parameters

caller_org_id Optional[str]
data Any
headers Optional[dict[str, str]]
idempotent bool
owner_org_id Optional[str]
query Optional[dict[str, Any]]
retry_wait_fn Optional[roboto.http.retry.RetryWaitFn]

Properties

RobotoClient.endpoint

endpoint str #
Return type: str

RobotoClient.for_profile()

classmethod for_profile(profile)#View Source

Parameters

profile str

Return type

RobotoClient.from_config()

classmethod from_config(config)#View Source

Return type

RobotoClient.from_env()

classmethod from_env()#View Source

Return type

Properties

RobotoClient.frontend_endpoint

frontend_endpoint str #
Return type: str

RobotoClient.get()

get(path, caller_org_id=None, headers=None, idempotent=True, owner_org_id=None, query=None, retry_wait_fn=None, timeout=NotSet)#View Source

Parameters

caller_org_id Optional[str]
headers Optional[dict[str, str]]
idempotent bool
owner_org_id Optional[str]
query Optional[dict[str, Any]]
retry_wait_fn Optional[roboto.http.retry.RetryWaitFn]

Properties

RobotoClient.http_client

RobotoClient.patch()

patch(path, caller_org_id=None, data=None, headers=None, idempotent=True, owner_org_id=None, query=None, retry_wait_fn=None, timeout=NotSet)#View Source

Parameters

caller_org_id Optional[str]
data Any
headers Optional[dict[str, str]]
idempotent bool
owner_org_id Optional[str]
query Optional[dict[str, Any]]
retry_wait_fn Optional[roboto.http.retry.RetryWaitFn]

RobotoClient.post()

post(path, caller_org_id=None, data=None, headers=None, idempotent=True, owner_org_id=None, query=None, retry_wait_fn=None, timeout=NotSet)#View Source

Parameters

caller_org_id Optional[str]
data Any
headers Optional[dict[str, str]]
idempotent bool
owner_org_id Optional[str]
query Optional[dict[str, Any]]
retry_wait_fn Optional[roboto.http.retry.RetryWaitFn]

RobotoClient.put()

put(path, caller_org_id=None, data=None, headers=None, idempotent=True, owner_org_id=None, query=None, retry_wait_fn=None, timeout=NotSet)#View Source

Parameters

caller_org_id Optional[str]
data Any
headers Optional[dict[str, str]]
idempotent bool
owner_org_id Optional[str]
query Optional[dict[str, Any]]
retry_wait_fn Optional[roboto.http.retry.RetryWaitFn]

RobotoRequester

class roboto.http.RobotoRequester(/, **data)#View Source

Bases: pydantic.BaseModel

Details about the entity making a request to Roboto. These are embedded in a header in order to see what tool versions / operating systems are making requests, and to aid debugging.

Parameters

data Any

RobotoRequester.for_tool()

classmethod for_tool(tool)#View Source

Called to intelligently populate a RobotoRequester for a request made from a named Roboto tool using the Python SDK.

Parameters

Return type

Attributes

RobotoRequester.platform

platform str | None = None #

The environment in which a request is being made, i.e. the user agent (for browser requests) or the results of platform.platform (for SDK requests)

RobotoRequester.roboto_tool

roboto_tool RobotoTool | str | None = None #

If a request is being made from a Roboto vended tool, the name of the tool

RobotoRequester.roboto_tool_details

roboto_tool_details str | None = None #

If a request is being made from a Roboto vended tool, free text pertinent details about the tool

RobotoRequester.roboto_tool_version

roboto_tool_version str | None = None #

If a request is being made from a Roboto vended tool, the version of the tool

RobotoRequester.schema_version

schema_version Literal['v1'] = 'v1' #

Roboto Requester payload schema version, used to ensure backward compatibility

RobotoTool

class roboto.http.RobotoTool#View Source

Bases: roboto.compat.StrEnum

Tool used to access Roboto

Attributes

RobotoTool.Cli

Cli = 'cli' #

RobotoTool.Sdk

Sdk = 'sdk' #

RobotoTool.UploadAgent

UploadAgent = 'upload-agent' #

RobotoTool.Website

Website = 'website' #

ServerError

exception roboto.http.ServerError(exc)#View Source

Bases: HttpError

Common base class for all non-exit exceptions.

Parameters

exc urllib.error.HTTPError

SigV4AuthDecorator

class roboto.http.SigV4AuthDecorator(service='execute-api', credentials=None, region=None)#View Source

Parameters

service str
credentials Optional[botocore.credentials.ReadOnlyCredentials]
region Optional[str]

SigV4AuthDecorator.lookup_credentials()

static lookup_credentials()#View Source

Return type

botocore.credentials.ReadOnlyCredentials

SigV4AuthDecorator.lookup_region()

static lookup_region()#View Source

Return type

str

StreamedList

class roboto.http.StreamedList(/, **data)#View Source

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

Attributes

StreamedList.has_next

has_next bool #

StreamedList.items

items list[Model] #

StreamedList.last_read

last_read str | None #

USER_OVERRIDE_HEADER

roboto.http.USER_OVERRIDE_HEADER = 'X-Roboto-User-Id'#View Source

Header to specify the user that is performing the REST operation.

USER_OVERRIDE_QUERY_PARAM

roboto.http.USER_OVERRIDE_QUERY_PARAM = 'robotoUserId'#View Source

“Query parameter to specify the user that is performing the REST operation.

is_expected_to_be_transient()

roboto.http.is_expected_to_be_transient(request, exc)#View Source

The default retry predicate: whether exc is expected to be transient for request.

Parameters

exc BaseException

Return type

bool

never_retry()

roboto.http.never_retry(_request, _exc)#View Source

Retry predicate giving every request exactly one attempt.

Use for calls whose side effect must not run twice and where the server offers no idempotency key: a retried delivery (a chat message, an email) lands as a duplicate.

Parameters

_exc BaseException

Return type

bool

roboto_headers()

roboto.http.roboto_headers(org_id=None, user_id=None, resource_owner_id=None, additional_headers=None, api_version=RobotoApiVersion.latest())#View Source

Parameters

org_id Optional[str]
user_id Optional[str]
resource_owner_id Optional[str]
additional_headers Optional[dict[str, str]]

Was this page helpful?