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