class ApiException(Exception): """Base TnOS API Client Exception. To correctly use this class, inherit from it and define a 'message' property. That message will get printf'd with the keyword arguments provided to the constructor. """ message = _("An unknown exception occurred.") def __init__(self, **kwargs): try: self._error_string = self.message % kwargs except Exception: # at least get the core message out if something happened self._error_string = self.message def __str__(self): return self._error_string
class InvalidSecurityCertificate(BadRequest): message = _("The backend received an invalid security certificate.")
class BadRequest(ApiException): message = _("The server is unable to fulfill the request due " "to a bad syntax")
class RequestTimeout(ApiException): message = _("The request has timed out.")
class ReadOnlyMode(Forbidden): message = _("Create/Update actions are forbidden when in read-only mode.")
class Forbidden(ApiException): message = _("The request is forbidden from accessing the " "referenced resource.")
class ServiceUnavailable(ApiException): message = _("Request could not completed because the associated " "resource could not be reached.")
class Failed_dependency(ApiException): message = _("Request failed dependency.")
class Conflict(ApiException): message = _("Request conflicts with configuration on a different " "entity.")
class ResourceNotFound(ApiException): message = _("An entity referenced in the request was not found.")
class UnAuthorizedRequest(ApiException): message = _("Server denied session's authentication credentials.")