2015-12-03 20:56:28 -05:00
|
|
|
from moto.core.exceptions import RESTError
|
|
|
|
|
2021-07-26 16:21:17 +02:00
|
|
|
XMLNS_IAM = "https://iam.amazonaws.com/doc/2010-05-08/"
|
|
|
|
|
2015-12-03 20:56:28 -05:00
|
|
|
|
|
|
|
class IAMNotFoundException(RESTError):
|
|
|
|
code = 404
|
|
|
|
|
|
|
|
def __init__(self, message):
|
2021-07-26 16:21:17 +02:00
|
|
|
super(IAMNotFoundException, self).__init__(
|
|
|
|
"NoSuchEntity", message, xmlns=XMLNS_IAM, template="wrapped_single_error"
|
|
|
|
)
|
2015-12-03 20:56:28 -05:00
|
|
|
|
|
|
|
|
|
|
|
class IAMConflictException(RESTError):
|
|
|
|
code = 409
|
|
|
|
|
2019-10-31 08:44:26 -07:00
|
|
|
def __init__(self, code="Conflict", message=""):
|
|
|
|
super(IAMConflictException, self).__init__(code, message)
|
2015-12-03 20:56:28 -05:00
|
|
|
|
|
|
|
|
|
|
|
class IAMReportNotPresentException(RESTError):
|
|
|
|
code = 410
|
|
|
|
|
|
|
|
def __init__(self, message):
|
2019-10-31 08:44:26 -07:00
|
|
|
super(IAMReportNotPresentException, self).__init__("ReportNotPresent", message)
|
2018-10-24 18:00:52 -07:00
|
|
|
|
|
|
|
|
2019-06-29 19:01:43 +02:00
|
|
|
class IAMLimitExceededException(RESTError):
|
|
|
|
code = 400
|
|
|
|
|
|
|
|
def __init__(self, message):
|
2019-10-31 08:44:26 -07:00
|
|
|
super(IAMLimitExceededException, self).__init__("LimitExceeded", message)
|
2019-06-29 19:01:43 +02:00
|
|
|
|
|
|
|
|
2018-10-24 18:00:52 -07:00
|
|
|
class MalformedCertificate(RESTError):
|
|
|
|
code = 400
|
|
|
|
|
|
|
|
def __init__(self, cert):
|
|
|
|
super(MalformedCertificate, self).__init__(
|
2019-10-31 08:44:26 -07:00
|
|
|
"MalformedCertificate", "Certificate {cert} is malformed".format(cert=cert)
|
|
|
|
)
|
2019-01-29 18:09:31 -08:00
|
|
|
|
|
|
|
|
2019-06-30 17:09:55 +02:00
|
|
|
class MalformedPolicyDocument(RESTError):
|
|
|
|
code = 400
|
|
|
|
|
|
|
|
def __init__(self, message=""):
|
|
|
|
super(MalformedPolicyDocument, self).__init__(
|
2021-12-04 21:24:06 +05:30
|
|
|
"MalformedPolicyDocument",
|
|
|
|
message,
|
|
|
|
xmlns=XMLNS_IAM,
|
|
|
|
template="wrapped_single_error",
|
2019-10-31 08:44:26 -07:00
|
|
|
)
|
2019-06-30 17:09:55 +02:00
|
|
|
|
|
|
|
|
2019-01-29 18:09:31 -08:00
|
|
|
class DuplicateTags(RESTError):
|
|
|
|
code = 400
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
super(DuplicateTags, self).__init__(
|
2019-10-31 08:44:26 -07:00
|
|
|
"InvalidInput",
|
|
|
|
"Duplicate tag keys found. Please note that Tag keys are case insensitive.",
|
|
|
|
)
|
2019-01-29 18:09:31 -08:00
|
|
|
|
|
|
|
|
|
|
|
class TagKeyTooBig(RESTError):
|
|
|
|
code = 400
|
|
|
|
|
2019-10-31 08:44:26 -07:00
|
|
|
def __init__(self, tag, param="tags.X.member.key"):
|
2019-01-29 18:09:31 -08:00
|
|
|
super(TagKeyTooBig, self).__init__(
|
2019-10-31 08:44:26 -07:00
|
|
|
"ValidationError",
|
|
|
|
"1 validation error detected: Value '{}' at '{}' failed to satisfy "
|
|
|
|
"constraint: Member must have length less than or equal to 128.".format(
|
|
|
|
tag, param
|
|
|
|
),
|
|
|
|
)
|
2019-01-29 18:09:31 -08:00
|
|
|
|
|
|
|
|
|
|
|
class TagValueTooBig(RESTError):
|
|
|
|
code = 400
|
|
|
|
|
|
|
|
def __init__(self, tag):
|
|
|
|
super(TagValueTooBig, self).__init__(
|
2019-10-31 08:44:26 -07:00
|
|
|
"ValidationError",
|
|
|
|
"1 validation error detected: Value '{}' at 'tags.X.member.value' failed to satisfy "
|
|
|
|
"constraint: Member must have length less than or equal to 256.".format(
|
|
|
|
tag
|
|
|
|
),
|
|
|
|
)
|
2019-01-29 18:09:31 -08:00
|
|
|
|
|
|
|
|
|
|
|
class InvalidTagCharacters(RESTError):
|
|
|
|
code = 400
|
|
|
|
|
2019-10-31 08:44:26 -07:00
|
|
|
def __init__(self, tag, param="tags.X.member.key"):
|
|
|
|
message = "1 validation error detected: Value '{}' at '{}' failed to satisfy ".format(
|
|
|
|
tag, param
|
|
|
|
)
|
2019-01-29 18:09:31 -08:00
|
|
|
message += "constraint: Member must satisfy regular expression pattern: [\\p{L}\\p{Z}\\p{N}_.:/=+\\-@]+"
|
|
|
|
|
2019-10-31 08:44:26 -07:00
|
|
|
super(InvalidTagCharacters, self).__init__("ValidationError", message)
|
2019-01-29 18:09:31 -08:00
|
|
|
|
|
|
|
|
|
|
|
class TooManyTags(RESTError):
|
|
|
|
code = 400
|
|
|
|
|
2019-10-31 08:44:26 -07:00
|
|
|
def __init__(self, tags, param="tags"):
|
2019-01-29 18:09:31 -08:00
|
|
|
super(TooManyTags, self).__init__(
|
2019-10-31 08:44:26 -07:00
|
|
|
"ValidationError",
|
|
|
|
"1 validation error detected: Value '{}' at '{}' failed to satisfy "
|
|
|
|
"constraint: Member must have length less than or equal to 50.".format(
|
|
|
|
tags, param
|
|
|
|
),
|
|
|
|
)
|
2019-10-18 17:29:15 +02:00
|
|
|
|
|
|
|
|
|
|
|
class EntityAlreadyExists(RESTError):
|
|
|
|
code = 409
|
|
|
|
|
2019-10-20 22:39:57 +02:00
|
|
|
def __init__(self, message):
|
2019-10-31 08:44:26 -07:00
|
|
|
super(EntityAlreadyExists, self).__init__("EntityAlreadyExists", message)
|
2019-10-18 17:29:15 +02:00
|
|
|
|
|
|
|
|
|
|
|
class ValidationError(RESTError):
|
|
|
|
code = 400
|
|
|
|
|
|
|
|
def __init__(self, message):
|
2019-10-31 08:44:26 -07:00
|
|
|
super(ValidationError, self).__init__("ValidationError", message)
|
2019-10-18 17:29:15 +02:00
|
|
|
|
|
|
|
|
|
|
|
class InvalidInput(RESTError):
|
|
|
|
code = 400
|
|
|
|
|
|
|
|
def __init__(self, message):
|
2019-11-01 07:14:03 +01:00
|
|
|
super(InvalidInput, self).__init__("InvalidInput", message)
|
2019-10-28 23:50:17 +01:00
|
|
|
|
|
|
|
|
|
|
|
class NoSuchEntity(RESTError):
|
|
|
|
code = 404
|
|
|
|
|
|
|
|
def __init__(self, message):
|
2021-07-26 16:21:17 +02:00
|
|
|
super(NoSuchEntity, self).__init__(
|
|
|
|
"NoSuchEntity", message, xmlns=XMLNS_IAM, template="wrapped_single_error"
|
|
|
|
)
|