The http Module

The http module wraps the underlying raw HTTP request module (requests currently) to separate the job of exposing the API from the job of dealing with lower-level interfacing with the HTTP client in use today.

class pyrabbit.http.HTTPClient(api_url, uname, passwd, timeout=5, scheme='http')[source]

A wrapper for requests. Abstracts away things like path building, return value parsing, etc., so the api module code stays clean and easy to read/use.

do_call(path, method, body=None, headers=None)[source]

Send an HTTP request to the REST API.

  • path (string) – A URL
  • method (string) – The HTTP method (GET, POST, etc.) to use in the request.
  • body (string) – A string representing any data to be sent in the body of the HTTP request.
  • headers (dictionary) – “{header-name: header-value}” dictionary.
exception pyrabbit.http.HTTPError(content, status=None, reason=None, path=None, body=None)[source]

An error response from the API server. This should be an HTTP error of some kind (404, 500, etc).

exception pyrabbit.http.NetworkError[source]

Denotes a failure to communicate with the REST API