hubgrep.lib.cached_session.cached_response module¶
A CachedResponse is a wrapper for requests.Response, for serialization and caching.
-
class
hubgrep.lib.cached_session.cached_response.
CachedResponse
(url, success, status_code, response_json, error_msg)¶ Bases:
object
Wrapper class for cached responses.
- url -
url this request was made to
- success -
True, if status_code was 2XX
- status_code -
http status code of the response. will be -1 if an exception was thrown, and we didnt get a status code.
- response_json -
dict from the response json data
- error_msg -
http error message, if we had a response code, otherwise the exception text
-
static
from_exception
(url, exception) → hubgrep.lib.cached_session.cached_response.CachedResponse¶ Create a CachedResponse object from an exception message.
-
static
from_response
(response: requests.models.Response) → hubgrep.lib.cached_session.cached_response.CachedResponse¶ Create a CachedResponse object from a request.Response.
-
static
from_serialized
(data: str) → hubgrep.lib.cached_session.cached_response.CachedResponse¶ Create a CachedResponse object from serialized CachedResponse.
-
serialize
() → str¶ Serialize this CachedResponse.