2014-08-27 15:17:06 +00:00
|
|
|
from __future__ import unicode_literals
|
2015-02-10 13:33:18 +00:00
|
|
|
from moto.core.exceptions import RESTError
|
2014-08-27 15:17:06 +00:00
|
|
|
|
|
|
|
|
2016-07-08 19:32:34 +00:00
|
|
|
ERROR_WITH_BUCKET_NAME = """{% extends 'single_error' %}
|
2015-02-10 13:33:18 +00:00
|
|
|
{% block extra %}<BucketName>{{ bucket }}</BucketName>{% endblock %}
|
|
|
|
"""
|
2014-07-09 01:20:29 +00:00
|
|
|
|
2016-07-08 19:32:34 +00:00
|
|
|
ERROR_WITH_KEY_NAME = """{% extends 'single_error' %}
|
2016-05-01 21:03:58 +00:00
|
|
|
{% block extra %}<KeyName>{{ key_name }}</KeyName>{% endblock %}
|
|
|
|
"""
|
|
|
|
|
2014-07-09 01:20:29 +00:00
|
|
|
|
2015-02-10 13:33:18 +00:00
|
|
|
class S3ClientError(RESTError):
|
2017-02-24 02:37:43 +00:00
|
|
|
|
2016-07-08 19:32:34 +00:00
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
kwargs.setdefault('template', 'single_error')
|
|
|
|
self.templates['bucket_error'] = ERROR_WITH_BUCKET_NAME
|
|
|
|
super(S3ClientError, self).__init__(*args, **kwargs)
|
2015-02-10 13:33:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
class BucketError(S3ClientError):
|
2017-02-24 02:37:43 +00:00
|
|
|
|
2015-02-10 13:33:18 +00:00
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
kwargs.setdefault('template', 'bucket_error')
|
|
|
|
self.templates['bucket_error'] = ERROR_WITH_BUCKET_NAME
|
|
|
|
super(BucketError, self).__init__(*args, **kwargs)
|
|
|
|
|
|
|
|
|
|
|
|
class BucketAlreadyExists(BucketError):
|
|
|
|
code = 409
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super(BucketAlreadyExists, self).__init__(
|
|
|
|
"BucketAlreadyExists",
|
|
|
|
("The requested bucket name is not available. The bucket "
|
|
|
|
"namespace is shared by all users of the system. Please "
|
|
|
|
"select a different name and try again"),
|
|
|
|
*args, **kwargs)
|
|
|
|
|
|
|
|
|
|
|
|
class MissingBucket(BucketError):
|
|
|
|
code = 404
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super(MissingBucket, self).__init__(
|
|
|
|
"NoSuchBucket",
|
|
|
|
"The specified bucket does not exist",
|
|
|
|
*args, **kwargs)
|
2015-02-10 14:56:56 +00:00
|
|
|
|
|
|
|
|
2016-05-01 21:03:58 +00:00
|
|
|
class MissingKey(S3ClientError):
|
|
|
|
code = 404
|
|
|
|
|
|
|
|
def __init__(self, key_name):
|
|
|
|
super(MissingKey, self).__init__(
|
|
|
|
"NoSuchKey",
|
|
|
|
"The specified key does not exist.",
|
|
|
|
Key=key_name,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2015-02-10 14:56:56 +00:00
|
|
|
class InvalidPartOrder(S3ClientError):
|
|
|
|
code = 400
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super(InvalidPartOrder, self).__init__(
|
|
|
|
"InvalidPartOrder",
|
|
|
|
("The list of parts was not in ascending order. The parts "
|
|
|
|
"list must be specified in order by part number."),
|
|
|
|
*args, **kwargs)
|
|
|
|
|
|
|
|
|
|
|
|
class InvalidPart(S3ClientError):
|
|
|
|
code = 400
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super(InvalidPart, self).__init__(
|
|
|
|
"InvalidPart",
|
|
|
|
("One or more of the specified parts could not be found. "
|
|
|
|
"The part might not have been uploaded, or the specified "
|
|
|
|
"entity tag might not have matched the part's entity tag."),
|
|
|
|
*args, **kwargs)
|
|
|
|
|
|
|
|
|
|
|
|
class EntityTooSmall(S3ClientError):
|
|
|
|
code = 400
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super(EntityTooSmall, self).__init__(
|
|
|
|
"EntityTooSmall",
|
|
|
|
"Your proposed upload is smaller than the minimum allowed object size.",
|
|
|
|
*args, **kwargs)
|
2017-09-07 18:30:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
class InvalidRequest(S3ClientError):
|
|
|
|
code = 400
|
|
|
|
|
|
|
|
def __init__(self, method, *args, **kwargs):
|
|
|
|
super(InvalidRequest, self).__init__(
|
|
|
|
"InvalidRequest",
|
|
|
|
"Found unsupported HTTP method in CORS config. Unsupported method is {}".format(method),
|
|
|
|
*args, **kwargs)
|
|
|
|
|
|
|
|
|
|
|
|
class MalformedXML(S3ClientError):
|
|
|
|
code = 400
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super(MalformedXML, self).__init__(
|
|
|
|
"MalformedXML",
|
|
|
|
"The XML you provided was not well-formed or did not validate against our published schema",
|
|
|
|
*args, **kwargs)
|
2018-01-03 04:47:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
class MalformedACLError(S3ClientError):
|
|
|
|
code = 400
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super(MalformedACLError, self).__init__(
|
|
|
|
"MalformedACLError",
|
|
|
|
"The XML you provided was not well-formed or did not validate against our published schema",
|
|
|
|
*args, **kwargs)
|
|
|
|
|
|
|
|
|
|
|
|
class InvalidTargetBucketForLogging(S3ClientError):
|
|
|
|
code = 400
|
|
|
|
|
|
|
|
def __init__(self, msg):
|
|
|
|
super(InvalidTargetBucketForLogging, self).__init__("InvalidTargetBucketForLogging", msg)
|
|
|
|
|
|
|
|
|
|
|
|
class CrossLocationLoggingProhibitted(S3ClientError):
|
|
|
|
code = 403
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
super(CrossLocationLoggingProhibitted, self).__init__(
|
|
|
|
"CrossLocationLoggingProhibitted",
|
|
|
|
"Cross S3 location logging not allowed."
|
|
|
|
)
|
2018-03-21 16:11:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
class InvalidNotificationARN(S3ClientError):
|
|
|
|
code = 400
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super(InvalidNotificationARN, self).__init__(
|
|
|
|
"InvalidArgument",
|
|
|
|
"The ARN is not well formed",
|
|
|
|
*args, **kwargs)
|
|
|
|
|
|
|
|
|
|
|
|
class InvalidNotificationDestination(S3ClientError):
|
|
|
|
code = 400
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super(InvalidNotificationDestination, self).__init__(
|
|
|
|
"InvalidArgument",
|
|
|
|
"The notification destination service region is not valid for the bucket location constraint",
|
|
|
|
*args, **kwargs)
|
|
|
|
|
|
|
|
|
|
|
|
class InvalidNotificationEvent(S3ClientError):
|
|
|
|
code = 400
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super(InvalidNotificationEvent, self).__init__(
|
|
|
|
"InvalidArgument",
|
|
|
|
"The event is not supported for notifications",
|
|
|
|
*args, **kwargs)
|
2018-06-07 07:09:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
class InvalidStorageClass(S3ClientError):
|
|
|
|
code = 400
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super(InvalidStorageClass, self).__init__(
|
|
|
|
"InvalidStorageClass",
|
|
|
|
"The storage class you specified is not valid",
|
|
|
|
*args, **kwargs)
|