Pylint remaining source code (#4760)
This commit is contained in:
parent
3f966541ce
commit
d118d592ca
2
Makefile
2
Makefile
@ -18,7 +18,7 @@ init:
|
|||||||
lint:
|
lint:
|
||||||
flake8 moto
|
flake8 moto
|
||||||
black --check moto/ tests/
|
black --check moto/ tests/
|
||||||
pylint -j 0 moto/a* moto/b* moto/c* moto/d* moto/e* tests
|
pylint -j 0 moto tests
|
||||||
|
|
||||||
format:
|
format:
|
||||||
black moto/ tests/
|
black moto/ tests/
|
||||||
|
@ -100,7 +100,7 @@ class DatasetGroup:
|
|||||||
|
|
||||||
class ForecastBackend(BaseBackend):
|
class ForecastBackend(BaseBackend):
|
||||||
def __init__(self, region_name):
|
def __init__(self, region_name):
|
||||||
super(ForecastBackend, self).__init__()
|
super().__init__()
|
||||||
self.dataset_groups = {}
|
self.dataset_groups = {}
|
||||||
self.datasets = {}
|
self.datasets = {}
|
||||||
self.region_name = region_name
|
self.region_name = region_name
|
||||||
|
@ -7,70 +7,64 @@ class GlueClientError(JsonRESTError):
|
|||||||
|
|
||||||
class AlreadyExistsException(GlueClientError):
|
class AlreadyExistsException(GlueClientError):
|
||||||
def __init__(self, typ):
|
def __init__(self, typ):
|
||||||
super(GlueClientError, self).__init__(
|
super().__init__("AlreadyExistsException", "%s already exists." % (typ))
|
||||||
"AlreadyExistsException", "%s already exists." % (typ)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class DatabaseAlreadyExistsException(AlreadyExistsException):
|
class DatabaseAlreadyExistsException(AlreadyExistsException):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(DatabaseAlreadyExistsException, self).__init__("Database")
|
super().__init__("Database")
|
||||||
|
|
||||||
|
|
||||||
class TableAlreadyExistsException(AlreadyExistsException):
|
class TableAlreadyExistsException(AlreadyExistsException):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(TableAlreadyExistsException, self).__init__("Table")
|
super().__init__("Table")
|
||||||
|
|
||||||
|
|
||||||
class PartitionAlreadyExistsException(AlreadyExistsException):
|
class PartitionAlreadyExistsException(AlreadyExistsException):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(PartitionAlreadyExistsException, self).__init__("Partition")
|
super().__init__("Partition")
|
||||||
|
|
||||||
|
|
||||||
class CrawlerAlreadyExistsException(AlreadyExistsException):
|
class CrawlerAlreadyExistsException(AlreadyExistsException):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(CrawlerAlreadyExistsException, self).__init__("Crawler")
|
super().__init__("Crawler")
|
||||||
|
|
||||||
|
|
||||||
class EntityNotFoundException(GlueClientError):
|
class EntityNotFoundException(GlueClientError):
|
||||||
def __init__(self, msg):
|
def __init__(self, msg):
|
||||||
super(GlueClientError, self).__init__("EntityNotFoundException", msg)
|
super().__init__("EntityNotFoundException", msg)
|
||||||
|
|
||||||
|
|
||||||
class DatabaseNotFoundException(EntityNotFoundException):
|
class DatabaseNotFoundException(EntityNotFoundException):
|
||||||
def __init__(self, db):
|
def __init__(self, db):
|
||||||
super(DatabaseNotFoundException, self).__init__("Database %s not found." % db)
|
super().__init__("Database %s not found." % db)
|
||||||
|
|
||||||
|
|
||||||
class TableNotFoundException(EntityNotFoundException):
|
class TableNotFoundException(EntityNotFoundException):
|
||||||
def __init__(self, tbl):
|
def __init__(self, tbl):
|
||||||
super(TableNotFoundException, self).__init__("Table %s not found." % tbl)
|
super().__init__("Table %s not found." % tbl)
|
||||||
|
|
||||||
|
|
||||||
class PartitionNotFoundException(EntityNotFoundException):
|
class PartitionNotFoundException(EntityNotFoundException):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(PartitionNotFoundException, self).__init__("Cannot find partition.")
|
super().__init__("Cannot find partition.")
|
||||||
|
|
||||||
|
|
||||||
class CrawlerNotFoundException(EntityNotFoundException):
|
class CrawlerNotFoundException(EntityNotFoundException):
|
||||||
def __init__(self, crawler):
|
def __init__(self, crawler):
|
||||||
super(CrawlerNotFoundException, self).__init__(
|
super().__init__("Crawler %s not found." % crawler)
|
||||||
"Crawler %s not found." % crawler
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class VersionNotFoundException(EntityNotFoundException):
|
class VersionNotFoundException(EntityNotFoundException):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(VersionNotFoundException, self).__init__("Version not found.")
|
super().__init__("Version not found.")
|
||||||
|
|
||||||
|
|
||||||
class CrawlerRunningException(GlueClientError):
|
class CrawlerRunningException(GlueClientError):
|
||||||
def __init__(self, msg):
|
def __init__(self, msg):
|
||||||
super(CrawlerRunningException, self).__init__("CrawlerRunningException", msg)
|
super().__init__("CrawlerRunningException", msg)
|
||||||
|
|
||||||
|
|
||||||
class CrawlerNotRunningException(GlueClientError):
|
class CrawlerNotRunningException(GlueClientError):
|
||||||
def __init__(self, msg):
|
def __init__(self, msg):
|
||||||
super(CrawlerNotRunningException, self).__init__(
|
super().__init__("CrawlerNotRunningException", msg)
|
||||||
"CrawlerNotRunningException", msg
|
|
||||||
)
|
|
||||||
|
@ -7,7 +7,7 @@ from uuid import uuid4
|
|||||||
|
|
||||||
class GuardDutyBackend(BaseBackend):
|
class GuardDutyBackend(BaseBackend):
|
||||||
def __init__(self, region_name=None):
|
def __init__(self, region_name=None):
|
||||||
super(GuardDutyBackend, self).__init__()
|
super().__init__()
|
||||||
self.region_name = region_name
|
self.region_name = region_name
|
||||||
self.detectors = {}
|
self.detectors = {}
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@ class AssumedRoleAccessKey(object):
|
|||||||
|
|
||||||
class CreateAccessKeyFailure(Exception):
|
class CreateAccessKeyFailure(Exception):
|
||||||
def __init__(self, reason, *args):
|
def __init__(self, reason, *args):
|
||||||
super(CreateAccessKeyFailure, self).__init__(*args)
|
super().__init__(*args)
|
||||||
self.reason = reason
|
self.reason = reason
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ class IAMNotFoundException(RESTError):
|
|||||||
code = 404
|
code = 404
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(IAMNotFoundException, self).__init__(
|
super().__init__(
|
||||||
"NoSuchEntity", message, xmlns=XMLNS_IAM, template="wrapped_single_error"
|
"NoSuchEntity", message, xmlns=XMLNS_IAM, template="wrapped_single_error"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -16,28 +16,28 @@ class IAMConflictException(RESTError):
|
|||||||
code = 409
|
code = 409
|
||||||
|
|
||||||
def __init__(self, code="Conflict", message=""):
|
def __init__(self, code="Conflict", message=""):
|
||||||
super(IAMConflictException, self).__init__(code, message)
|
super().__init__(code, message)
|
||||||
|
|
||||||
|
|
||||||
class IAMReportNotPresentException(RESTError):
|
class IAMReportNotPresentException(RESTError):
|
||||||
code = 410
|
code = 410
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(IAMReportNotPresentException, self).__init__("ReportNotPresent", message)
|
super().__init__("ReportNotPresent", message)
|
||||||
|
|
||||||
|
|
||||||
class IAMLimitExceededException(RESTError):
|
class IAMLimitExceededException(RESTError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(IAMLimitExceededException, self).__init__("LimitExceeded", message)
|
super().__init__("LimitExceeded", message)
|
||||||
|
|
||||||
|
|
||||||
class MalformedCertificate(RESTError):
|
class MalformedCertificate(RESTError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, cert):
|
def __init__(self, cert):
|
||||||
super(MalformedCertificate, self).__init__(
|
super().__init__(
|
||||||
"MalformedCertificate", "Certificate {cert} is malformed".format(cert=cert)
|
"MalformedCertificate", "Certificate {cert} is malformed".format(cert=cert)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ class MalformedPolicyDocument(RESTError):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, message=""):
|
def __init__(self, message=""):
|
||||||
super(MalformedPolicyDocument, self).__init__(
|
super().__init__(
|
||||||
"MalformedPolicyDocument",
|
"MalformedPolicyDocument",
|
||||||
message,
|
message,
|
||||||
xmlns=XMLNS_IAM,
|
xmlns=XMLNS_IAM,
|
||||||
@ -58,7 +58,7 @@ class DuplicateTags(RESTError):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(DuplicateTags, self).__init__(
|
super().__init__(
|
||||||
"InvalidInput",
|
"InvalidInput",
|
||||||
"Duplicate tag keys found. Please note that Tag keys are case insensitive.",
|
"Duplicate tag keys found. Please note that Tag keys are case insensitive.",
|
||||||
)
|
)
|
||||||
@ -68,7 +68,7 @@ class TagKeyTooBig(RESTError):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, tag, param="tags.X.member.key"):
|
def __init__(self, tag, param="tags.X.member.key"):
|
||||||
super(TagKeyTooBig, self).__init__(
|
super().__init__(
|
||||||
"ValidationError",
|
"ValidationError",
|
||||||
"1 validation error detected: Value '{}' at '{}' failed to satisfy "
|
"1 validation error detected: Value '{}' at '{}' failed to satisfy "
|
||||||
"constraint: Member must have length less than or equal to 128.".format(
|
"constraint: Member must have length less than or equal to 128.".format(
|
||||||
@ -81,7 +81,7 @@ class TagValueTooBig(RESTError):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, tag):
|
def __init__(self, tag):
|
||||||
super(TagValueTooBig, self).__init__(
|
super().__init__(
|
||||||
"ValidationError",
|
"ValidationError",
|
||||||
"1 validation error detected: Value '{}' at 'tags.X.member.value' failed to satisfy "
|
"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(
|
"constraint: Member must have length less than or equal to 256.".format(
|
||||||
@ -99,14 +99,14 @@ class InvalidTagCharacters(RESTError):
|
|||||||
)
|
)
|
||||||
message += "constraint: Member must satisfy regular expression pattern: [\\p{L}\\p{Z}\\p{N}_.:/=+\\-@]+"
|
message += "constraint: Member must satisfy regular expression pattern: [\\p{L}\\p{Z}\\p{N}_.:/=+\\-@]+"
|
||||||
|
|
||||||
super(InvalidTagCharacters, self).__init__("ValidationError", message)
|
super().__init__("ValidationError", message)
|
||||||
|
|
||||||
|
|
||||||
class TooManyTags(RESTError):
|
class TooManyTags(RESTError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, tags, param="tags"):
|
def __init__(self, tags, param="tags"):
|
||||||
super(TooManyTags, self).__init__(
|
super().__init__(
|
||||||
"ValidationError",
|
"ValidationError",
|
||||||
"1 validation error detected: Value '{}' at '{}' failed to satisfy "
|
"1 validation error detected: Value '{}' at '{}' failed to satisfy "
|
||||||
"constraint: Member must have length less than or equal to 50.".format(
|
"constraint: Member must have length less than or equal to 50.".format(
|
||||||
@ -119,27 +119,27 @@ class EntityAlreadyExists(RESTError):
|
|||||||
code = 409
|
code = 409
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(EntityAlreadyExists, self).__init__("EntityAlreadyExists", message)
|
super().__init__("EntityAlreadyExists", message)
|
||||||
|
|
||||||
|
|
||||||
class ValidationError(RESTError):
|
class ValidationError(RESTError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(ValidationError, self).__init__("ValidationError", message)
|
super().__init__("ValidationError", message)
|
||||||
|
|
||||||
|
|
||||||
class InvalidInput(RESTError):
|
class InvalidInput(RESTError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(InvalidInput, self).__init__("InvalidInput", message)
|
super().__init__("InvalidInput", message)
|
||||||
|
|
||||||
|
|
||||||
class NoSuchEntity(RESTError):
|
class NoSuchEntity(RESTError):
|
||||||
code = 404
|
code = 404
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(NoSuchEntity, self).__init__(
|
super().__init__(
|
||||||
"NoSuchEntity", message, xmlns=XMLNS_IAM, template="wrapped_single_error"
|
"NoSuchEntity", message, xmlns=XMLNS_IAM, template="wrapped_single_error"
|
||||||
)
|
)
|
||||||
|
@ -617,12 +617,12 @@ class Role(CloudFormationModel):
|
|||||||
def delete_from_cloudformation_json(
|
def delete_from_cloudformation_json(
|
||||||
cls, resource_name, cloudformation_json, region_name
|
cls, resource_name, cloudformation_json, region_name
|
||||||
):
|
):
|
||||||
for profile_name, profile in iam_backend.instance_profiles.items():
|
for profile in iam_backend.instance_profiles.values():
|
||||||
profile.delete_role(role_name=resource_name)
|
profile.delete_role(role_name=resource_name)
|
||||||
|
|
||||||
for _, role in iam_backend.roles.items():
|
for role in iam_backend.roles.values():
|
||||||
if role.name == resource_name:
|
if role.name == resource_name:
|
||||||
for arn, policy in role.policies.items():
|
for arn in role.policies.keys():
|
||||||
role.delete_policy(arn)
|
role.delete_policy(arn)
|
||||||
iam_backend.delete_role(resource_name)
|
iam_backend.delete_role(resource_name)
|
||||||
|
|
||||||
@ -645,7 +645,7 @@ class Role(CloudFormationModel):
|
|||||||
|
|
||||||
_instance_profiles = []
|
_instance_profiles = []
|
||||||
for key, instance_profile in iam_backend.instance_profiles.items():
|
for key, instance_profile in iam_backend.instance_profiles.items():
|
||||||
for role in instance_profile.roles:
|
for _ in instance_profile.roles:
|
||||||
_instance_profiles.append(instance_profile.to_embedded_config_dict())
|
_instance_profiles.append(instance_profile.to_embedded_config_dict())
|
||||||
break
|
break
|
||||||
|
|
||||||
@ -852,8 +852,8 @@ class Certificate(BaseModel):
|
|||||||
|
|
||||||
|
|
||||||
class SigningCertificate(BaseModel):
|
class SigningCertificate(BaseModel):
|
||||||
def __init__(self, id, user_name, body):
|
def __init__(self, certificate_id, user_name, body):
|
||||||
self.id = id
|
self.id = certificate_id
|
||||||
self.user_name = user_name
|
self.user_name = user_name
|
||||||
self.body = body
|
self.body = body
|
||||||
self.upload_date = datetime.utcnow()
|
self.upload_date = datetime.utcnow()
|
||||||
@ -1526,7 +1526,7 @@ class IAMBackend(BaseBackend):
|
|||||||
self.access_keys = {}
|
self.access_keys = {}
|
||||||
|
|
||||||
self.tagger = TaggingService()
|
self.tagger = TaggingService()
|
||||||
super(IAMBackend, self).__init__()
|
super().__init__()
|
||||||
|
|
||||||
def _init_managed_policies(self):
|
def _init_managed_policies(self):
|
||||||
return dict((p.arn, p) for p in aws_managed_policies)
|
return dict((p.arn, p) for p in aws_managed_policies)
|
||||||
@ -1664,8 +1664,6 @@ class IAMBackend(BaseBackend):
|
|||||||
return self._filter_attached_policies(policies, marker, max_items, path_prefix)
|
return self._filter_attached_policies(policies, marker, max_items, path_prefix)
|
||||||
|
|
||||||
def set_default_policy_version(self, policy_arn, version_id):
|
def set_default_policy_version(self, policy_arn, version_id):
|
||||||
import re
|
|
||||||
|
|
||||||
if re.match(r"v[1-9][0-9]*(\.[A-Za-z0-9-]*)?", version_id) is None:
|
if re.match(r"v[1-9][0-9]*(\.[A-Za-z0-9-]*)?", version_id) is None:
|
||||||
raise ValidationError(
|
raise ValidationError(
|
||||||
"Value '{0}' at 'versionId' failed to satisfy constraint: Member must satisfy regular expression pattern: v[1-9][0-9]*(\\.[A-Za-z0-9-]*)?".format(
|
"Value '{0}' at 'versionId' failed to satisfy constraint: Member must satisfy regular expression pattern: v[1-9][0-9]*(\\.[A-Za-z0-9-]*)?".format(
|
||||||
@ -2048,7 +2046,7 @@ class IAMBackend(BaseBackend):
|
|||||||
return cert
|
return cert
|
||||||
|
|
||||||
def get_server_certificate(self, name):
|
def get_server_certificate(self, name):
|
||||||
for key, cert in self.certificates.items():
|
for cert in self.certificates.values():
|
||||||
if name == cert.cert_name:
|
if name == cert.cert_name:
|
||||||
return cert
|
return cert
|
||||||
|
|
||||||
@ -2556,12 +2554,12 @@ class IAMBackend(BaseBackend):
|
|||||||
def delete_account_alias(self, alias):
|
def delete_account_alias(self, alias):
|
||||||
self.account_aliases = []
|
self.account_aliases = []
|
||||||
|
|
||||||
def get_account_authorization_details(self, filter):
|
def get_account_authorization_details(self, policy_filter):
|
||||||
policies = self.managed_policies.values()
|
policies = self.managed_policies.values()
|
||||||
local_policies = set(policies) - set(aws_managed_policies)
|
local_policies = set(policies) - set(aws_managed_policies)
|
||||||
returned_policies = []
|
returned_policies = []
|
||||||
|
|
||||||
if len(filter) == 0:
|
if len(policy_filter) == 0:
|
||||||
return {
|
return {
|
||||||
"instance_profiles": self.instance_profiles.values(),
|
"instance_profiles": self.instance_profiles.values(),
|
||||||
"roles": self.roles.values(),
|
"roles": self.roles.values(),
|
||||||
@ -2570,16 +2568,16 @@ class IAMBackend(BaseBackend):
|
|||||||
"managed_policies": self.managed_policies.values(),
|
"managed_policies": self.managed_policies.values(),
|
||||||
}
|
}
|
||||||
|
|
||||||
if "AWSManagedPolicy" in filter:
|
if "AWSManagedPolicy" in policy_filter:
|
||||||
returned_policies = aws_managed_policies
|
returned_policies = aws_managed_policies
|
||||||
if "LocalManagedPolicy" in filter:
|
if "LocalManagedPolicy" in policy_filter:
|
||||||
returned_policies = returned_policies + list(local_policies)
|
returned_policies = returned_policies + list(local_policies)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"instance_profiles": self.instance_profiles.values(),
|
"instance_profiles": self.instance_profiles.values(),
|
||||||
"roles": self.roles.values() if "Role" in filter else [],
|
"roles": self.roles.values() if "Role" in policy_filter else [],
|
||||||
"groups": self.groups.values() if "Group" in filter else [],
|
"groups": self.groups.values() if "Group" in policy_filter else [],
|
||||||
"users": self.users.values() if "User" in filter else [],
|
"users": self.users.values() if "User" in policy_filter else [],
|
||||||
"managed_policies": returned_policies,
|
"managed_policies": returned_policies,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,10 +233,7 @@ class IAMPolicyDocumentValidator:
|
|||||||
assert isinstance(statement["Condition"], dict)
|
assert isinstance(statement["Condition"], dict)
|
||||||
for condition_key, condition_value in statement["Condition"].items():
|
for condition_key, condition_value in statement["Condition"].items():
|
||||||
assert isinstance(condition_value, dict)
|
assert isinstance(condition_value, dict)
|
||||||
for (
|
for condition_element_value in condition_value.values():
|
||||||
condition_element_key,
|
|
||||||
condition_element_value,
|
|
||||||
) in condition_value.items():
|
|
||||||
assert isinstance(condition_element_value, (list, str))
|
assert isinstance(condition_element_value, (list, str))
|
||||||
|
|
||||||
if (
|
if (
|
||||||
@ -455,10 +452,7 @@ class IAMPolicyDocumentValidator:
|
|||||||
)
|
)
|
||||||
|
|
||||||
if stripped_condition_key.startswith("Date"):
|
if stripped_condition_key.startswith("Date"):
|
||||||
for (
|
for condition_element_value in condition_value.values():
|
||||||
condition_element_key,
|
|
||||||
condition_element_value,
|
|
||||||
) in condition_value.items():
|
|
||||||
if isinstance(condition_element_value, str):
|
if isinstance(condition_element_value, str):
|
||||||
IAMPolicyDocumentValidator._legacy_parse_date_condition_value(
|
IAMPolicyDocumentValidator._legacy_parse_date_condition_value(
|
||||||
condition_element_value
|
condition_element_value
|
||||||
|
@ -8,7 +8,7 @@ class IoTClientError(JsonRESTError):
|
|||||||
class ResourceNotFoundException(IoTClientError):
|
class ResourceNotFoundException(IoTClientError):
|
||||||
def __init__(self, msg=None):
|
def __init__(self, msg=None):
|
||||||
self.code = 404
|
self.code = 404
|
||||||
super(ResourceNotFoundException, self).__init__(
|
super().__init__(
|
||||||
"ResourceNotFoundException", msg or "The specified resource does not exist"
|
"ResourceNotFoundException", msg or "The specified resource does not exist"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -16,15 +16,13 @@ class ResourceNotFoundException(IoTClientError):
|
|||||||
class InvalidRequestException(IoTClientError):
|
class InvalidRequestException(IoTClientError):
|
||||||
def __init__(self, msg=None):
|
def __init__(self, msg=None):
|
||||||
self.code = 400
|
self.code = 400
|
||||||
super(InvalidRequestException, self).__init__(
|
super().__init__("InvalidRequestException", msg or "The request is not valid.")
|
||||||
"InvalidRequestException", msg or "The request is not valid."
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class InvalidStateTransitionException(IoTClientError):
|
class InvalidStateTransitionException(IoTClientError):
|
||||||
def __init__(self, msg=None):
|
def __init__(self, msg=None):
|
||||||
self.code = 409
|
self.code = 409
|
||||||
super(InvalidStateTransitionException, self).__init__(
|
super().__init__(
|
||||||
"InvalidStateTransitionException",
|
"InvalidStateTransitionException",
|
||||||
msg or "An attempt was made to change to an invalid state.",
|
msg or "An attempt was made to change to an invalid state.",
|
||||||
)
|
)
|
||||||
@ -33,7 +31,7 @@ class InvalidStateTransitionException(IoTClientError):
|
|||||||
class VersionConflictException(IoTClientError):
|
class VersionConflictException(IoTClientError):
|
||||||
def __init__(self, name):
|
def __init__(self, name):
|
||||||
self.code = 409
|
self.code = 409
|
||||||
super(VersionConflictException, self).__init__(
|
super().__init__(
|
||||||
"VersionConflictException",
|
"VersionConflictException",
|
||||||
"The version for thing %s does not match the expected version." % name,
|
"The version for thing %s does not match the expected version." % name,
|
||||||
)
|
)
|
||||||
@ -42,21 +40,19 @@ class VersionConflictException(IoTClientError):
|
|||||||
class CertificateStateException(IoTClientError):
|
class CertificateStateException(IoTClientError):
|
||||||
def __init__(self, msg, cert_id):
|
def __init__(self, msg, cert_id):
|
||||||
self.code = 406
|
self.code = 406
|
||||||
super(CertificateStateException, self).__init__(
|
super().__init__("CertificateStateException", "%s Id: %s" % (msg, cert_id))
|
||||||
"CertificateStateException", "%s Id: %s" % (msg, cert_id)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class DeleteConflictException(IoTClientError):
|
class DeleteConflictException(IoTClientError):
|
||||||
def __init__(self, msg):
|
def __init__(self, msg):
|
||||||
self.code = 409
|
self.code = 409
|
||||||
super(DeleteConflictException, self).__init__("DeleteConflictException", msg)
|
super().__init__("DeleteConflictException", msg)
|
||||||
|
|
||||||
|
|
||||||
class ResourceAlreadyExistsException(IoTClientError):
|
class ResourceAlreadyExistsException(IoTClientError):
|
||||||
def __init__(self, msg):
|
def __init__(self, msg):
|
||||||
self.code = 409
|
self.code = 409
|
||||||
super(ResourceAlreadyExistsException, self).__init__(
|
super().__init__(
|
||||||
"ResourceAlreadyExistsException", msg or "The resource already exists."
|
"ResourceAlreadyExistsException", msg or "The resource already exists."
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -64,7 +60,7 @@ class ResourceAlreadyExistsException(IoTClientError):
|
|||||||
class VersionsLimitExceededException(IoTClientError):
|
class VersionsLimitExceededException(IoTClientError):
|
||||||
def __init__(self, name):
|
def __init__(self, name):
|
||||||
self.code = 409
|
self.code = 409
|
||||||
super(VersionsLimitExceededException, self).__init__(
|
super().__init__(
|
||||||
"VersionsLimitExceededException",
|
"VersionsLimitExceededException",
|
||||||
"The policy %s already has the maximum number of versions (5)" % name,
|
"The policy %s already has the maximum number of versions (5)" % name,
|
||||||
)
|
)
|
||||||
|
@ -96,7 +96,7 @@ class FakeThingGroup(BaseModel):
|
|||||||
if "rootToParentThingGroups" not in self.metadata:
|
if "rootToParentThingGroups" not in self.metadata:
|
||||||
self.metadata["rootToParentThingGroups"] = []
|
self.metadata["rootToParentThingGroups"] = []
|
||||||
# search for parent arn
|
# search for parent arn
|
||||||
for thing_group_arn, thing_group in thing_groups.items():
|
for thing_group in thing_groups.values():
|
||||||
if thing_group.thing_group_name == parent_group_name:
|
if thing_group.thing_group_name == parent_group_name:
|
||||||
parent_thing_group_structure = thing_group
|
parent_thing_group_structure = thing_group
|
||||||
break
|
break
|
||||||
@ -338,12 +338,12 @@ class FakeJobExecution(BaseModel):
|
|||||||
thing_arn,
|
thing_arn,
|
||||||
status="QUEUED",
|
status="QUEUED",
|
||||||
force_canceled=False,
|
force_canceled=False,
|
||||||
status_details_map={},
|
status_details_map=None,
|
||||||
):
|
):
|
||||||
self.job_id = job_id
|
self.job_id = job_id
|
||||||
self.status = status # IN_PROGRESS | CANCELED | COMPLETED
|
self.status = status # IN_PROGRESS | CANCELED | COMPLETED
|
||||||
self.force_canceled = force_canceled
|
self.force_canceled = force_canceled
|
||||||
self.status_details_map = status_details_map
|
self.status_details_map = status_details_map or {}
|
||||||
self.thing_arn = thing_arn
|
self.thing_arn = thing_arn
|
||||||
self.queued_at = time.mktime(datetime(2015, 1, 1).timetuple())
|
self.queued_at = time.mktime(datetime(2015, 1, 1).timetuple())
|
||||||
self.started_at = time.mktime(datetime(2015, 1, 1).timetuple())
|
self.started_at = time.mktime(datetime(2015, 1, 1).timetuple())
|
||||||
@ -543,7 +543,7 @@ class FakeDomainConfiguration(BaseModel):
|
|||||||
|
|
||||||
class IoTBackend(BaseBackend):
|
class IoTBackend(BaseBackend):
|
||||||
def __init__(self, region_name=None):
|
def __init__(self, region_name=None):
|
||||||
super(IoTBackend, self).__init__()
|
super().__init__()
|
||||||
self.region_name = region_name
|
self.region_name = region_name
|
||||||
self.things = OrderedDict()
|
self.things = OrderedDict()
|
||||||
self.jobs = OrderedDict()
|
self.jobs = OrderedDict()
|
||||||
|
@ -8,7 +8,7 @@ class IoTDataPlaneClientError(JsonRESTError):
|
|||||||
class ResourceNotFoundException(IoTDataPlaneClientError):
|
class ResourceNotFoundException(IoTDataPlaneClientError):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.code = 404
|
self.code = 404
|
||||||
super(ResourceNotFoundException, self).__init__(
|
super().__init__(
|
||||||
"ResourceNotFoundException", "The specified resource does not exist"
|
"ResourceNotFoundException", "The specified resource does not exist"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -16,12 +16,10 @@ class ResourceNotFoundException(IoTDataPlaneClientError):
|
|||||||
class InvalidRequestException(IoTDataPlaneClientError):
|
class InvalidRequestException(IoTDataPlaneClientError):
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
self.code = 400
|
self.code = 400
|
||||||
super(InvalidRequestException, self).__init__(
|
super().__init__("InvalidRequestException", message)
|
||||||
"InvalidRequestException", message
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class ConflictException(IoTDataPlaneClientError):
|
class ConflictException(IoTDataPlaneClientError):
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
self.code = 409
|
self.code = 409
|
||||||
super(ConflictException, self).__init__("ConflictException", message)
|
super().__init__("ConflictException", message)
|
||||||
|
@ -140,7 +140,7 @@ class FakeShadow(BaseModel):
|
|||||||
|
|
||||||
class IoTDataPlaneBackend(BaseBackend):
|
class IoTDataPlaneBackend(BaseBackend):
|
||||||
def __init__(self, region_name=None):
|
def __init__(self, region_name=None):
|
||||||
super(IoTDataPlaneBackend, self).__init__()
|
super().__init__()
|
||||||
self.region_name = region_name
|
self.region_name = region_name
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
|
@ -5,7 +5,7 @@ from moto.core import ACCOUNT_ID
|
|||||||
|
|
||||||
class ResourceNotFoundError(BadRequest):
|
class ResourceNotFoundError(BadRequest):
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(ResourceNotFoundError, self).__init__()
|
super().__init__()
|
||||||
self.description = json.dumps(
|
self.description = json.dumps(
|
||||||
{"message": message, "__type": "ResourceNotFoundException"}
|
{"message": message, "__type": "ResourceNotFoundException"}
|
||||||
)
|
)
|
||||||
@ -13,7 +13,7 @@ class ResourceNotFoundError(BadRequest):
|
|||||||
|
|
||||||
class ResourceInUseError(BadRequest):
|
class ResourceInUseError(BadRequest):
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(ResourceInUseError, self).__init__()
|
super().__init__()
|
||||||
self.description = json.dumps(
|
self.description = json.dumps(
|
||||||
{"message": message, "__type": "ResourceInUseException"}
|
{"message": message, "__type": "ResourceInUseException"}
|
||||||
)
|
)
|
||||||
@ -21,21 +21,21 @@ class ResourceInUseError(BadRequest):
|
|||||||
|
|
||||||
class StreamNotFoundError(ResourceNotFoundError):
|
class StreamNotFoundError(ResourceNotFoundError):
|
||||||
def __init__(self, stream_name):
|
def __init__(self, stream_name):
|
||||||
super(StreamNotFoundError, self).__init__(
|
super().__init__(
|
||||||
"Stream {0} under account {1} not found.".format(stream_name, ACCOUNT_ID)
|
"Stream {0} under account {1} not found.".format(stream_name, ACCOUNT_ID)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class ShardNotFoundError(ResourceNotFoundError):
|
class ShardNotFoundError(ResourceNotFoundError):
|
||||||
def __init__(self, shard_id, stream):
|
def __init__(self, shard_id, stream):
|
||||||
super(ShardNotFoundError, self).__init__(
|
super().__init__(
|
||||||
f"Could not find shard {shard_id} in stream {stream} under account {ACCOUNT_ID}."
|
f"Could not find shard {shard_id} in stream {stream} under account {ACCOUNT_ID}."
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class InvalidArgumentError(BadRequest):
|
class InvalidArgumentError(BadRequest):
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(InvalidArgumentError, self).__init__()
|
super().__init__()
|
||||||
self.description = json.dumps(
|
self.description = json.dumps(
|
||||||
{"message": message, "__type": "InvalidArgumentException"}
|
{"message": message, "__type": "InvalidArgumentException"}
|
||||||
)
|
)
|
||||||
@ -43,7 +43,7 @@ class InvalidArgumentError(BadRequest):
|
|||||||
|
|
||||||
class ValidationException(BadRequest):
|
class ValidationException(BadRequest):
|
||||||
def __init__(self, value, position, regex_to_match):
|
def __init__(self, value, position, regex_to_match):
|
||||||
super(ValidationException, self).__init__()
|
super().__init__()
|
||||||
self.description = json.dumps(
|
self.description = json.dumps(
|
||||||
{
|
{
|
||||||
"message": f"1 validation error detected: Value '{value}' at '{position}' failed to satisfy constraint: Member must satisfy regular expression pattern: {regex_to_match}",
|
"message": f"1 validation error detected: Value '{value}' at '{position}' failed to satisfy constraint: Member must satisfy regular expression pattern: {regex_to_match}",
|
||||||
|
@ -140,11 +140,9 @@ class KinesisResponse(BaseResponse):
|
|||||||
def list_shards(self):
|
def list_shards(self):
|
||||||
stream_name = self.parameters.get("StreamName")
|
stream_name = self.parameters.get("StreamName")
|
||||||
next_token = self.parameters.get("NextToken")
|
next_token = self.parameters.get("NextToken")
|
||||||
start_id = self.parameters.get("ExclusiveStartShardId") # noqa
|
max_results = self.parameters.get("MaxResults", 10000)
|
||||||
max = self.parameters.get("MaxResults", 10000)
|
|
||||||
start_timestamp = self.parameters.get("StreamCreationTimestamp") # noqa
|
|
||||||
shards, token = self.kinesis_backend.list_shards(
|
shards, token = self.kinesis_backend.list_shards(
|
||||||
stream_name=stream_name, limit=max, next_token=next_token
|
stream_name=stream_name, limit=max_results, next_token=next_token
|
||||||
)
|
)
|
||||||
res = {"Shards": shards}
|
res = {"Shards": shards}
|
||||||
if token:
|
if token:
|
||||||
|
@ -8,7 +8,7 @@ class KinesisvideoClientError(RESTError):
|
|||||||
class ResourceNotFoundException(KinesisvideoClientError):
|
class ResourceNotFoundException(KinesisvideoClientError):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.code = 404
|
self.code = 404
|
||||||
super(ResourceNotFoundException, self).__init__(
|
super().__init__(
|
||||||
"ResourceNotFoundException",
|
"ResourceNotFoundException",
|
||||||
"The requested stream is not found or not active.",
|
"The requested stream is not found or not active.",
|
||||||
)
|
)
|
||||||
@ -17,6 +17,6 @@ class ResourceNotFoundException(KinesisvideoClientError):
|
|||||||
class ResourceInUseException(KinesisvideoClientError):
|
class ResourceInUseException(KinesisvideoClientError):
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
self.code = 400
|
self.code = 400
|
||||||
super(ResourceInUseException, self).__init__(
|
super().__init__(
|
||||||
"ResourceInUseException", message,
|
"ResourceInUseException", message,
|
||||||
)
|
)
|
||||||
|
@ -64,7 +64,7 @@ class Stream(BaseModel):
|
|||||||
|
|
||||||
class KinesisVideoBackend(BaseBackend):
|
class KinesisVideoBackend(BaseBackend):
|
||||||
def __init__(self, region_name=None):
|
def __init__(self, region_name=None):
|
||||||
super(KinesisVideoBackend, self).__init__()
|
super().__init__()
|
||||||
self.region_name = region_name
|
self.region_name = region_name
|
||||||
self.streams = {}
|
self.streams = {}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ from moto.sts.utils import random_session_token
|
|||||||
|
|
||||||
class KinesisVideoArchivedMediaBackend(BaseBackend):
|
class KinesisVideoArchivedMediaBackend(BaseBackend):
|
||||||
def __init__(self, region_name=None):
|
def __init__(self, region_name=None):
|
||||||
super(KinesisVideoArchivedMediaBackend, self).__init__()
|
super().__init__()
|
||||||
self.region_name = region_name
|
self.region_name = region_name
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
|
@ -5,28 +5,28 @@ class NotFoundException(JsonRESTError):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(NotFoundException, self).__init__("NotFoundException", message)
|
super().__init__("NotFoundException", message)
|
||||||
|
|
||||||
|
|
||||||
class ValidationException(JsonRESTError):
|
class ValidationException(JsonRESTError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(ValidationException, self).__init__("ValidationException", message)
|
super().__init__("ValidationException", message)
|
||||||
|
|
||||||
|
|
||||||
class AlreadyExistsException(JsonRESTError):
|
class AlreadyExistsException(JsonRESTError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(AlreadyExistsException, self).__init__("AlreadyExistsException", message)
|
super().__init__("AlreadyExistsException", message)
|
||||||
|
|
||||||
|
|
||||||
class NotAuthorizedException(JsonRESTError):
|
class NotAuthorizedException(JsonRESTError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(NotAuthorizedException, self).__init__("NotAuthorizedException", None)
|
super().__init__("NotAuthorizedException", None)
|
||||||
|
|
||||||
self.description = '{"__type":"NotAuthorizedException"}'
|
self.description = '{"__type":"NotAuthorizedException"}'
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ class AccessDeniedException(JsonRESTError):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(AccessDeniedException, self).__init__("AccessDeniedException", message)
|
super().__init__("AccessDeniedException", message)
|
||||||
|
|
||||||
self.description = '{"__type":"AccessDeniedException"}'
|
self.description = '{"__type":"AccessDeniedException"}'
|
||||||
|
|
||||||
@ -44,8 +44,6 @@ class InvalidCiphertextException(JsonRESTError):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(InvalidCiphertextException, self).__init__(
|
super().__init__("InvalidCiphertextException", None)
|
||||||
"InvalidCiphertextException", None
|
|
||||||
)
|
|
||||||
|
|
||||||
self.description = '{"__type":"InvalidCiphertextException"}'
|
self.description = '{"__type":"InvalidCiphertextException"}'
|
||||||
|
@ -18,7 +18,6 @@ class ManagedBlockchainClientError(HTTPException):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, error_type, message, **kwargs):
|
def __init__(self, error_type, message, **kwargs):
|
||||||
super(HTTPException, self).__init__()
|
|
||||||
self.error_type = error_type
|
self.error_type = error_type
|
||||||
self.message = message
|
self.message = message
|
||||||
self.description = json.dumps({"message": self.message})
|
self.description = json.dumps({"message": self.message})
|
||||||
@ -39,7 +38,7 @@ class ManagedBlockchainClientError(HTTPException):
|
|||||||
|
|
||||||
class BadRequestException(ManagedBlockchainClientError):
|
class BadRequestException(ManagedBlockchainClientError):
|
||||||
def __init__(self, pretty_called_method, operation_error):
|
def __init__(self, pretty_called_method, operation_error):
|
||||||
super(BadRequestException, self).__init__(
|
super().__init__(
|
||||||
"BadRequestException",
|
"BadRequestException",
|
||||||
"An error occurred (BadRequestException) when calling the {0} operation: {1}".format(
|
"An error occurred (BadRequestException) when calling the {0} operation: {1}".format(
|
||||||
pretty_called_method, operation_error
|
pretty_called_method, operation_error
|
||||||
@ -49,7 +48,7 @@ class BadRequestException(ManagedBlockchainClientError):
|
|||||||
|
|
||||||
class InvalidRequestException(ManagedBlockchainClientError):
|
class InvalidRequestException(ManagedBlockchainClientError):
|
||||||
def __init__(self, pretty_called_method, operation_error):
|
def __init__(self, pretty_called_method, operation_error):
|
||||||
super(InvalidRequestException, self).__init__(
|
super().__init__(
|
||||||
"InvalidRequestException",
|
"InvalidRequestException",
|
||||||
"An error occurred (InvalidRequestException) when calling the {0} operation: {1}".format(
|
"An error occurred (InvalidRequestException) when calling the {0} operation: {1}".format(
|
||||||
pretty_called_method, operation_error
|
pretty_called_method, operation_error
|
||||||
@ -60,7 +59,7 @@ class InvalidRequestException(ManagedBlockchainClientError):
|
|||||||
class ResourceNotFoundException(ManagedBlockchainClientError):
|
class ResourceNotFoundException(ManagedBlockchainClientError):
|
||||||
def __init__(self, pretty_called_method, operation_error):
|
def __init__(self, pretty_called_method, operation_error):
|
||||||
self.code = 404
|
self.code = 404
|
||||||
super(ResourceNotFoundException, self).__init__(
|
super().__init__(
|
||||||
"ResourceNotFoundException",
|
"ResourceNotFoundException",
|
||||||
"An error occurred (ResourceNotFoundException) when calling the {0} operation: {1}".format(
|
"An error occurred (ResourceNotFoundException) when calling the {0} operation: {1}".format(
|
||||||
pretty_called_method, operation_error
|
pretty_called_method, operation_error
|
||||||
@ -71,7 +70,7 @@ class ResourceNotFoundException(ManagedBlockchainClientError):
|
|||||||
class ResourceAlreadyExistsException(ManagedBlockchainClientError):
|
class ResourceAlreadyExistsException(ManagedBlockchainClientError):
|
||||||
def __init__(self, pretty_called_method, operation_error):
|
def __init__(self, pretty_called_method, operation_error):
|
||||||
self.code = 409
|
self.code = 409
|
||||||
super(ResourceAlreadyExistsException, self).__init__(
|
super().__init__(
|
||||||
"ResourceAlreadyExistsException",
|
"ResourceAlreadyExistsException",
|
||||||
"An error occurred (ResourceAlreadyExistsException) when calling the {0} operation: {1}".format(
|
"An error occurred (ResourceAlreadyExistsException) when calling the {0} operation: {1}".format(
|
||||||
pretty_called_method, operation_error
|
pretty_called_method, operation_error
|
||||||
@ -82,7 +81,7 @@ class ResourceAlreadyExistsException(ManagedBlockchainClientError):
|
|||||||
class ResourceLimitExceededException(ManagedBlockchainClientError):
|
class ResourceLimitExceededException(ManagedBlockchainClientError):
|
||||||
def __init__(self, pretty_called_method, operation_error):
|
def __init__(self, pretty_called_method, operation_error):
|
||||||
self.code = 429
|
self.code = 429
|
||||||
super(ResourceLimitExceededException, self).__init__(
|
super().__init__(
|
||||||
"ResourceLimitExceededException",
|
"ResourceLimitExceededException",
|
||||||
"An error occurred (ResourceLimitExceededException) when calling the {0} operation: {1}".format(
|
"An error occurred (ResourceLimitExceededException) when calling the {0} operation: {1}".format(
|
||||||
pretty_called_method, operation_error
|
pretty_called_method, operation_error
|
||||||
|
@ -54,7 +54,7 @@ VOTEVALUES = ["YES", "NO"]
|
|||||||
class ManagedBlockchainNetwork(BaseModel):
|
class ManagedBlockchainNetwork(BaseModel):
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
id,
|
network_id,
|
||||||
name,
|
name,
|
||||||
framework,
|
framework,
|
||||||
frameworkversion,
|
frameworkversion,
|
||||||
@ -65,7 +65,7 @@ class ManagedBlockchainNetwork(BaseModel):
|
|||||||
description=None,
|
description=None,
|
||||||
):
|
):
|
||||||
self.creationdate = datetime.datetime.utcnow()
|
self.creationdate = datetime.datetime.utcnow()
|
||||||
self.id = id
|
self.id = network_id
|
||||||
self.name = name
|
self.name = name
|
||||||
self.description = description
|
self.description = description
|
||||||
self.framework = framework
|
self.framework = framework
|
||||||
@ -159,7 +159,7 @@ class ManagedBlockchainNetwork(BaseModel):
|
|||||||
class ManagedBlockchainProposal(BaseModel):
|
class ManagedBlockchainProposal(BaseModel):
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
id,
|
proposal_id,
|
||||||
networkid,
|
networkid,
|
||||||
memberid,
|
memberid,
|
||||||
membername,
|
membername,
|
||||||
@ -172,7 +172,7 @@ class ManagedBlockchainProposal(BaseModel):
|
|||||||
):
|
):
|
||||||
# In general, passing all values instead of creating
|
# In general, passing all values instead of creating
|
||||||
# an apparatus to look them up
|
# an apparatus to look them up
|
||||||
self.id = id
|
self.id = proposal_id
|
||||||
self.networkid = networkid
|
self.networkid = networkid
|
||||||
self.memberid = memberid
|
self.memberid = memberid
|
||||||
self.membername = membername
|
self.membername = membername
|
||||||
@ -289,7 +289,7 @@ class ManagedBlockchainProposal(BaseModel):
|
|||||||
class ManagedBlockchainInvitation(BaseModel):
|
class ManagedBlockchainInvitation(BaseModel):
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
id,
|
invitation_id,
|
||||||
networkid,
|
networkid,
|
||||||
networkname,
|
networkname,
|
||||||
networkframework,
|
networkframework,
|
||||||
@ -298,7 +298,7 @@ class ManagedBlockchainInvitation(BaseModel):
|
|||||||
region,
|
region,
|
||||||
networkdescription=None,
|
networkdescription=None,
|
||||||
):
|
):
|
||||||
self.id = id
|
self.id = invitation_id
|
||||||
self.networkid = networkid
|
self.networkid = networkid
|
||||||
self.networkname = networkname
|
self.networkname = networkname
|
||||||
self.networkdescription = networkdescription
|
self.networkdescription = networkdescription
|
||||||
@ -351,10 +351,10 @@ class ManagedBlockchainInvitation(BaseModel):
|
|||||||
|
|
||||||
class ManagedBlockchainMember(BaseModel):
|
class ManagedBlockchainMember(BaseModel):
|
||||||
def __init__(
|
def __init__(
|
||||||
self, id, networkid, member_configuration, region,
|
self, member_id, networkid, member_configuration, region,
|
||||||
):
|
):
|
||||||
self.creationdate = datetime.datetime.utcnow()
|
self.creationdate = datetime.datetime.utcnow()
|
||||||
self.id = id
|
self.id = member_id
|
||||||
self.networkid = networkid
|
self.networkid = networkid
|
||||||
self.member_configuration = member_configuration
|
self.member_configuration = member_configuration
|
||||||
self.status = "AVAILABLE"
|
self.status = "AVAILABLE"
|
||||||
@ -426,7 +426,7 @@ class ManagedBlockchainMember(BaseModel):
|
|||||||
class ManagedBlockchainNode(BaseModel):
|
class ManagedBlockchainNode(BaseModel):
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
id,
|
node_id,
|
||||||
networkid,
|
networkid,
|
||||||
memberid,
|
memberid,
|
||||||
availabilityzone,
|
availabilityzone,
|
||||||
@ -435,7 +435,7 @@ class ManagedBlockchainNode(BaseModel):
|
|||||||
region,
|
region,
|
||||||
):
|
):
|
||||||
self.creationdate = datetime.datetime.utcnow()
|
self.creationdate = datetime.datetime.utcnow()
|
||||||
self.id = id
|
self.id = node_id
|
||||||
self.instancetype = instancetype
|
self.instancetype = instancetype
|
||||||
self.networkid = networkid
|
self.networkid = networkid
|
||||||
self.memberid = memberid
|
self.memberid = memberid
|
||||||
@ -549,14 +549,14 @@ class ManagedBlockchainBackend(BaseBackend):
|
|||||||
# Generate memberid ID and initial member
|
# Generate memberid ID and initial member
|
||||||
member_id = get_member_id()
|
member_id = get_member_id()
|
||||||
self.members[member_id] = ManagedBlockchainMember(
|
self.members[member_id] = ManagedBlockchainMember(
|
||||||
id=member_id,
|
member_id=member_id,
|
||||||
networkid=network_id,
|
networkid=network_id,
|
||||||
member_configuration=member_configuration,
|
member_configuration=member_configuration,
|
||||||
region=self.region_name,
|
region=self.region_name,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.networks[network_id] = ManagedBlockchainNetwork(
|
self.networks[network_id] = ManagedBlockchainNetwork(
|
||||||
id=network_id,
|
network_id=network_id,
|
||||||
name=name,
|
name=name,
|
||||||
framework=framework,
|
framework=framework,
|
||||||
frameworkversion=frameworkversion,
|
frameworkversion=frameworkversion,
|
||||||
@ -618,7 +618,7 @@ class ManagedBlockchainBackend(BaseBackend):
|
|||||||
proposal_id = get_proposal_id()
|
proposal_id = get_proposal_id()
|
||||||
|
|
||||||
self.proposals[proposal_id] = ManagedBlockchainProposal(
|
self.proposals[proposal_id] = ManagedBlockchainProposal(
|
||||||
id=proposal_id,
|
proposal_id=proposal_id,
|
||||||
networkid=networkid,
|
networkid=networkid,
|
||||||
memberid=memberid,
|
memberid=memberid,
|
||||||
membername=self.members.get(memberid).name,
|
membername=self.members.get(memberid).name,
|
||||||
@ -724,12 +724,10 @@ class ManagedBlockchainBackend(BaseBackend):
|
|||||||
|
|
||||||
if self.proposals.get(proposalid).proposal_status == "APPROVED":
|
if self.proposals.get(proposalid).proposal_status == "APPROVED":
|
||||||
# Generate invitations
|
# Generate invitations
|
||||||
for propinvitation in self.proposals.get(proposalid).proposal_actions(
|
for _ in self.proposals.get(proposalid).proposal_actions("Invitations"):
|
||||||
"Invitations"
|
|
||||||
):
|
|
||||||
invitation_id = get_invitation_id()
|
invitation_id = get_invitation_id()
|
||||||
self.invitations[invitation_id] = ManagedBlockchainInvitation(
|
self.invitations[invitation_id] = ManagedBlockchainInvitation(
|
||||||
id=invitation_id,
|
invitation_id=invitation_id,
|
||||||
networkid=networkid,
|
networkid=networkid,
|
||||||
networkname=self.networks.get(networkid).network_name,
|
networkname=self.networks.get(networkid).network_name,
|
||||||
networkframework=self.networks.get(networkid).network_framework,
|
networkframework=self.networks.get(networkid).network_framework,
|
||||||
@ -833,7 +831,7 @@ class ManagedBlockchainBackend(BaseBackend):
|
|||||||
|
|
||||||
member_id = get_member_id()
|
member_id = get_member_id()
|
||||||
self.members[member_id] = ManagedBlockchainMember(
|
self.members[member_id] = ManagedBlockchainMember(
|
||||||
id=member_id,
|
member_id=member_id,
|
||||||
networkid=networkid,
|
networkid=networkid,
|
||||||
member_configuration=member_configuration,
|
member_configuration=member_configuration,
|
||||||
region=self.region_name,
|
region=self.region_name,
|
||||||
@ -992,7 +990,7 @@ class ManagedBlockchainBackend(BaseBackend):
|
|||||||
|
|
||||||
node_id = get_node_id()
|
node_id = get_node_id()
|
||||||
self.nodes[node_id] = ManagedBlockchainNode(
|
self.nodes[node_id] = ManagedBlockchainNode(
|
||||||
id=node_id,
|
node_id=node_id,
|
||||||
networkid=networkid,
|
networkid=networkid,
|
||||||
memberid=memberid,
|
memberid=memberid,
|
||||||
availabilityzone=availabilityzone,
|
availabilityzone=availabilityzone,
|
||||||
|
@ -16,7 +16,7 @@ from .utils import (
|
|||||||
|
|
||||||
class ManagedBlockchainResponse(BaseResponse):
|
class ManagedBlockchainResponse(BaseResponse):
|
||||||
def __init__(self, backend):
|
def __init__(self, backend):
|
||||||
super(ManagedBlockchainResponse, self).__init__()
|
super().__init__()
|
||||||
self.backend = backend
|
self.backend = backend
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -5,4 +5,4 @@ class NotFoundException(JsonRESTError):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(NotFoundException, self).__init__("NotFoundException", message)
|
super().__init__("NotFoundException", message)
|
||||||
|
@ -73,7 +73,7 @@ class Resource(BaseModel):
|
|||||||
|
|
||||||
class MediaConnectBackend(BaseBackend):
|
class MediaConnectBackend(BaseBackend):
|
||||||
def __init__(self, region_name=None):
|
def __init__(self, region_name=None):
|
||||||
super(MediaConnectBackend, self).__init__()
|
super().__init__()
|
||||||
self.region_name = region_name
|
self.region_name = region_name
|
||||||
self._flows = OrderedDict()
|
self._flows = OrderedDict()
|
||||||
self._resources = OrderedDict()
|
self._resources = OrderedDict()
|
||||||
|
@ -114,7 +114,7 @@ class Channel(BaseModel):
|
|||||||
|
|
||||||
class MediaLiveBackend(BaseBackend):
|
class MediaLiveBackend(BaseBackend):
|
||||||
def __init__(self, region_name=None):
|
def __init__(self, region_name=None):
|
||||||
super(MediaLiveBackend, self).__init__()
|
super().__init__()
|
||||||
self.region_name = region_name
|
self.region_name = region_name
|
||||||
self._channels = OrderedDict()
|
self._channels = OrderedDict()
|
||||||
self._inputs = OrderedDict()
|
self._inputs = OrderedDict()
|
||||||
@ -229,7 +229,7 @@ class MediaLiveBackend(BaseBackend):
|
|||||||
role_arn,
|
role_arn,
|
||||||
sources,
|
sources,
|
||||||
tags,
|
tags,
|
||||||
type,
|
input_type,
|
||||||
vpc,
|
vpc,
|
||||||
):
|
):
|
||||||
input_id = uuid4().hex
|
input_id = uuid4().hex
|
||||||
@ -245,7 +245,7 @@ class MediaLiveBackend(BaseBackend):
|
|||||||
role_arn=role_arn,
|
role_arn=role_arn,
|
||||||
sources=sources,
|
sources=sources,
|
||||||
tags=tags,
|
tags=tags,
|
||||||
input_type=type,
|
input_type=input_type,
|
||||||
state="CREATING",
|
state="CREATING",
|
||||||
)
|
)
|
||||||
self._inputs[input_id] = a_input
|
self._inputs[input_id] = a_input
|
||||||
|
@ -102,7 +102,7 @@ class MediaLiveResponse(BaseResponse):
|
|||||||
role_arn = self._get_param("roleArn")
|
role_arn = self._get_param("roleArn")
|
||||||
sources = self._get_param("sources")
|
sources = self._get_param("sources")
|
||||||
tags = self._get_param("tags")
|
tags = self._get_param("tags")
|
||||||
type = self._get_param("type")
|
input_type = self._get_param("type")
|
||||||
vpc = self._get_param("vpc")
|
vpc = self._get_param("vpc")
|
||||||
a_input = self.medialive_backend.create_input(
|
a_input = self.medialive_backend.create_input(
|
||||||
destinations=destinations,
|
destinations=destinations,
|
||||||
@ -114,7 +114,7 @@ class MediaLiveResponse(BaseResponse):
|
|||||||
role_arn=role_arn,
|
role_arn=role_arn,
|
||||||
sources=sources,
|
sources=sources,
|
||||||
tags=tags,
|
tags=tags,
|
||||||
type=type,
|
input_type=input_type,
|
||||||
vpc=vpc,
|
vpc=vpc,
|
||||||
)
|
)
|
||||||
return json.dumps({"input": a_input.to_dict()})
|
return json.dumps({"input": a_input.to_dict()})
|
||||||
|
@ -8,4 +8,4 @@ class MediaPackageClientError(JsonRESTError):
|
|||||||
# AWS service exceptions are caught with the underlying botocore exception, ClientError
|
# AWS service exceptions are caught with the underlying botocore exception, ClientError
|
||||||
class ClientError(MediaPackageClientError):
|
class ClientError(MediaPackageClientError):
|
||||||
def __init__(self, error, message):
|
def __init__(self, error, message):
|
||||||
super(ClientError, self).__init__(error, message)
|
super().__init__(error, message)
|
||||||
|
@ -35,7 +35,7 @@ class OriginEndpoint(BaseModel):
|
|||||||
self.dash_package = kwargs.get("dash_package")
|
self.dash_package = kwargs.get("dash_package")
|
||||||
self.description = kwargs.get("description")
|
self.description = kwargs.get("description")
|
||||||
self.hls_package = kwargs.get("hls_package")
|
self.hls_package = kwargs.get("hls_package")
|
||||||
self.id = kwargs.get("id")
|
self.id = kwargs.get("endpoint_id")
|
||||||
self.manifest_name = kwargs.get("manifest_name")
|
self.manifest_name = kwargs.get("manifest_name")
|
||||||
self.mss_package = kwargs.get("mss_package")
|
self.mss_package = kwargs.get("mss_package")
|
||||||
self.origination = kwargs.get("origination")
|
self.origination = kwargs.get("origination")
|
||||||
@ -69,7 +69,7 @@ class OriginEndpoint(BaseModel):
|
|||||||
|
|
||||||
class MediaPackageBackend(BaseBackend):
|
class MediaPackageBackend(BaseBackend):
|
||||||
def __init__(self, region_name=None):
|
def __init__(self, region_name=None):
|
||||||
super(MediaPackageBackend, self).__init__()
|
super().__init__()
|
||||||
self.region_name = region_name
|
self.region_name = region_name
|
||||||
self._channels = OrderedDict()
|
self._channels = OrderedDict()
|
||||||
self._origin_endpoints = OrderedDict()
|
self._origin_endpoints = OrderedDict()
|
||||||
@ -79,18 +79,18 @@ class MediaPackageBackend(BaseBackend):
|
|||||||
self.__dict__ = {}
|
self.__dict__ = {}
|
||||||
self.__init__(region_name)
|
self.__init__(region_name)
|
||||||
|
|
||||||
def create_channel(self, description, id, tags):
|
def create_channel(self, description, channel_id, tags):
|
||||||
arn = "arn:aws:mediapackage:channel:{}".format(id)
|
arn = "arn:aws:mediapackage:channel:{}".format(channel_id)
|
||||||
channel = Channel(
|
channel = Channel(
|
||||||
arn=arn,
|
arn=arn,
|
||||||
description=description,
|
description=description,
|
||||||
egress_access_logs={},
|
egress_access_logs={},
|
||||||
hls_ingest={},
|
hls_ingest={},
|
||||||
channel_id=id,
|
channel_id=channel_id,
|
||||||
ingress_access_logs={},
|
ingress_access_logs={},
|
||||||
tags=tags,
|
tags=tags,
|
||||||
)
|
)
|
||||||
self._channels[id] = channel
|
self._channels[channel_id] = channel
|
||||||
return channel
|
return channel
|
||||||
|
|
||||||
def list_channels(self):
|
def list_channels(self):
|
||||||
@ -98,23 +98,23 @@ class MediaPackageBackend(BaseBackend):
|
|||||||
response_channels = [c.to_dict() for c in channels]
|
response_channels = [c.to_dict() for c in channels]
|
||||||
return response_channels
|
return response_channels
|
||||||
|
|
||||||
def describe_channel(self, id):
|
def describe_channel(self, channel_id):
|
||||||
try:
|
try:
|
||||||
channel = self._channels[id]
|
channel = self._channels[channel_id]
|
||||||
return channel.to_dict()
|
return channel.to_dict()
|
||||||
except KeyError:
|
except KeyError:
|
||||||
error = "NotFoundException"
|
error = "NotFoundException"
|
||||||
raise ClientError(error, "channel with id={} not found".format(id))
|
raise ClientError(error, "channel with id={} not found".format(channel_id))
|
||||||
|
|
||||||
def delete_channel(self, id):
|
def delete_channel(self, channel_id):
|
||||||
try:
|
try:
|
||||||
channel = self._channels[id]
|
channel = self._channels[channel_id]
|
||||||
del self._channels[id]
|
del self._channels[channel_id]
|
||||||
return channel.to_dict()
|
return channel.to_dict()
|
||||||
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
error = "NotFoundException"
|
error = "NotFoundException"
|
||||||
raise ClientError(error, "channel with id={} not found".format(id))
|
raise ClientError(error, "channel with id={} not found".format(channel_id))
|
||||||
|
|
||||||
def create_origin_endpoint(
|
def create_origin_endpoint(
|
||||||
self,
|
self,
|
||||||
@ -124,7 +124,7 @@ class MediaPackageBackend(BaseBackend):
|
|||||||
dash_package,
|
dash_package,
|
||||||
description,
|
description,
|
||||||
hls_package,
|
hls_package,
|
||||||
id,
|
endpoint_id,
|
||||||
manifest_name,
|
manifest_name,
|
||||||
mss_package,
|
mss_package,
|
||||||
origination,
|
origination,
|
||||||
@ -133,9 +133,9 @@ class MediaPackageBackend(BaseBackend):
|
|||||||
time_delay_seconds,
|
time_delay_seconds,
|
||||||
whitelist,
|
whitelist,
|
||||||
):
|
):
|
||||||
arn = "arn:aws:mediapackage:origin_endpoint:{}".format(id)
|
arn = "arn:aws:mediapackage:origin_endpoint:{}".format(endpoint_id)
|
||||||
url = "https://origin-endpoint.mediapackage.{}.amazonaws.com/{}".format(
|
url = "https://origin-endpoint.mediapackage.{}.amazonaws.com/{}".format(
|
||||||
self.region_name, id
|
self.region_name, endpoint_id
|
||||||
)
|
)
|
||||||
origin_endpoint = OriginEndpoint(
|
origin_endpoint = OriginEndpoint(
|
||||||
arn=arn,
|
arn=arn,
|
||||||
@ -145,7 +145,7 @@ class MediaPackageBackend(BaseBackend):
|
|||||||
dash_package=dash_package,
|
dash_package=dash_package,
|
||||||
description=description,
|
description=description,
|
||||||
hls_package=hls_package,
|
hls_package=hls_package,
|
||||||
id=id,
|
endpoint_id=endpoint_id,
|
||||||
manifest_name=manifest_name,
|
manifest_name=manifest_name,
|
||||||
mss_package=mss_package,
|
mss_package=mss_package,
|
||||||
origination=origination,
|
origination=origination,
|
||||||
@ -155,30 +155,34 @@ class MediaPackageBackend(BaseBackend):
|
|||||||
url=url,
|
url=url,
|
||||||
whitelist=whitelist,
|
whitelist=whitelist,
|
||||||
)
|
)
|
||||||
self._origin_endpoints[id] = origin_endpoint
|
self._origin_endpoints[endpoint_id] = origin_endpoint
|
||||||
return origin_endpoint
|
return origin_endpoint
|
||||||
|
|
||||||
def describe_origin_endpoint(self, id):
|
def describe_origin_endpoint(self, endpoint_id):
|
||||||
try:
|
try:
|
||||||
origin_endpoint = self._origin_endpoints[id]
|
origin_endpoint = self._origin_endpoints[endpoint_id]
|
||||||
return origin_endpoint.to_dict()
|
return origin_endpoint.to_dict()
|
||||||
except KeyError:
|
except KeyError:
|
||||||
error = "NotFoundException"
|
error = "NotFoundException"
|
||||||
raise ClientError(error, "origin endpoint with id={} not found".format(id))
|
raise ClientError(
|
||||||
|
error, "origin endpoint with id={} not found".format(endpoint_id)
|
||||||
|
)
|
||||||
|
|
||||||
def list_origin_endpoints(self):
|
def list_origin_endpoints(self):
|
||||||
origin_endpoints = list(self._origin_endpoints.values())
|
origin_endpoints = list(self._origin_endpoints.values())
|
||||||
response_origin_endpoints = [o.to_dict() for o in origin_endpoints]
|
response_origin_endpoints = [o.to_dict() for o in origin_endpoints]
|
||||||
return response_origin_endpoints
|
return response_origin_endpoints
|
||||||
|
|
||||||
def delete_origin_endpoint(self, id):
|
def delete_origin_endpoint(self, endpoint_id):
|
||||||
try:
|
try:
|
||||||
origin_endpoint = self._origin_endpoints[id]
|
origin_endpoint = self._origin_endpoints[endpoint_id]
|
||||||
del self._origin_endpoints[id]
|
del self._origin_endpoints[endpoint_id]
|
||||||
return origin_endpoint.to_dict()
|
return origin_endpoint.to_dict()
|
||||||
except KeyError:
|
except KeyError:
|
||||||
error = "NotFoundException"
|
error = "NotFoundException"
|
||||||
raise ClientError(error, "origin endpoint with id={} not found".format(id))
|
raise ClientError(
|
||||||
|
error, "origin endpoint with id={} not found".format(endpoint_id)
|
||||||
|
)
|
||||||
|
|
||||||
def update_origin_endpoint(
|
def update_origin_endpoint(
|
||||||
self,
|
self,
|
||||||
@ -187,7 +191,7 @@ class MediaPackageBackend(BaseBackend):
|
|||||||
dash_package,
|
dash_package,
|
||||||
description,
|
description,
|
||||||
hls_package,
|
hls_package,
|
||||||
id,
|
endpoint_id,
|
||||||
manifest_name,
|
manifest_name,
|
||||||
mss_package,
|
mss_package,
|
||||||
origination,
|
origination,
|
||||||
@ -196,7 +200,7 @@ class MediaPackageBackend(BaseBackend):
|
|||||||
whitelist,
|
whitelist,
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
origin_endpoint = self._origin_endpoints[id]
|
origin_endpoint = self._origin_endpoints[endpoint_id]
|
||||||
origin_endpoint.authorization = authorization
|
origin_endpoint.authorization = authorization
|
||||||
origin_endpoint.cmaf_package = cmaf_package
|
origin_endpoint.cmaf_package = cmaf_package
|
||||||
origin_endpoint.dash_package = dash_package
|
origin_endpoint.dash_package = dash_package
|
||||||
@ -212,7 +216,9 @@ class MediaPackageBackend(BaseBackend):
|
|||||||
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
error = "NotFoundException"
|
error = "NotFoundException"
|
||||||
raise ClientError(error, "origin endpoint with id={} not found".format(id))
|
raise ClientError(
|
||||||
|
error, "origin endpoint with id={} not found".format(endpoint_id)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
mediapackage_backends = BackendDict(MediaPackageBackend, "mediapackage")
|
mediapackage_backends = BackendDict(MediaPackageBackend, "mediapackage")
|
||||||
|
@ -12,10 +12,10 @@ class MediaPackageResponse(BaseResponse):
|
|||||||
|
|
||||||
def create_channel(self):
|
def create_channel(self):
|
||||||
description = self._get_param("description")
|
description = self._get_param("description")
|
||||||
id = self._get_param("id")
|
channel_id = self._get_param("id")
|
||||||
tags = self._get_param("tags")
|
tags = self._get_param("tags")
|
||||||
channel = self.mediapackage_backend.create_channel(
|
channel = self.mediapackage_backend.create_channel(
|
||||||
description=description, id=id, tags=tags,
|
description=description, channel_id=channel_id, tags=tags,
|
||||||
)
|
)
|
||||||
return json.dumps(channel.to_dict())
|
return json.dumps(channel.to_dict())
|
||||||
|
|
||||||
@ -24,12 +24,16 @@ class MediaPackageResponse(BaseResponse):
|
|||||||
return json.dumps(dict(channels=channels))
|
return json.dumps(dict(channels=channels))
|
||||||
|
|
||||||
def describe_channel(self):
|
def describe_channel(self):
|
||||||
id = self._get_param("id")
|
channel_id = self._get_param("id")
|
||||||
return json.dumps(self.mediapackage_backend.describe_channel(id=id))
|
return json.dumps(
|
||||||
|
self.mediapackage_backend.describe_channel(channel_id=channel_id)
|
||||||
|
)
|
||||||
|
|
||||||
def delete_channel(self):
|
def delete_channel(self):
|
||||||
channel_id = self._get_param("id")
|
channel_id = self._get_param("id")
|
||||||
return json.dumps(self.mediapackage_backend.delete_channel(id=channel_id))
|
return json.dumps(
|
||||||
|
self.mediapackage_backend.delete_channel(channel_id=channel_id)
|
||||||
|
)
|
||||||
|
|
||||||
def create_origin_endpoint(self):
|
def create_origin_endpoint(self):
|
||||||
authorization = self._get_param("authorization")
|
authorization = self._get_param("authorization")
|
||||||
@ -38,7 +42,7 @@ class MediaPackageResponse(BaseResponse):
|
|||||||
dash_package = self._get_param("dashPackage")
|
dash_package = self._get_param("dashPackage")
|
||||||
description = self._get_param("description")
|
description = self._get_param("description")
|
||||||
hls_package = self._get_param("hlsPackage")
|
hls_package = self._get_param("hlsPackage")
|
||||||
id = self._get_param("id")
|
endpoint_id = self._get_param("id")
|
||||||
manifest_name = self._get_param("manifestName")
|
manifest_name = self._get_param("manifestName")
|
||||||
mss_package = self._get_param("mssPackage")
|
mss_package = self._get_param("mssPackage")
|
||||||
origination = self._get_param("origination")
|
origination = self._get_param("origination")
|
||||||
@ -53,7 +57,7 @@ class MediaPackageResponse(BaseResponse):
|
|||||||
dash_package=dash_package,
|
dash_package=dash_package,
|
||||||
description=description,
|
description=description,
|
||||||
hls_package=hls_package,
|
hls_package=hls_package,
|
||||||
id=id,
|
endpoint_id=endpoint_id,
|
||||||
manifest_name=manifest_name,
|
manifest_name=manifest_name,
|
||||||
mss_package=mss_package,
|
mss_package=mss_package,
|
||||||
origination=origination,
|
origination=origination,
|
||||||
@ -69,12 +73,16 @@ class MediaPackageResponse(BaseResponse):
|
|||||||
return json.dumps(dict(originEndpoints=origin_endpoints))
|
return json.dumps(dict(originEndpoints=origin_endpoints))
|
||||||
|
|
||||||
def describe_origin_endpoint(self):
|
def describe_origin_endpoint(self):
|
||||||
id = self._get_param("id")
|
endpoint_id = self._get_param("id")
|
||||||
return json.dumps(self.mediapackage_backend.describe_origin_endpoint(id=id))
|
return json.dumps(
|
||||||
|
self.mediapackage_backend.describe_origin_endpoint(endpoint_id=endpoint_id)
|
||||||
|
)
|
||||||
|
|
||||||
def delete_origin_endpoint(self):
|
def delete_origin_endpoint(self):
|
||||||
id = self._get_param("id")
|
endpoint_id = self._get_param("id")
|
||||||
return json.dumps(self.mediapackage_backend.delete_origin_endpoint(id=id))
|
return json.dumps(
|
||||||
|
self.mediapackage_backend.delete_origin_endpoint(endpoint_id=endpoint_id)
|
||||||
|
)
|
||||||
|
|
||||||
def update_origin_endpoint(self):
|
def update_origin_endpoint(self):
|
||||||
authorization = self._get_param("authorization")
|
authorization = self._get_param("authorization")
|
||||||
@ -82,7 +90,7 @@ class MediaPackageResponse(BaseResponse):
|
|||||||
dash_package = self._get_param("dashPackage")
|
dash_package = self._get_param("dashPackage")
|
||||||
description = self._get_param("description")
|
description = self._get_param("description")
|
||||||
hls_package = self._get_param("hlsPackage")
|
hls_package = self._get_param("hlsPackage")
|
||||||
id = self._get_param("id")
|
endpoint_id = self._get_param("id")
|
||||||
manifest_name = self._get_param("manifestName")
|
manifest_name = self._get_param("manifestName")
|
||||||
mss_package = self._get_param("mssPackage")
|
mss_package = self._get_param("mssPackage")
|
||||||
origination = self._get_param("origination")
|
origination = self._get_param("origination")
|
||||||
@ -95,7 +103,7 @@ class MediaPackageResponse(BaseResponse):
|
|||||||
dash_package=dash_package,
|
dash_package=dash_package,
|
||||||
description=description,
|
description=description,
|
||||||
hls_package=hls_package,
|
hls_package=hls_package,
|
||||||
id=id,
|
endpoint_id=endpoint_id,
|
||||||
manifest_name=manifest_name,
|
manifest_name=manifest_name,
|
||||||
mss_package=mss_package,
|
mss_package=mss_package,
|
||||||
origination=origination,
|
origination=origination,
|
||||||
|
@ -8,7 +8,7 @@ class MediaStoreClientError(JsonRESTError):
|
|||||||
class ContainerNotFoundException(MediaStoreClientError):
|
class ContainerNotFoundException(MediaStoreClientError):
|
||||||
def __init__(self, msg=None):
|
def __init__(self, msg=None):
|
||||||
self.code = 400
|
self.code = 400
|
||||||
super(ContainerNotFoundException, self).__init__(
|
super().__init__(
|
||||||
"ContainerNotFoundException",
|
"ContainerNotFoundException",
|
||||||
msg or "The specified container does not exist",
|
msg or "The specified container does not exist",
|
||||||
)
|
)
|
||||||
@ -17,7 +17,7 @@ class ContainerNotFoundException(MediaStoreClientError):
|
|||||||
class ResourceNotFoundException(MediaStoreClientError):
|
class ResourceNotFoundException(MediaStoreClientError):
|
||||||
def __init__(self, msg=None):
|
def __init__(self, msg=None):
|
||||||
self.code = 400
|
self.code = 400
|
||||||
super(ResourceNotFoundException, self).__init__(
|
super().__init__(
|
||||||
"ResourceNotFoundException", msg or "The specified container does not exist"
|
"ResourceNotFoundException", msg or "The specified container does not exist"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -25,7 +25,7 @@ class ResourceNotFoundException(MediaStoreClientError):
|
|||||||
class PolicyNotFoundException(MediaStoreClientError):
|
class PolicyNotFoundException(MediaStoreClientError):
|
||||||
def __init__(self, msg=None):
|
def __init__(self, msg=None):
|
||||||
self.code = 400
|
self.code = 400
|
||||||
super(PolicyNotFoundException, self).__init__(
|
super().__init__(
|
||||||
"PolicyNotFoundException",
|
"PolicyNotFoundException",
|
||||||
msg or "The policy does not exist within the specfied container",
|
msg or "The policy does not exist within the specfied container",
|
||||||
)
|
)
|
||||||
|
@ -39,7 +39,7 @@ class Container(BaseModel):
|
|||||||
|
|
||||||
class MediaStoreBackend(BaseBackend):
|
class MediaStoreBackend(BaseBackend):
|
||||||
def __init__(self, region_name=None):
|
def __init__(self, region_name=None):
|
||||||
super(MediaStoreBackend, self).__init__()
|
super().__init__()
|
||||||
self.region_name = region_name
|
self.region_name = region_name
|
||||||
self._containers = OrderedDict()
|
self._containers = OrderedDict()
|
||||||
|
|
||||||
|
@ -8,4 +8,4 @@ class MediaStoreDataClientError(JsonRESTError):
|
|||||||
# AWS service exceptions are caught with the underlying botocore exception, ClientError
|
# AWS service exceptions are caught with the underlying botocore exception, ClientError
|
||||||
class ClientError(MediaStoreDataClientError):
|
class ClientError(MediaStoreDataClientError):
|
||||||
def __init__(self, error, message):
|
def __init__(self, error, message):
|
||||||
super(ClientError, self).__init__(error, message)
|
super().__init__(error, message)
|
||||||
|
@ -30,7 +30,7 @@ class Object(BaseModel):
|
|||||||
|
|
||||||
class MediaStoreDataBackend(BaseBackend):
|
class MediaStoreDataBackend(BaseBackend):
|
||||||
def __init__(self, region_name=None):
|
def __init__(self, region_name=None):
|
||||||
super(MediaStoreDataBackend, self).__init__()
|
super().__init__()
|
||||||
self.region_name = region_name
|
self.region_name = region_name
|
||||||
self._objects = OrderedDict()
|
self._objects = OrderedDict()
|
||||||
|
|
||||||
@ -61,7 +61,10 @@ class MediaStoreDataBackend(BaseBackend):
|
|||||||
del self._objects[path]
|
del self._objects[path]
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
def get_object(self, path, range=None):
|
def get_object(self, path, object_range=None):
|
||||||
|
"""
|
||||||
|
The Range-parameter is not yet supported.
|
||||||
|
"""
|
||||||
objects_found = [item for item in self._objects.values() if item.path == path]
|
objects_found = [item for item in self._objects.values() if item.path == path]
|
||||||
if len(objects_found) == 0:
|
if len(objects_found) == 0:
|
||||||
error = "ObjectNotFoundException"
|
error = "ObjectNotFoundException"
|
||||||
@ -69,6 +72,9 @@ class MediaStoreDataBackend(BaseBackend):
|
|||||||
return objects_found[0]
|
return objects_found[0]
|
||||||
|
|
||||||
def list_items(self, path, max_results=1000, next_token=None):
|
def list_items(self, path, max_results=1000, next_token=None):
|
||||||
|
"""
|
||||||
|
The Path- and MaxResults-parameters are not yet supported.
|
||||||
|
"""
|
||||||
items = self._objects.values()
|
items = self._objects.values()
|
||||||
response_items = [c.to_dict() for c in items]
|
response_items = [c.to_dict() for c in items]
|
||||||
return response_items
|
return response_items
|
||||||
|
@ -13,8 +13,10 @@ class MediaStoreDataResponse(BaseResponse):
|
|||||||
|
|
||||||
def get_object(self):
|
def get_object(self):
|
||||||
path = self._get_param("Path")
|
path = self._get_param("Path")
|
||||||
range = self._get_param("Range")
|
object_range = self._get_param("Range")
|
||||||
result = self.mediastoredata_backend.get_object(path=path, range=range)
|
result = self.mediastoredata_backend.get_object(
|
||||||
|
path=path, object_range=object_range
|
||||||
|
)
|
||||||
headers = {"Path": result.path}
|
headers = {"Path": result.path}
|
||||||
return result.body, headers
|
return result.body, headers
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ from werkzeug.exceptions import BadRequest
|
|||||||
|
|
||||||
class ResourceNotFoundException(BadRequest):
|
class ResourceNotFoundException(BadRequest):
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(ResourceNotFoundException, self).__init__()
|
super().__init__()
|
||||||
self.description = json.dumps(
|
self.description = json.dumps(
|
||||||
{"message": message, "__type": "ResourceNotFoundException"}
|
{"message": message, "__type": "ResourceNotFoundException"}
|
||||||
)
|
)
|
||||||
@ -12,7 +12,7 @@ class ResourceNotFoundException(BadRequest):
|
|||||||
|
|
||||||
class ValidationException(BadRequest):
|
class ValidationException(BadRequest):
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(ValidationException, self).__init__()
|
super().__init__()
|
||||||
self.description = json.dumps(
|
self.description = json.dumps(
|
||||||
{"message": message, "__type": "ResourceNotFoundException"}
|
{"message": message, "__type": "ResourceNotFoundException"}
|
||||||
)
|
)
|
||||||
|
@ -185,7 +185,7 @@ class Layer(BaseModel):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
stack_id,
|
stack_id,
|
||||||
type,
|
layer_type,
|
||||||
name,
|
name,
|
||||||
shortname,
|
shortname,
|
||||||
attributes=None,
|
attributes=None,
|
||||||
@ -203,7 +203,7 @@ class Layer(BaseModel):
|
|||||||
lifecycle_event_configuration=None,
|
lifecycle_event_configuration=None,
|
||||||
):
|
):
|
||||||
self.stack_id = stack_id
|
self.stack_id = stack_id
|
||||||
self.type = type
|
self.type = layer_type
|
||||||
self.name = name
|
self.name = name
|
||||||
self.shortname = shortname
|
self.shortname = shortname
|
||||||
|
|
||||||
@ -425,7 +425,7 @@ class App(BaseModel):
|
|||||||
self,
|
self,
|
||||||
stack_id,
|
stack_id,
|
||||||
name,
|
name,
|
||||||
type,
|
app_type,
|
||||||
shortname=None,
|
shortname=None,
|
||||||
description=None,
|
description=None,
|
||||||
datasources=None,
|
datasources=None,
|
||||||
@ -438,7 +438,7 @@ class App(BaseModel):
|
|||||||
):
|
):
|
||||||
self.stack_id = stack_id
|
self.stack_id = stack_id
|
||||||
self.name = name
|
self.name = name
|
||||||
self.type = type
|
self.type = app_type
|
||||||
self.shortname = shortname
|
self.shortname = shortname
|
||||||
self.description = description
|
self.description = description
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ class OpsWorksResponse(BaseResponse):
|
|||||||
def create_layer(self):
|
def create_layer(self):
|
||||||
kwargs = dict(
|
kwargs = dict(
|
||||||
stack_id=self.parameters.get("StackId"),
|
stack_id=self.parameters.get("StackId"),
|
||||||
type=self.parameters.get("Type"),
|
layer_type=self.parameters.get("Type"),
|
||||||
name=self.parameters.get("Name"),
|
name=self.parameters.get("Name"),
|
||||||
shortname=self.parameters.get("Shortname"),
|
shortname=self.parameters.get("Shortname"),
|
||||||
attributes=self.parameters.get("Attributes"),
|
attributes=self.parameters.get("Attributes"),
|
||||||
@ -71,7 +71,7 @@ class OpsWorksResponse(BaseResponse):
|
|||||||
kwargs = dict(
|
kwargs = dict(
|
||||||
stack_id=self.parameters.get("StackId"),
|
stack_id=self.parameters.get("StackId"),
|
||||||
name=self.parameters.get("Name"),
|
name=self.parameters.get("Name"),
|
||||||
type=self.parameters.get("Type"),
|
app_type=self.parameters.get("Type"),
|
||||||
shortname=self.parameters.get("Shortname"),
|
shortname=self.parameters.get("Shortname"),
|
||||||
description=self.parameters.get("Description"),
|
description=self.parameters.get("Description"),
|
||||||
datasources=self.parameters.get("DataSources"),
|
datasources=self.parameters.get("DataSources"),
|
||||||
|
@ -5,7 +5,7 @@ class AccountAlreadyRegisteredException(JsonRESTError):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(AccountAlreadyRegisteredException, self).__init__(
|
super().__init__(
|
||||||
"AccountAlreadyRegisteredException",
|
"AccountAlreadyRegisteredException",
|
||||||
"The provided account is already a delegated administrator for your organization.",
|
"The provided account is already a delegated administrator for your organization.",
|
||||||
)
|
)
|
||||||
@ -15,7 +15,7 @@ class AccountNotRegisteredException(JsonRESTError):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(AccountNotRegisteredException, self).__init__(
|
super().__init__(
|
||||||
"AccountNotRegisteredException",
|
"AccountNotRegisteredException",
|
||||||
"The provided account is not a registered delegated administrator for your organization.",
|
"The provided account is not a registered delegated administrator for your organization.",
|
||||||
)
|
)
|
||||||
@ -25,7 +25,7 @@ class AccountNotFoundException(JsonRESTError):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(AccountNotFoundException, self).__init__(
|
super().__init__(
|
||||||
"AccountNotFoundException", "You specified an account that doesn't exist."
|
"AccountNotFoundException", "You specified an account that doesn't exist."
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ class AWSOrganizationsNotInUseException(JsonRESTError):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(AWSOrganizationsNotInUseException, self).__init__(
|
super().__init__(
|
||||||
"AWSOrganizationsNotInUseException",
|
"AWSOrganizationsNotInUseException",
|
||||||
"Your account is not a member of an organization.",
|
"Your account is not a member of an organization.",
|
||||||
)
|
)
|
||||||
@ -44,23 +44,21 @@ class ConstraintViolationException(JsonRESTError):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(ConstraintViolationException, self).__init__(
|
super().__init__("ConstraintViolationException", message)
|
||||||
"ConstraintViolationException", message
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class InvalidInputException(JsonRESTError):
|
class InvalidInputException(JsonRESTError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(InvalidInputException, self).__init__("InvalidInputException", message)
|
super().__init__("InvalidInputException", message)
|
||||||
|
|
||||||
|
|
||||||
class DuplicateOrganizationalUnitException(JsonRESTError):
|
class DuplicateOrganizationalUnitException(JsonRESTError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(DuplicateOrganizationalUnitException, self).__init__(
|
super().__init__(
|
||||||
"DuplicateOrganizationalUnitException",
|
"DuplicateOrganizationalUnitException",
|
||||||
"An OU with the same name already exists.",
|
"An OU with the same name already exists.",
|
||||||
)
|
)
|
||||||
@ -70,7 +68,7 @@ class DuplicatePolicyException(JsonRESTError):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(DuplicatePolicyException, self).__init__(
|
super().__init__(
|
||||||
"DuplicatePolicyException", "A policy with the same name already exists."
|
"DuplicatePolicyException", "A policy with the same name already exists."
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -79,7 +77,7 @@ class PolicyTypeAlreadyEnabledException(JsonRESTError):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(PolicyTypeAlreadyEnabledException, self).__init__(
|
super().__init__(
|
||||||
"PolicyTypeAlreadyEnabledException",
|
"PolicyTypeAlreadyEnabledException",
|
||||||
"The specified policy type is already enabled.",
|
"The specified policy type is already enabled.",
|
||||||
)
|
)
|
||||||
@ -89,7 +87,7 @@ class PolicyTypeNotEnabledException(JsonRESTError):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(PolicyTypeNotEnabledException, self).__init__(
|
super().__init__(
|
||||||
"PolicyTypeNotEnabledException",
|
"PolicyTypeNotEnabledException",
|
||||||
"This operation can be performed only for enabled policy types.",
|
"This operation can be performed only for enabled policy types.",
|
||||||
)
|
)
|
||||||
@ -99,7 +97,7 @@ class RootNotFoundException(JsonRESTError):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(RootNotFoundException, self).__init__(
|
super().__init__(
|
||||||
"RootNotFoundException", "You specified a root that doesn't exist."
|
"RootNotFoundException", "You specified a root that doesn't exist."
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -108,6 +106,6 @@ class TargetNotFoundException(JsonRESTError):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(TargetNotFoundException, self).__init__(
|
super().__init__(
|
||||||
"TargetNotFoundException", "You specified a target that doesn't exist."
|
"TargetNotFoundException", "You specified a target that doesn't exist."
|
||||||
)
|
)
|
||||||
|
@ -136,7 +136,7 @@ class FakeRoot(FakeOrganizationalUnit):
|
|||||||
]
|
]
|
||||||
|
|
||||||
def __init__(self, organization, **kwargs):
|
def __init__(self, organization, **kwargs):
|
||||||
super(FakeRoot, self).__init__(organization, **kwargs)
|
super().__init__(organization, **kwargs)
|
||||||
self.type = "ROOT"
|
self.type = "ROOT"
|
||||||
self.id = organization.root_id
|
self.id = organization.root_id
|
||||||
self.name = "Root"
|
self.name = "Root"
|
||||||
@ -629,7 +629,7 @@ class OrganizationsBackend(BaseBackend):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def list_policies_for_target(self, **kwargs):
|
def list_policies_for_target(self, **kwargs):
|
||||||
filter = kwargs["Filter"]
|
_filter = kwargs["Filter"]
|
||||||
|
|
||||||
if re.match(utils.ROOT_ID_REGEX, kwargs["TargetId"]):
|
if re.match(utils.ROOT_ID_REGEX, kwargs["TargetId"]):
|
||||||
obj = next((ou for ou in self.ou if ou.id == kwargs["TargetId"]), None)
|
obj = next((ou for ou in self.ou if ou.id == kwargs["TargetId"]), None)
|
||||||
@ -649,19 +649,19 @@ class OrganizationsBackend(BaseBackend):
|
|||||||
else:
|
else:
|
||||||
raise InvalidInputException("You specified an invalid value.")
|
raise InvalidInputException("You specified an invalid value.")
|
||||||
|
|
||||||
if not FakePolicy.supported_policy_type(filter):
|
if not FakePolicy.supported_policy_type(_filter):
|
||||||
raise InvalidInputException("You specified an invalid value.")
|
raise InvalidInputException("You specified an invalid value.")
|
||||||
|
|
||||||
if filter not in ["AISERVICES_OPT_OUT_POLICY", "SERVICE_CONTROL_POLICY"]:
|
if _filter not in ["AISERVICES_OPT_OUT_POLICY", "SERVICE_CONTROL_POLICY"]:
|
||||||
raise NotImplementedError(
|
raise NotImplementedError(
|
||||||
"The {0} policy type has not been implemented".format(filter)
|
"The {0} policy type has not been implemented".format(_filter)
|
||||||
)
|
)
|
||||||
|
|
||||||
return dict(
|
return dict(
|
||||||
Policies=[
|
Policies=[
|
||||||
p.describe()["Policy"]["PolicySummary"]
|
p.describe()["Policy"]["PolicySummary"]
|
||||||
for p in obj.attached_policies
|
for p in obj.attached_policies
|
||||||
if p.type == filter
|
if p.type == _filter
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ class Lexicon(BaseModel):
|
|||||||
|
|
||||||
class PollyBackend(BaseBackend):
|
class PollyBackend(BaseBackend):
|
||||||
def __init__(self, region_name=None):
|
def __init__(self, region_name=None):
|
||||||
super(PollyBackend, self).__init__()
|
super().__init__()
|
||||||
self.region_name = region_name
|
self.region_name = region_name
|
||||||
|
|
||||||
self._lexicons = {}
|
self._lexicons = {}
|
||||||
|
@ -5,23 +5,21 @@ class InvalidParameterException(JsonRESTError):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(InvalidParameterException, self).__init__(
|
super().__init__("InvalidParameterException", message)
|
||||||
"InvalidParameterException", message
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class MalformedArnException(JsonRESTError):
|
class MalformedArnException(JsonRESTError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(MalformedArnException, self).__init__("MalformedArnException", message)
|
super().__init__("MalformedArnException", message)
|
||||||
|
|
||||||
|
|
||||||
class OperationNotPermittedException(JsonRESTError):
|
class OperationNotPermittedException(JsonRESTError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(OperationNotPermittedException, self).__init__(
|
super().__init__(
|
||||||
"OperationNotPermittedException",
|
"OperationNotPermittedException",
|
||||||
"Unable to enable sharing with AWS Organizations. "
|
"Unable to enable sharing with AWS Organizations. "
|
||||||
"Received AccessDeniedException from AWSOrganizations with the following error message: "
|
"Received AccessDeniedException from AWSOrganizations with the following error message: "
|
||||||
@ -33,6 +31,4 @@ class UnknownResourceException(JsonRESTError):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(UnknownResourceException, self).__init__(
|
super().__init__("UnknownResourceException", message)
|
||||||
"UnknownResourceException", message
|
|
||||||
)
|
|
||||||
|
@ -153,7 +153,7 @@ class ResourceShare(BaseModel):
|
|||||||
|
|
||||||
class ResourceAccessManagerBackend(BaseBackend):
|
class ResourceAccessManagerBackend(BaseBackend):
|
||||||
def __init__(self, region_name=None):
|
def __init__(self, region_name=None):
|
||||||
super(ResourceAccessManagerBackend, self).__init__()
|
super().__init__()
|
||||||
self.region_name = region_name
|
self.region_name = region_name
|
||||||
self.resource_shares = []
|
self.resource_shares = []
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ from werkzeug.exceptions import BadRequest
|
|||||||
|
|
||||||
class RDSClientError(BadRequest):
|
class RDSClientError(BadRequest):
|
||||||
def __init__(self, code, message):
|
def __init__(self, code, message):
|
||||||
super(RDSClientError, self).__init__()
|
super().__init__()
|
||||||
self.description = json.dumps(
|
self.description = json.dumps(
|
||||||
{
|
{
|
||||||
"Error": {"Code": code, "Message": message, "Type": "Sender"},
|
"Error": {"Code": code, "Message": message, "Type": "Sender"},
|
||||||
@ -15,14 +15,14 @@ class RDSClientError(BadRequest):
|
|||||||
|
|
||||||
class DBInstanceNotFoundError(RDSClientError):
|
class DBInstanceNotFoundError(RDSClientError):
|
||||||
def __init__(self, database_identifier):
|
def __init__(self, database_identifier):
|
||||||
super(DBInstanceNotFoundError, self).__init__(
|
super().__init__(
|
||||||
"DBInstanceNotFound", "Database {0} not found.".format(database_identifier)
|
"DBInstanceNotFound", "Database {0} not found.".format(database_identifier)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class DBSecurityGroupNotFoundError(RDSClientError):
|
class DBSecurityGroupNotFoundError(RDSClientError):
|
||||||
def __init__(self, security_group_name):
|
def __init__(self, security_group_name):
|
||||||
super(DBSecurityGroupNotFoundError, self).__init__(
|
super().__init__(
|
||||||
"DBSecurityGroupNotFound",
|
"DBSecurityGroupNotFound",
|
||||||
"Security Group {0} not found.".format(security_group_name),
|
"Security Group {0} not found.".format(security_group_name),
|
||||||
)
|
)
|
||||||
@ -30,7 +30,7 @@ class DBSecurityGroupNotFoundError(RDSClientError):
|
|||||||
|
|
||||||
class DBSubnetGroupNotFoundError(RDSClientError):
|
class DBSubnetGroupNotFoundError(RDSClientError):
|
||||||
def __init__(self, subnet_group_name):
|
def __init__(self, subnet_group_name):
|
||||||
super(DBSubnetGroupNotFoundError, self).__init__(
|
super().__init__(
|
||||||
"DBSubnetGroupNotFound",
|
"DBSubnetGroupNotFound",
|
||||||
"Subnet Group {0} not found.".format(subnet_group_name),
|
"Subnet Group {0} not found.".format(subnet_group_name),
|
||||||
)
|
)
|
||||||
|
@ -4,7 +4,7 @@ from werkzeug.exceptions import BadRequest
|
|||||||
|
|
||||||
class RDSClientError(BadRequest):
|
class RDSClientError(BadRequest):
|
||||||
def __init__(self, code, message):
|
def __init__(self, code, message):
|
||||||
super(RDSClientError, self).__init__()
|
super().__init__()
|
||||||
template = Template(
|
template = Template(
|
||||||
"""
|
"""
|
||||||
<RDSClientError>
|
<RDSClientError>
|
||||||
@ -21,7 +21,7 @@ class RDSClientError(BadRequest):
|
|||||||
|
|
||||||
class DBInstanceNotFoundError(RDSClientError):
|
class DBInstanceNotFoundError(RDSClientError):
|
||||||
def __init__(self, database_identifier):
|
def __init__(self, database_identifier):
|
||||||
super(DBInstanceNotFoundError, self).__init__(
|
super().__init__(
|
||||||
"DBInstanceNotFound",
|
"DBInstanceNotFound",
|
||||||
"DBInstance {0} not found.".format(database_identifier),
|
"DBInstance {0} not found.".format(database_identifier),
|
||||||
)
|
)
|
||||||
@ -29,7 +29,7 @@ class DBInstanceNotFoundError(RDSClientError):
|
|||||||
|
|
||||||
class DBSnapshotNotFoundError(RDSClientError):
|
class DBSnapshotNotFoundError(RDSClientError):
|
||||||
def __init__(self, snapshot_identifier):
|
def __init__(self, snapshot_identifier):
|
||||||
super(DBSnapshotNotFoundError, self).__init__(
|
super().__init__(
|
||||||
"DBSnapshotNotFound",
|
"DBSnapshotNotFound",
|
||||||
"DBSnapshot {} not found.".format(snapshot_identifier),
|
"DBSnapshot {} not found.".format(snapshot_identifier),
|
||||||
)
|
)
|
||||||
@ -37,7 +37,7 @@ class DBSnapshotNotFoundError(RDSClientError):
|
|||||||
|
|
||||||
class DBSecurityGroupNotFoundError(RDSClientError):
|
class DBSecurityGroupNotFoundError(RDSClientError):
|
||||||
def __init__(self, security_group_name):
|
def __init__(self, security_group_name):
|
||||||
super(DBSecurityGroupNotFoundError, self).__init__(
|
super().__init__(
|
||||||
"DBSecurityGroupNotFound",
|
"DBSecurityGroupNotFound",
|
||||||
"Security Group {0} not found.".format(security_group_name),
|
"Security Group {0} not found.".format(security_group_name),
|
||||||
)
|
)
|
||||||
@ -45,7 +45,7 @@ class DBSecurityGroupNotFoundError(RDSClientError):
|
|||||||
|
|
||||||
class DBSubnetGroupNotFoundError(RDSClientError):
|
class DBSubnetGroupNotFoundError(RDSClientError):
|
||||||
def __init__(self, subnet_group_name):
|
def __init__(self, subnet_group_name):
|
||||||
super(DBSubnetGroupNotFoundError, self).__init__(
|
super().__init__(
|
||||||
"DBSubnetGroupNotFound",
|
"DBSubnetGroupNotFound",
|
||||||
"Subnet Group {0} not found.".format(subnet_group_name),
|
"Subnet Group {0} not found.".format(subnet_group_name),
|
||||||
)
|
)
|
||||||
@ -53,7 +53,7 @@ class DBSubnetGroupNotFoundError(RDSClientError):
|
|||||||
|
|
||||||
class DBParameterGroupNotFoundError(RDSClientError):
|
class DBParameterGroupNotFoundError(RDSClientError):
|
||||||
def __init__(self, db_parameter_group_name):
|
def __init__(self, db_parameter_group_name):
|
||||||
super(DBParameterGroupNotFoundError, self).__init__(
|
super().__init__(
|
||||||
"DBParameterGroupNotFound",
|
"DBParameterGroupNotFound",
|
||||||
"DB Parameter Group {0} not found.".format(db_parameter_group_name),
|
"DB Parameter Group {0} not found.".format(db_parameter_group_name),
|
||||||
)
|
)
|
||||||
@ -61,7 +61,7 @@ class DBParameterGroupNotFoundError(RDSClientError):
|
|||||||
|
|
||||||
class OptionGroupNotFoundFaultError(RDSClientError):
|
class OptionGroupNotFoundFaultError(RDSClientError):
|
||||||
def __init__(self, option_group_name):
|
def __init__(self, option_group_name):
|
||||||
super(OptionGroupNotFoundFaultError, self).__init__(
|
super().__init__(
|
||||||
"OptionGroupNotFoundFault",
|
"OptionGroupNotFoundFault",
|
||||||
"Specified OptionGroupName: {0} not found.".format(option_group_name),
|
"Specified OptionGroupName: {0} not found.".format(option_group_name),
|
||||||
)
|
)
|
||||||
@ -69,7 +69,7 @@ class OptionGroupNotFoundFaultError(RDSClientError):
|
|||||||
|
|
||||||
class InvalidDBClusterStateFaultError(RDSClientError):
|
class InvalidDBClusterStateFaultError(RDSClientError):
|
||||||
def __init__(self, database_identifier):
|
def __init__(self, database_identifier):
|
||||||
super(InvalidDBClusterStateFaultError, self).__init__(
|
super().__init__(
|
||||||
"InvalidDBClusterStateFault",
|
"InvalidDBClusterStateFault",
|
||||||
"Invalid DB type, when trying to perform StopDBInstance on {0}e. See AWS RDS documentation on rds.stop_db_instance".format(
|
"Invalid DB type, when trying to perform StopDBInstance on {0}e. See AWS RDS documentation on rds.stop_db_instance".format(
|
||||||
database_identifier
|
database_identifier
|
||||||
@ -84,7 +84,7 @@ class InvalidDBInstanceStateError(RDSClientError):
|
|||||||
if istate == "stop"
|
if istate == "stop"
|
||||||
else "stopped, it cannot be started"
|
else "stopped, it cannot be started"
|
||||||
)
|
)
|
||||||
super(InvalidDBInstanceStateError, self).__init__(
|
super().__init__(
|
||||||
"InvalidDBInstanceState",
|
"InvalidDBInstanceState",
|
||||||
"Instance {} is not {}.".format(database_identifier, estate),
|
"Instance {} is not {}.".format(database_identifier, estate),
|
||||||
)
|
)
|
||||||
@ -92,7 +92,7 @@ class InvalidDBInstanceStateError(RDSClientError):
|
|||||||
|
|
||||||
class SnapshotQuotaExceededError(RDSClientError):
|
class SnapshotQuotaExceededError(RDSClientError):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(SnapshotQuotaExceededError, self).__init__(
|
super().__init__(
|
||||||
"SnapshotQuotaExceeded",
|
"SnapshotQuotaExceeded",
|
||||||
"The request cannot be processed because it would exceed the maximum number of snapshots.",
|
"The request cannot be processed because it would exceed the maximum number of snapshots.",
|
||||||
)
|
)
|
||||||
@ -100,7 +100,7 @@ class SnapshotQuotaExceededError(RDSClientError):
|
|||||||
|
|
||||||
class DBSnapshotAlreadyExistsError(RDSClientError):
|
class DBSnapshotAlreadyExistsError(RDSClientError):
|
||||||
def __init__(self, database_snapshot_identifier):
|
def __init__(self, database_snapshot_identifier):
|
||||||
super(DBSnapshotAlreadyExistsError, self).__init__(
|
super().__init__(
|
||||||
"DBSnapshotAlreadyExists",
|
"DBSnapshotAlreadyExists",
|
||||||
"Cannot create the snapshot because a snapshot with the identifier {} already exists.".format(
|
"Cannot create the snapshot because a snapshot with the identifier {} already exists.".format(
|
||||||
database_snapshot_identifier
|
database_snapshot_identifier
|
||||||
@ -110,14 +110,12 @@ class DBSnapshotAlreadyExistsError(RDSClientError):
|
|||||||
|
|
||||||
class InvalidParameterValue(RDSClientError):
|
class InvalidParameterValue(RDSClientError):
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(InvalidParameterValue, self).__init__("InvalidParameterValue", message)
|
super().__init__("InvalidParameterValue", message)
|
||||||
|
|
||||||
|
|
||||||
class InvalidParameterCombination(RDSClientError):
|
class InvalidParameterCombination(RDSClientError):
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(InvalidParameterCombination, self).__init__(
|
super().__init__("InvalidParameterCombination", message)
|
||||||
"InvalidParameterCombination", message
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class InvalidDBClusterStateFault(RDSClientError):
|
class InvalidDBClusterStateFault(RDSClientError):
|
||||||
@ -127,7 +125,7 @@ class InvalidDBClusterStateFault(RDSClientError):
|
|||||||
|
|
||||||
class DBClusterNotFoundError(RDSClientError):
|
class DBClusterNotFoundError(RDSClientError):
|
||||||
def __init__(self, cluster_identifier):
|
def __init__(self, cluster_identifier):
|
||||||
super(DBClusterNotFoundError, self).__init__(
|
super().__init__(
|
||||||
"DBClusterNotFoundFault",
|
"DBClusterNotFoundFault",
|
||||||
"DBCluster {} not found.".format(cluster_identifier),
|
"DBCluster {} not found.".format(cluster_identifier),
|
||||||
)
|
)
|
||||||
|
@ -1270,7 +1270,7 @@ class RDS2Backend(BaseBackend):
|
|||||||
else:
|
else:
|
||||||
max_records = 100
|
max_records = 100
|
||||||
|
|
||||||
for option_group_name, option_group in self.option_groups.items():
|
for option_group in self.option_groups.values():
|
||||||
if (
|
if (
|
||||||
option_group_kwargs["name"]
|
option_group_kwargs["name"]
|
||||||
and option_group.name != option_group_kwargs["name"]
|
and option_group.name != option_group_kwargs["name"]
|
||||||
@ -1401,10 +1401,7 @@ class RDS2Backend(BaseBackend):
|
|||||||
else:
|
else:
|
||||||
max_records = 100
|
max_records = 100
|
||||||
|
|
||||||
for (
|
for db_parameter_group in self.db_parameter_groups.values():
|
||||||
db_parameter_group_name,
|
|
||||||
db_parameter_group,
|
|
||||||
) in self.db_parameter_groups.items():
|
|
||||||
if not db_parameter_group_kwargs.get(
|
if not db_parameter_group_kwargs.get(
|
||||||
"name"
|
"name"
|
||||||
) or db_parameter_group.name == db_parameter_group_kwargs.get("name"):
|
) or db_parameter_group.name == db_parameter_group_kwargs.get("name"):
|
||||||
|
@ -4,7 +4,7 @@ from werkzeug.exceptions import BadRequest
|
|||||||
|
|
||||||
class RedshiftClientError(BadRequest):
|
class RedshiftClientError(BadRequest):
|
||||||
def __init__(self, code, message):
|
def __init__(self, code, message):
|
||||||
super(RedshiftClientError, self).__init__()
|
super().__init__()
|
||||||
self.description = json.dumps(
|
self.description = json.dumps(
|
||||||
{
|
{
|
||||||
"Error": {"Code": code, "Message": message, "Type": "Sender"},
|
"Error": {"Code": code, "Message": message, "Type": "Sender"},
|
||||||
@ -15,14 +15,14 @@ class RedshiftClientError(BadRequest):
|
|||||||
|
|
||||||
class ClusterNotFoundError(RedshiftClientError):
|
class ClusterNotFoundError(RedshiftClientError):
|
||||||
def __init__(self, cluster_identifier):
|
def __init__(self, cluster_identifier):
|
||||||
super(ClusterNotFoundError, self).__init__(
|
super().__init__(
|
||||||
"ClusterNotFound", "Cluster {0} not found.".format(cluster_identifier)
|
"ClusterNotFound", "Cluster {0} not found.".format(cluster_identifier)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class ClusterSubnetGroupNotFoundError(RedshiftClientError):
|
class ClusterSubnetGroupNotFoundError(RedshiftClientError):
|
||||||
def __init__(self, subnet_identifier):
|
def __init__(self, subnet_identifier):
|
||||||
super(ClusterSubnetGroupNotFoundError, self).__init__(
|
super().__init__(
|
||||||
"ClusterSubnetGroupNotFound",
|
"ClusterSubnetGroupNotFound",
|
||||||
"Subnet group {0} not found.".format(subnet_identifier),
|
"Subnet group {0} not found.".format(subnet_identifier),
|
||||||
)
|
)
|
||||||
@ -30,7 +30,7 @@ class ClusterSubnetGroupNotFoundError(RedshiftClientError):
|
|||||||
|
|
||||||
class ClusterSecurityGroupNotFoundError(RedshiftClientError):
|
class ClusterSecurityGroupNotFoundError(RedshiftClientError):
|
||||||
def __init__(self, group_identifier):
|
def __init__(self, group_identifier):
|
||||||
super(ClusterSecurityGroupNotFoundError, self).__init__(
|
super().__init__(
|
||||||
"ClusterSecurityGroupNotFound",
|
"ClusterSecurityGroupNotFound",
|
||||||
"Security group {0} not found.".format(group_identifier),
|
"Security group {0} not found.".format(group_identifier),
|
||||||
)
|
)
|
||||||
@ -38,7 +38,7 @@ class ClusterSecurityGroupNotFoundError(RedshiftClientError):
|
|||||||
|
|
||||||
class ClusterParameterGroupNotFoundError(RedshiftClientError):
|
class ClusterParameterGroupNotFoundError(RedshiftClientError):
|
||||||
def __init__(self, group_identifier):
|
def __init__(self, group_identifier):
|
||||||
super(ClusterParameterGroupNotFoundError, self).__init__(
|
super().__init__(
|
||||||
"ClusterParameterGroupNotFound",
|
"ClusterParameterGroupNotFound",
|
||||||
"Parameter group {0} not found.".format(group_identifier),
|
"Parameter group {0} not found.".format(group_identifier),
|
||||||
)
|
)
|
||||||
@ -46,14 +46,14 @@ class ClusterParameterGroupNotFoundError(RedshiftClientError):
|
|||||||
|
|
||||||
class InvalidSubnetError(RedshiftClientError):
|
class InvalidSubnetError(RedshiftClientError):
|
||||||
def __init__(self, subnet_identifier):
|
def __init__(self, subnet_identifier):
|
||||||
super(InvalidSubnetError, self).__init__(
|
super().__init__(
|
||||||
"InvalidSubnet", "Subnet {0} not found.".format(subnet_identifier)
|
"InvalidSubnet", "Subnet {0} not found.".format(subnet_identifier)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class SnapshotCopyGrantAlreadyExistsFaultError(RedshiftClientError):
|
class SnapshotCopyGrantAlreadyExistsFaultError(RedshiftClientError):
|
||||||
def __init__(self, snapshot_copy_grant_name):
|
def __init__(self, snapshot_copy_grant_name):
|
||||||
super(SnapshotCopyGrantAlreadyExistsFaultError, self).__init__(
|
super().__init__(
|
||||||
"SnapshotCopyGrantAlreadyExistsFault",
|
"SnapshotCopyGrantAlreadyExistsFault",
|
||||||
"Cannot create the snapshot copy grant because a grant "
|
"Cannot create the snapshot copy grant because a grant "
|
||||||
"with the identifier '{0}' already exists".format(snapshot_copy_grant_name),
|
"with the identifier '{0}' already exists".format(snapshot_copy_grant_name),
|
||||||
@ -62,7 +62,7 @@ class SnapshotCopyGrantAlreadyExistsFaultError(RedshiftClientError):
|
|||||||
|
|
||||||
class SnapshotCopyGrantNotFoundFaultError(RedshiftClientError):
|
class SnapshotCopyGrantNotFoundFaultError(RedshiftClientError):
|
||||||
def __init__(self, snapshot_copy_grant_name):
|
def __init__(self, snapshot_copy_grant_name):
|
||||||
super(SnapshotCopyGrantNotFoundFaultError, self).__init__(
|
super().__init__(
|
||||||
"SnapshotCopyGrantNotFoundFault",
|
"SnapshotCopyGrantNotFoundFault",
|
||||||
"Snapshot copy grant not found: {0}".format(snapshot_copy_grant_name),
|
"Snapshot copy grant not found: {0}".format(snapshot_copy_grant_name),
|
||||||
)
|
)
|
||||||
@ -70,7 +70,7 @@ class SnapshotCopyGrantNotFoundFaultError(RedshiftClientError):
|
|||||||
|
|
||||||
class ClusterSnapshotNotFoundError(RedshiftClientError):
|
class ClusterSnapshotNotFoundError(RedshiftClientError):
|
||||||
def __init__(self, snapshot_identifier):
|
def __init__(self, snapshot_identifier):
|
||||||
super(ClusterSnapshotNotFoundError, self).__init__(
|
super().__init__(
|
||||||
"ClusterSnapshotNotFound",
|
"ClusterSnapshotNotFound",
|
||||||
"Snapshot {0} not found.".format(snapshot_identifier),
|
"Snapshot {0} not found.".format(snapshot_identifier),
|
||||||
)
|
)
|
||||||
@ -78,7 +78,7 @@ class ClusterSnapshotNotFoundError(RedshiftClientError):
|
|||||||
|
|
||||||
class ClusterSnapshotAlreadyExistsError(RedshiftClientError):
|
class ClusterSnapshotAlreadyExistsError(RedshiftClientError):
|
||||||
def __init__(self, snapshot_identifier):
|
def __init__(self, snapshot_identifier):
|
||||||
super(ClusterSnapshotAlreadyExistsError, self).__init__(
|
super().__init__(
|
||||||
"ClusterSnapshotAlreadyExists",
|
"ClusterSnapshotAlreadyExists",
|
||||||
"Cannot create the snapshot because a snapshot with the "
|
"Cannot create the snapshot because a snapshot with the "
|
||||||
"identifier {0} already exists".format(snapshot_identifier),
|
"identifier {0} already exists".format(snapshot_identifier),
|
||||||
@ -87,9 +87,7 @@ class ClusterSnapshotAlreadyExistsError(RedshiftClientError):
|
|||||||
|
|
||||||
class InvalidParameterValueError(RedshiftClientError):
|
class InvalidParameterValueError(RedshiftClientError):
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(InvalidParameterValueError, self).__init__(
|
super().__init__("InvalidParameterValue", message)
|
||||||
"InvalidParameterValue", message
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class ResourceNotFoundFaultError(RedshiftClientError):
|
class ResourceNotFoundFaultError(RedshiftClientError):
|
||||||
@ -103,12 +101,12 @@ class ResourceNotFoundFaultError(RedshiftClientError):
|
|||||||
msg = "{0} ({1}) not found.".format(resource_type, resource_name)
|
msg = "{0} ({1}) not found.".format(resource_type, resource_name)
|
||||||
if message:
|
if message:
|
||||||
msg = message
|
msg = message
|
||||||
super(ResourceNotFoundFaultError, self).__init__("ResourceNotFoundFault", msg)
|
super().__init__("ResourceNotFoundFault", msg)
|
||||||
|
|
||||||
|
|
||||||
class SnapshotCopyDisabledFaultError(RedshiftClientError):
|
class SnapshotCopyDisabledFaultError(RedshiftClientError):
|
||||||
def __init__(self, cluster_identifier):
|
def __init__(self, cluster_identifier):
|
||||||
super(SnapshotCopyDisabledFaultError, self).__init__(
|
super().__init__(
|
||||||
"SnapshotCopyDisabledFault",
|
"SnapshotCopyDisabledFault",
|
||||||
"Cannot modify retention period because snapshot copy is disabled on Cluster {0}.".format(
|
"Cannot modify retention period because snapshot copy is disabled on Cluster {0}.".format(
|
||||||
cluster_identifier
|
cluster_identifier
|
||||||
@ -118,7 +116,7 @@ class SnapshotCopyDisabledFaultError(RedshiftClientError):
|
|||||||
|
|
||||||
class SnapshotCopyAlreadyDisabledFaultError(RedshiftClientError):
|
class SnapshotCopyAlreadyDisabledFaultError(RedshiftClientError):
|
||||||
def __init__(self, cluster_identifier):
|
def __init__(self, cluster_identifier):
|
||||||
super(SnapshotCopyAlreadyDisabledFaultError, self).__init__(
|
super().__init__(
|
||||||
"SnapshotCopyAlreadyDisabledFault",
|
"SnapshotCopyAlreadyDisabledFault",
|
||||||
"Snapshot Copy is already disabled on Cluster {0}.".format(
|
"Snapshot Copy is already disabled on Cluster {0}.".format(
|
||||||
cluster_identifier
|
cluster_identifier
|
||||||
@ -128,7 +126,7 @@ class SnapshotCopyAlreadyDisabledFaultError(RedshiftClientError):
|
|||||||
|
|
||||||
class SnapshotCopyAlreadyEnabledFaultError(RedshiftClientError):
|
class SnapshotCopyAlreadyEnabledFaultError(RedshiftClientError):
|
||||||
def __init__(self, cluster_identifier):
|
def __init__(self, cluster_identifier):
|
||||||
super(SnapshotCopyAlreadyEnabledFaultError, self).__init__(
|
super().__init__(
|
||||||
"SnapshotCopyAlreadyEnabledFault",
|
"SnapshotCopyAlreadyEnabledFault",
|
||||||
"Snapshot Copy is already enabled on Cluster {0}.".format(
|
"Snapshot Copy is already enabled on Cluster {0}.".format(
|
||||||
cluster_identifier
|
cluster_identifier
|
||||||
@ -138,28 +136,22 @@ class SnapshotCopyAlreadyEnabledFaultError(RedshiftClientError):
|
|||||||
|
|
||||||
class ClusterAlreadyExistsFaultError(RedshiftClientError):
|
class ClusterAlreadyExistsFaultError(RedshiftClientError):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(ClusterAlreadyExistsFaultError, self).__init__(
|
super().__init__("ClusterAlreadyExists", "Cluster already exists")
|
||||||
"ClusterAlreadyExists", "Cluster already exists"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class InvalidParameterCombinationError(RedshiftClientError):
|
class InvalidParameterCombinationError(RedshiftClientError):
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(InvalidParameterCombinationError, self).__init__(
|
super().__init__("InvalidParameterCombination", message)
|
||||||
"InvalidParameterCombination", message
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class UnknownSnapshotCopyRegionFaultError(RedshiftClientError):
|
class UnknownSnapshotCopyRegionFaultError(RedshiftClientError):
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(UnknownSnapshotCopyRegionFaultError, self).__init__(
|
super().__init__("UnknownSnapshotCopyRegionFault", message)
|
||||||
"UnknownSnapshotCopyRegionFault", message
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class ClusterSecurityGroupNotFoundFaultError(RedshiftClientError):
|
class ClusterSecurityGroupNotFoundFaultError(RedshiftClientError):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(ClusterSecurityGroupNotFoundFaultError, self).__init__(
|
super().__init__(
|
||||||
"ClusterSecurityGroupNotFoundFault",
|
"ClusterSecurityGroupNotFoundFault",
|
||||||
"The cluster security group name does not refer to an existing cluster security group.",
|
"The cluster security group name does not refer to an existing cluster security group.",
|
||||||
)
|
)
|
||||||
|
@ -96,7 +96,7 @@ class Cluster(TaggableResourceMixin, CloudFormationModel):
|
|||||||
restored_from_snapshot=False,
|
restored_from_snapshot=False,
|
||||||
kms_key_id=None,
|
kms_key_id=None,
|
||||||
):
|
):
|
||||||
super(Cluster, self).__init__(region_name, tags)
|
super().__init__(region_name, tags)
|
||||||
self.redshift_backend = redshift_backend
|
self.redshift_backend = redshift_backend
|
||||||
self.cluster_identifier = cluster_identifier
|
self.cluster_identifier = cluster_identifier
|
||||||
self.create_time = iso_8601_datetime_with_milliseconds(
|
self.create_time = iso_8601_datetime_with_milliseconds(
|
||||||
@ -358,7 +358,7 @@ class SubnetGroup(TaggableResourceMixin, CloudFormationModel):
|
|||||||
region_name,
|
region_name,
|
||||||
tags=None,
|
tags=None,
|
||||||
):
|
):
|
||||||
super(SubnetGroup, self).__init__(region_name, tags)
|
super().__init__(region_name, tags)
|
||||||
self.ec2_backend = ec2_backend
|
self.ec2_backend = ec2_backend
|
||||||
self.cluster_subnet_group_name = cluster_subnet_group_name
|
self.cluster_subnet_group_name = cluster_subnet_group_name
|
||||||
self.description = description
|
self.description = description
|
||||||
@ -427,7 +427,7 @@ class SecurityGroup(TaggableResourceMixin, BaseModel):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self, cluster_security_group_name, description, region_name, tags=None
|
self, cluster_security_group_name, description, region_name, tags=None
|
||||||
):
|
):
|
||||||
super(SecurityGroup, self).__init__(region_name, tags)
|
super().__init__(region_name, tags)
|
||||||
self.cluster_security_group_name = cluster_security_group_name
|
self.cluster_security_group_name = cluster_security_group_name
|
||||||
self.description = description
|
self.description = description
|
||||||
self.ingress_rules = []
|
self.ingress_rules = []
|
||||||
@ -458,7 +458,7 @@ class ParameterGroup(TaggableResourceMixin, CloudFormationModel):
|
|||||||
region_name,
|
region_name,
|
||||||
tags=None,
|
tags=None,
|
||||||
):
|
):
|
||||||
super(ParameterGroup, self).__init__(region_name, tags)
|
super().__init__(region_name, tags)
|
||||||
self.cluster_parameter_group_name = cluster_parameter_group_name
|
self.cluster_parameter_group_name = cluster_parameter_group_name
|
||||||
self.group_family = group_family
|
self.group_family = group_family
|
||||||
self.description = description
|
self.description = description
|
||||||
@ -507,7 +507,7 @@ class Snapshot(TaggableResourceMixin, BaseModel):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self, cluster, snapshot_identifier, region_name, tags=None, iam_roles_arn=None
|
self, cluster, snapshot_identifier, region_name, tags=None, iam_roles_arn=None
|
||||||
):
|
):
|
||||||
super(Snapshot, self).__init__(region_name, tags)
|
super().__init__(region_name, tags)
|
||||||
self.cluster = copy.copy(cluster)
|
self.cluster = copy.copy(cluster)
|
||||||
self.snapshot_identifier = snapshot_identifier
|
self.snapshot_identifier = snapshot_identifier
|
||||||
self.snapshot_type = "manual"
|
self.snapshot_type = "manual"
|
||||||
|
@ -59,7 +59,7 @@ class RedshiftResponse(BaseResponse):
|
|||||||
return xml
|
return xml
|
||||||
|
|
||||||
def call_action(self):
|
def call_action(self):
|
||||||
status, headers, body = super(RedshiftResponse, self).call_action()
|
status, headers, body = super().call_action()
|
||||||
if status >= 400 and not self.request_json:
|
if status >= 400 and not self.request_json:
|
||||||
body = convert_json_error_to_xml(body)
|
body = convert_json_error_to_xml(body)
|
||||||
return status, headers, body
|
return status, headers, body
|
||||||
|
@ -7,7 +7,7 @@ class BadRequestException(HTTPException):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, message, **kwargs):
|
def __init__(self, message, **kwargs):
|
||||||
super(BadRequestException, self).__init__(
|
super().__init__(
|
||||||
description=json.dumps({"Message": message, "Code": "BadRequestException"}),
|
description=json.dumps({"Message": message, "Code": "BadRequestException"}),
|
||||||
**kwargs
|
**kwargs
|
||||||
)
|
)
|
||||||
|
@ -222,7 +222,7 @@ class ResourceGroups:
|
|||||||
|
|
||||||
class ResourceGroupsBackend(BaseBackend):
|
class ResourceGroupsBackend(BaseBackend):
|
||||||
def __init__(self, region_name=None):
|
def __init__(self, region_name=None):
|
||||||
super(ResourceGroupsBackend, self).__init__()
|
super().__init__()
|
||||||
self.region_name = region_name
|
self.region_name = region_name
|
||||||
self.groups = ResourceGroups()
|
self.groups = ResourceGroups()
|
||||||
|
|
||||||
@ -230,7 +230,7 @@ class ResourceGroupsBackend(BaseBackend):
|
|||||||
def _validate_resource_query(resource_query):
|
def _validate_resource_query(resource_query):
|
||||||
if not resource_query:
|
if not resource_query:
|
||||||
return
|
return
|
||||||
type = resource_query["Type"]
|
query_type = resource_query["Type"]
|
||||||
query = json.loads(resource_query["Query"])
|
query = json.loads(resource_query["Query"])
|
||||||
query_keys = set(query.keys())
|
query_keys = set(query.keys())
|
||||||
invalid_json_exception = BadRequestException(
|
invalid_json_exception = BadRequestException(
|
||||||
@ -238,7 +238,7 @@ class ResourceGroupsBackend(BaseBackend):
|
|||||||
)
|
)
|
||||||
if not isinstance(query["ResourceTypeFilters"], list):
|
if not isinstance(query["ResourceTypeFilters"], list):
|
||||||
raise invalid_json_exception
|
raise invalid_json_exception
|
||||||
if type == "CLOUDFORMATION_STACK_1_0":
|
if query_type == "CLOUDFORMATION_STACK_1_0":
|
||||||
if query_keys != {"ResourceTypeFilters", "StackIdentifier"}:
|
if query_keys != {"ResourceTypeFilters", "StackIdentifier"}:
|
||||||
raise invalid_json_exception
|
raise invalid_json_exception
|
||||||
stack_identifier = query["StackIdentifier"]
|
stack_identifier = query["StackIdentifier"]
|
||||||
@ -254,7 +254,7 @@ class ResourceGroupsBackend(BaseBackend):
|
|||||||
# Once checking other resources is implemented.
|
# Once checking other resources is implemented.
|
||||||
# if stack_identifier not in self.cloudformation_backend.stacks:
|
# if stack_identifier not in self.cloudformation_backend.stacks:
|
||||||
# raise BadRequestException("Invalid query: The specified CloudFormation stack doesn't exist.")
|
# raise BadRequestException("Invalid query: The specified CloudFormation stack doesn't exist.")
|
||||||
if type == "TAG_FILTERS_1_0":
|
if query_type == "TAG_FILTERS_1_0":
|
||||||
if query_keys != {"ResourceTypeFilters", "TagFilters"}:
|
if query_keys != {"ResourceTypeFilters", "TagFilters"}:
|
||||||
raise invalid_json_exception
|
raise invalid_json_exception
|
||||||
tag_filters = query["TagFilters"]
|
tag_filters = query["TagFilters"]
|
||||||
|
@ -24,7 +24,7 @@ from moto.awslambda import lambda_backends
|
|||||||
|
|
||||||
class ResourceGroupsTaggingAPIBackend(BaseBackend):
|
class ResourceGroupsTaggingAPIBackend(BaseBackend):
|
||||||
def __init__(self, region_name=None):
|
def __init__(self, region_name=None):
|
||||||
super(ResourceGroupsTaggingAPIBackend, self).__init__()
|
super().__init__()
|
||||||
self.region_name = region_name
|
self.region_name = region_name
|
||||||
|
|
||||||
self._pages = {}
|
self._pages = {}
|
||||||
|
@ -148,8 +148,8 @@ class S3AccountPublicAccessBlockConfigQuery(ConfigQueryModel):
|
|||||||
|
|
||||||
# If a resource ID was passed in, then filter accordingly:
|
# If a resource ID was passed in, then filter accordingly:
|
||||||
if resource_ids:
|
if resource_ids:
|
||||||
for id in resource_ids:
|
for resource_id in resource_ids:
|
||||||
if account_id == id:
|
if account_id == resource_id:
|
||||||
pab = self.backends["global"].account_public_access_block
|
pab = self.backends["global"].account_public_access_block
|
||||||
break
|
break
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ class S3ClientError(RESTError):
|
|||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
kwargs.setdefault("template", "single_error")
|
kwargs.setdefault("template", "single_error")
|
||||||
self.templates["bucket_error"] = ERROR_WITH_BUCKET_NAME
|
self.templates["bucket_error"] = ERROR_WITH_BUCKET_NAME
|
||||||
super(S3ClientError, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class InvalidArgumentError(S3ClientError):
|
class InvalidArgumentError(S3ClientError):
|
||||||
@ -49,16 +49,14 @@ class InvalidArgumentError(S3ClientError):
|
|||||||
kwargs["name"] = name
|
kwargs["name"] = name
|
||||||
kwargs["value"] = value
|
kwargs["value"] = value
|
||||||
self.templates["argument_error"] = ERROR_WITH_ARGUMENT
|
self.templates["argument_error"] = ERROR_WITH_ARGUMENT
|
||||||
super(InvalidArgumentError, self).__init__(
|
super().__init__("InvalidArgument", message, *args, **kwargs)
|
||||||
"InvalidArgument", message, *args, **kwargs
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class BucketError(S3ClientError):
|
class BucketError(S3ClientError):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
kwargs.setdefault("template", "bucket_error")
|
kwargs.setdefault("template", "bucket_error")
|
||||||
self.templates["bucket_error"] = ERROR_WITH_BUCKET_NAME
|
self.templates["bucket_error"] = ERROR_WITH_BUCKET_NAME
|
||||||
super(BucketError, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class BucketAlreadyExists(BucketError):
|
class BucketAlreadyExists(BucketError):
|
||||||
@ -67,7 +65,7 @@ class BucketAlreadyExists(BucketError):
|
|||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
kwargs.setdefault("template", "bucket_error")
|
kwargs.setdefault("template", "bucket_error")
|
||||||
self.templates["bucket_error"] = ERROR_WITH_BUCKET_NAME
|
self.templates["bucket_error"] = ERROR_WITH_BUCKET_NAME
|
||||||
super(BucketAlreadyExists, self).__init__(
|
super().__init__(
|
||||||
"BucketAlreadyExists",
|
"BucketAlreadyExists",
|
||||||
(
|
(
|
||||||
"The requested bucket name is not available. The bucket "
|
"The requested bucket name is not available. The bucket "
|
||||||
@ -83,7 +81,7 @@ class MissingBucket(BucketError):
|
|||||||
code = 404
|
code = 404
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(MissingBucket, self).__init__(
|
super().__init__(
|
||||||
"NoSuchBucket", "The specified bucket does not exist", *args, **kwargs
|
"NoSuchBucket", "The specified bucket does not exist", *args, **kwargs
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -94,16 +92,14 @@ class MissingKey(S3ClientError):
|
|||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
kwargs.setdefault("template", "key_error")
|
kwargs.setdefault("template", "key_error")
|
||||||
self.templates["key_error"] = ERROR_WITH_KEY_NAME
|
self.templates["key_error"] = ERROR_WITH_KEY_NAME
|
||||||
super(MissingKey, self).__init__(
|
super().__init__("NoSuchKey", "The specified key does not exist.", **kwargs)
|
||||||
"NoSuchKey", "The specified key does not exist.", **kwargs
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class MissingVersion(S3ClientError):
|
class MissingVersion(S3ClientError):
|
||||||
code = 404
|
code = 404
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(MissingVersion, self).__init__(
|
super().__init__(
|
||||||
"NoSuchVersion", "The specified version does not exist.", *args, **kwargs
|
"NoSuchVersion", "The specified version does not exist.", *args, **kwargs
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -116,7 +112,7 @@ class InvalidVersion(S3ClientError):
|
|||||||
kwargs["name"] = "versionId"
|
kwargs["name"] = "versionId"
|
||||||
kwargs["value"] = version_id
|
kwargs["value"] = version_id
|
||||||
self.templates["argument_error"] = ERROR_WITH_ARGUMENT
|
self.templates["argument_error"] = ERROR_WITH_ARGUMENT
|
||||||
super(InvalidVersion, self).__init__(
|
super().__init__(
|
||||||
"InvalidArgument", "Invalid version id specified", *args, **kwargs
|
"InvalidArgument", "Invalid version id specified", *args, **kwargs
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -125,7 +121,7 @@ class ObjectNotInActiveTierError(S3ClientError):
|
|||||||
code = 403
|
code = 403
|
||||||
|
|
||||||
def __init__(self, key_name):
|
def __init__(self, key_name):
|
||||||
super(ObjectNotInActiveTierError, self).__init__(
|
super().__init__(
|
||||||
"ObjectNotInActiveTierError",
|
"ObjectNotInActiveTierError",
|
||||||
"The source object of the COPY operation is not in the active tier and is only stored in Amazon Glacier.",
|
"The source object of the COPY operation is not in the active tier and is only stored in Amazon Glacier.",
|
||||||
Key=key_name,
|
Key=key_name,
|
||||||
@ -136,7 +132,7 @@ class InvalidPartOrder(S3ClientError):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(InvalidPartOrder, self).__init__(
|
super().__init__(
|
||||||
"InvalidPartOrder",
|
"InvalidPartOrder",
|
||||||
(
|
(
|
||||||
"The list of parts was not in ascending order. The parts "
|
"The list of parts was not in ascending order. The parts "
|
||||||
@ -151,7 +147,7 @@ class InvalidPart(S3ClientError):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(InvalidPart, self).__init__(
|
super().__init__(
|
||||||
"InvalidPart",
|
"InvalidPart",
|
||||||
(
|
(
|
||||||
"One or more of the specified parts could not be found. "
|
"One or more of the specified parts could not be found. "
|
||||||
@ -167,7 +163,7 @@ class EntityTooSmall(S3ClientError):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(EntityTooSmall, self).__init__(
|
super().__init__(
|
||||||
"EntityTooSmall",
|
"EntityTooSmall",
|
||||||
"Your proposed upload is smaller than the minimum allowed object size.",
|
"Your proposed upload is smaller than the minimum allowed object size.",
|
||||||
*args,
|
*args,
|
||||||
@ -179,7 +175,7 @@ class InvalidRequest(S3ClientError):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, method, *args, **kwargs):
|
def __init__(self, method, *args, **kwargs):
|
||||||
super(InvalidRequest, self).__init__(
|
super().__init__(
|
||||||
"InvalidRequest",
|
"InvalidRequest",
|
||||||
"Found unsupported HTTP method in CORS config. Unsupported method is {}".format(
|
"Found unsupported HTTP method in CORS config. Unsupported method is {}".format(
|
||||||
method
|
method
|
||||||
@ -193,7 +189,7 @@ class IllegalLocationConstraintException(S3ClientError):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(IllegalLocationConstraintException, self).__init__(
|
super().__init__(
|
||||||
"IllegalLocationConstraintException",
|
"IllegalLocationConstraintException",
|
||||||
"The unspecified location constraint is incompatible for the region specific endpoint this request was sent to.",
|
"The unspecified location constraint is incompatible for the region specific endpoint this request was sent to.",
|
||||||
*args,
|
*args,
|
||||||
@ -205,7 +201,7 @@ class MalformedXML(S3ClientError):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(MalformedXML, self).__init__(
|
super().__init__(
|
||||||
"MalformedXML",
|
"MalformedXML",
|
||||||
"The XML you provided was not well-formed or did not validate against our published schema",
|
"The XML you provided was not well-formed or did not validate against our published schema",
|
||||||
*args,
|
*args,
|
||||||
@ -217,7 +213,7 @@ class MalformedACLError(S3ClientError):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(MalformedACLError, self).__init__(
|
super().__init__(
|
||||||
"MalformedACLError",
|
"MalformedACLError",
|
||||||
"The XML you provided was not well-formed or did not validate against our published schema",
|
"The XML you provided was not well-formed or did not validate against our published schema",
|
||||||
*args,
|
*args,
|
||||||
@ -229,16 +225,14 @@ class InvalidTargetBucketForLogging(S3ClientError):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, msg):
|
def __init__(self, msg):
|
||||||
super(InvalidTargetBucketForLogging, self).__init__(
|
super().__init__("InvalidTargetBucketForLogging", msg)
|
||||||
"InvalidTargetBucketForLogging", msg
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class CrossLocationLoggingProhibitted(S3ClientError):
|
class CrossLocationLoggingProhibitted(S3ClientError):
|
||||||
code = 403
|
code = 403
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(CrossLocationLoggingProhibitted, self).__init__(
|
super().__init__(
|
||||||
"CrossLocationLoggingProhibitted", "Cross S3 location logging not allowed."
|
"CrossLocationLoggingProhibitted", "Cross S3 location logging not allowed."
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -250,7 +244,7 @@ class InvalidMaxPartArgument(S3ClientError):
|
|||||||
error = "Argument {} must be an integer between {} and {}".format(
|
error = "Argument {} must be an integer between {} and {}".format(
|
||||||
arg, min_val, max_val
|
arg, min_val, max_val
|
||||||
)
|
)
|
||||||
super(InvalidMaxPartArgument, self).__init__("InvalidArgument", error)
|
super().__init__("InvalidArgument", error)
|
||||||
|
|
||||||
|
|
||||||
class InvalidMaxPartNumberArgument(InvalidArgumentError):
|
class InvalidMaxPartNumberArgument(InvalidArgumentError):
|
||||||
@ -273,7 +267,7 @@ class InvalidNotificationARN(S3ClientError):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(InvalidNotificationARN, self).__init__(
|
super().__init__(
|
||||||
"InvalidArgument", "The ARN is not well formed", *args, **kwargs
|
"InvalidArgument", "The ARN is not well formed", *args, **kwargs
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -282,7 +276,7 @@ class InvalidNotificationDestination(S3ClientError):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(InvalidNotificationDestination, self).__init__(
|
super().__init__(
|
||||||
"InvalidArgument",
|
"InvalidArgument",
|
||||||
"The notification destination service region is not valid for the bucket location constraint",
|
"The notification destination service region is not valid for the bucket location constraint",
|
||||||
*args,
|
*args,
|
||||||
@ -294,7 +288,7 @@ class InvalidNotificationEvent(S3ClientError):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(InvalidNotificationEvent, self).__init__(
|
super().__init__(
|
||||||
"InvalidArgument",
|
"InvalidArgument",
|
||||||
"The event is not supported for notifications",
|
"The event is not supported for notifications",
|
||||||
*args,
|
*args,
|
||||||
@ -306,7 +300,7 @@ class InvalidStorageClass(S3ClientError):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(InvalidStorageClass, self).__init__(
|
super().__init__(
|
||||||
"InvalidStorageClass",
|
"InvalidStorageClass",
|
||||||
"The storage class you specified is not valid",
|
"The storage class you specified is not valid",
|
||||||
*args,
|
*args,
|
||||||
@ -318,7 +312,7 @@ class InvalidBucketName(S3ClientError):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(InvalidBucketName, self).__init__(
|
super().__init__(
|
||||||
"InvalidBucketName", "The specified bucket is not valid.", *args, **kwargs
|
"InvalidBucketName", "The specified bucket is not valid.", *args, **kwargs
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -327,7 +321,7 @@ class DuplicateTagKeys(S3ClientError):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(DuplicateTagKeys, self).__init__(
|
super().__init__(
|
||||||
"InvalidTag",
|
"InvalidTag",
|
||||||
"Cannot provide multiple Tags with the same key",
|
"Cannot provide multiple Tags with the same key",
|
||||||
*args,
|
*args,
|
||||||
@ -339,25 +333,21 @@ class S3AccessDeniedError(S3ClientError):
|
|||||||
code = 403
|
code = 403
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(S3AccessDeniedError, self).__init__(
|
super().__init__("AccessDenied", "Access Denied", *args, **kwargs)
|
||||||
"AccessDenied", "Access Denied", *args, **kwargs
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class BucketAccessDeniedError(BucketError):
|
class BucketAccessDeniedError(BucketError):
|
||||||
code = 403
|
code = 403
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(BucketAccessDeniedError, self).__init__(
|
super().__init__("AccessDenied", "Access Denied", *args, **kwargs)
|
||||||
"AccessDenied", "Access Denied", *args, **kwargs
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class S3InvalidTokenError(S3ClientError):
|
class S3InvalidTokenError(S3ClientError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(S3InvalidTokenError, self).__init__(
|
super().__init__(
|
||||||
"InvalidToken",
|
"InvalidToken",
|
||||||
"The provided token is malformed or otherwise invalid.",
|
"The provided token is malformed or otherwise invalid.",
|
||||||
*args,
|
*args,
|
||||||
@ -369,7 +359,7 @@ class S3AclAndGrantError(S3ClientError):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(S3AclAndGrantError, self).__init__(
|
super().__init__(
|
||||||
"InvalidRequest",
|
"InvalidRequest",
|
||||||
"Specifying both Canned ACLs and Header Grants is not allowed",
|
"Specifying both Canned ACLs and Header Grants is not allowed",
|
||||||
*args,
|
*args,
|
||||||
@ -381,7 +371,7 @@ class BucketInvalidTokenError(BucketError):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(BucketInvalidTokenError, self).__init__(
|
super().__init__(
|
||||||
"InvalidToken",
|
"InvalidToken",
|
||||||
"The provided token is malformed or otherwise invalid.",
|
"The provided token is malformed or otherwise invalid.",
|
||||||
*args,
|
*args,
|
||||||
@ -393,7 +383,7 @@ class S3InvalidAccessKeyIdError(S3ClientError):
|
|||||||
code = 403
|
code = 403
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(S3InvalidAccessKeyIdError, self).__init__(
|
super().__init__(
|
||||||
"InvalidAccessKeyId",
|
"InvalidAccessKeyId",
|
||||||
"The AWS Access Key Id you provided does not exist in our records.",
|
"The AWS Access Key Id you provided does not exist in our records.",
|
||||||
*args,
|
*args,
|
||||||
@ -405,7 +395,7 @@ class BucketInvalidAccessKeyIdError(S3ClientError):
|
|||||||
code = 403
|
code = 403
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(BucketInvalidAccessKeyIdError, self).__init__(
|
super().__init__(
|
||||||
"InvalidAccessKeyId",
|
"InvalidAccessKeyId",
|
||||||
"The AWS Access Key Id you provided does not exist in our records.",
|
"The AWS Access Key Id you provided does not exist in our records.",
|
||||||
*args,
|
*args,
|
||||||
@ -417,7 +407,7 @@ class S3SignatureDoesNotMatchError(S3ClientError):
|
|||||||
code = 403
|
code = 403
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(S3SignatureDoesNotMatchError, self).__init__(
|
super().__init__(
|
||||||
"SignatureDoesNotMatch",
|
"SignatureDoesNotMatch",
|
||||||
"The request signature we calculated does not match the signature you provided. Check your key and signing method.",
|
"The request signature we calculated does not match the signature you provided. Check your key and signing method.",
|
||||||
*args,
|
*args,
|
||||||
@ -429,7 +419,7 @@ class BucketSignatureDoesNotMatchError(S3ClientError):
|
|||||||
code = 403
|
code = 403
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(BucketSignatureDoesNotMatchError, self).__init__(
|
super().__init__(
|
||||||
"SignatureDoesNotMatch",
|
"SignatureDoesNotMatch",
|
||||||
"The request signature we calculated does not match the signature you provided. Check your key and signing method.",
|
"The request signature we calculated does not match the signature you provided. Check your key and signing method.",
|
||||||
*args,
|
*args,
|
||||||
@ -441,7 +431,7 @@ class NoSuchPublicAccessBlockConfiguration(S3ClientError):
|
|||||||
code = 404
|
code = 404
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(NoSuchPublicAccessBlockConfiguration, self).__init__(
|
super().__init__(
|
||||||
"NoSuchPublicAccessBlockConfiguration",
|
"NoSuchPublicAccessBlockConfiguration",
|
||||||
"The public access block configuration was not found",
|
"The public access block configuration was not found",
|
||||||
*args,
|
*args,
|
||||||
@ -453,7 +443,7 @@ class InvalidPublicAccessBlockConfiguration(S3ClientError):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(InvalidPublicAccessBlockConfiguration, self).__init__(
|
super().__init__(
|
||||||
"InvalidRequest",
|
"InvalidRequest",
|
||||||
"Must specify at least one configuration.",
|
"Must specify at least one configuration.",
|
||||||
*args,
|
*args,
|
||||||
@ -465,16 +455,14 @@ class WrongPublicAccessBlockAccountIdError(S3ClientError):
|
|||||||
code = 403
|
code = 403
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(WrongPublicAccessBlockAccountIdError, self).__init__(
|
super().__init__("AccessDenied", "Access Denied")
|
||||||
"AccessDenied", "Access Denied"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class NoSystemTags(S3ClientError):
|
class NoSystemTags(S3ClientError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(NoSystemTags, self).__init__(
|
super().__init__(
|
||||||
"InvalidTag", "System tags cannot be added/updated by requester"
|
"InvalidTag", "System tags cannot be added/updated by requester"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -486,7 +474,7 @@ class NoSuchUpload(S3ClientError):
|
|||||||
kwargs.setdefault("template", "error_uploadid")
|
kwargs.setdefault("template", "error_uploadid")
|
||||||
kwargs["upload_id"] = upload_id
|
kwargs["upload_id"] = upload_id
|
||||||
self.templates["error_uploadid"] = ERROR_WITH_UPLOADID
|
self.templates["error_uploadid"] = ERROR_WITH_UPLOADID
|
||||||
super(NoSuchUpload, self).__init__(
|
super().__init__(
|
||||||
"NoSuchUpload",
|
"NoSuchUpload",
|
||||||
"The specified upload does not exist. The upload ID may be invalid, or the upload may have been aborted or completed.",
|
"The specified upload does not exist. The upload ID may be invalid, or the upload may have been aborted or completed.",
|
||||||
*args,
|
*args,
|
||||||
@ -500,7 +488,7 @@ class PreconditionFailed(S3ClientError):
|
|||||||
def __init__(self, failed_condition, **kwargs):
|
def __init__(self, failed_condition, **kwargs):
|
||||||
kwargs.setdefault("template", "condition_error")
|
kwargs.setdefault("template", "condition_error")
|
||||||
self.templates["condition_error"] = ERROR_WITH_CONDITION_NAME
|
self.templates["condition_error"] = ERROR_WITH_CONDITION_NAME
|
||||||
super(PreconditionFailed, self).__init__(
|
super().__init__(
|
||||||
"PreconditionFailed",
|
"PreconditionFailed",
|
||||||
"At least one of the pre-conditions you specified did not hold",
|
"At least one of the pre-conditions you specified did not hold",
|
||||||
condition=failed_condition,
|
condition=failed_condition,
|
||||||
@ -514,7 +502,7 @@ class InvalidRange(S3ClientError):
|
|||||||
def __init__(self, range_requested, actual_size, **kwargs):
|
def __init__(self, range_requested, actual_size, **kwargs):
|
||||||
kwargs.setdefault("template", "range_error")
|
kwargs.setdefault("template", "range_error")
|
||||||
self.templates["range_error"] = ERROR_WITH_RANGE
|
self.templates["range_error"] = ERROR_WITH_RANGE
|
||||||
super(InvalidRange, self).__init__(
|
super().__init__(
|
||||||
"InvalidRange",
|
"InvalidRange",
|
||||||
"The requested range is not satisfiable",
|
"The requested range is not satisfiable",
|
||||||
range_requested=range_requested,
|
range_requested=range_requested,
|
||||||
@ -527,7 +515,7 @@ class InvalidContinuationToken(S3ClientError):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(InvalidContinuationToken, self).__init__(
|
super().__init__(
|
||||||
"InvalidArgument",
|
"InvalidArgument",
|
||||||
"The continuation token provided is incorrect",
|
"The continuation token provided is incorrect",
|
||||||
*args,
|
*args,
|
||||||
@ -541,7 +529,7 @@ class InvalidObjectState(BucketError):
|
|||||||
def __init__(self, storage_class, **kwargs):
|
def __init__(self, storage_class, **kwargs):
|
||||||
kwargs.setdefault("template", "storage_error")
|
kwargs.setdefault("template", "storage_error")
|
||||||
self.templates["storage_error"] = ERROR_WITH_STORAGE_CLASS
|
self.templates["storage_error"] = ERROR_WITH_STORAGE_CLASS
|
||||||
super(BucketError, self).__init__(
|
super().__init__(
|
||||||
error_type="InvalidObjectState",
|
error_type="InvalidObjectState",
|
||||||
message="The operation is not valid for the object's storage class",
|
message="The operation is not valid for the object's storage class",
|
||||||
storage_class=storage_class,
|
storage_class=storage_class,
|
||||||
@ -553,41 +541,35 @@ class LockNotEnabled(S3ClientError):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(LockNotEnabled, self).__init__(
|
super().__init__("InvalidRequest", "Bucket is missing ObjectLockConfiguration")
|
||||||
"InvalidRequest", "Bucket is missing ObjectLockConfiguration"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class AccessDeniedByLock(S3ClientError):
|
class AccessDeniedByLock(S3ClientError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(AccessDeniedByLock, self).__init__("AccessDenied", "Access Denied")
|
super().__init__("AccessDenied", "Access Denied")
|
||||||
|
|
||||||
|
|
||||||
class InvalidContentMD5(S3ClientError):
|
class InvalidContentMD5(S3ClientError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(InvalidContentMD5, self).__init__(
|
super().__init__("InvalidContentMD5", "Content MD5 header is invalid")
|
||||||
"InvalidContentMD5", "Content MD5 header is invalid"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class BucketNeedsToBeNew(S3ClientError):
|
class BucketNeedsToBeNew(S3ClientError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(BucketNeedsToBeNew, self).__init__(
|
super().__init__("InvalidBucket", "Bucket needs to be empty")
|
||||||
"InvalidBucket", "Bucket needs to be empty"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class BucketMustHaveLockeEnabled(S3ClientError):
|
class BucketMustHaveLockeEnabled(S3ClientError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(BucketMustHaveLockeEnabled, self).__init__(
|
super().__init__(
|
||||||
"InvalidBucketState",
|
"InvalidBucketState",
|
||||||
"Object Lock configuration cannot be enabled on existing buckets",
|
"Object Lock configuration cannot be enabled on existing buckets",
|
||||||
)
|
)
|
||||||
@ -597,7 +579,7 @@ class InvalidFilterRuleName(InvalidArgumentError):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, value, *args, **kwargs):
|
def __init__(self, value, *args, **kwargs):
|
||||||
super(InvalidFilterRuleName, self).__init__(
|
super().__init__(
|
||||||
"filter rule name must be either prefix or suffix",
|
"filter rule name must be either prefix or suffix",
|
||||||
"FilterRule.Name",
|
"FilterRule.Name",
|
||||||
value,
|
value,
|
||||||
@ -610,7 +592,7 @@ class InvalidTagError(S3ClientError):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, value, *args, **kwargs):
|
def __init__(self, value, *args, **kwargs):
|
||||||
super(InvalidTagError, self).__init__(
|
super().__init__(
|
||||||
"InvalidTag", value, *args, **kwargs,
|
"InvalidTag", value, *args, **kwargs,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -619,7 +601,7 @@ class ObjectLockConfigurationNotFoundError(S3ClientError):
|
|||||||
code = 404
|
code = 404
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(ObjectLockConfigurationNotFoundError, self).__init__(
|
super().__init__(
|
||||||
"ObjectLockConfigurationNotFoundError",
|
"ObjectLockConfigurationNotFoundError",
|
||||||
"Object Lock configuration does not exist for this bucket",
|
"Object Lock configuration does not exist for this bucket",
|
||||||
)
|
)
|
||||||
|
@ -392,8 +392,8 @@ class FakeMultipart(BaseModel):
|
|||||||
|
|
||||||
|
|
||||||
class FakeGrantee(BaseModel):
|
class FakeGrantee(BaseModel):
|
||||||
def __init__(self, id="", uri="", display_name=""):
|
def __init__(self, grantee_id="", uri="", display_name=""):
|
||||||
self.id = id
|
self.id = grantee_id
|
||||||
self.uri = uri
|
self.uri = uri
|
||||||
self.display_name = display_name
|
self.display_name = display_name
|
||||||
|
|
||||||
@ -512,7 +512,7 @@ class FakeAcl(BaseModel):
|
|||||||
|
|
||||||
|
|
||||||
def get_canned_acl(acl):
|
def get_canned_acl(acl):
|
||||||
owner_grantee = FakeGrantee(id=OWNER)
|
owner_grantee = FakeGrantee(grantee_id=OWNER)
|
||||||
grants = [FakeGrant([owner_grantee], [PERMISSION_FULL_CONTROL])]
|
grants = [FakeGrant([owner_grantee], [PERMISSION_FULL_CONTROL])]
|
||||||
if acl == "private":
|
if acl == "private":
|
||||||
pass # no other permissions
|
pass # no other permissions
|
||||||
@ -590,7 +590,7 @@ class LifecycleAndFilter(BaseModel):
|
|||||||
class LifecycleRule(BaseModel):
|
class LifecycleRule(BaseModel):
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
id=None,
|
rule_id=None,
|
||||||
prefix=None,
|
prefix=None,
|
||||||
lc_filter=None,
|
lc_filter=None,
|
||||||
status=None,
|
status=None,
|
||||||
@ -605,7 +605,7 @@ class LifecycleRule(BaseModel):
|
|||||||
nvt_storage_class=None,
|
nvt_storage_class=None,
|
||||||
aimu_days=None,
|
aimu_days=None,
|
||||||
):
|
):
|
||||||
self.id = id
|
self.id = rule_id
|
||||||
self.prefix = prefix
|
self.prefix = prefix
|
||||||
self.filter = lc_filter
|
self.filter = lc_filter
|
||||||
self.status = status
|
self.status = status
|
||||||
@ -689,14 +689,10 @@ class CorsRule(BaseModel):
|
|||||||
|
|
||||||
|
|
||||||
class Notification(BaseModel):
|
class Notification(BaseModel):
|
||||||
def __init__(self, arn, events, filters=None, id=None):
|
def __init__(self, arn, events, filters=None, notification_id=None):
|
||||||
self.id = (
|
self.id = notification_id or "".join(
|
||||||
id
|
|
||||||
if id
|
|
||||||
else "".join(
|
|
||||||
random.choice(string.ascii_letters + string.digits) for _ in range(50)
|
random.choice(string.ascii_letters + string.digits) for _ in range(50)
|
||||||
)
|
)
|
||||||
)
|
|
||||||
self.arn = arn
|
self.arn = arn
|
||||||
self.events = events
|
self.events = events
|
||||||
self.filters = filters if filters else {}
|
self.filters = filters if filters else {}
|
||||||
@ -730,7 +726,10 @@ class NotificationConfiguration(BaseModel):
|
|||||||
self.topic = (
|
self.topic = (
|
||||||
[
|
[
|
||||||
Notification(
|
Notification(
|
||||||
t["Topic"], t["Event"], filters=t.get("Filter"), id=t.get("Id")
|
t["Topic"],
|
||||||
|
t["Event"],
|
||||||
|
filters=t.get("Filter"),
|
||||||
|
notification_id=t.get("Id"),
|
||||||
)
|
)
|
||||||
for t in topic
|
for t in topic
|
||||||
]
|
]
|
||||||
@ -740,7 +739,10 @@ class NotificationConfiguration(BaseModel):
|
|||||||
self.queue = (
|
self.queue = (
|
||||||
[
|
[
|
||||||
Notification(
|
Notification(
|
||||||
q["Queue"], q["Event"], filters=q.get("Filter"), id=q.get("Id")
|
q["Queue"],
|
||||||
|
q["Event"],
|
||||||
|
filters=q.get("Filter"),
|
||||||
|
notification_id=q.get("Id"),
|
||||||
)
|
)
|
||||||
for q in queue
|
for q in queue
|
||||||
]
|
]
|
||||||
@ -753,7 +755,7 @@ class NotificationConfiguration(BaseModel):
|
|||||||
c["CloudFunction"],
|
c["CloudFunction"],
|
||||||
c["Event"],
|
c["Event"],
|
||||||
filters=c.get("Filter"),
|
filters=c.get("Filter"),
|
||||||
id=c.get("Id"),
|
notification_id=c.get("Id"),
|
||||||
)
|
)
|
||||||
for c in cloud_function
|
for c in cloud_function
|
||||||
]
|
]
|
||||||
@ -972,7 +974,7 @@ class FakeBucket(CloudFormationModel):
|
|||||||
|
|
||||||
self.rules.append(
|
self.rules.append(
|
||||||
LifecycleRule(
|
LifecycleRule(
|
||||||
id=rule.get("ID"),
|
rule_id=rule.get("ID"),
|
||||||
prefix=top_level_prefix,
|
prefix=top_level_prefix,
|
||||||
lc_filter=lc_filter,
|
lc_filter=lc_filter,
|
||||||
status=rule["Status"],
|
status=rule["Status"],
|
||||||
|
@ -169,7 +169,7 @@ def is_delete_keys(request, path, bucket_name):
|
|||||||
|
|
||||||
class ResponseObject(_TemplateEnvironmentMixin, ActionAuthenticatorMixin):
|
class ResponseObject(_TemplateEnvironmentMixin, ActionAuthenticatorMixin):
|
||||||
def __init__(self, backend):
|
def __init__(self, backend):
|
||||||
super(ResponseObject, self).__init__()
|
super().__init__()
|
||||||
self.backend = backend
|
self.backend = backend
|
||||||
self.method = ""
|
self.method = ""
|
||||||
self.path = ""
|
self.path = ""
|
||||||
@ -1742,7 +1742,7 @@ class ResponseObject(_TemplateEnvironmentMixin, ActionAuthenticatorMixin):
|
|||||||
FakeGrant(
|
FakeGrant(
|
||||||
[
|
[
|
||||||
FakeGrantee(
|
FakeGrantee(
|
||||||
id=grant["Grantee"].get("ID", ""),
|
grantee_id=grant["Grantee"].get("ID", ""),
|
||||||
display_name=grant["Grantee"].get("DisplayName", ""),
|
display_name=grant["Grantee"].get("DisplayName", ""),
|
||||||
uri=grant["Grantee"].get("URI", ""),
|
uri=grant["Grantee"].get("URI", ""),
|
||||||
)
|
)
|
||||||
@ -1776,7 +1776,7 @@ class ResponseObject(_TemplateEnvironmentMixin, ActionAuthenticatorMixin):
|
|||||||
'([^=]+)="?([^"]+)"?', key_and_value.strip()
|
'([^=]+)="?([^"]+)"?', key_and_value.strip()
|
||||||
).groups()
|
).groups()
|
||||||
if key.lower() == "id":
|
if key.lower() == "id":
|
||||||
grantees.append(FakeGrantee(id=value))
|
grantees.append(FakeGrantee(grantee_id=value))
|
||||||
else:
|
else:
|
||||||
grantees.append(FakeGrantee(uri=value))
|
grantees.append(FakeGrantee(uri=value))
|
||||||
grants.append(FakeGrant(grantees, [permission]))
|
grants.append(FakeGrant(grantees, [permission]))
|
||||||
@ -2012,7 +2012,7 @@ class ResponseObject(_TemplateEnvironmentMixin, ActionAuthenticatorMixin):
|
|||||||
template = self.response_template(S3_DELETE_KEY_TAGGING_RESPONSE)
|
template = self.response_template(S3_DELETE_KEY_TAGGING_RESPONSE)
|
||||||
return 204, {}, template.render(version_id=version_id)
|
return 204, {}, template.render(version_id=version_id)
|
||||||
bypass = headers.get("X-Amz-Bypass-Governance-Retention")
|
bypass = headers.get("X-Amz-Bypass-Governance-Retention")
|
||||||
success, response_meta = self.backend.delete_object(
|
_, response_meta = self.backend.delete_object(
|
||||||
bucket_name, key_name, version_id=version_id, bypass=bypass
|
bucket_name, key_name, version_id=version_id, bypass=bypass
|
||||||
)
|
)
|
||||||
response_headers = {}
|
response_headers = {}
|
||||||
|
@ -72,7 +72,7 @@ def parse_region_from_url(url):
|
|||||||
def metadata_from_headers(headers):
|
def metadata_from_headers(headers):
|
||||||
metadata = CaseInsensitiveDict()
|
metadata = CaseInsensitiveDict()
|
||||||
meta_regex = re.compile(r"^x-amz-meta-([a-zA-Z0-9\-_.]+)$", flags=re.IGNORECASE)
|
meta_regex = re.compile(r"^x-amz-meta-([a-zA-Z0-9\-_.]+)$", flags=re.IGNORECASE)
|
||||||
for header, value in headers.items():
|
for header in headers.keys():
|
||||||
if isinstance(header, str):
|
if isinstance(header, str):
|
||||||
result = meta_regex.match(header)
|
result = meta_regex.match(header)
|
||||||
meta_key = None
|
meta_key = None
|
||||||
@ -106,7 +106,7 @@ class _VersionedKeyStore(dict):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __sgetitem__(self, key):
|
def __sgetitem__(self, key):
|
||||||
return super(_VersionedKeyStore, self).__getitem__(key)
|
return super().__getitem__(key)
|
||||||
|
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
return self.__sgetitem__(key)[-1]
|
return self.__sgetitem__(key)[-1]
|
||||||
@ -118,7 +118,7 @@ class _VersionedKeyStore(dict):
|
|||||||
except (KeyError, IndexError):
|
except (KeyError, IndexError):
|
||||||
current = [value]
|
current = [value]
|
||||||
|
|
||||||
super(_VersionedKeyStore, self).__setitem__(key, current)
|
super().__setitem__(key, current)
|
||||||
|
|
||||||
def get(self, key, default=None):
|
def get(self, key, default=None):
|
||||||
try:
|
try:
|
||||||
@ -140,7 +140,7 @@ class _VersionedKeyStore(dict):
|
|||||||
elif not isinstance(list_, list):
|
elif not isinstance(list_, list):
|
||||||
list_ = [list_]
|
list_ = [list_]
|
||||||
|
|
||||||
super(_VersionedKeyStore, self).__setitem__(key, list_)
|
super().__setitem__(key, list_)
|
||||||
|
|
||||||
def _iteritems(self):
|
def _iteritems(self):
|
||||||
for key in self._self_iterable():
|
for key in self._self_iterable():
|
||||||
@ -168,14 +168,3 @@ class _VersionedKeyStore(dict):
|
|||||||
items = iteritems = _iteritems
|
items = iteritems = _iteritems
|
||||||
lists = iterlists = _iterlists
|
lists = iterlists = _iterlists
|
||||||
values = itervalues = _itervalues
|
values = itervalues = _itervalues
|
||||||
|
|
||||||
if sys.version_info[0] < 3:
|
|
||||||
|
|
||||||
def items(self):
|
|
||||||
return list(self.iteritems())
|
|
||||||
|
|
||||||
def values(self):
|
|
||||||
return list(self.itervalues())
|
|
||||||
|
|
||||||
def lists(self):
|
|
||||||
return list(self.iterlists())
|
|
||||||
|
@ -9,28 +9,26 @@ class SagemakerClientError(RESTError):
|
|||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
kwargs.setdefault("template", "single_error")
|
kwargs.setdefault("template", "single_error")
|
||||||
self.templates["model_error"] = ERROR_WITH_MODEL_NAME
|
self.templates["model_error"] = ERROR_WITH_MODEL_NAME
|
||||||
super(SagemakerClientError, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class ModelError(RESTError):
|
class ModelError(RESTError):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
kwargs.setdefault("template", "model_error")
|
kwargs.setdefault("template", "model_error")
|
||||||
self.templates["model_error"] = ERROR_WITH_MODEL_NAME
|
self.templates["model_error"] = ERROR_WITH_MODEL_NAME
|
||||||
super(ModelError, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class MissingModel(ModelError):
|
class MissingModel(ModelError):
|
||||||
code = 404
|
code = 404
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(MissingModel, self).__init__(
|
super().__init__("NoSuchModel", "Could not find model", *args, **kwargs)
|
||||||
"NoSuchModel", "Could not find model", *args, **kwargs
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class ValidationError(JsonRESTError):
|
class ValidationError(JsonRESTError):
|
||||||
def __init__(self, message, **kwargs):
|
def __init__(self, message, **kwargs):
|
||||||
super(ValidationError, self).__init__("ValidationException", message, **kwargs)
|
super().__init__("ValidationException", message, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class AWSValidationException(AWSError):
|
class AWSValidationException(AWSError):
|
||||||
@ -39,4 +37,4 @@ class AWSValidationException(AWSError):
|
|||||||
|
|
||||||
class ResourceNotFound(JsonRESTError):
|
class ResourceNotFound(JsonRESTError):
|
||||||
def __init__(self, message, **kwargs):
|
def __init__(self, message, **kwargs):
|
||||||
super(ResourceNotFound, self).__init__(__class__.__name__, message, **kwargs)
|
super().__init__(__class__.__name__, message, **kwargs)
|
||||||
|
@ -42,7 +42,7 @@ PAGINATION_MODEL = {
|
|||||||
class BaseObject(BaseModel):
|
class BaseObject(BaseModel):
|
||||||
def camelCase(self, key):
|
def camelCase(self, key):
|
||||||
words = []
|
words = []
|
||||||
for i, word in enumerate(key.split("_")):
|
for word in key.split("_"):
|
||||||
words.append(word.title())
|
words.append(word.title())
|
||||||
return "".join(words)
|
return "".join(words)
|
||||||
|
|
||||||
@ -541,13 +541,13 @@ class Model(BaseObject, CloudFormationModel):
|
|||||||
execution_role_arn,
|
execution_role_arn,
|
||||||
primary_container,
|
primary_container,
|
||||||
vpc_config,
|
vpc_config,
|
||||||
containers=[],
|
containers=None,
|
||||||
tags=[],
|
tags=None,
|
||||||
):
|
):
|
||||||
self.model_name = model_name
|
self.model_name = model_name
|
||||||
self.creation_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
self.creation_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||||
self.containers = containers
|
self.containers = containers or []
|
||||||
self.tags = tags
|
self.tags = tags or []
|
||||||
self.enable_network_isolation = False
|
self.enable_network_isolation = False
|
||||||
self.vpc_config = vpc_config
|
self.vpc_config = vpc_config
|
||||||
self.primary_container = primary_container
|
self.primary_container = primary_container
|
||||||
|
@ -8,15 +8,13 @@ class SecretsManagerClientError(JsonRESTError):
|
|||||||
class ResourceNotFoundException(SecretsManagerClientError):
|
class ResourceNotFoundException(SecretsManagerClientError):
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
self.code = 404
|
self.code = 404
|
||||||
super(ResourceNotFoundException, self).__init__(
|
super().__init__("ResourceNotFoundException", message)
|
||||||
"ResourceNotFoundException", message
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class SecretNotFoundException(SecretsManagerClientError):
|
class SecretNotFoundException(SecretsManagerClientError):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.code = 404
|
self.code = 404
|
||||||
super(SecretNotFoundException, self).__init__(
|
super().__init__(
|
||||||
"ResourceNotFoundException",
|
"ResourceNotFoundException",
|
||||||
message="Secrets Manager can't find the specified secret.",
|
message="Secrets Manager can't find the specified secret.",
|
||||||
)
|
)
|
||||||
@ -25,7 +23,7 @@ class SecretNotFoundException(SecretsManagerClientError):
|
|||||||
class SecretHasNoValueException(SecretsManagerClientError):
|
class SecretHasNoValueException(SecretsManagerClientError):
|
||||||
def __init__(self, version_stage):
|
def __init__(self, version_stage):
|
||||||
self.code = 404
|
self.code = 404
|
||||||
super(SecretHasNoValueException, self).__init__(
|
super().__init__(
|
||||||
"ResourceNotFoundException",
|
"ResourceNotFoundException",
|
||||||
message="Secrets Manager can't find the specified secret "
|
message="Secrets Manager can't find the specified secret "
|
||||||
"value for staging label: {}".format(version_stage),
|
"value for staging label: {}".format(version_stage),
|
||||||
@ -34,30 +32,24 @@ class SecretHasNoValueException(SecretsManagerClientError):
|
|||||||
|
|
||||||
class ClientError(SecretsManagerClientError):
|
class ClientError(SecretsManagerClientError):
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(ClientError, self).__init__("InvalidParameterValue", message)
|
super().__init__("InvalidParameterValue", message)
|
||||||
|
|
||||||
|
|
||||||
class InvalidParameterException(SecretsManagerClientError):
|
class InvalidParameterException(SecretsManagerClientError):
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(InvalidParameterException, self).__init__(
|
super().__init__("InvalidParameterException", message)
|
||||||
"InvalidParameterException", message
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class ResourceExistsException(SecretsManagerClientError):
|
class ResourceExistsException(SecretsManagerClientError):
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(ResourceExistsException, self).__init__(
|
super().__init__("ResourceExistsException", message)
|
||||||
"ResourceExistsException", message
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class InvalidRequestException(SecretsManagerClientError):
|
class InvalidRequestException(SecretsManagerClientError):
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(InvalidRequestException, self).__init__(
|
super().__init__("InvalidRequestException", message)
|
||||||
"InvalidRequestException", message
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class ValidationException(SecretsManagerClientError):
|
class ValidationException(SecretsManagerClientError):
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(ValidationException, self).__init__("ValidationException", message)
|
super().__init__("ValidationException", message)
|
||||||
|
@ -14,7 +14,7 @@ def tag_value(secret, tag_values):
|
|||||||
return _matcher(tag_values, [tag["Value"] for tag in secret.tags])
|
return _matcher(tag_values, [tag["Value"] for tag in secret.tags])
|
||||||
|
|
||||||
|
|
||||||
def all(secret, values):
|
def filter_all(secret, values):
|
||||||
attributes = (
|
attributes = (
|
||||||
[secret.name, secret.description]
|
[secret.name, secret.description]
|
||||||
+ [tag["Key"] for tag in secret.tags]
|
+ [tag["Key"] for tag in secret.tags]
|
||||||
@ -37,8 +37,8 @@ def _matcher(patterns, strings):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def _match_pattern(pattern, str):
|
def _match_pattern(pattern, value):
|
||||||
for word in pattern.split(" "):
|
for word in pattern.split(" "):
|
||||||
if word not in str:
|
if word not in value:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
@ -17,11 +17,11 @@ from .exceptions import (
|
|||||||
ClientError,
|
ClientError,
|
||||||
)
|
)
|
||||||
from .utils import random_password, secret_arn, get_secret_name_from_arn
|
from .utils import random_password, secret_arn, get_secret_name_from_arn
|
||||||
from .list_secrets.filters import all, tag_key, tag_value, description, name
|
from .list_secrets.filters import filter_all, tag_key, tag_value, description, name
|
||||||
|
|
||||||
|
|
||||||
_filter_functions = {
|
_filter_functions = {
|
||||||
"all": all,
|
"all": filter_all,
|
||||||
"name": name,
|
"name": name,
|
||||||
"description": description,
|
"description": description,
|
||||||
"tag-key": tag_key,
|
"tag-key": tag_key,
|
||||||
@ -57,7 +57,7 @@ class FakeSecret:
|
|||||||
secret_string=None,
|
secret_string=None,
|
||||||
secret_binary=None,
|
secret_binary=None,
|
||||||
description=None,
|
description=None,
|
||||||
tags=[],
|
tags=None,
|
||||||
kms_key_id=None,
|
kms_key_id=None,
|
||||||
version_id=None,
|
version_id=None,
|
||||||
version_stages=None,
|
version_stages=None,
|
||||||
@ -68,7 +68,7 @@ class FakeSecret:
|
|||||||
self.secret_string = secret_string
|
self.secret_string = secret_string
|
||||||
self.secret_binary = secret_binary
|
self.secret_binary = secret_binary
|
||||||
self.description = description
|
self.description = description
|
||||||
self.tags = tags
|
self.tags = tags or []
|
||||||
self.kms_key_id = kms_key_id
|
self.kms_key_id = kms_key_id
|
||||||
self.version_id = version_id
|
self.version_id = version_id
|
||||||
self.version_stages = version_stages
|
self.version_stages = version_stages
|
||||||
@ -77,9 +77,9 @@ class FakeSecret:
|
|||||||
self.auto_rotate_after_days = 0
|
self.auto_rotate_after_days = 0
|
||||||
self.deleted_date = None
|
self.deleted_date = None
|
||||||
|
|
||||||
def update(self, description=None, tags=[], kms_key_id=None):
|
def update(self, description=None, tags=None, kms_key_id=None):
|
||||||
self.description = description
|
self.description = description
|
||||||
self.tags = tags
|
self.tags = tags or []
|
||||||
|
|
||||||
if kms_key_id is not None:
|
if kms_key_id is not None:
|
||||||
self.kms_key_id = kms_key_id
|
self.kms_key_id = kms_key_id
|
||||||
@ -153,11 +153,11 @@ class FakeSecret:
|
|||||||
class SecretsStore(dict):
|
class SecretsStore(dict):
|
||||||
def __setitem__(self, key, value):
|
def __setitem__(self, key, value):
|
||||||
new_key = get_secret_name_from_arn(key)
|
new_key = get_secret_name_from_arn(key)
|
||||||
super(SecretsStore, self).__setitem__(new_key, value)
|
super().__setitem__(new_key, value)
|
||||||
|
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
new_key = get_secret_name_from_arn(key)
|
new_key = get_secret_name_from_arn(key)
|
||||||
return super(SecretsStore, self).__getitem__(new_key)
|
return super().__getitem__(new_key)
|
||||||
|
|
||||||
def __contains__(self, key):
|
def __contains__(self, key):
|
||||||
new_key = get_secret_name_from_arn(key)
|
new_key = get_secret_name_from_arn(key)
|
||||||
@ -165,12 +165,12 @@ class SecretsStore(dict):
|
|||||||
|
|
||||||
def pop(self, key, *args, **kwargs):
|
def pop(self, key, *args, **kwargs):
|
||||||
new_key = get_secret_name_from_arn(key)
|
new_key = get_secret_name_from_arn(key)
|
||||||
return super(SecretsStore, self).pop(new_key, *args, **kwargs)
|
return super().pop(new_key, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class SecretsManagerBackend(BaseBackend):
|
class SecretsManagerBackend(BaseBackend):
|
||||||
def __init__(self, region_name=None, **kwargs):
|
def __init__(self, region_name=None, **kwargs):
|
||||||
super(SecretsManagerBackend, self).__init__()
|
super().__init__()
|
||||||
self.region = region_name
|
self.region = region_name
|
||||||
self.secrets = SecretsStore()
|
self.secrets = SecretsStore()
|
||||||
|
|
||||||
@ -298,7 +298,7 @@ class SecretsManagerBackend(BaseBackend):
|
|||||||
secret_string=None,
|
secret_string=None,
|
||||||
secret_binary=None,
|
secret_binary=None,
|
||||||
description=None,
|
description=None,
|
||||||
tags=[],
|
tags=None,
|
||||||
kms_key_id=None,
|
kms_key_id=None,
|
||||||
):
|
):
|
||||||
|
|
||||||
@ -325,7 +325,7 @@ class SecretsManagerBackend(BaseBackend):
|
|||||||
secret_string=None,
|
secret_string=None,
|
||||||
secret_binary=None,
|
secret_binary=None,
|
||||||
description=None,
|
description=None,
|
||||||
tags=[],
|
tags=None,
|
||||||
kms_key_id=None,
|
kms_key_id=None,
|
||||||
version_id=None,
|
version_id=None,
|
||||||
version_stages=None,
|
version_stages=None,
|
||||||
|
@ -243,7 +243,7 @@ class RegexConverter(BaseConverter):
|
|||||||
# http://werkzeug.pocoo.org/docs/routing/#custom-converters
|
# http://werkzeug.pocoo.org/docs/routing/#custom-converters
|
||||||
|
|
||||||
def __init__(self, url_map, *items):
|
def __init__(self, url_map, *items):
|
||||||
super(RegexConverter, self).__init__(url_map)
|
super().__init__(url_map)
|
||||||
self.regex = items[0]
|
self.regex = items[0]
|
||||||
|
|
||||||
|
|
||||||
@ -327,7 +327,8 @@ def signal_handler(reset_server_port, signum, frame):
|
|||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
def main(argv=sys.argv[1:]):
|
def main(argv=None):
|
||||||
|
argv = argv or sys.argv[1:]
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
|
|
||||||
# Keep this for backwards compat
|
# Keep this for backwards compat
|
||||||
|
@ -5,101 +5,91 @@ class MessageRejectedError(RESTError):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(MessageRejectedError, self).__init__("MessageRejected", message)
|
super().__init__("MessageRejected", message)
|
||||||
|
|
||||||
|
|
||||||
class ConfigurationSetDoesNotExist(RESTError):
|
class ConfigurationSetDoesNotExist(RESTError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(ConfigurationSetDoesNotExist, self).__init__(
|
super().__init__("ConfigurationSetDoesNotExist", message)
|
||||||
"ConfigurationSetDoesNotExist", message
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class EventDestinationAlreadyExists(RESTError):
|
class EventDestinationAlreadyExists(RESTError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(EventDestinationAlreadyExists, self).__init__(
|
super().__init__("EventDestinationAlreadyExists", message)
|
||||||
"EventDestinationAlreadyExists", message
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class TemplateNameAlreadyExists(RESTError):
|
class TemplateNameAlreadyExists(RESTError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(TemplateNameAlreadyExists, self).__init__(
|
super().__init__("TemplateNameAlreadyExists", message)
|
||||||
"TemplateNameAlreadyExists", message
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class ValidationError(RESTError):
|
class ValidationError(RESTError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(ValidationError, self).__init__("ValidationError", message)
|
super().__init__("ValidationError", message)
|
||||||
|
|
||||||
|
|
||||||
class InvalidParameterValue(RESTError):
|
class InvalidParameterValue(RESTError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(InvalidParameterValue, self).__init__("InvalidParameterValue", message)
|
super().__init__("InvalidParameterValue", message)
|
||||||
|
|
||||||
|
|
||||||
class InvalidRenderingParameterException:
|
class InvalidRenderingParameterException:
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(InvalidRenderingParameterException, self).__init__(
|
super().__init__("InvalidRenderingParameterException", message)
|
||||||
"InvalidRenderingParameterException", message
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class TemplateDoesNotExist(RESTError):
|
class TemplateDoesNotExist(RESTError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(TemplateDoesNotExist, self).__init__("TemplateDoesNotExist", message)
|
super().__init__("TemplateDoesNotExist", message)
|
||||||
|
|
||||||
|
|
||||||
class RuleSetNameAlreadyExists(RESTError):
|
class RuleSetNameAlreadyExists(RESTError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(RuleSetNameAlreadyExists, self).__init__(
|
super().__init__("RuleSetNameAlreadyExists", message)
|
||||||
"RuleSetNameAlreadyExists", message
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class RuleAlreadyExists(RESTError):
|
class RuleAlreadyExists(RESTError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(RuleAlreadyExists, self).__init__("RuleAlreadyExists", message)
|
super().__init__("RuleAlreadyExists", message)
|
||||||
|
|
||||||
|
|
||||||
class RuleSetDoesNotExist(RESTError):
|
class RuleSetDoesNotExist(RESTError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(RuleSetDoesNotExist, self).__init__("RuleSetDoesNotExist", message)
|
super().__init__("RuleSetDoesNotExist", message)
|
||||||
|
|
||||||
|
|
||||||
class RuleDoesNotExist(RESTError):
|
class RuleDoesNotExist(RESTError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(RuleDoesNotExist, self).__init__("RuleDoesNotExist", message)
|
super().__init__("RuleDoesNotExist", message)
|
||||||
|
|
||||||
|
|
||||||
class MissingRenderingAttributeException(RESTError):
|
class MissingRenderingAttributeException(RESTError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, var):
|
def __init__(self, var):
|
||||||
super(MissingRenderingAttributeException, self).__init__(
|
super().__init__(
|
||||||
"MissingRenderingAttributeException",
|
"MissingRenderingAttributeException",
|
||||||
"Attribute '{0}' is not present in the rendering data.".format(var),
|
"Attribute '{0}' is not present in the rendering data.".format(var),
|
||||||
)
|
)
|
||||||
|
@ -126,7 +126,7 @@ class SESBackend(BaseBackend):
|
|||||||
return True
|
return True
|
||||||
if address in self.email_addresses:
|
if address in self.email_addresses:
|
||||||
return True
|
return True
|
||||||
user, host = address.split("@", 1)
|
_, host = address.split("@", 1)
|
||||||
return host in self.domains
|
return host in self.domains
|
||||||
|
|
||||||
def verify_email_identity(self, address):
|
def verify_email_identity(self, address):
|
||||||
|
@ -17,44 +17,42 @@ class ResourceNotFoundError(RESTError):
|
|||||||
code = 404
|
code = 404
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(ResourceNotFoundError, self).__init__(
|
super().__init__("ResourceNotFound", "Resource does not exist")
|
||||||
"ResourceNotFound", "Resource does not exist"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class DuplicateSnsEndpointError(RESTError):
|
class DuplicateSnsEndpointError(RESTError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(DuplicateSnsEndpointError, self).__init__("DuplicateEndpoint", message)
|
super().__init__("DuplicateEndpoint", message)
|
||||||
|
|
||||||
|
|
||||||
class SnsEndpointDisabled(RESTError):
|
class SnsEndpointDisabled(RESTError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(SnsEndpointDisabled, self).__init__("EndpointDisabled", message)
|
super().__init__("EndpointDisabled", message)
|
||||||
|
|
||||||
|
|
||||||
class SNSInvalidParameter(RESTError):
|
class SNSInvalidParameter(RESTError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(SNSInvalidParameter, self).__init__("InvalidParameter", message)
|
super().__init__("InvalidParameter", message)
|
||||||
|
|
||||||
|
|
||||||
class InvalidParameterValue(RESTError):
|
class InvalidParameterValue(RESTError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(InvalidParameterValue, self).__init__("InvalidParameterValue", message)
|
super().__init__("InvalidParameterValue", message)
|
||||||
|
|
||||||
|
|
||||||
class TagLimitExceededError(RESTError):
|
class TagLimitExceededError(RESTError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(TagLimitExceededError, self).__init__(
|
super().__init__(
|
||||||
"TagLimitExceeded",
|
"TagLimitExceeded",
|
||||||
"Could not complete request: tag quota of per resource exceeded",
|
"Could not complete request: tag quota of per resource exceeded",
|
||||||
)
|
)
|
||||||
@ -64,7 +62,7 @@ class InternalError(RESTError):
|
|||||||
code = 500
|
code = 500
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(InternalError, self).__init__("InternalFailure", message)
|
super().__init__("InternalFailure", message)
|
||||||
|
|
||||||
|
|
||||||
class TooManyEntriesInBatchRequest(RESTError):
|
class TooManyEntriesInBatchRequest(RESTError):
|
||||||
|
@ -210,16 +210,16 @@ class Subscription(BaseModel):
|
|||||||
else:
|
else:
|
||||||
raw_message_attributes = {}
|
raw_message_attributes = {}
|
||||||
for key, value in message_attributes.items():
|
for key, value in message_attributes.items():
|
||||||
type = "string_value"
|
attr_type = "string_value"
|
||||||
type_value = value["Value"]
|
type_value = value["Value"]
|
||||||
if value["Type"].startswith("Binary"):
|
if value["Type"].startswith("Binary"):
|
||||||
type = "binary_value"
|
attr_type = "binary_value"
|
||||||
elif value["Type"].startswith("Number"):
|
elif value["Type"].startswith("Number"):
|
||||||
type_value = "{0:g}".format(value["Value"])
|
type_value = "{0:g}".format(value["Value"])
|
||||||
|
|
||||||
raw_message_attributes[key] = {
|
raw_message_attributes[key] = {
|
||||||
"data_type": value["Type"],
|
"data_type": value["Type"],
|
||||||
type: type_value,
|
attr_type: type_value,
|
||||||
}
|
}
|
||||||
|
|
||||||
sqs_backends[region].send_message(
|
sqs_backends[region].send_message(
|
||||||
@ -405,7 +405,7 @@ class PlatformEndpoint(BaseModel):
|
|||||||
|
|
||||||
class SNSBackend(BaseBackend):
|
class SNSBackend(BaseBackend):
|
||||||
def __init__(self, region_name):
|
def __init__(self, region_name):
|
||||||
super(SNSBackend, self).__init__()
|
super().__init__()
|
||||||
self.topics = OrderedDict()
|
self.topics = OrderedDict()
|
||||||
self.subscriptions: OrderedDict[str, Subscription] = OrderedDict()
|
self.subscriptions: OrderedDict[str, Subscription] = OrderedDict()
|
||||||
self.applications = {}
|
self.applications = {}
|
||||||
@ -737,7 +737,7 @@ class SNSBackend(BaseBackend):
|
|||||||
"Invalid parameter: FilterPolicy: Filter policy is too complex"
|
"Invalid parameter: FilterPolicy: Filter policy is too complex"
|
||||||
)
|
)
|
||||||
|
|
||||||
for field, rules in value.items():
|
for rules in value.values():
|
||||||
for rule in rules:
|
for rule in rules:
|
||||||
if rule is None:
|
if rule is None:
|
||||||
continue
|
continue
|
||||||
|
@ -5,7 +5,7 @@ class ReceiptHandleIsInvalid(RESTError):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(ReceiptHandleIsInvalid, self).__init__(
|
super().__init__(
|
||||||
"ReceiptHandleIsInvalid", "The input receipt handle is invalid."
|
"ReceiptHandleIsInvalid", "The input receipt handle is invalid."
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -14,9 +14,7 @@ class MessageAttributesInvalid(RESTError):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, description):
|
def __init__(self, description):
|
||||||
super(MessageAttributesInvalid, self).__init__(
|
super().__init__("MessageAttributesInvalid", description)
|
||||||
"MessageAttributesInvalid", description
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class QueueDoesNotExist(RESTError):
|
class QueueDoesNotExist(RESTError):
|
||||||
@ -34,14 +32,14 @@ class QueueAlreadyExists(RESTError):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(QueueAlreadyExists, self).__init__("QueueAlreadyExists", message)
|
super().__init__("QueueAlreadyExists", message)
|
||||||
|
|
||||||
|
|
||||||
class EmptyBatchRequest(RESTError):
|
class EmptyBatchRequest(RESTError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(EmptyBatchRequest, self).__init__(
|
super().__init__(
|
||||||
"EmptyBatchRequest",
|
"EmptyBatchRequest",
|
||||||
"There should be at least one SendMessageBatchRequestEntry in the request.",
|
"There should be at least one SendMessageBatchRequestEntry in the request.",
|
||||||
)
|
)
|
||||||
@ -51,7 +49,7 @@ class InvalidBatchEntryId(RESTError):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(InvalidBatchEntryId, self).__init__(
|
super().__init__(
|
||||||
"InvalidBatchEntryId",
|
"InvalidBatchEntryId",
|
||||||
"A batch entry id can only contain alphanumeric characters, "
|
"A batch entry id can only contain alphanumeric characters, "
|
||||||
"hyphens and underscores. It can be at most 80 letters long.",
|
"hyphens and underscores. It can be at most 80 letters long.",
|
||||||
@ -62,7 +60,7 @@ class BatchRequestTooLong(RESTError):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, length):
|
def __init__(self, length):
|
||||||
super(BatchRequestTooLong, self).__init__(
|
super().__init__(
|
||||||
"BatchRequestTooLong",
|
"BatchRequestTooLong",
|
||||||
"Batch requests cannot be longer than 262144 bytes. "
|
"Batch requests cannot be longer than 262144 bytes. "
|
||||||
"You have sent {} bytes.".format(length),
|
"You have sent {} bytes.".format(length),
|
||||||
@ -73,16 +71,14 @@ class BatchEntryIdsNotDistinct(RESTError):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, entry_id):
|
def __init__(self, entry_id):
|
||||||
super(BatchEntryIdsNotDistinct, self).__init__(
|
super().__init__("BatchEntryIdsNotDistinct", "Id {} repeated.".format(entry_id))
|
||||||
"BatchEntryIdsNotDistinct", "Id {} repeated.".format(entry_id)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class TooManyEntriesInBatchRequest(RESTError):
|
class TooManyEntriesInBatchRequest(RESTError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, number):
|
def __init__(self, number):
|
||||||
super(TooManyEntriesInBatchRequest, self).__init__(
|
super().__init__(
|
||||||
"TooManyEntriesInBatchRequest",
|
"TooManyEntriesInBatchRequest",
|
||||||
"Maximum number of entries per request are 10. "
|
"Maximum number of entries per request are 10. "
|
||||||
"You have sent {}.".format(number),
|
"You have sent {}.".format(number),
|
||||||
@ -93,7 +89,7 @@ class InvalidAttributeName(RESTError):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, attribute_name):
|
def __init__(self, attribute_name):
|
||||||
super(InvalidAttributeName, self).__init__(
|
super().__init__(
|
||||||
"InvalidAttributeName", "Unknown Attribute {}.".format(attribute_name)
|
"InvalidAttributeName", "Unknown Attribute {}.".format(attribute_name)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -102,7 +98,7 @@ class InvalidAttributeValue(RESTError):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, attribute_name):
|
def __init__(self, attribute_name):
|
||||||
super(InvalidAttributeValue, self).__init__(
|
super().__init__(
|
||||||
"InvalidAttributeValue",
|
"InvalidAttributeValue",
|
||||||
"Invalid value for the parameter {}.".format(attribute_name),
|
"Invalid value for the parameter {}.".format(attribute_name),
|
||||||
)
|
)
|
||||||
@ -112,14 +108,14 @@ class InvalidParameterValue(RESTError):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(InvalidParameterValue, self).__init__("InvalidParameterValue", message)
|
super().__init__("InvalidParameterValue", message)
|
||||||
|
|
||||||
|
|
||||||
class MissingParameter(RESTError):
|
class MissingParameter(RESTError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, parameter):
|
def __init__(self, parameter):
|
||||||
super(MissingParameter, self).__init__(
|
super().__init__(
|
||||||
"MissingParameter",
|
"MissingParameter",
|
||||||
"The request must contain the parameter {}.".format(parameter),
|
"The request must contain the parameter {}.".format(parameter),
|
||||||
)
|
)
|
||||||
@ -129,7 +125,7 @@ class OverLimit(RESTError):
|
|||||||
code = 403
|
code = 403
|
||||||
|
|
||||||
def __init__(self, count):
|
def __init__(self, count):
|
||||||
super(OverLimit, self).__init__(
|
super().__init__(
|
||||||
"OverLimit", "{} Actions were found, maximum allowed is 7.".format(count)
|
"OverLimit", "{} Actions were found, maximum allowed is 7.".format(count)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -138,7 +134,7 @@ class InvalidAddress(RESTError):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, address):
|
def __init__(self, address):
|
||||||
super(InvalidAddress, self).__init__(
|
super().__init__(
|
||||||
"InvalidAddress",
|
"InvalidAddress",
|
||||||
"The address {} is not valid for this endpoint.".format(address),
|
"The address {} is not valid for this endpoint.".format(address),
|
||||||
)
|
)
|
||||||
|
@ -66,7 +66,7 @@ DEDUPLICATION_TIME_IN_SECONDS = 300
|
|||||||
|
|
||||||
|
|
||||||
class Message(BaseModel):
|
class Message(BaseModel):
|
||||||
def __init__(self, message_id, body, system_attributes={}):
|
def __init__(self, message_id, body, system_attributes=None):
|
||||||
self.id = message_id
|
self.id = message_id
|
||||||
self._body = body
|
self._body = body
|
||||||
self.message_attributes = {}
|
self.message_attributes = {}
|
||||||
@ -81,7 +81,7 @@ class Message(BaseModel):
|
|||||||
self.sequence_number = None
|
self.sequence_number = None
|
||||||
self.visible_at = 0
|
self.visible_at = 0
|
||||||
self.delayed_until = 0
|
self.delayed_until = 0
|
||||||
self.system_attributes = system_attributes
|
self.system_attributes = system_attributes or {}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def body_md5(self):
|
def body_md5(self):
|
||||||
@ -630,7 +630,7 @@ class SQSBackend(BaseBackend):
|
|||||||
def __init__(self, region_name):
|
def __init__(self, region_name):
|
||||||
self.region_name = region_name
|
self.region_name = region_name
|
||||||
self.queues: Dict[str, Queue] = {}
|
self.queues: Dict[str, Queue] = {}
|
||||||
super(SQSBackend, self).__init__()
|
super().__init__()
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
region_name = self.region_name
|
region_name = self.region_name
|
||||||
@ -828,7 +828,7 @@ class SQSBackend(BaseBackend):
|
|||||||
raise TooManyEntriesInBatchRequest(len(entries))
|
raise TooManyEntriesInBatchRequest(len(entries))
|
||||||
|
|
||||||
messages = []
|
messages = []
|
||||||
for index, entry in entries.items():
|
for entry in entries.values():
|
||||||
# Loop through looking for messages
|
# Loop through looking for messages
|
||||||
message = self.send_message(
|
message = self.send_message(
|
||||||
queue_name,
|
queue_name,
|
||||||
@ -846,10 +846,10 @@ class SQSBackend(BaseBackend):
|
|||||||
|
|
||||||
def _get_first_duplicate_id(self, ids):
|
def _get_first_duplicate_id(self, ids):
|
||||||
unique_ids = set()
|
unique_ids = set()
|
||||||
for id in ids:
|
for _id in ids:
|
||||||
if id in unique_ids:
|
if _id in unique_ids:
|
||||||
return id
|
return _id
|
||||||
unique_ids.add(id)
|
unique_ids.add(_id)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def receive_messages(
|
def receive_messages(
|
||||||
|
@ -76,7 +76,7 @@ class SQSResponse(BaseResponse):
|
|||||||
@amz_crc32 # crc last as request_id can edit XML
|
@amz_crc32 # crc last as request_id can edit XML
|
||||||
@amzn_request_id
|
@amzn_request_id
|
||||||
def call_action(self):
|
def call_action(self):
|
||||||
status_code, headers, body = super(SQSResponse, self).call_action()
|
status_code, headers, body = super().call_action()
|
||||||
if status_code == 404:
|
if status_code == 404:
|
||||||
queue_name = self.querystring.get("QueueName", [""])[0]
|
queue_name = self.querystring.get("QueueName", [""])[0]
|
||||||
template = self.response_template(ERROR_INEXISTENT_QUEUE)
|
template = self.response_template(ERROR_INEXISTENT_QUEUE)
|
||||||
|
@ -5,155 +5,137 @@ class InvalidFilterKey(JsonRESTError):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(InvalidFilterKey, self).__init__("InvalidFilterKey", message)
|
super().__init__("InvalidFilterKey", message)
|
||||||
|
|
||||||
|
|
||||||
class InvalidFilterOption(JsonRESTError):
|
class InvalidFilterOption(JsonRESTError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(InvalidFilterOption, self).__init__("InvalidFilterOption", message)
|
super().__init__("InvalidFilterOption", message)
|
||||||
|
|
||||||
|
|
||||||
class InvalidFilterValue(JsonRESTError):
|
class InvalidFilterValue(JsonRESTError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(InvalidFilterValue, self).__init__("InvalidFilterValue", message)
|
super().__init__("InvalidFilterValue", message)
|
||||||
|
|
||||||
|
|
||||||
class InvalidResourceId(JsonRESTError):
|
class InvalidResourceId(JsonRESTError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(InvalidResourceId, self).__init__(
|
super().__init__("InvalidResourceId", "Invalid Resource Id")
|
||||||
"InvalidResourceId", "Invalid Resource Id"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class InvalidResourceType(JsonRESTError):
|
class InvalidResourceType(JsonRESTError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(InvalidResourceType, self).__init__(
|
super().__init__("InvalidResourceType", "Invalid Resource Type")
|
||||||
"InvalidResourceType", "Invalid Resource Type"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class ParameterNotFound(JsonRESTError):
|
class ParameterNotFound(JsonRESTError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(ParameterNotFound, self).__init__("ParameterNotFound", message)
|
super().__init__("ParameterNotFound", message)
|
||||||
|
|
||||||
|
|
||||||
class ParameterVersionNotFound(JsonRESTError):
|
class ParameterVersionNotFound(JsonRESTError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(ParameterVersionNotFound, self).__init__(
|
super().__init__("ParameterVersionNotFound", message)
|
||||||
"ParameterVersionNotFound", message
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class ParameterVersionLabelLimitExceeded(JsonRESTError):
|
class ParameterVersionLabelLimitExceeded(JsonRESTError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(ParameterVersionLabelLimitExceeded, self).__init__(
|
super().__init__("ParameterVersionLabelLimitExceeded", message)
|
||||||
"ParameterVersionLabelLimitExceeded", message
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class ValidationException(JsonRESTError):
|
class ValidationException(JsonRESTError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(ValidationException, self).__init__("ValidationException", message)
|
super().__init__("ValidationException", message)
|
||||||
|
|
||||||
|
|
||||||
class DocumentAlreadyExists(JsonRESTError):
|
class DocumentAlreadyExists(JsonRESTError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(DocumentAlreadyExists, self).__init__("DocumentAlreadyExists", message)
|
super().__init__("DocumentAlreadyExists", message)
|
||||||
|
|
||||||
|
|
||||||
class DocumentPermissionLimit(JsonRESTError):
|
class DocumentPermissionLimit(JsonRESTError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(DocumentPermissionLimit, self).__init__(
|
super().__init__("DocumentPermissionLimit", message)
|
||||||
"DocumentPermissionLimit", message
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class InvalidPermissionType(JsonRESTError):
|
class InvalidPermissionType(JsonRESTError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(InvalidPermissionType, self).__init__("InvalidPermissionType", message)
|
super().__init__("InvalidPermissionType", message)
|
||||||
|
|
||||||
|
|
||||||
class InvalidDocument(JsonRESTError):
|
class InvalidDocument(JsonRESTError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(InvalidDocument, self).__init__("InvalidDocument", message)
|
super().__init__("InvalidDocument", message)
|
||||||
|
|
||||||
|
|
||||||
class InvalidDocumentOperation(JsonRESTError):
|
class InvalidDocumentOperation(JsonRESTError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(InvalidDocumentOperation, self).__init__(
|
super().__init__("InvalidDocumentOperation", message)
|
||||||
"InvalidDocumentOperation", message
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class AccessDeniedException(JsonRESTError):
|
class AccessDeniedException(JsonRESTError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(AccessDeniedException, self).__init__("AccessDeniedException", message)
|
super().__init__("AccessDeniedException", message)
|
||||||
|
|
||||||
|
|
||||||
class InvalidDocumentContent(JsonRESTError):
|
class InvalidDocumentContent(JsonRESTError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(InvalidDocumentContent, self).__init__("InvalidDocumentContent", message)
|
super().__init__("InvalidDocumentContent", message)
|
||||||
|
|
||||||
|
|
||||||
class InvalidDocumentVersion(JsonRESTError):
|
class InvalidDocumentVersion(JsonRESTError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(InvalidDocumentVersion, self).__init__("InvalidDocumentVersion", message)
|
super().__init__("InvalidDocumentVersion", message)
|
||||||
|
|
||||||
|
|
||||||
class DuplicateDocumentVersionName(JsonRESTError):
|
class DuplicateDocumentVersionName(JsonRESTError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(DuplicateDocumentVersionName, self).__init__(
|
super().__init__("DuplicateDocumentVersionName", message)
|
||||||
"DuplicateDocumentVersionName", message
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class DuplicateDocumentContent(JsonRESTError):
|
class DuplicateDocumentContent(JsonRESTError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(DuplicateDocumentContent, self).__init__(
|
super().__init__("DuplicateDocumentContent", message)
|
||||||
"DuplicateDocumentContent", message
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class ParameterMaxVersionLimitExceeded(JsonRESTError):
|
class ParameterMaxVersionLimitExceeded(JsonRESTError):
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(ParameterMaxVersionLimitExceeded, self).__init__(
|
super().__init__("ParameterMaxVersionLimitExceeded", message)
|
||||||
"ParameterMaxVersionLimitExceeded", message
|
|
||||||
)
|
|
||||||
|
@ -51,7 +51,7 @@ class Parameter(BaseModel):
|
|||||||
self,
|
self,
|
||||||
name,
|
name,
|
||||||
value,
|
value,
|
||||||
type,
|
parameter_type,
|
||||||
description,
|
description,
|
||||||
allowed_pattern,
|
allowed_pattern,
|
||||||
keyid,
|
keyid,
|
||||||
@ -61,7 +61,7 @@ class Parameter(BaseModel):
|
|||||||
tags=None,
|
tags=None,
|
||||||
):
|
):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.type = type
|
self.type = parameter_type
|
||||||
self.description = description
|
self.description = description
|
||||||
self.allowed_pattern = allowed_pattern
|
self.allowed_pattern = allowed_pattern
|
||||||
self.keyid = keyid
|
self.keyid = keyid
|
||||||
@ -612,50 +612,50 @@ def _validate_document_info(content, name, document_type, document_format, stric
|
|||||||
raise ValidationException("Invalid document type " + str(document_type))
|
raise ValidationException("Invalid document type " + str(document_type))
|
||||||
|
|
||||||
|
|
||||||
def _document_filter_equal_comparator(keyed_value, filter):
|
def _document_filter_equal_comparator(keyed_value, _filter):
|
||||||
for v in filter["Values"]:
|
for v in _filter["Values"]:
|
||||||
if keyed_value == v:
|
if keyed_value == v:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def _document_filter_list_includes_comparator(keyed_value_list, filter):
|
def _document_filter_list_includes_comparator(keyed_value_list, _filter):
|
||||||
for v in filter["Values"]:
|
for v in _filter["Values"]:
|
||||||
if v in keyed_value_list:
|
if v in keyed_value_list:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def _document_filter_match(filters, ssm_doc):
|
def _document_filter_match(filters, ssm_doc):
|
||||||
for filter in filters:
|
for _filter in filters:
|
||||||
if filter["Key"] == "Name" and not _document_filter_equal_comparator(
|
if _filter["Key"] == "Name" and not _document_filter_equal_comparator(
|
||||||
ssm_doc.name, filter
|
ssm_doc.name, _filter
|
||||||
):
|
):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
elif filter["Key"] == "Owner":
|
elif _filter["Key"] == "Owner":
|
||||||
if len(filter["Values"]) != 1:
|
if len(_filter["Values"]) != 1:
|
||||||
raise ValidationException("Owner filter can only have one value.")
|
raise ValidationException("Owner filter can only have one value.")
|
||||||
if filter["Values"][0] == "Self":
|
if _filter["Values"][0] == "Self":
|
||||||
# Update to running account ID
|
# Update to running account ID
|
||||||
filter["Values"][0] = ACCOUNT_ID
|
_filter["Values"][0] = ACCOUNT_ID
|
||||||
if not _document_filter_equal_comparator(ssm_doc.owner, filter):
|
if not _document_filter_equal_comparator(ssm_doc.owner, _filter):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
elif filter[
|
elif _filter[
|
||||||
"Key"
|
"Key"
|
||||||
] == "PlatformTypes" and not _document_filter_list_includes_comparator(
|
] == "PlatformTypes" and not _document_filter_list_includes_comparator(
|
||||||
ssm_doc.platform_types, filter
|
ssm_doc.platform_types, _filter
|
||||||
):
|
):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
elif filter["Key"] == "DocumentType" and not _document_filter_equal_comparator(
|
elif _filter["Key"] == "DocumentType" and not _document_filter_equal_comparator(
|
||||||
ssm_doc.document_type, filter
|
ssm_doc.document_type, _filter
|
||||||
):
|
):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
elif filter["Key"] == "TargetType" and not _document_filter_equal_comparator(
|
elif _filter["Key"] == "TargetType" and not _document_filter_equal_comparator(
|
||||||
ssm_doc.target_type, filter
|
ssm_doc.target_type, _filter
|
||||||
):
|
):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -719,7 +719,7 @@ class FakeMaintenanceWindow:
|
|||||||
|
|
||||||
class SimpleSystemManagerBackend(BaseBackend):
|
class SimpleSystemManagerBackend(BaseBackend):
|
||||||
def __init__(self, region):
|
def __init__(self, region):
|
||||||
super(SimpleSystemManagerBackend, self).__init__()
|
super().__init__()
|
||||||
# each value is a list of all of the versions for a parameter
|
# each value is a list of all of the versions for a parameter
|
||||||
# to get the current value, grab the last item of the list
|
# to get the current value, grab the last item of the list
|
||||||
self._parameters = defaultdict(list)
|
self._parameters = defaultdict(list)
|
||||||
@ -965,7 +965,7 @@ class SimpleSystemManagerBackend(BaseBackend):
|
|||||||
document_version=new_version,
|
document_version=new_version,
|
||||||
)
|
)
|
||||||
|
|
||||||
for doc_version, document in documents.versions.items():
|
for document in documents.versions.values():
|
||||||
if document.content == new_ssm_document.content:
|
if document.content == new_ssm_document.content:
|
||||||
if not target_type or target_type == document.target_type:
|
if not target_type or target_type == document.target_type:
|
||||||
raise DuplicateDocumentContent(
|
raise DuplicateDocumentContent(
|
||||||
@ -994,7 +994,7 @@ class SimpleSystemManagerBackend(BaseBackend):
|
|||||||
results = []
|
results = []
|
||||||
dummy_token_tracker = 0
|
dummy_token_tracker = 0
|
||||||
# Sort to maintain next token adjacency
|
# Sort to maintain next token adjacency
|
||||||
for document_name, documents in sorted(self._documents.items()):
|
for _, documents in sorted(self._documents.items()):
|
||||||
if len(results) == max_results:
|
if len(results) == max_results:
|
||||||
# There's still more to go so we need a next token
|
# There's still more to go so we need a next token
|
||||||
return results, str(next_token + len(results))
|
return results, str(next_token + len(results))
|
||||||
@ -1109,23 +1109,23 @@ class SimpleSystemManagerBackend(BaseBackend):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
if filters:
|
if filters:
|
||||||
for filter in filters:
|
for _filter in filters:
|
||||||
if filter["Key"] == "Name":
|
if _filter["Key"] == "Name":
|
||||||
k = ssm_parameter.name
|
k = ssm_parameter.name
|
||||||
for v in filter["Values"]:
|
for v in _filter["Values"]:
|
||||||
if k.startswith(v):
|
if k.startswith(v):
|
||||||
result.append(ssm_parameter)
|
result.append(ssm_parameter)
|
||||||
break
|
break
|
||||||
elif filter["Key"] == "Type":
|
elif _filter["Key"] == "Type":
|
||||||
k = ssm_parameter.type
|
k = ssm_parameter.type
|
||||||
for v in filter["Values"]:
|
for v in _filter["Values"]:
|
||||||
if k == v:
|
if k == v:
|
||||||
result.append(ssm_parameter)
|
result.append(ssm_parameter)
|
||||||
break
|
break
|
||||||
elif filter["Key"] == "KeyId":
|
elif _filter["Key"] == "KeyId":
|
||||||
k = ssm_parameter.keyid
|
k = ssm_parameter.keyid
|
||||||
if k:
|
if k:
|
||||||
for v in filter["Values"]:
|
for v in _filter["Values"]:
|
||||||
if k == v:
|
if k == v:
|
||||||
result.append(ssm_parameter)
|
result.append(ssm_parameter)
|
||||||
break
|
break
|
||||||
@ -1595,7 +1595,7 @@ class SimpleSystemManagerBackend(BaseBackend):
|
|||||||
name,
|
name,
|
||||||
description,
|
description,
|
||||||
value,
|
value,
|
||||||
type,
|
parameter_type,
|
||||||
allowed_pattern,
|
allowed_pattern,
|
||||||
keyid,
|
keyid,
|
||||||
overwrite,
|
overwrite,
|
||||||
@ -1659,7 +1659,7 @@ class SimpleSystemManagerBackend(BaseBackend):
|
|||||||
Parameter(
|
Parameter(
|
||||||
name=name,
|
name=name,
|
||||||
value=value,
|
value=value,
|
||||||
type=type,
|
parameter_type=parameter_type,
|
||||||
description=description,
|
description=description,
|
||||||
allowed_pattern=allowed_pattern,
|
allowed_pattern=allowed_pattern,
|
||||||
keyid=keyid,
|
keyid=keyid,
|
||||||
@ -1758,9 +1758,10 @@ class SimpleSystemManagerBackend(BaseBackend):
|
|||||||
|
|
||||||
return {"Commands": [command.response_object() for command in commands]}
|
return {"Commands": [command.response_object() for command in commands]}
|
||||||
|
|
||||||
def get_command_by_id(self, id):
|
def get_command_by_id(self, command_id):
|
||||||
command = next(
|
command = next(
|
||||||
(command for command in self._commands if command.command_id == id), None
|
(command for command in self._commands if command.command_id == command_id),
|
||||||
|
None,
|
||||||
)
|
)
|
||||||
|
|
||||||
if command is None:
|
if command is None:
|
||||||
|
@ -36,7 +36,7 @@ class InvalidToken(AWSError):
|
|||||||
STATUS = 400
|
STATUS = 400
|
||||||
|
|
||||||
def __init__(self, message="Invalid token"):
|
def __init__(self, message="Invalid token"):
|
||||||
super(InvalidToken, self).__init__("Invalid Token: {}".format(message))
|
super().__init__("Invalid Token: {}".format(message))
|
||||||
|
|
||||||
|
|
||||||
class ResourceNotFound(AWSError):
|
class ResourceNotFound(AWSError):
|
||||||
@ -44,4 +44,4 @@ class ResourceNotFound(AWSError):
|
|||||||
STATUS = 400
|
STATUS = 400
|
||||||
|
|
||||||
def __init__(self, arn):
|
def __init__(self, arn):
|
||||||
super(ResourceNotFound, self).__init__("Resource not found: '{}'".format(arn))
|
super().__init__("Resource not found: '{}'".format(arn))
|
||||||
|
@ -7,4 +7,4 @@ class STSClientError(RESTError):
|
|||||||
|
|
||||||
class STSValidationError(STSClientError):
|
class STSValidationError(STSClientError):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(STSValidationError, self).__init__("ValidationError", *args, **kwargs)
|
super().__init__("ValidationError", *args, **kwargs)
|
||||||
|
@ -49,7 +49,7 @@ class SupportCase(object):
|
|||||||
|
|
||||||
class SupportBackend(BaseBackend):
|
class SupportBackend(BaseBackend):
|
||||||
def __init__(self, region_name=None):
|
def __init__(self, region_name=None):
|
||||||
super(SupportBackend, self).__init__()
|
super().__init__()
|
||||||
self.region_name = region_name
|
self.region_name = region_name
|
||||||
self.check_status = {}
|
self.check_status = {}
|
||||||
self.cases = {}
|
self.cases = {}
|
||||||
|
@ -11,21 +11,19 @@ class SWFUnknownResourceFault(SWFClientError):
|
|||||||
message = "Unknown {0}: {1}".format(resource_type, resource_name)
|
message = "Unknown {0}: {1}".format(resource_type, resource_name)
|
||||||
else:
|
else:
|
||||||
message = "Unknown {0}".format(resource_type)
|
message = "Unknown {0}".format(resource_type)
|
||||||
super(SWFUnknownResourceFault, self).__init__(
|
super().__init__("com.amazonaws.swf.base.model#UnknownResourceFault", message)
|
||||||
"com.amazonaws.swf.base.model#UnknownResourceFault", message
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class SWFDomainAlreadyExistsFault(SWFClientError):
|
class SWFDomainAlreadyExistsFault(SWFClientError):
|
||||||
def __init__(self, domain_name):
|
def __init__(self, domain_name):
|
||||||
super(SWFDomainAlreadyExistsFault, self).__init__(
|
super().__init__(
|
||||||
"com.amazonaws.swf.base.model#DomainAlreadyExistsFault", domain_name
|
"com.amazonaws.swf.base.model#DomainAlreadyExistsFault", domain_name
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class SWFDomainDeprecatedFault(SWFClientError):
|
class SWFDomainDeprecatedFault(SWFClientError):
|
||||||
def __init__(self, domain_name):
|
def __init__(self, domain_name):
|
||||||
super(SWFDomainDeprecatedFault, self).__init__(
|
super().__init__(
|
||||||
"com.amazonaws.swf.base.model#DomainDeprecatedFault", domain_name
|
"com.amazonaws.swf.base.model#DomainDeprecatedFault", domain_name
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -35,12 +33,12 @@ class SWFSerializationException(SWFClientError):
|
|||||||
message = "class java.lang.Foo can not be converted to an String "
|
message = "class java.lang.Foo can not be converted to an String "
|
||||||
message += " (not a real SWF exception ; happened on: {0})".format(value)
|
message += " (not a real SWF exception ; happened on: {0})".format(value)
|
||||||
__type = "com.amazonaws.swf.base.model#SerializationException"
|
__type = "com.amazonaws.swf.base.model#SerializationException"
|
||||||
super(SWFSerializationException, self).__init__(__type, message)
|
super().__init__(__type, message)
|
||||||
|
|
||||||
|
|
||||||
class SWFTypeAlreadyExistsFault(SWFClientError):
|
class SWFTypeAlreadyExistsFault(SWFClientError):
|
||||||
def __init__(self, _type):
|
def __init__(self, _type):
|
||||||
super(SWFTypeAlreadyExistsFault, self).__init__(
|
super().__init__(
|
||||||
"com.amazonaws.swf.base.model#TypeAlreadyExistsFault",
|
"com.amazonaws.swf.base.model#TypeAlreadyExistsFault",
|
||||||
"{0}=[name={1}, version={2}]".format(
|
"{0}=[name={1}, version={2}]".format(
|
||||||
_type.__class__.__name__, _type.name, _type.version
|
_type.__class__.__name__, _type.name, _type.version
|
||||||
@ -50,7 +48,7 @@ class SWFTypeAlreadyExistsFault(SWFClientError):
|
|||||||
|
|
||||||
class SWFTypeDeprecatedFault(SWFClientError):
|
class SWFTypeDeprecatedFault(SWFClientError):
|
||||||
def __init__(self, _type):
|
def __init__(self, _type):
|
||||||
super(SWFTypeDeprecatedFault, self).__init__(
|
super().__init__(
|
||||||
"com.amazonaws.swf.base.model#TypeDeprecatedFault",
|
"com.amazonaws.swf.base.model#TypeDeprecatedFault",
|
||||||
"{0}=[name={1}, version={2}]".format(
|
"{0}=[name={1}, version={2}]".format(
|
||||||
_type.__class__.__name__, _type.name, _type.version
|
_type.__class__.__name__, _type.name, _type.version
|
||||||
@ -60,7 +58,7 @@ class SWFTypeDeprecatedFault(SWFClientError):
|
|||||||
|
|
||||||
class SWFWorkflowExecutionAlreadyStartedFault(SWFClientError):
|
class SWFWorkflowExecutionAlreadyStartedFault(SWFClientError):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(SWFWorkflowExecutionAlreadyStartedFault, self).__init__(
|
super().__init__(
|
||||||
"com.amazonaws.swf.base.model#WorkflowExecutionAlreadyStartedFault",
|
"com.amazonaws.swf.base.model#WorkflowExecutionAlreadyStartedFault",
|
||||||
"Already Started",
|
"Already Started",
|
||||||
)
|
)
|
||||||
@ -73,16 +71,14 @@ class SWFDefaultUndefinedFault(SWFClientError):
|
|||||||
key_camel_case = words.pop(0)
|
key_camel_case = words.pop(0)
|
||||||
for word in words:
|
for word in words:
|
||||||
key_camel_case += word.capitalize()
|
key_camel_case += word.capitalize()
|
||||||
super(SWFDefaultUndefinedFault, self).__init__(
|
super().__init__(
|
||||||
"com.amazonaws.swf.base.model#DefaultUndefinedFault", key_camel_case
|
"com.amazonaws.swf.base.model#DefaultUndefinedFault", key_camel_case
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class SWFValidationException(SWFClientError):
|
class SWFValidationException(SWFClientError):
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(SWFValidationException, self).__init__(
|
super().__init__("com.amazon.coral.validate#ValidationException", message)
|
||||||
"com.amazon.coral.validate#ValidationException", message
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class SWFDecisionValidationException(SWFClientError):
|
class SWFDecisionValidationException(SWFClientError):
|
||||||
@ -111,7 +107,7 @@ class SWFDecisionValidationException(SWFClientError):
|
|||||||
prefix = "{0} validation error detected: "
|
prefix = "{0} validation error detected: "
|
||||||
else:
|
else:
|
||||||
prefix = "{0} validation errors detected: "
|
prefix = "{0} validation errors detected: "
|
||||||
super(SWFDecisionValidationException, self).__init__(
|
super().__init__(
|
||||||
"com.amazon.coral.validate#ValidationException",
|
"com.amazon.coral.validate#ValidationException",
|
||||||
prefix.format(count) + "; ".join(messages),
|
prefix.format(count) + "; ".join(messages),
|
||||||
)
|
)
|
||||||
|
@ -28,7 +28,7 @@ class SWFBackend(BaseBackend):
|
|||||||
def __init__(self, region_name):
|
def __init__(self, region_name):
|
||||||
self.region_name = region_name
|
self.region_name = region_name
|
||||||
self.domains = []
|
self.domains = []
|
||||||
super(SWFBackend, self).__init__()
|
super().__init__()
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
region_name = self.region_name
|
region_name = self.region_name
|
||||||
@ -175,7 +175,7 @@ class SWFBackend(BaseBackend):
|
|||||||
workflow_name,
|
workflow_name,
|
||||||
workflow_version,
|
workflow_version,
|
||||||
tag_list=None,
|
tag_list=None,
|
||||||
input=None,
|
workflow_input=None,
|
||||||
**kwargs
|
**kwargs
|
||||||
):
|
):
|
||||||
domain = self._get_domain(domain_name)
|
domain = self._get_domain(domain_name)
|
||||||
@ -183,7 +183,12 @@ class SWFBackend(BaseBackend):
|
|||||||
if wf_type.status == "DEPRECATED":
|
if wf_type.status == "DEPRECATED":
|
||||||
raise SWFTypeDeprecatedFault(wf_type)
|
raise SWFTypeDeprecatedFault(wf_type)
|
||||||
wfe = WorkflowExecution(
|
wfe = WorkflowExecution(
|
||||||
domain, wf_type, workflow_id, tag_list=tag_list, input=input, **kwargs
|
domain,
|
||||||
|
wf_type,
|
||||||
|
workflow_id,
|
||||||
|
tag_list=tag_list,
|
||||||
|
workflow_input=workflow_input,
|
||||||
|
**kwargs
|
||||||
)
|
)
|
||||||
domain.add_workflow_execution(wfe)
|
domain.add_workflow_execution(wfe)
|
||||||
wfe.start()
|
wfe.start()
|
||||||
@ -422,7 +427,7 @@ class SWFBackend(BaseBackend):
|
|||||||
activity_task.details = details
|
activity_task.details = details
|
||||||
|
|
||||||
def signal_workflow_execution(
|
def signal_workflow_execution(
|
||||||
self, domain_name, signal_name, workflow_id, input=None, run_id=None
|
self, domain_name, signal_name, workflow_id, workflow_input=None, run_id=None
|
||||||
):
|
):
|
||||||
# process timeouts on all objects
|
# process timeouts on all objects
|
||||||
self._process_timeouts()
|
self._process_timeouts()
|
||||||
@ -430,7 +435,7 @@ class SWFBackend(BaseBackend):
|
|||||||
wfe = domain.get_workflow_execution(
|
wfe = domain.get_workflow_execution(
|
||||||
workflow_id, run_id=run_id, raise_if_closed=True
|
workflow_id, run_id=run_id, raise_if_closed=True
|
||||||
)
|
)
|
||||||
wfe.signal(signal_name, input)
|
wfe.signal(signal_name, workflow_input)
|
||||||
|
|
||||||
|
|
||||||
swf_backends = BackendDict(SWFBackend, "swf")
|
swf_backends = BackendDict(SWFBackend, "swf")
|
||||||
|
@ -16,12 +16,12 @@ class ActivityTask(BaseModel):
|
|||||||
scheduled_event_id,
|
scheduled_event_id,
|
||||||
workflow_execution,
|
workflow_execution,
|
||||||
timeouts,
|
timeouts,
|
||||||
input=None,
|
workflow_input=None,
|
||||||
):
|
):
|
||||||
self.activity_id = activity_id
|
self.activity_id = activity_id
|
||||||
self.activity_type = activity_type
|
self.activity_type = activity_type
|
||||||
self.details = None
|
self.details = None
|
||||||
self.input = input
|
self.input = workflow_input
|
||||||
self.last_heartbeat_timestamp = unix_time()
|
self.last_heartbeat_timestamp = unix_time()
|
||||||
self.scheduled_event_id = scheduled_event_id
|
self.scheduled_event_id = scheduled_event_id
|
||||||
self.started_event_id = None
|
self.started_event_id = None
|
||||||
|
@ -70,7 +70,7 @@ class WorkflowExecution(BaseModel):
|
|||||||
self._set_from_kwargs_or_workflow_type(kwargs, "task_list", "task_list")
|
self._set_from_kwargs_or_workflow_type(kwargs, "task_list", "task_list")
|
||||||
self._set_from_kwargs_or_workflow_type(kwargs, "task_start_to_close_timeout")
|
self._set_from_kwargs_or_workflow_type(kwargs, "task_start_to_close_timeout")
|
||||||
self._set_from_kwargs_or_workflow_type(kwargs, "child_policy")
|
self._set_from_kwargs_or_workflow_type(kwargs, "child_policy")
|
||||||
self.input = kwargs.get("input")
|
self.input = kwargs.get("workflow_input")
|
||||||
# counters
|
# counters
|
||||||
self.open_counts = {
|
self.open_counts = {
|
||||||
"openTimers": 0,
|
"openTimers": 0,
|
||||||
@ -563,7 +563,7 @@ class WorkflowExecution(BaseModel):
|
|||||||
task = ActivityTask(
|
task = ActivityTask(
|
||||||
activity_id=attributes["activityId"],
|
activity_id=attributes["activityId"],
|
||||||
activity_type=activity_type,
|
activity_type=activity_type,
|
||||||
input=attributes.get("input"),
|
workflow_input=attributes.get("input"),
|
||||||
scheduled_event_id=evt.event_id,
|
scheduled_event_id=evt.event_id,
|
||||||
workflow_execution=self,
|
workflow_execution=self,
|
||||||
timeouts=timeouts,
|
timeouts=timeouts,
|
||||||
@ -632,9 +632,9 @@ class WorkflowExecution(BaseModel):
|
|||||||
self.close_status = "TERMINATED"
|
self.close_status = "TERMINATED"
|
||||||
self.close_cause = "OPERATOR_INITIATED"
|
self.close_cause = "OPERATOR_INITIATED"
|
||||||
|
|
||||||
def signal(self, signal_name, input):
|
def signal(self, signal_name, workflow_input):
|
||||||
self._add_event(
|
self._add_event(
|
||||||
"WorkflowExecutionSignaled", signal_name=signal_name, input=input
|
"WorkflowExecutionSignaled", signal_name=signal_name, input=workflow_input
|
||||||
)
|
)
|
||||||
self.schedule_decision_task()
|
self.schedule_decision_task()
|
||||||
|
|
||||||
|
@ -396,7 +396,7 @@ class SWFResponse(BaseResponse):
|
|||||||
task_list=task_list,
|
task_list=task_list,
|
||||||
child_policy=child_policy,
|
child_policy=child_policy,
|
||||||
execution_start_to_close_timeout=execution_start_to_close_timeout,
|
execution_start_to_close_timeout=execution_start_to_close_timeout,
|
||||||
input=input_,
|
workflow_input=input_,
|
||||||
tag_list=tag_list,
|
tag_list=tag_list,
|
||||||
task_start_to_close_timeout=task_start_to_close_timeout,
|
task_start_to_close_timeout=task_start_to_close_timeout,
|
||||||
)
|
)
|
||||||
|
@ -3,11 +3,9 @@ from moto.core.exceptions import JsonRESTError
|
|||||||
|
|
||||||
class ConflictException(JsonRESTError):
|
class ConflictException(JsonRESTError):
|
||||||
def __init__(self, message, **kwargs):
|
def __init__(self, message, **kwargs):
|
||||||
super(ConflictException, self).__init__("ConflictException", message, **kwargs)
|
super().__init__("ConflictException", message, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class BadRequestException(JsonRESTError):
|
class BadRequestException(JsonRESTError):
|
||||||
def __init__(self, message, **kwargs):
|
def __init__(self, message, **kwargs):
|
||||||
super(BadRequestException, self).__init__(
|
super().__init__("BadRequestException", message, **kwargs)
|
||||||
"BadRequestException", message, **kwargs
|
|
||||||
)
|
|
||||||
|
@ -9,7 +9,7 @@ from .exceptions import ConflictException, BadRequestException
|
|||||||
class BaseObject(BaseModel):
|
class BaseObject(BaseModel):
|
||||||
def camelCase(self, key):
|
def camelCase(self, key):
|
||||||
words = []
|
words = []
|
||||||
for i, word in enumerate(key.split("_")):
|
for word in key.split("_"):
|
||||||
words.append(word.title())
|
words.append(word.title())
|
||||||
return "".join(words)
|
return "".join(words)
|
||||||
|
|
||||||
@ -269,7 +269,7 @@ class FakeMedicalTranscriptionJob(BaseObject):
|
|||||||
output_encryption_kms_key_id,
|
output_encryption_kms_key_id,
|
||||||
settings,
|
settings,
|
||||||
specialty,
|
specialty,
|
||||||
type,
|
job_type,
|
||||||
):
|
):
|
||||||
self._region_name = region_name
|
self._region_name = region_name
|
||||||
self.medical_transcription_job_name = medical_transcription_job_name
|
self.medical_transcription_job_name = medical_transcription_job_name
|
||||||
@ -287,7 +287,7 @@ class FakeMedicalTranscriptionJob(BaseObject):
|
|||||||
"ShowAlternatives": False,
|
"ShowAlternatives": False,
|
||||||
}
|
}
|
||||||
self.specialty = specialty
|
self.specialty = specialty
|
||||||
self.type = type
|
self.type = job_type
|
||||||
self._output_bucket_name = output_bucket_name
|
self._output_bucket_name = output_bucket_name
|
||||||
self._output_encryption_kms_key_id = output_encryption_kms_key_id
|
self._output_encryption_kms_key_id = output_encryption_kms_key_id
|
||||||
self.output_location_type = "CUSTOMER_BUCKET"
|
self.output_location_type = "CUSTOMER_BUCKET"
|
||||||
@ -524,7 +524,7 @@ class TranscribeBackend(BaseBackend):
|
|||||||
output_encryption_kms_key_id=kwargs.get("output_encryption_kms_key_id"),
|
output_encryption_kms_key_id=kwargs.get("output_encryption_kms_key_id"),
|
||||||
settings=settings,
|
settings=settings,
|
||||||
specialty=kwargs.get("specialty"),
|
specialty=kwargs.get("specialty"),
|
||||||
type=kwargs.get("type"),
|
job_type=kwargs.get("type"),
|
||||||
)
|
)
|
||||||
|
|
||||||
self.medical_transcriptions[name] = transcription_job_object
|
self.medical_transcriptions[name] = transcription_job_object
|
||||||
|
@ -107,7 +107,7 @@ class Paginator(object):
|
|||||||
if isinstance(self._fail_on_invalid_token, type):
|
if isinstance(self._fail_on_invalid_token, type):
|
||||||
# we need to raise a custom exception
|
# we need to raise a custom exception
|
||||||
func_info = inspect.getfullargspec(self._fail_on_invalid_token)
|
func_info = inspect.getfullargspec(self._fail_on_invalid_token)
|
||||||
arg_names, _, _, _, kwarg_names, _, _ = func_info
|
arg_names, _, _, _, _, _, _ = func_info
|
||||||
# arg_names == [self] or [self, token_argument_that_can_have_any_name]
|
# arg_names == [self] or [self, token_argument_that_can_have_any_name]
|
||||||
requires_token_arg = len(arg_names) > 1
|
requires_token_arg = len(arg_names) > 1
|
||||||
if requires_token_arg:
|
if requires_token_arg:
|
||||||
@ -146,7 +146,7 @@ class Paginator(object):
|
|||||||
if self._param_checksum:
|
if self._param_checksum:
|
||||||
token_dict["parameterChecksum"] = self._param_checksum
|
token_dict["parameterChecksum"] = self._param_checksum
|
||||||
range_keys = []
|
range_keys = []
|
||||||
for (index, attr) in enumerate(self._unique_attributes):
|
for attr in self._unique_attributes:
|
||||||
if type(next_item) == dict:
|
if type(next_item) == dict:
|
||||||
range_keys.append(next_item[attr])
|
range_keys.append(next_item[attr])
|
||||||
else:
|
else:
|
||||||
|
@ -7,7 +7,7 @@ class WAFv2ClientError(RESTError):
|
|||||||
|
|
||||||
class WAFV2DuplicateItemException(WAFv2ClientError):
|
class WAFV2DuplicateItemException(WAFv2ClientError):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(WAFV2DuplicateItemException, self).__init__(
|
super().__init__(
|
||||||
"WafV2DuplicateItem",
|
"WafV2DuplicateItem",
|
||||||
"AWS WAF could not perform the operation because some resource in your request is a duplicate of an existing one.",
|
"AWS WAF could not perform the operation because some resource in your request is a duplicate of an existing one.",
|
||||||
)
|
)
|
||||||
|
@ -31,9 +31,9 @@ class DefaultAction(BaseModel):
|
|||||||
https://docs.aws.amazon.com/waf/latest/APIReference/API_DefaultAction.html
|
https://docs.aws.amazon.com/waf/latest/APIReference/API_DefaultAction.html
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, allow={}, block={}):
|
def __init__(self, allow=None, block=None):
|
||||||
self.allow = allow
|
self.allow = allow or {}
|
||||||
self.block = block
|
self.block = block or {}
|
||||||
|
|
||||||
|
|
||||||
# TODO: Add remaining properties
|
# TODO: Add remaining properties
|
||||||
@ -42,10 +42,10 @@ class FakeWebACL(BaseModel):
|
|||||||
https://docs.aws.amazon.com/waf/latest/APIReference/API_WebACL.html
|
https://docs.aws.amazon.com/waf/latest/APIReference/API_WebACL.html
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, name, arn, id, visibility_config, default_action):
|
def __init__(self, name, arn, wacl_id, visibility_config, default_action):
|
||||||
self.name = name if name else utils.create_test_name("Mock-WebACL-name")
|
self.name = name if name else utils.create_test_name("Mock-WebACL-name")
|
||||||
self.created_time = iso_8601_datetime_with_milliseconds(datetime.datetime.now())
|
self.created_time = iso_8601_datetime_with_milliseconds(datetime.datetime.now())
|
||||||
self.id = id
|
self.id = wacl_id
|
||||||
self.arn = arn
|
self.arn = arn
|
||||||
self.description = "Mock WebACL named {0}".format(self.name)
|
self.description = "Mock WebACL named {0}".format(self.name)
|
||||||
self.capacity = 3
|
self.capacity = 3
|
||||||
@ -73,7 +73,7 @@ class WAFV2Backend(BaseBackend):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, region_name=None):
|
def __init__(self, region_name=None):
|
||||||
super(WAFV2Backend, self).__init__()
|
super().__init__()
|
||||||
self.region_name = region_name
|
self.region_name = region_name
|
||||||
self.wacls = OrderedDict() # self.wacls[ARN] = FakeWacl
|
self.wacls = OrderedDict() # self.wacls[ARN] = FakeWacl
|
||||||
# TODO: self.load_balancers = OrderedDict()
|
# TODO: self.load_balancers = OrderedDict()
|
||||||
@ -86,7 +86,7 @@ class WAFV2Backend(BaseBackend):
|
|||||||
def create_web_acl(self, name, visibility_config, default_action, scope):
|
def create_web_acl(self, name, visibility_config, default_action, scope):
|
||||||
wacl_id = str(uuid4())
|
wacl_id = str(uuid4())
|
||||||
arn = make_arn_for_wacl(
|
arn = make_arn_for_wacl(
|
||||||
name=name, region_name=self.region_name, id=wacl_id, scope=scope
|
name=name, region_name=self.region_name, wacl_id=wacl_id, scope=scope
|
||||||
)
|
)
|
||||||
if arn in self.wacls or self._is_duplicate_name(name):
|
if arn in self.wacls or self._is_duplicate_name(name):
|
||||||
raise WAFV2DuplicateItemException()
|
raise WAFV2DuplicateItemException()
|
||||||
|
@ -2,7 +2,7 @@ from moto.core import ACCOUNT_ID
|
|||||||
from moto.core.utils import pascal_to_camelcase, camelcase_to_underscores
|
from moto.core.utils import pascal_to_camelcase, camelcase_to_underscores
|
||||||
|
|
||||||
|
|
||||||
def make_arn_for_wacl(name, region_name, id, scope):
|
def make_arn_for_wacl(name, region_name, wacl_id, scope):
|
||||||
"""https://docs.aws.amazon.com/waf/latest/developerguide/how-aws-waf-works.html - explains --scope (cloudfront vs regional)"""
|
"""https://docs.aws.amazon.com/waf/latest/developerguide/how-aws-waf-works.html - explains --scope (cloudfront vs regional)"""
|
||||||
|
|
||||||
if scope == "REGIONAL":
|
if scope == "REGIONAL":
|
||||||
@ -10,7 +10,7 @@ def make_arn_for_wacl(name, region_name, id, scope):
|
|||||||
elif scope == "CLOUDFRONT":
|
elif scope == "CLOUDFRONT":
|
||||||
scope = "global"
|
scope = "global"
|
||||||
return "arn:aws:wafv2:{}:{}:{}/webacl/{}/{}".format(
|
return "arn:aws:wafv2:{}:{}:{}/webacl/{}/{}".format(
|
||||||
region_name, ACCOUNT_ID, scope, name, id
|
region_name, ACCOUNT_ID, scope, name, wacl_id
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,6 +12,9 @@ relative_files = True
|
|||||||
ignore = W503,W605,E128,E501,E203,E266,E501,E231
|
ignore = W503,W605,E128,E501,E203,E266,E501,E231
|
||||||
exclude = moto/packages,dist
|
exclude = moto/packages,dist
|
||||||
|
|
||||||
|
[pylint.MASTER]
|
||||||
|
ignore-paths=moto/packages
|
||||||
|
|
||||||
[pylint.'MESSAGES CONTROL']
|
[pylint.'MESSAGES CONTROL']
|
||||||
disable = W,C,R,E
|
disable = W,C,R,E
|
||||||
# Check we have any tests with duplicate names (causing them to be skipped)
|
# Check we have any tests with duplicate names (causing them to be skipped)
|
||||||
|
@ -6071,7 +6071,7 @@ def test_s3_acl_to_config_dict():
|
|||||||
[FakeGrantee(uri="http://acs.amazonaws.com/groups/s3/LogDelivery")],
|
[FakeGrantee(uri="http://acs.amazonaws.com/groups/s3/LogDelivery")],
|
||||||
"READ_ACP",
|
"READ_ACP",
|
||||||
),
|
),
|
||||||
FakeGrant([FakeGrantee(id=OWNER)], "FULL_CONTROL"),
|
FakeGrant([FakeGrantee(grantee_id=OWNER)], "FULL_CONTROL"),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
s3_config_query.backends["global"].put_bucket_acl("logbucket", log_acls)
|
s3_config_query.backends["global"].put_bucket_acl("logbucket", log_acls)
|
||||||
@ -6096,8 +6096,8 @@ def test_s3_acl_to_config_dict():
|
|||||||
# Give the owner less than full_control permissions:
|
# Give the owner less than full_control permissions:
|
||||||
log_acls = FakeAcl(
|
log_acls = FakeAcl(
|
||||||
[
|
[
|
||||||
FakeGrant([FakeGrantee(id=OWNER)], "READ_ACP"),
|
FakeGrant([FakeGrantee(grantee_id=OWNER)], "READ_ACP"),
|
||||||
FakeGrant([FakeGrantee(id=OWNER)], "WRITE_ACP"),
|
FakeGrant([FakeGrantee(grantee_id=OWNER)], "WRITE_ACP"),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
s3_config_query.backends["global"].put_bucket_acl("logbucket", log_acls)
|
s3_config_query.backends["global"].put_bucket_acl("logbucket", log_acls)
|
||||||
@ -6143,7 +6143,7 @@ def test_s3_config_dict():
|
|||||||
[FakeGrantee(uri="http://acs.amazonaws.com/groups/s3/LogDelivery")],
|
[FakeGrantee(uri="http://acs.amazonaws.com/groups/s3/LogDelivery")],
|
||||||
"READ_ACP",
|
"READ_ACP",
|
||||||
),
|
),
|
||||||
FakeGrant([FakeGrantee(id=OWNER)], "FULL_CONTROL"),
|
FakeGrant([FakeGrantee(grantee_id=OWNER)], "FULL_CONTROL"),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ def test_activity_task_creation():
|
|||||||
task = ActivityTask(
|
task = ActivityTask(
|
||||||
activity_id="my-activity-123",
|
activity_id="my-activity-123",
|
||||||
activity_type="foo",
|
activity_type="foo",
|
||||||
input="optional",
|
workflow_input="optional",
|
||||||
scheduled_event_id=117,
|
scheduled_event_id=117,
|
||||||
workflow_execution=wfe,
|
workflow_execution=wfe,
|
||||||
timeouts=ACTIVITY_TASK_TIMEOUTS,
|
timeouts=ACTIVITY_TASK_TIMEOUTS,
|
||||||
@ -45,7 +45,7 @@ def test_activity_task_full_dict_representation():
|
|||||||
at = ActivityTask(
|
at = ActivityTask(
|
||||||
activity_id="my-activity-123",
|
activity_id="my-activity-123",
|
||||||
activity_type=ActivityType("foo", "v1.0"),
|
activity_type=ActivityType("foo", "v1.0"),
|
||||||
input="optional",
|
workflow_input="optional",
|
||||||
scheduled_event_id=117,
|
scheduled_event_id=117,
|
||||||
timeouts=ACTIVITY_TASK_TIMEOUTS,
|
timeouts=ACTIVITY_TASK_TIMEOUTS,
|
||||||
workflow_execution=wfe,
|
workflow_execution=wfe,
|
||||||
@ -72,7 +72,7 @@ def test_activity_task_reset_heartbeat_clock():
|
|||||||
task = ActivityTask(
|
task = ActivityTask(
|
||||||
activity_id="my-activity-123",
|
activity_id="my-activity-123",
|
||||||
activity_type="foo",
|
activity_type="foo",
|
||||||
input="optional",
|
workflow_input="optional",
|
||||||
scheduled_event_id=117,
|
scheduled_event_id=117,
|
||||||
timeouts=ACTIVITY_TASK_TIMEOUTS,
|
timeouts=ACTIVITY_TASK_TIMEOUTS,
|
||||||
workflow_execution=wfe,
|
workflow_execution=wfe,
|
||||||
@ -93,7 +93,7 @@ def test_activity_task_first_timeout():
|
|||||||
task = ActivityTask(
|
task = ActivityTask(
|
||||||
activity_id="my-activity-123",
|
activity_id="my-activity-123",
|
||||||
activity_type="foo",
|
activity_type="foo",
|
||||||
input="optional",
|
workflow_input="optional",
|
||||||
scheduled_event_id=117,
|
scheduled_event_id=117,
|
||||||
timeouts=ACTIVITY_TASK_TIMEOUTS,
|
timeouts=ACTIVITY_TASK_TIMEOUTS,
|
||||||
workflow_execution=wfe,
|
workflow_execution=wfe,
|
||||||
@ -118,7 +118,7 @@ def test_activity_task_first_timeout_with_heartbeat_timeout_none():
|
|||||||
task = ActivityTask(
|
task = ActivityTask(
|
||||||
activity_id="my-activity-123",
|
activity_id="my-activity-123",
|
||||||
activity_type="foo",
|
activity_type="foo",
|
||||||
input="optional",
|
workflow_input="optional",
|
||||||
scheduled_event_id=117,
|
scheduled_event_id=117,
|
||||||
timeouts=activity_task_timeouts,
|
timeouts=activity_task_timeouts,
|
||||||
workflow_execution=wfe,
|
workflow_execution=wfe,
|
||||||
@ -135,7 +135,7 @@ def test_activity_task_cannot_timeout_on_closed_workflow_execution():
|
|||||||
task = ActivityTask(
|
task = ActivityTask(
|
||||||
activity_id="my-activity-123",
|
activity_id="my-activity-123",
|
||||||
activity_type="foo",
|
activity_type="foo",
|
||||||
input="optional",
|
workflow_input="optional",
|
||||||
scheduled_event_id=117,
|
scheduled_event_id=117,
|
||||||
timeouts=ACTIVITY_TASK_TIMEOUTS,
|
timeouts=ACTIVITY_TASK_TIMEOUTS,
|
||||||
workflow_execution=wfe,
|
workflow_execution=wfe,
|
||||||
@ -155,7 +155,7 @@ def test_activity_task_cannot_change_state_on_closed_workflow_execution():
|
|||||||
task = ActivityTask(
|
task = ActivityTask(
|
||||||
activity_id="my-activity-123",
|
activity_id="my-activity-123",
|
||||||
activity_type="foo",
|
activity_type="foo",
|
||||||
input="optional",
|
workflow_input="optional",
|
||||||
scheduled_event_id=117,
|
scheduled_event_id=117,
|
||||||
timeouts=ACTIVITY_TASK_TIMEOUTS,
|
timeouts=ACTIVITY_TASK_TIMEOUTS,
|
||||||
workflow_execution=wfe,
|
workflow_execution=wfe,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user