2019-03-01 22:49:31 +00:00
|
|
|
class StructuredException(Exception):
|
|
|
|
status_code = 0
|
|
|
|
|
|
|
|
def __init__(self, name=None, message="You want override this error!"):
|
|
|
|
Exception.__init__(self)
|
|
|
|
self.message = message
|
|
|
|
self.name = name
|
|
|
|
|
|
|
|
def to_dict(self):
|
|
|
|
rv = dict()
|
|
|
|
msg = ''
|
|
|
|
if self.name:
|
|
|
|
msg = '{0} {1}'.format(self.message, self.name)
|
|
|
|
else:
|
|
|
|
msg = self.message
|
|
|
|
|
|
|
|
rv['msg'] = msg
|
|
|
|
return rv
|
|
|
|
|
|
|
|
|
|
|
|
class DomainNotExists(StructuredException):
|
2019-06-29 15:29:06 +00:00
|
|
|
status_code = 404
|
2019-03-01 22:49:31 +00:00
|
|
|
|
|
|
|
def __init__(self, name=None, message="Domain does not exist"):
|
|
|
|
StructuredException.__init__(self)
|
|
|
|
self.message = message
|
|
|
|
self.name = name
|
|
|
|
|
|
|
|
|
2019-12-02 03:32:03 +00:00
|
|
|
class DomainAlreadyExists(StructuredException):
|
|
|
|
status_code = 409
|
|
|
|
|
|
|
|
def __init__(self, name=None, message="Domain already exists"):
|
|
|
|
StructuredException.__init__(self)
|
|
|
|
self.message = message
|
|
|
|
self.name = name
|
|
|
|
|
|
|
|
|
2019-03-01 22:49:31 +00:00
|
|
|
class DomainAccessForbidden(StructuredException):
|
2019-06-29 15:29:06 +00:00
|
|
|
status_code = 403
|
2019-03-01 22:49:31 +00:00
|
|
|
|
|
|
|
def __init__(self, name=None, message="Domain access not allowed"):
|
|
|
|
StructuredException.__init__(self)
|
|
|
|
self.message = message
|
|
|
|
self.name = name
|
|
|
|
|
2022-06-17 15:50:51 +00:00
|
|
|
class DomainOverrideForbidden(StructuredException):
|
|
|
|
status_code = 409
|
|
|
|
|
|
|
|
def __init__(self, name=None, message="Domain override of record not allowed"):
|
|
|
|
StructuredException.__init__(self)
|
|
|
|
self.message = message
|
|
|
|
self.name = name
|
2019-03-01 22:49:31 +00:00
|
|
|
|
|
|
|
class ApiKeyCreateFail(StructuredException):
|
2019-06-29 15:29:06 +00:00
|
|
|
status_code = 500
|
2019-03-01 22:49:31 +00:00
|
|
|
|
|
|
|
def __init__(self, name=None, message="Creation of api key failed"):
|
|
|
|
StructuredException.__init__(self)
|
|
|
|
self.message = message
|
|
|
|
self.name = name
|
|
|
|
|
|
|
|
|
|
|
|
class ApiKeyNotUsable(StructuredException):
|
2019-06-29 15:29:06 +00:00
|
|
|
status_code = 400
|
2019-03-01 22:49:31 +00:00
|
|
|
|
2019-12-22 03:06:02 +00:00
|
|
|
def __init__(
|
|
|
|
self,
|
|
|
|
name=None,
|
2021-12-03 14:12:11 +00:00
|
|
|
message=("Api key must have domains or accounts"
|
|
|
|
" or an administrative role")):
|
2019-03-01 22:49:31 +00:00
|
|
|
StructuredException.__init__(self)
|
|
|
|
self.message = message
|
|
|
|
self.name = name
|
|
|
|
|
|
|
|
|
|
|
|
class NotEnoughPrivileges(StructuredException):
|
2019-06-29 15:29:06 +00:00
|
|
|
status_code = 401
|
2019-03-01 22:49:31 +00:00
|
|
|
|
|
|
|
def __init__(self, name=None, message="Not enough privileges"):
|
|
|
|
StructuredException.__init__(self)
|
|
|
|
self.message = message
|
|
|
|
self.name = name
|
|
|
|
|
|
|
|
|
|
|
|
class RequestIsNotJSON(StructuredException):
|
2019-06-29 15:29:06 +00:00
|
|
|
status_code = 400
|
2019-03-01 22:49:31 +00:00
|
|
|
|
|
|
|
def __init__(self, name=None, message="Request is not json"):
|
|
|
|
StructuredException.__init__(self)
|
|
|
|
self.message = message
|
|
|
|
self.name = name
|
2020-01-27 12:38:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
class AccountCreateFail(StructuredException):
|
|
|
|
status_code = 500
|
|
|
|
|
|
|
|
def __init__(self, name=None, message="Creation of account failed"):
|
|
|
|
StructuredException.__init__(self)
|
|
|
|
self.message = message
|
|
|
|
self.name = name
|
|
|
|
|
|
|
|
|
2021-03-16 18:39:53 +00:00
|
|
|
class AccountCreateDuplicate(StructuredException):
|
|
|
|
status_code = 409
|
|
|
|
|
|
|
|
def __init__(self, name=None, message="Creation of account failed"):
|
|
|
|
StructuredException.__init__(self)
|
|
|
|
self.message = message
|
|
|
|
self.name = name
|
|
|
|
|
|
|
|
|
2020-01-27 12:38:38 +00:00
|
|
|
class AccountUpdateFail(StructuredException):
|
|
|
|
status_code = 500
|
|
|
|
|
|
|
|
def __init__(self, name=None, message="Update of account failed"):
|
|
|
|
StructuredException.__init__(self)
|
|
|
|
self.message = message
|
|
|
|
self.name = name
|
|
|
|
|
|
|
|
|
|
|
|
class AccountDeleteFail(StructuredException):
|
|
|
|
status_code = 500
|
|
|
|
|
|
|
|
def __init__(self, name=None, message="Delete of account failed"):
|
|
|
|
StructuredException.__init__(self)
|
|
|
|
self.message = message
|
|
|
|
self.name = name
|
|
|
|
|
|
|
|
|
2021-12-03 14:12:11 +00:00
|
|
|
class AccountNotExists(StructuredException):
|
|
|
|
status_code = 404
|
|
|
|
|
|
|
|
def __init__(self, name=None, message="Account does not exist"):
|
|
|
|
StructuredException.__init__(self)
|
|
|
|
self.message = message
|
|
|
|
self.name = name
|
|
|
|
|
2021-12-31 08:51:12 +00:00
|
|
|
class InvalidAccountNameException(StructuredException):
|
|
|
|
status_code = 400
|
|
|
|
|
|
|
|
def __init__(self, name=None, message="The account name is invalid"):
|
|
|
|
StructuredException.__init__(self)
|
|
|
|
self.message = message
|
|
|
|
self.name = name
|
2021-12-03 14:12:11 +00:00
|
|
|
|
2020-01-27 12:38:38 +00:00
|
|
|
class UserCreateFail(StructuredException):
|
|
|
|
status_code = 500
|
|
|
|
|
|
|
|
def __init__(self, name=None, message="Creation of user failed"):
|
|
|
|
StructuredException.__init__(self)
|
|
|
|
self.message = message
|
|
|
|
self.name = name
|
|
|
|
|
2021-03-16 18:39:53 +00:00
|
|
|
class UserCreateDuplicate(StructuredException):
|
|
|
|
status_code = 409
|
|
|
|
|
|
|
|
def __init__(self, name=None, message="Creation of user failed"):
|
|
|
|
StructuredException.__init__(self)
|
|
|
|
self.message = message
|
|
|
|
self.name = name
|
|
|
|
|
2020-01-27 12:38:38 +00:00
|
|
|
class UserUpdateFail(StructuredException):
|
|
|
|
status_code = 500
|
|
|
|
|
|
|
|
def __init__(self, name=None, message="Update of user failed"):
|
|
|
|
StructuredException.__init__(self)
|
|
|
|
self.message = message
|
|
|
|
self.name = name
|
|
|
|
|
2021-03-16 18:39:53 +00:00
|
|
|
class UserUpdateFailEmail(StructuredException):
|
|
|
|
status_code = 409
|
|
|
|
|
|
|
|
def __init__(self, name=None, message="Update of user failed"):
|
|
|
|
StructuredException.__init__(self)
|
|
|
|
self.message = message
|
|
|
|
self.name = name
|
|
|
|
|
2020-01-27 12:38:38 +00:00
|
|
|
class UserDeleteFail(StructuredException):
|
|
|
|
status_code = 500
|
|
|
|
|
|
|
|
def __init__(self, name=None, message="Delete of user failed"):
|
|
|
|
StructuredException.__init__(self)
|
|
|
|
self.message = message
|
|
|
|
self.name = name
|
2022-06-18 12:20:49 +00:00
|
|
|
|
|
|
|
class RecordTypeNotAllowed(StructuredException):
|
|
|
|
status_code = 400
|
|
|
|
|
|
|
|
def __init__(self, name=None, message="Record type not allowed or does not present"):
|
|
|
|
StructuredException.__init__(self)
|
|
|
|
self.message = message
|
|
|
|
self.name = name
|
|
|
|
|
|
|
|
class RecordTTLNotAllowed(StructuredException):
|
|
|
|
status_code = 400
|
|
|
|
|
|
|
|
def __init__(self, name=None, message="Record TTL not allowed or does not present"):
|
|
|
|
StructuredException.__init__(self)
|
|
|
|
self.message = message
|
|
|
|
self.name = name
|