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, client=None)[source]#
Bases:
objectResponse object that wraps an HTTP response from the underlying HTTP library. If the response is JSON, the parsed data will be available in
data, otherwisedatawill beNoneandtextshould be used instead.The most common response data is a JSON dictionary. To make handling this type of response as seamless as possible, the
GlobusHTTPResponseobject 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, default=None)[source]#
getis just an alias fordata.get(key, default), but with the added checks that ifdataisNoneor 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, client=None, *, iter_key=None)[source]#
Bases:
GlobusHTTPResponseThis response class adds an __iter__ method on an ‘iter_key’ variable. The assumption is that iter produces dicts or dict-like mappings.
- class globus_sdk.response.ArrayResponse(response, client=None)[source]#
Bases:
GlobusHTTPResponseThis response class adds an
__iter__method which assumes that the top-level data of the response is a JSON array.