Utility Classes

DOAPIError

exception doapi.DOAPIError(response)[source]

An exception raised in reaction to the API endpoint responding with a 4xx or 5xx error. If the body of the response is a JSON object, its fields will be added to the DOAPIError‘s attributes (except where a pre-existing attribute would be overwritten). DigitalOcean error response bodies have been observed to consist of an object with two string fields, "id" and "message".

Note that this class is only for representing errors reported by the endpoint in response to API requests. Everything else that can go wrong uses the normal Python exceptions.

response = None

The requests.Response object

http_error_msg = None

An error message that should be appropriate for human consumption, containing the type of HTTP error, the URL that was requested, and the body of the response.

DOEncoder

class doapi.DOEncoder(skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, encoding='utf-8', default=None)[source]

A json.JSONEncoder subclass that converts resource objects to dicts for JSONification. It also converts iterators to lists.

default(obj)[source]