Responses#
Unless noted otherwise, all method return values for Globus SDK Clients are
GlobusHTTPResponse
objects.
To customize client methods with additional detail, the SDK uses subclasses of
GlobusHTTPResponse
.
- class globus_sdk.response.GlobusHTTPResponse(response: Response | GlobusHTTPResponse, client: globus_sdk.BaseClient | None = None)[source]#
Bases:
object
Response object that wraps an HTTP response from the underlying HTTP library. If the response is JSON, the parsed data will be available in
data
, otherwisedata
will beNone
andtext
should be used instead.The most common response data is a JSON dictionary. To make handling this type of response as seamless as possible, the
GlobusHTTPResponse
object implements the immutable mapping protocol for dict-style access. This is just an alias for access to the underlying data.If the response data is not a dictionary or list, item access will raise
TypeError
.>>> print("Response ID": r["id"]) # alias for r.data["id"]
- Variables:
client – The client instance which made the request
- get(key: str, default: Any | None = None) Any [source]#
get
is just an alias fordata.get(key, default)
, but with the added checks that ifdata
isNone
or a list, it returns the default.
- property headers: Mapping[str, str]#
The HTTP response headers as a case-insensitive mapping.
For example,
headers["Content-Length"]
andheaders["content-length"]
are treated as equivalent.
- class globus_sdk.response.IterableResponse(response: Response | GlobusHTTPResponse, client: globus_sdk.BaseClient | None = None, *, iter_key: str | None = None)[source]#
Bases:
GlobusHTTPResponse
This response class adds an __iter__ method on an ‘iter_key’ variable. The assumption is that iter produces dicts or dict-like mappings.