esdc_api.response¶
This module provides the Response object returned by Danube Cloud API Client request methods.
-
class
esdc_api.response.Response(response)¶ Danube Cloud API Response (wrapper around
requests.Responseclass).Parameters: response – The requests.Responseobject.-
consume_raw_content()¶ Iterate over the generator returned by
fetch_raw_content()and return the last item - the raw content.Returns: Raw content. Return type: bytes
-
content¶ Parse raw content and return a content tuple.
Returns: Content namedtuple with Content.resultattribute.Return type: ContentRaise: ESAPIError
-
fetch_raw_content()¶ Fetch content from the server and yield None while waiting for some data. The last yielded item is always the raw content (bytes).
Returns: Generator which yields None until it yields the raw content (bytes). Return type: generator
-
headers¶ Return the response headers.
-
static
is_status_code_ok(status_code)¶ Helper method for checking the HTTP status code.
Parameters: status_code (int) – HTTP status code. Returns: True if status_code < 400. Return type: bool
-
method¶ Return the request method.
-
ok¶ Return True if response status code is < 400. Also fetch the raw content if needed.
Returns: Response status according to the HTTP status code. Return type: bool
-
parse_raw_content(raw_content)¶ Parse raw content and return content tuple or API error exception (without raising it).
Parameters: raw_content – Last item yielded by fetch_raw_content().Returns: ESAPIErrororContent.
-
raw_content¶ Return raw content. Fetch and cache it by using
consume_raw_content(); if not already consumed.Returns: Raw content. Return type: bytes
-
ready¶ Indicate whether raw content was already consumed from server.
Returns: Raw content status. Return type: bool
-
status_code¶ Return HTTP status code of this response.
Returns: HTTP status code. Return type: int
-
url¶ Return the request URL.
-
version= None¶ Danube Cloud API version.
-