Utility Classes¶
Exceptions¶
ActionError¶
-
exception
doapi.ActionError(action)[source]¶ Bases:
exceptions.ExceptionNew in version 0.2.0.
Raised when
raise_for_error()is called on anActionthat failed to complete successfully
DOAPIError¶
-
exception
doapi.DOAPIError(response)[source]¶ Bases:
exceptions.ExceptionAn exception raised in reaction to the API endpoint responding with a 4xx or 5xx error. Any method that performs an API request may raise this error.
If the body of the error 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.Responseobject
-
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.
-
WaitTimeoutError¶
-
exception
doapi.WaitTimeoutError(in_progress, attr, value, wait_interval, wait_time)[source]¶ Bases:
exceptions.ExceptionNew in version 0.2.0.
Raised when the runtime of a
waitmethod exceedswait_time-
in_progress= None¶ A list of any waited-on objects that have not yet completed
-
attr= None¶ The objects’ attribute that was being monitored
-
wait_interval= None¶ The
wait_intervalvalue for the wait operation
-
wait_time= None¶ The
wait_timevalue for the wait operation
-
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]¶ Bases:
json.encoder.JSONEncoderA
json.JSONEncodersubclass that converts resource objects todicts for JSONification. It also converts iterators to lists.-
default(obj)[source]¶ Implement this method in a subclass such that it returns a serializable object for
o, or calls the base implementation (to raise aTypeError).For example, to support arbitrary iterators, you could implement default like this:
def default(self, o): try: iterable = iter(o) except TypeError: pass else: return list(iterable) # Let the base class default method raise the TypeError return JSONEncoder.default(self, o)
-