TechDebt: Move BackendDict to base_backend (#5645)
This commit is contained in:
parent
3a66ef567f
commit
ea8718d402
@ -1,8 +1,7 @@
|
|||||||
import base64
|
import base64
|
||||||
import re
|
import re
|
||||||
import datetime
|
import datetime
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core.utils import BackendDict
|
|
||||||
from moto import settings
|
from moto import settings
|
||||||
from typing import Any, Dict, List, Iterable, Optional, Tuple, Set
|
from typing import Any, Dict, List, Iterable, Optional, Tuple, Set
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
"""PrometheusServiceBackend class with methods for supported APIs."""
|
"""PrometheusServiceBackend class with methods for supported APIs."""
|
||||||
|
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core.utils import BackendDict, unix_time
|
from moto.core.utils import unix_time
|
||||||
from moto.moto_api._internal import mock_random
|
from moto.moto_api._internal import mock_random
|
||||||
from moto.utilities.paginator import paginate
|
from moto.utilities.paginator import paginate
|
||||||
from moto.utilities.tagging_service import TaggingService
|
from moto.utilities.tagging_service import TaggingService
|
||||||
|
@ -15,9 +15,9 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
# OpenAPI Spec Validator < 0.5.0
|
# OpenAPI Spec Validator < 0.5.0
|
||||||
from openapi_spec_validator.exceptions import OpenAPIValidationError # type: ignore
|
from openapi_spec_validator.exceptions import OpenAPIValidationError # type: ignore
|
||||||
from moto.core import BaseBackend, BaseModel, CloudFormationModel
|
from moto.core import BaseBackend, BackendDict, BaseModel, CloudFormationModel
|
||||||
from .utils import create_id, to_path
|
from .utils import create_id, to_path
|
||||||
from moto.core.utils import path_url, BackendDict
|
from moto.core.utils import path_url
|
||||||
from .exceptions import (
|
from .exceptions import (
|
||||||
ConflictException,
|
ConflictException,
|
||||||
DeploymentNotFoundException,
|
DeploymentNotFoundException,
|
||||||
|
@ -3,8 +3,8 @@ import string
|
|||||||
import yaml
|
import yaml
|
||||||
from typing import Any, Dict, List, Optional
|
from typing import Any, Dict, List, Optional
|
||||||
|
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core.utils import BackendDict, unix_time
|
from moto.core.utils import unix_time
|
||||||
from moto.moto_api._internal import mock_random as random
|
from moto.moto_api._internal import mock_random as random
|
||||||
from moto.utilities.tagging_service import TaggingService
|
from moto.utilities.tagging_service import TaggingService
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core.utils import BackendDict
|
|
||||||
from moto.ecs import ecs_backends
|
from moto.ecs import ecs_backends
|
||||||
from moto.moto_api._internal import mock_random
|
from moto.moto_api._internal import mock_random
|
||||||
from .exceptions import AWSValidationException
|
from .exceptions import AWSValidationException
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import base64
|
import base64
|
||||||
from datetime import timedelta, datetime, timezone
|
from datetime import timedelta, datetime, timezone
|
||||||
from typing import Any, Dict, Iterable, List, Optional, Tuple
|
from typing import Any, Dict, Iterable, List, Optional, Tuple
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core.utils import BackendDict, unix_time
|
from moto.core.utils import unix_time
|
||||||
from moto.moto_api._internal import mock_random
|
from moto.moto_api._internal import mock_random
|
||||||
from moto.utilities.tagging_service import TaggingService
|
from moto.utilities.tagging_service import TaggingService
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core.utils import BackendDict
|
|
||||||
from moto.moto_api._internal import mock_random
|
from moto.moto_api._internal import mock_random
|
||||||
from typing import Any, Dict, List, Optional
|
from typing import Any, Dict, List, Optional
|
||||||
|
|
||||||
|
@ -8,8 +8,8 @@ from moto.packages.boto.ec2.blockdevicemapping import (
|
|||||||
from moto.ec2.exceptions import InvalidInstanceIdError
|
from moto.ec2.exceptions import InvalidInstanceIdError
|
||||||
|
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from moto.core import BaseBackend, BaseModel, CloudFormationModel
|
from moto.core import BaseBackend, BackendDict, BaseModel, CloudFormationModel
|
||||||
from moto.core.utils import camelcase_to_underscores, BackendDict
|
from moto.core.utils import camelcase_to_underscores
|
||||||
from moto.ec2 import ec2_backends
|
from moto.ec2 import ec2_backends
|
||||||
from moto.ec2.models import EC2Backend
|
from moto.ec2.models import EC2Backend
|
||||||
from moto.ec2.models.instances import Instance
|
from moto.ec2.models.instances import Instance
|
||||||
@ -398,7 +398,7 @@ class FakeAutoScalingGroup(CloudFormationModel):
|
|||||||
load_balancers: List[str],
|
load_balancers: List[str],
|
||||||
target_group_arns: List[str],
|
target_group_arns: List[str],
|
||||||
placement_group: str,
|
placement_group: str,
|
||||||
termination_policies: str,
|
termination_policies: List[str],
|
||||||
autoscaling_backend: "AutoScalingBackend",
|
autoscaling_backend: "AutoScalingBackend",
|
||||||
ec2_backend: EC2Backend,
|
ec2_backend: EC2Backend,
|
||||||
tags: List[Dict[str, str]],
|
tags: List[Dict[str, str]],
|
||||||
@ -824,7 +824,7 @@ class AutoScalingBackend(BaseBackend):
|
|||||||
self.elbv2_backend: ELBv2Backend = elbv2_backends[self.account_id][region_name]
|
self.elbv2_backend: ELBv2Backend = elbv2_backends[self.account_id][region_name]
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def default_vpc_endpoint_service(service_region: str, zones: List[Dict[str, Any]]) -> List[Dict[str, Any]]: # type: ignore[misc]
|
def default_vpc_endpoint_service(service_region: str, zones: List[str]) -> List[Dict[str, Any]]: # type: ignore[misc]
|
||||||
"""Default VPC endpoint service."""
|
"""Default VPC endpoint service."""
|
||||||
return BaseBackend.default_vpc_endpoint_service_factory(
|
return BaseBackend.default_vpc_endpoint_service_factory(
|
||||||
service_region, zones, "autoscaling"
|
service_region, zones, "autoscaling"
|
||||||
@ -980,7 +980,7 @@ class AutoScalingBackend(BaseBackend):
|
|||||||
load_balancers: List[str],
|
load_balancers: List[str],
|
||||||
target_group_arns: List[str],
|
target_group_arns: List[str],
|
||||||
placement_group: str,
|
placement_group: str,
|
||||||
termination_policies: str,
|
termination_policies: List[str],
|
||||||
tags: List[Dict[str, str]],
|
tags: List[Dict[str, str]],
|
||||||
capacity_rebalance: bool = False,
|
capacity_rebalance: bool = False,
|
||||||
new_instances_protected_from_scale_in: bool = False,
|
new_instances_protected_from_scale_in: bool = False,
|
||||||
@ -1223,7 +1223,7 @@ class AutoScalingBackend(BaseBackend):
|
|||||||
return lifecycle_hook
|
return lifecycle_hook
|
||||||
|
|
||||||
def describe_lifecycle_hooks(
|
def describe_lifecycle_hooks(
|
||||||
self, as_name: str, lifecycle_hook_names: Optional[str] = None
|
self, as_name: str, lifecycle_hook_names: Optional[List[str]] = None
|
||||||
) -> List[FakeLifeCycleHook]:
|
) -> List[FakeLifeCycleHook]:
|
||||||
return [
|
return [
|
||||||
lifecycle_hook
|
lifecycle_hook
|
||||||
|
@ -22,20 +22,20 @@ class AutoScalingResponse(BaseResponse):
|
|||||||
instance_monitoring = False
|
instance_monitoring = False
|
||||||
params = self._get_params()
|
params = self._get_params()
|
||||||
self.autoscaling_backend.create_launch_configuration(
|
self.autoscaling_backend.create_launch_configuration(
|
||||||
name=params.get("LaunchConfigurationName"),
|
name=params.get("LaunchConfigurationName"), # type: ignore[arg-type]
|
||||||
image_id=params.get("ImageId"),
|
image_id=params.get("ImageId"), # type: ignore[arg-type]
|
||||||
key_name=params.get("KeyName"),
|
key_name=params.get("KeyName"),
|
||||||
ramdisk_id=params.get("RamdiskId"),
|
ramdisk_id=params.get("RamdiskId"), # type: ignore[arg-type]
|
||||||
kernel_id=params.get("KernelId"),
|
kernel_id=params.get("KernelId"), # type: ignore[arg-type]
|
||||||
security_groups=self._get_multi_param("SecurityGroups.member"),
|
security_groups=self._get_multi_param("SecurityGroups.member"),
|
||||||
user_data=params.get("UserData"),
|
user_data=params.get("UserData"), # type: ignore[arg-type]
|
||||||
instance_type=params.get("InstanceType"),
|
instance_type=params.get("InstanceType"), # type: ignore[arg-type]
|
||||||
instance_monitoring=instance_monitoring,
|
instance_monitoring=instance_monitoring,
|
||||||
instance_profile_name=params.get("IamInstanceProfile"),
|
instance_profile_name=params.get("IamInstanceProfile"),
|
||||||
spot_price=params.get("SpotPrice"),
|
spot_price=params.get("SpotPrice"),
|
||||||
ebs_optimized=params.get("EbsOptimized"),
|
ebs_optimized=params.get("EbsOptimized"), # type: ignore[arg-type]
|
||||||
associate_public_ip_address=params.get("AssociatePublicIpAddress"),
|
associate_public_ip_address=params.get("AssociatePublicIpAddress"), # type: ignore[arg-type]
|
||||||
block_device_mappings=params.get("BlockDeviceMappings"),
|
block_device_mappings=params.get("BlockDeviceMappings"), # type: ignore[arg-type]
|
||||||
instance_id=params.get("InstanceId"),
|
instance_id=params.get("InstanceId"),
|
||||||
metadata_options=params.get("MetadataOptions"),
|
metadata_options=params.get("MetadataOptions"),
|
||||||
classic_link_vpc_id=params.get("ClassicLinkVPCId"),
|
classic_link_vpc_id=params.get("ClassicLinkVPCId"),
|
||||||
@ -311,17 +311,17 @@ class AutoScalingResponse(BaseResponse):
|
|||||||
def put_scaling_policy(self) -> str:
|
def put_scaling_policy(self) -> str:
|
||||||
params = self._get_params()
|
params = self._get_params()
|
||||||
policy = self.autoscaling_backend.put_scaling_policy(
|
policy = self.autoscaling_backend.put_scaling_policy(
|
||||||
name=params.get("PolicyName"),
|
name=params.get("PolicyName"), # type: ignore[arg-type]
|
||||||
policy_type=params.get("PolicyType", "SimpleScaling"),
|
policy_type=params.get("PolicyType", "SimpleScaling"),
|
||||||
metric_aggregation_type=params.get("MetricAggregationType"),
|
metric_aggregation_type=params.get("MetricAggregationType"), # type: ignore[arg-type]
|
||||||
adjustment_type=params.get("AdjustmentType"),
|
adjustment_type=params.get("AdjustmentType"), # type: ignore[arg-type]
|
||||||
as_name=params.get("AutoScalingGroupName"),
|
as_name=params.get("AutoScalingGroupName"), # type: ignore[arg-type]
|
||||||
min_adjustment_magnitude=params.get("MinAdjustmentMagnitude"),
|
min_adjustment_magnitude=params.get("MinAdjustmentMagnitude"), # type: ignore[arg-type]
|
||||||
scaling_adjustment=self._get_int_param("ScalingAdjustment"),
|
scaling_adjustment=self._get_int_param("ScalingAdjustment"),
|
||||||
cooldown=self._get_int_param("Cooldown"),
|
cooldown=self._get_int_param("Cooldown"),
|
||||||
target_tracking_config=params.get("TargetTrackingConfiguration", {}),
|
target_tracking_config=params.get("TargetTrackingConfiguration", {}),
|
||||||
step_adjustments=params.get("StepAdjustments", []),
|
step_adjustments=params.get("StepAdjustments", []),
|
||||||
estimated_instance_warmup=params.get("EstimatedInstanceWarmup"),
|
estimated_instance_warmup=params.get("EstimatedInstanceWarmup"), # type: ignore[arg-type]
|
||||||
predictive_scaling_configuration=params.get(
|
predictive_scaling_configuration=params.get(
|
||||||
"PredictiveScalingConfiguration", {}
|
"PredictiveScalingConfiguration", {}
|
||||||
),
|
),
|
||||||
@ -480,7 +480,7 @@ class AutoScalingResponse(BaseResponse):
|
|||||||
def enable_metrics_collection(self) -> str:
|
def enable_metrics_collection(self) -> str:
|
||||||
group_name = self._get_param("AutoScalingGroupName")
|
group_name = self._get_param("AutoScalingGroupName")
|
||||||
metrics = self._get_params().get("Metrics")
|
metrics = self._get_params().get("Metrics")
|
||||||
self.autoscaling_backend.enable_metrics_collection(group_name, metrics)
|
self.autoscaling_backend.enable_metrics_collection(group_name, metrics) # type: ignore[arg-type]
|
||||||
template = self.response_template(ENABLE_METRICS_COLLECTION_TEMPLATE)
|
template = self.response_template(ENABLE_METRICS_COLLECTION_TEMPLATE)
|
||||||
return template.render()
|
return template.render()
|
||||||
|
|
||||||
|
@ -23,9 +23,9 @@ import weakref
|
|||||||
import requests.exceptions
|
import requests.exceptions
|
||||||
|
|
||||||
from moto.awslambda.policy import Policy
|
from moto.awslambda.policy import Policy
|
||||||
from moto.core import BaseBackend, BaseModel, CloudFormationModel
|
from moto.core import BaseBackend, BackendDict, BaseModel, CloudFormationModel
|
||||||
from moto.core.exceptions import RESTError
|
from moto.core.exceptions import RESTError
|
||||||
from moto.core.utils import unix_time_millis, BackendDict
|
from moto.core.utils import unix_time_millis
|
||||||
from moto.iam.models import iam_backends
|
from moto.iam.models import iam_backends
|
||||||
from moto.iam.exceptions import IAMNotFoundException
|
from moto.iam.exceptions import IAMNotFoundException
|
||||||
from moto.logs.models import logs_backends
|
from moto.logs.models import logs_backends
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import importlib
|
import importlib
|
||||||
import moto
|
import moto
|
||||||
import sys
|
import sys
|
||||||
from moto.core.utils import BackendDict
|
from moto.core import BackendDict
|
||||||
from typing import Iterable, Tuple
|
from typing import Iterable, Tuple
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ import threading
|
|||||||
import dateutil.parser
|
import dateutil.parser
|
||||||
from sys import platform
|
from sys import platform
|
||||||
|
|
||||||
from moto.core import BaseBackend, BaseModel, CloudFormationModel
|
from moto.core import BaseBackend, BackendDict, BaseModel, CloudFormationModel
|
||||||
from moto.iam.models import iam_backends, IAMBackend
|
from moto.iam.models import iam_backends, IAMBackend
|
||||||
from moto.ec2.models import ec2_backends, EC2Backend
|
from moto.ec2.models import ec2_backends, EC2Backend
|
||||||
from moto.ec2.models.instances import Instance
|
from moto.ec2.models.instances import Instance
|
||||||
@ -28,7 +28,7 @@ from moto.ec2.exceptions import InvalidSubnetIdError
|
|||||||
from moto.ec2.models.instance_types import INSTANCE_TYPES as EC2_INSTANCE_TYPES
|
from moto.ec2.models.instance_types import INSTANCE_TYPES as EC2_INSTANCE_TYPES
|
||||||
from moto.ec2.models.instance_types import INSTANCE_FAMILIES as EC2_INSTANCE_FAMILIES
|
from moto.ec2.models.instance_types import INSTANCE_FAMILIES as EC2_INSTANCE_FAMILIES
|
||||||
from moto.iam.exceptions import IAMNotFoundException
|
from moto.iam.exceptions import IAMNotFoundException
|
||||||
from moto.core.utils import unix_time_millis, BackendDict
|
from moto.core.utils import unix_time_millis
|
||||||
from moto.moto_api import state_manager
|
from moto.moto_api import state_manager
|
||||||
from moto.moto_api._internal import mock_random
|
from moto.moto_api._internal import mock_random
|
||||||
from moto.moto_api._internal.managed_state_model import ManagedState
|
from moto.moto_api._internal.managed_state_model import ManagedState
|
||||||
|
@ -5,7 +5,7 @@ from ..batch.models import (
|
|||||||
ClientException,
|
ClientException,
|
||||||
BatchBackend,
|
BatchBackend,
|
||||||
)
|
)
|
||||||
from ..core.utils import BackendDict
|
from ..core import BackendDict
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
from typing import Any, Dict, List, Tuple, Optional
|
from typing import Any, Dict, List, Tuple, Optional
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core.utils import unix_time, BackendDict
|
from moto.core.utils import unix_time
|
||||||
from typing import Any, Dict, Iterable, List
|
from typing import Any, Dict, Iterable, List
|
||||||
from .exceptions import BudgetMissingLimit, DuplicateRecordException, NotFoundException
|
from .exceptions import BudgetMissingLimit, DuplicateRecordException, NotFoundException
|
||||||
|
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
"""CostExplorerBackend class with methods for supported APIs."""
|
"""CostExplorerBackend class with methods for supported APIs."""
|
||||||
|
|
||||||
from .exceptions import CostCategoryNotFound
|
from .exceptions import CostCategoryNotFound
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core.utils import BackendDict
|
|
||||||
from moto.utilities.tagging_service import TaggingService
|
from moto.utilities.tagging_service import TaggingService
|
||||||
from moto.moto_api._internal import mock_random
|
from moto.moto_api._internal import mock_random
|
||||||
from typing import Any, Dict, List, Tuple
|
from typing import Any, Dict, List, Tuple
|
||||||
|
@ -7,11 +7,10 @@ from typing import Any, Dict, List, Optional, Iterable, Tuple, Union, Type
|
|||||||
from yaml.parser import ParserError # pylint:disable=c-extension-no-member
|
from yaml.parser import ParserError # pylint:disable=c-extension-no-member
|
||||||
from yaml.scanner import ScannerError # pylint:disable=c-extension-no-member
|
from yaml.scanner import ScannerError # pylint:disable=c-extension-no-member
|
||||||
|
|
||||||
from moto.core import BaseBackend, BaseModel, CloudFormationModel
|
from moto.core import BaseBackend, BackendDict, BaseModel, CloudFormationModel
|
||||||
from moto.core.utils import (
|
from moto.core.utils import (
|
||||||
iso_8601_datetime_with_milliseconds,
|
iso_8601_datetime_with_milliseconds,
|
||||||
iso_8601_datetime_without_milliseconds,
|
iso_8601_datetime_without_milliseconds,
|
||||||
BackendDict,
|
|
||||||
)
|
)
|
||||||
from moto.moto_api._internal import mock_random
|
from moto.moto_api._internal import mock_random
|
||||||
from moto.sns.models import sns_backends
|
from moto.sns.models import sns_backends
|
||||||
@ -117,7 +116,7 @@ class FakeStackSet(BaseModel):
|
|||||||
self.execution_role = execution_role or self.execution_role
|
self.execution_role = execution_role or self.execution_role
|
||||||
|
|
||||||
if accounts and regions:
|
if accounts and regions:
|
||||||
self.update_instances(accounts, regions, self.parameters)
|
self.update_instances(accounts, regions, self.parameters) # type: ignore[arg-type]
|
||||||
|
|
||||||
operation = self._create_operation(
|
operation = self._create_operation(
|
||||||
operation_id=operation_id,
|
operation_id=operation_id,
|
||||||
@ -158,7 +157,7 @@ class FakeStackSet(BaseModel):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def update_instances(
|
def update_instances(
|
||||||
self, accounts: List[str], regions: List[str], parameters: Dict[str, str]
|
self, accounts: List[str], regions: List[str], parameters: List[Dict[str, Any]]
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
operation_id = str(mock_random.uuid4())
|
operation_id = str(mock_random.uuid4())
|
||||||
|
|
||||||
@ -208,7 +207,7 @@ class FakeStackInstances(BaseModel):
|
|||||||
self,
|
self,
|
||||||
accounts: List[str],
|
accounts: List[str],
|
||||||
regions: List[str],
|
regions: List[str],
|
||||||
parameters: Optional[Dict[str, str]],
|
parameters: Optional[List[Dict[str, Any]]],
|
||||||
) -> Any:
|
) -> Any:
|
||||||
for account in accounts:
|
for account in accounts:
|
||||||
for region in regions:
|
for region in regions:
|
||||||
@ -655,7 +654,7 @@ class CloudFormationBackend(BaseBackend):
|
|||||||
stackset_name: str,
|
stackset_name: str,
|
||||||
accounts: List[str],
|
accounts: List[str],
|
||||||
regions: List[str],
|
regions: List[str],
|
||||||
parameters: Dict[str, str],
|
parameters: List[Dict[str, Any]],
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
stack_set = self.get_stack_set(stackset_name)
|
stack_set = self.get_stack_set(stackset_name)
|
||||||
return stack_set.update_instances(accounts, regions, parameters)
|
return stack_set.update_instances(accounts, regions, parameters)
|
||||||
|
@ -2,8 +2,8 @@ import string
|
|||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import Any, Dict, Iterable, List, Tuple, Optional
|
from typing import Any, Dict, Iterable, List, Tuple, Optional
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core.utils import BackendDict, iso_8601_datetime_with_milliseconds
|
from moto.core.utils import iso_8601_datetime_with_milliseconds
|
||||||
from moto.moto_api import state_manager
|
from moto.moto_api import state_manager
|
||||||
from moto.moto_api._internal.managed_state_model import ManagedState
|
from moto.moto_api._internal.managed_state_model import ManagedState
|
||||||
from moto.moto_api._internal import mock_random as random
|
from moto.moto_api._internal import mock_random as random
|
||||||
|
@ -3,8 +3,8 @@ import time
|
|||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import Any, Dict, List, Optional, Iterable, Tuple
|
from typing import Any, Dict, List, Optional, Iterable, Tuple
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core.utils import iso_8601_datetime_without_milliseconds, BackendDict
|
from moto.core.utils import iso_8601_datetime_without_milliseconds
|
||||||
from moto.utilities.tagging_service import TaggingService
|
from moto.utilities.tagging_service import TaggingService
|
||||||
from .exceptions import (
|
from .exceptions import (
|
||||||
S3BucketDoesNotExistException,
|
S3BucketDoesNotExistException,
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
import json
|
import json
|
||||||
import statistics
|
import statistics
|
||||||
|
|
||||||
from moto.core import BaseBackend, BaseModel, CloudWatchMetricProvider
|
from moto.core import BaseBackend, BackendDict, BaseModel, CloudWatchMetricProvider
|
||||||
from moto.core.utils import (
|
from moto.core.utils import (
|
||||||
iso_8601_datetime_without_milliseconds,
|
iso_8601_datetime_without_milliseconds,
|
||||||
iso_8601_datetime_with_nanoseconds,
|
iso_8601_datetime_with_nanoseconds,
|
||||||
BackendDict,
|
|
||||||
)
|
)
|
||||||
from moto.moto_api._internal import mock_random
|
from moto.moto_api._internal import mock_random
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core.utils import iso_8601_datetime_with_milliseconds, BackendDict
|
from moto.core.utils import iso_8601_datetime_with_milliseconds
|
||||||
from moto.moto_api._internal import mock_random
|
from moto.moto_api._internal import mock_random
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from dateutil import parser
|
from dateutil import parser
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core.utils import iso_8601_datetime_with_milliseconds, BackendDict
|
from moto.core.utils import iso_8601_datetime_with_milliseconds
|
||||||
from moto.moto_api._internal import mock_random
|
from moto.moto_api._internal import mock_random
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import Dict, List, Optional
|
from typing import Dict, List, Optional
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import json
|
import json
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import Any, Dict, List, Tuple
|
from typing import Any, Dict, List, Tuple
|
||||||
from moto.core.utils import iso_8601_datetime_with_milliseconds, BackendDict
|
from moto.core.utils import iso_8601_datetime_with_milliseconds
|
||||||
from moto.iam.exceptions import IAMNotFoundException
|
from moto.iam.exceptions import IAMNotFoundException
|
||||||
from moto.iam.models import iam_backends, IAMBackend
|
from moto.iam.models import iam_backends, IAMBackend
|
||||||
|
|
||||||
@ -12,7 +12,7 @@ from moto.codepipeline.exceptions import (
|
|||||||
InvalidTagsException,
|
InvalidTagsException,
|
||||||
TooManyTagsException,
|
TooManyTagsException,
|
||||||
)
|
)
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
|
|
||||||
|
|
||||||
class CodePipeline(BaseModel):
|
class CodePipeline(BaseModel):
|
||||||
|
@ -4,8 +4,8 @@ import re
|
|||||||
|
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from typing import Any, Dict, List, Optional
|
from typing import Any, Dict, List, Optional
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core.utils import iso_8601_datetime_with_milliseconds, BackendDict
|
from moto.core.utils import iso_8601_datetime_with_milliseconds
|
||||||
from .exceptions import InvalidNameException, ResourceNotFoundError
|
from .exceptions import InvalidNameException, ResourceNotFoundError
|
||||||
from .utils import get_random_identity_id
|
from .utils import get_random_identity_id
|
||||||
|
|
||||||
|
@ -7,8 +7,7 @@ import enum
|
|||||||
from jose import jws
|
from jose import jws
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from typing import Any, Dict, List, Tuple, Optional, Set
|
from typing import Any, Dict, List, Tuple, Optional, Set
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core.utils import BackendDict
|
|
||||||
from moto.moto_api._internal import mock_random as random
|
from moto.moto_api._internal import mock_random as random
|
||||||
from .exceptions import (
|
from .exceptions import (
|
||||||
GroupExistsException,
|
GroupExistsException,
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
"""ComprehendBackend class with methods for supported APIs."""
|
"""ComprehendBackend class with methods for supported APIs."""
|
||||||
|
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core.utils import BackendDict
|
|
||||||
from moto.utilities.tagging_service import TaggingService
|
from moto.utilities.tagging_service import TaggingService
|
||||||
from .exceptions import ResourceNotFound
|
from .exceptions import ResourceNotFound
|
||||||
from typing import Any, Dict, List, Iterable
|
from typing import Any, Dict, List, Iterable
|
||||||
|
@ -48,10 +48,9 @@ from moto.config.exceptions import (
|
|||||||
MissingRequiredConfigRuleParameterException,
|
MissingRequiredConfigRuleParameterException,
|
||||||
)
|
)
|
||||||
|
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core.common_models import ConfigQueryModel
|
from moto.core.common_models import ConfigQueryModel
|
||||||
from moto.core.responses import AWSServiceSpec
|
from moto.core.responses import AWSServiceSpec
|
||||||
from moto.core.utils import BackendDict
|
|
||||||
from moto.iam.config import role_config_query, policy_config_query
|
from moto.iam.config import role_config_query, policy_config_query
|
||||||
from moto.moto_api._internal import mock_random as random
|
from moto.moto_api._internal import mock_random as random
|
||||||
from moto.s3.config import s3_config_query
|
from moto.s3.config import s3_config_query
|
||||||
@ -1382,7 +1381,7 @@ class ConfigBackend(BaseBackend):
|
|||||||
:param next_token:
|
:param next_token:
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
identifiers = []
|
identifiers: List[Dict[str, Any]] = []
|
||||||
new_token = None
|
new_token = None
|
||||||
|
|
||||||
limit = limit or DEFAULT_PAGE_SIZE
|
limit = limit or DEFAULT_PAGE_SIZE
|
||||||
@ -1437,7 +1436,7 @@ class ConfigBackend(BaseBackend):
|
|||||||
|
|
||||||
resource_identifiers.append(item)
|
resource_identifiers.append(item)
|
||||||
|
|
||||||
result = {"resourceIdentifiers": resource_identifiers}
|
result: Dict[str, Any] = {"resourceIdentifiers": resource_identifiers}
|
||||||
|
|
||||||
if new_token:
|
if new_token:
|
||||||
result["nextToken"] = new_token
|
result["nextToken"] = new_token
|
||||||
@ -1469,7 +1468,7 @@ class ConfigBackend(BaseBackend):
|
|||||||
if not self.config_aggregators.get(aggregator_name):
|
if not self.config_aggregators.get(aggregator_name):
|
||||||
raise NoSuchConfigurationAggregatorException()
|
raise NoSuchConfigurationAggregatorException()
|
||||||
|
|
||||||
identifiers = []
|
identifiers: List[Dict[str, Any]] = []
|
||||||
new_token = None
|
new_token = None
|
||||||
filters = filters or {}
|
filters = filters or {}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
from .models import DEFAULT_ACCOUNT_ID # noqa
|
from .models import DEFAULT_ACCOUNT_ID # noqa
|
||||||
from .base_backend import BaseBackend # noqa
|
from .base_backend import BaseBackend, BackendDict # noqa
|
||||||
from .common_models import BaseModel # noqa
|
from .common_models import BaseModel # noqa
|
||||||
from .common_models import CloudFormationModel, CloudWatchMetricProvider # noqa
|
from .common_models import CloudFormationModel, CloudWatchMetricProvider # noqa
|
||||||
from .models import patch_client, patch_resource # noqa
|
from .models import patch_client, patch_resource # noqa
|
||||||
|
@ -1,15 +1,20 @@
|
|||||||
|
from boto3 import Session
|
||||||
import re
|
import re
|
||||||
import string
|
import string
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from typing import List, Dict
|
from functools import lru_cache
|
||||||
|
from threading import RLock
|
||||||
|
from typing import Any, List, Dict, Optional, ClassVar, TypeVar, Iterator
|
||||||
|
from uuid import uuid4
|
||||||
|
from moto.settings import allow_unknown_region
|
||||||
from .utils import convert_regex_to_flask_path
|
from .utils import convert_regex_to_flask_path
|
||||||
|
|
||||||
|
|
||||||
model_data = defaultdict(dict)
|
model_data: Dict[str, Dict[str, object]] = defaultdict(dict)
|
||||||
|
|
||||||
|
|
||||||
class InstanceTrackerMeta(type):
|
class InstanceTrackerMeta(type):
|
||||||
def __new__(meta, name, bases, dct):
|
def __new__(meta, name: str, bases: Any, dct: Dict[str, Any]) -> type:
|
||||||
cls = super(InstanceTrackerMeta, meta).__new__(meta, name, bases, dct)
|
cls = super(InstanceTrackerMeta, meta).__new__(meta, name, bases, dct)
|
||||||
if name == "BaseModel":
|
if name == "BaseModel":
|
||||||
return cls
|
return cls
|
||||||
@ -17,30 +22,30 @@ class InstanceTrackerMeta(type):
|
|||||||
service = cls.__module__.split(".")[1]
|
service = cls.__module__.split(".")[1]
|
||||||
if name not in model_data[service]:
|
if name not in model_data[service]:
|
||||||
model_data[service][name] = cls
|
model_data[service][name] = cls
|
||||||
cls.instances = []
|
cls.instances: ClassVar[List[Any]] = [] # type: ignore
|
||||||
return cls
|
return cls
|
||||||
|
|
||||||
|
|
||||||
class BaseBackend:
|
class BaseBackend:
|
||||||
def __init__(self, region_name, account_id=None) -> None:
|
def __init__(self, region_name: str, account_id: str):
|
||||||
self.region_name = region_name
|
self.region_name = region_name
|
||||||
self.account_id = account_id
|
self.account_id = account_id
|
||||||
|
|
||||||
def _reset_model_refs(self):
|
def _reset_model_refs(self) -> None:
|
||||||
# Remove all references to the models stored
|
# Remove all references to the models stored
|
||||||
for models in model_data.values():
|
for models in model_data.values():
|
||||||
for model in models.values():
|
for model in models.values():
|
||||||
model.instances = []
|
model.instances = [] # type: ignore[attr-defined]
|
||||||
|
|
||||||
def reset(self) -> None:
|
def reset(self) -> None:
|
||||||
region_name = self.region_name
|
region_name = self.region_name
|
||||||
account_id = self.account_id
|
account_id = self.account_id
|
||||||
self._reset_model_refs()
|
self._reset_model_refs()
|
||||||
self.__dict__ = {}
|
self.__dict__ = {}
|
||||||
self.__init__(region_name, account_id)
|
self.__init__(region_name, account_id) # type: ignore[misc]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def _url_module(self):
|
def _url_module(self) -> Any: # type: ignore[misc]
|
||||||
backend_module = self.__class__.__module__
|
backend_module = self.__class__.__module__
|
||||||
backend_urls_module_name = backend_module.replace("models", "urls")
|
backend_urls_module_name = backend_module.replace("models", "urls")
|
||||||
backend_urls_module = __import__(
|
backend_urls_module = __import__(
|
||||||
@ -49,7 +54,7 @@ class BaseBackend:
|
|||||||
return backend_urls_module
|
return backend_urls_module
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def urls(self):
|
def urls(self) -> Dict[str, str]:
|
||||||
"""
|
"""
|
||||||
A dictionary of the urls to be mocked with this service and the handlers
|
A dictionary of the urls to be mocked with this service and the handlers
|
||||||
that should be called in their place
|
that should be called in their place
|
||||||
@ -71,7 +76,7 @@ class BaseBackend:
|
|||||||
return urls
|
return urls
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def url_paths(self):
|
def url_paths(self) -> Dict[str, str]:
|
||||||
"""
|
"""
|
||||||
A dictionary of the paths of the urls to be mocked with this service and
|
A dictionary of the paths of the urls to be mocked with this service and
|
||||||
the handlers that should be called in their place
|
the handlers that should be called in their place
|
||||||
@ -86,14 +91,14 @@ class BaseBackend:
|
|||||||
return paths
|
return paths
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def url_bases(self):
|
def url_bases(self) -> List[str]:
|
||||||
"""
|
"""
|
||||||
A list containing the url_bases extracted from urls.py
|
A list containing the url_bases extracted from urls.py
|
||||||
"""
|
"""
|
||||||
return self._url_module.url_bases
|
return self._url_module.url_bases
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def flask_paths(self):
|
def flask_paths(self) -> Dict[str, str]:
|
||||||
"""
|
"""
|
||||||
The url paths that will be used for the flask server
|
The url paths that will be used for the flask server
|
||||||
"""
|
"""
|
||||||
@ -106,29 +111,29 @@ class BaseBackend:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def default_vpc_endpoint_service(
|
def default_vpc_endpoint_service(
|
||||||
service_region, zones
|
service_region: str, zones: List[str] # pylint: disable=unused-argument
|
||||||
): # pylint: disable=unused-argument
|
) -> List[Dict[str, str]]:
|
||||||
"""Invoke the factory method for any VPC endpoint(s) services."""
|
"""Invoke the factory method for any VPC endpoint(s) services."""
|
||||||
return None
|
return []
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def vpce_random_number():
|
def vpce_random_number() -> str:
|
||||||
from moto.moto_api._internal import mock_random as random
|
from moto.moto_api._internal import mock_random as random
|
||||||
|
|
||||||
"""Return random number for a VPC endpoint service ID."""
|
"""Return random number for a VPC endpoint service ID."""
|
||||||
return "".join([random.choice(string.hexdigits.lower()) for i in range(17)])
|
return "".join([random.choice(string.hexdigits.lower()) for i in range(17)])
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def default_vpc_endpoint_service_factory(
|
def default_vpc_endpoint_service_factory( # type: ignore[misc]
|
||||||
service_region,
|
service_region: str,
|
||||||
zones,
|
zones: List[str],
|
||||||
service="",
|
service: str = "",
|
||||||
service_type="Interface",
|
service_type: str = "Interface",
|
||||||
private_dns_names=True,
|
private_dns_names: bool = True,
|
||||||
special_service_name="",
|
special_service_name: str = "",
|
||||||
policy_supported=True,
|
policy_supported: bool = True,
|
||||||
base_endpoint_dns_names=None,
|
base_endpoint_dns_names: Optional[List[str]] = None,
|
||||||
) -> List[Dict[str, str]]: # pylint: disable=too-many-arguments
|
) -> List[Dict[str, Any]]: # pylint: disable=too-many-arguments
|
||||||
"""List of dicts representing default VPC endpoints for this service."""
|
"""List of dicts representing default VPC endpoints for this service."""
|
||||||
if special_service_name:
|
if special_service_name:
|
||||||
service_name = f"com.amazonaws.{service_region}.{special_service_name}"
|
service_name = f"com.amazonaws.{service_region}.{special_service_name}"
|
||||||
@ -166,3 +171,148 @@ class BaseBackend:
|
|||||||
# def list_config_service_resources(self, resource_ids, resource_name, limit, next_token):
|
# def list_config_service_resources(self, resource_ids, resource_name, limit, next_token):
|
||||||
# """For AWS Config. This will list all of the resources of the given type and optional resource name and region"""
|
# """For AWS Config. This will list all of the resources of the given type and optional resource name and region"""
|
||||||
# raise NotImplementedError()
|
# raise NotImplementedError()
|
||||||
|
|
||||||
|
|
||||||
|
backend_lock = RLock()
|
||||||
|
SERVICE_BACKEND = TypeVar("SERVICE_BACKEND", bound=BaseBackend)
|
||||||
|
|
||||||
|
|
||||||
|
class AccountSpecificBackend(Dict[str, SERVICE_BACKEND]):
|
||||||
|
"""
|
||||||
|
Dictionary storing the data for a service in a specific account.
|
||||||
|
Data access pattern:
|
||||||
|
account_specific_backend[region: str] = backend: BaseBackend
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
service_name: str,
|
||||||
|
account_id: str,
|
||||||
|
backend: type,
|
||||||
|
use_boto3_regions: bool,
|
||||||
|
additional_regions: Optional[List[str]],
|
||||||
|
):
|
||||||
|
self.service_name = service_name
|
||||||
|
self.account_id = account_id
|
||||||
|
self.backend = backend
|
||||||
|
self.regions = []
|
||||||
|
if use_boto3_regions:
|
||||||
|
sess = Session()
|
||||||
|
self.regions.extend(sess.get_available_regions(service_name))
|
||||||
|
self.regions.extend(
|
||||||
|
sess.get_available_regions(service_name, partition_name="aws-us-gov")
|
||||||
|
)
|
||||||
|
self.regions.extend(
|
||||||
|
sess.get_available_regions(service_name, partition_name="aws-cn")
|
||||||
|
)
|
||||||
|
self.regions.extend(additional_regions or [])
|
||||||
|
self._id = str(uuid4())
|
||||||
|
|
||||||
|
def __hash__(self) -> int: # type: ignore[override]
|
||||||
|
return hash(self._id)
|
||||||
|
|
||||||
|
def __eq__(self, other: Any) -> bool:
|
||||||
|
return (
|
||||||
|
other
|
||||||
|
and isinstance(other, AccountSpecificBackend)
|
||||||
|
and other._id == self._id
|
||||||
|
)
|
||||||
|
|
||||||
|
def __ne__(self, other: Any) -> bool:
|
||||||
|
return not self.__eq__(other)
|
||||||
|
|
||||||
|
def reset(self) -> None:
|
||||||
|
for region_specific_backend in self.values():
|
||||||
|
region_specific_backend.reset()
|
||||||
|
|
||||||
|
def __contains__(self, region: str) -> bool: # type: ignore[override]
|
||||||
|
return region in self.regions or region in self.keys()
|
||||||
|
|
||||||
|
def __delitem__(self, key: str) -> None:
|
||||||
|
super().__delitem__(key)
|
||||||
|
|
||||||
|
def __iter__(self) -> Iterator[str]:
|
||||||
|
return super().__iter__()
|
||||||
|
|
||||||
|
def __len__(self) -> int:
|
||||||
|
return super().__len__()
|
||||||
|
|
||||||
|
def __setitem__(self, key: str, value: SERVICE_BACKEND) -> None:
|
||||||
|
super().__setitem__(key, value)
|
||||||
|
|
||||||
|
@lru_cache()
|
||||||
|
def __getitem__(self, region_name: str) -> SERVICE_BACKEND: # type: ignore[override]
|
||||||
|
if region_name in self.keys():
|
||||||
|
return super().__getitem__(region_name)
|
||||||
|
# Create the backend for a specific region
|
||||||
|
with backend_lock:
|
||||||
|
if region_name in self.regions and region_name not in self.keys():
|
||||||
|
super().__setitem__(
|
||||||
|
region_name, self.backend(region_name, account_id=self.account_id)
|
||||||
|
)
|
||||||
|
if region_name not in self.regions and allow_unknown_region():
|
||||||
|
super().__setitem__(
|
||||||
|
region_name, self.backend(region_name, account_id=self.account_id)
|
||||||
|
)
|
||||||
|
return super().__getitem__(region_name)
|
||||||
|
|
||||||
|
|
||||||
|
class BackendDict(Dict[str, AccountSpecificBackend]): # type: ignore[type-arg]
|
||||||
|
"""
|
||||||
|
Data Structure to store everything related to a specific service.
|
||||||
|
Format:
|
||||||
|
[account_id: str]: AccountSpecificBackend
|
||||||
|
[account_id: str][region: str] = BaseBackend
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
backend: Any,
|
||||||
|
service_name: str,
|
||||||
|
use_boto3_regions: bool = True,
|
||||||
|
additional_regions: Optional[List[str]] = None,
|
||||||
|
):
|
||||||
|
self.backend = backend
|
||||||
|
self.service_name = service_name
|
||||||
|
self._use_boto3_regions = use_boto3_regions
|
||||||
|
self._additional_regions = additional_regions
|
||||||
|
self._id = str(uuid4())
|
||||||
|
|
||||||
|
def __hash__(self) -> int: # type: ignore[override]
|
||||||
|
# Required for the LRUcache to work.
|
||||||
|
# service_name is enough to determine uniqueness - other properties are dependent
|
||||||
|
return hash(self._id)
|
||||||
|
|
||||||
|
def __eq__(self, other: Any) -> bool:
|
||||||
|
return other and isinstance(other, BackendDict) and other._id == self._id
|
||||||
|
|
||||||
|
def __ne__(self, other: Any) -> bool:
|
||||||
|
return not self.__eq__(other)
|
||||||
|
|
||||||
|
@lru_cache()
|
||||||
|
def __getitem__(self, account_id: str) -> AccountSpecificBackend: # type: ignore
|
||||||
|
self._create_account_specific_backend(account_id)
|
||||||
|
return super().__getitem__(account_id)
|
||||||
|
|
||||||
|
def __delitem__(self, key: str) -> None:
|
||||||
|
super().__delitem__(key)
|
||||||
|
|
||||||
|
def __iter__(self) -> Iterator[str]:
|
||||||
|
return super().__iter__()
|
||||||
|
|
||||||
|
def __len__(self) -> int:
|
||||||
|
return super().__len__()
|
||||||
|
|
||||||
|
def __setitem__(self, key: str, value: AccountSpecificBackend) -> None: # type: ignore[type-arg]
|
||||||
|
super().__setitem__(key, value)
|
||||||
|
|
||||||
|
def _create_account_specific_backend(self, account_id: str) -> None:
|
||||||
|
with backend_lock:
|
||||||
|
if account_id not in list(self.keys()):
|
||||||
|
self[account_id] = AccountSpecificBackend(
|
||||||
|
service_name=self.service_name,
|
||||||
|
account_id=account_id,
|
||||||
|
backend=self.backend,
|
||||||
|
use_boto3_regions=self._use_boto3_regions,
|
||||||
|
additional_regions=self._additional_regions,
|
||||||
|
)
|
||||||
|
@ -14,7 +14,7 @@ from botocore.config import Config
|
|||||||
from botocore.handlers import BUILTIN_HANDLERS
|
from botocore.handlers import BUILTIN_HANDLERS
|
||||||
|
|
||||||
from moto import settings
|
from moto import settings
|
||||||
from moto.core.utils import BackendDict
|
from moto.core.base_backend import BackendDict
|
||||||
from .botocore_stubber import BotocoreStubber
|
from .botocore_stubber import BotocoreStubber
|
||||||
from .custom_responses_mock import (
|
from .custom_responses_mock import (
|
||||||
get_response_mock,
|
get_response_mock,
|
||||||
|
@ -1,15 +1,9 @@
|
|||||||
from functools import lru_cache
|
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import inspect
|
import inspect
|
||||||
import re
|
import re
|
||||||
from botocore.exceptions import ClientError
|
from botocore.exceptions import ClientError
|
||||||
from boto3 import Session
|
from typing import Optional
|
||||||
from moto.settings import allow_unknown_region
|
|
||||||
from threading import RLock
|
|
||||||
from typing import Any, Optional, List
|
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
from uuid import uuid4
|
|
||||||
|
|
||||||
|
|
||||||
def camelcase_to_underscores(argument: Optional[str]) -> str:
|
def camelcase_to_underscores(argument: Optional[str]) -> str:
|
||||||
@ -69,7 +63,7 @@ def method_names_from_class(clazz):
|
|||||||
return [x[0] for x in inspect.getmembers(clazz, predicate=predicate)]
|
return [x[0] for x in inspect.getmembers(clazz, predicate=predicate)]
|
||||||
|
|
||||||
|
|
||||||
def convert_regex_to_flask_path(url_path):
|
def convert_regex_to_flask_path(url_path: str) -> str:
|
||||||
"""
|
"""
|
||||||
Converts a regex matching url to one that can be used with flask
|
Converts a regex matching url to one that can be used with flask
|
||||||
"""
|
"""
|
||||||
@ -308,118 +302,3 @@ def extract_region_from_aws_authorization(string):
|
|||||||
if region == auth:
|
if region == auth:
|
||||||
return None
|
return None
|
||||||
return region
|
return region
|
||||||
|
|
||||||
|
|
||||||
backend_lock = RLock()
|
|
||||||
|
|
||||||
|
|
||||||
class AccountSpecificBackend(dict):
|
|
||||||
"""
|
|
||||||
Dictionary storing the data for a service in a specific account.
|
|
||||||
Data access pattern:
|
|
||||||
account_specific_backend[region: str] = backend: BaseBackend
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(
|
|
||||||
self, service_name, account_id, backend, use_boto3_regions, additional_regions
|
|
||||||
):
|
|
||||||
self.service_name = service_name
|
|
||||||
self.account_id = account_id
|
|
||||||
self.backend = backend
|
|
||||||
self.regions = []
|
|
||||||
if use_boto3_regions:
|
|
||||||
sess = Session()
|
|
||||||
self.regions.extend(sess.get_available_regions(service_name))
|
|
||||||
self.regions.extend(
|
|
||||||
sess.get_available_regions(service_name, partition_name="aws-us-gov")
|
|
||||||
)
|
|
||||||
self.regions.extend(
|
|
||||||
sess.get_available_regions(service_name, partition_name="aws-cn")
|
|
||||||
)
|
|
||||||
self.regions.extend(additional_regions or [])
|
|
||||||
self._id = str(uuid4())
|
|
||||||
|
|
||||||
def __hash__(self):
|
|
||||||
return hash(self._id)
|
|
||||||
|
|
||||||
def __eq__(self, other):
|
|
||||||
return (
|
|
||||||
other
|
|
||||||
and isinstance(other, AccountSpecificBackend)
|
|
||||||
and other._id == self._id
|
|
||||||
)
|
|
||||||
|
|
||||||
def __ne__(self, other):
|
|
||||||
return not self.__eq__(other)
|
|
||||||
|
|
||||||
def reset(self):
|
|
||||||
for region_specific_backend in self.values():
|
|
||||||
region_specific_backend.reset()
|
|
||||||
|
|
||||||
def __contains__(self, region):
|
|
||||||
return region in self.regions or region in self.keys()
|
|
||||||
|
|
||||||
@lru_cache()
|
|
||||||
def __getitem__(self, region_name):
|
|
||||||
if region_name in self.keys():
|
|
||||||
return super().__getitem__(region_name)
|
|
||||||
# Create the backend for a specific region
|
|
||||||
with backend_lock:
|
|
||||||
if region_name in self.regions and region_name not in self.keys():
|
|
||||||
super().__setitem__(
|
|
||||||
region_name, self.backend(region_name, account_id=self.account_id)
|
|
||||||
)
|
|
||||||
if region_name not in self.regions and allow_unknown_region():
|
|
||||||
super().__setitem__(
|
|
||||||
region_name, self.backend(region_name, account_id=self.account_id)
|
|
||||||
)
|
|
||||||
return super().__getitem__(region_name)
|
|
||||||
|
|
||||||
|
|
||||||
class BackendDict(dict):
|
|
||||||
"""
|
|
||||||
Data Structure to store everything related to a specific service.
|
|
||||||
Format:
|
|
||||||
[account_id: str]: AccountSpecificBackend
|
|
||||||
[account_id: str][region: str] = BaseBackend
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(
|
|
||||||
self,
|
|
||||||
backend: Any,
|
|
||||||
service_name: str,
|
|
||||||
use_boto3_regions: bool = True,
|
|
||||||
additional_regions: Optional[List[str]] = None,
|
|
||||||
):
|
|
||||||
self.backend = backend
|
|
||||||
self.service_name = service_name
|
|
||||||
self._use_boto3_regions = use_boto3_regions
|
|
||||||
self._additional_regions = additional_regions
|
|
||||||
self._id = str(uuid4())
|
|
||||||
|
|
||||||
def __hash__(self):
|
|
||||||
# Required for the LRUcache to work.
|
|
||||||
# service_name is enough to determine uniqueness - other properties are dependent
|
|
||||||
return hash(self._id)
|
|
||||||
|
|
||||||
def __eq__(self, other):
|
|
||||||
return other and isinstance(other, BackendDict) and other._id == self._id
|
|
||||||
|
|
||||||
def __ne__(self, other):
|
|
||||||
return not self.__eq__(other)
|
|
||||||
|
|
||||||
@lru_cache()
|
|
||||||
def __getitem__(self, account_id) -> AccountSpecificBackend:
|
|
||||||
self._create_account_specific_backend(account_id)
|
|
||||||
return super().__getitem__(account_id)
|
|
||||||
|
|
||||||
def _create_account_specific_backend(self, account_id) -> None:
|
|
||||||
with backend_lock:
|
|
||||||
if account_id not in self.keys():
|
|
||||||
self[account_id] = AccountSpecificBackend(
|
|
||||||
service_name=self.service_name,
|
|
||||||
account_id=account_id,
|
|
||||||
backend=self.backend,
|
|
||||||
use_boto3_regions=self._use_boto3_regions,
|
|
||||||
additional_regions=self._additional_regions,
|
|
||||||
)
|
|
||||||
|
@ -6,8 +6,7 @@ from copy import deepcopy
|
|||||||
import math
|
import math
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core.utils import BackendDict
|
|
||||||
from moto.core.utils import underscores_to_camelcase
|
from moto.core.utils import underscores_to_camelcase
|
||||||
from moto.core.utils import camelcase_to_pascal
|
from moto.core.utils import camelcase_to_pascal
|
||||||
|
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from moto.core import BaseBackend, BaseModel, CloudFormationModel
|
from moto.core import BaseBackend, BackendDict, BaseModel, CloudFormationModel
|
||||||
from moto.core.utils import BackendDict
|
|
||||||
from .utils import get_random_pipeline_id, remove_capitalization_of_dict_keys
|
from .utils import get_random_pipeline_id, remove_capitalization_of_dict_keys
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core.utils import BackendDict
|
|
||||||
|
|
||||||
from .exceptions import InvalidRequestException
|
from .exceptions import InvalidRequestException
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
"""DAXBackend class with methods for supported APIs."""
|
"""DAXBackend class with methods for supported APIs."""
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core.utils import BackendDict, unix_time
|
from moto.core.utils import unix_time
|
||||||
from moto.moto_api import state_manager
|
from moto.moto_api import state_manager
|
||||||
from moto.moto_api._internal import mock_random as random
|
from moto.moto_api._internal import mock_random as random
|
||||||
from moto.moto_api._internal.managed_state_model import ManagedState
|
from moto.moto_api._internal.managed_state_model import ManagedState
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import json
|
import json
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core.utils import BackendDict
|
|
||||||
|
|
||||||
from .exceptions import (
|
from .exceptions import (
|
||||||
InvalidResourceStateFault,
|
InvalidResourceStateFault,
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
"""DirectoryServiceBackend class with methods for supported APIs."""
|
"""DirectoryServiceBackend class with methods for supported APIs."""
|
||||||
from datetime import datetime, timezone
|
from datetime import datetime, timezone
|
||||||
|
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core.utils import BackendDict
|
|
||||||
from moto.ds.exceptions import (
|
from moto.ds.exceptions import (
|
||||||
ClientException,
|
ClientException,
|
||||||
DirectoryLimitExceededException,
|
DirectoryLimitExceededException,
|
||||||
|
@ -6,8 +6,8 @@ import json
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from moto.core import BaseBackend, BaseModel, CloudFormationModel
|
from moto.core import BaseBackend, BackendDict, BaseModel, CloudFormationModel
|
||||||
from moto.core.utils import unix_time, unix_time_millis, BackendDict
|
from moto.core.utils import unix_time, unix_time_millis
|
||||||
from moto.core.exceptions import JsonRESTError
|
from moto.core.exceptions import JsonRESTError
|
||||||
from moto.dynamodb.comparisons import get_filter_expression
|
from moto.dynamodb.comparisons import get_filter_expression
|
||||||
from moto.dynamodb.comparisons import get_expected
|
from moto.dynamodb.comparisons import get_expected
|
||||||
|
@ -3,8 +3,8 @@ import datetime
|
|||||||
import json
|
import json
|
||||||
|
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from moto.core import BaseBackend, BaseModel, CloudFormationModel
|
from moto.core import BaseBackend, BackendDict, BaseModel, CloudFormationModel
|
||||||
from moto.core.utils import unix_time, BackendDict
|
from moto.core.utils import unix_time
|
||||||
from .comparisons import get_comparison_func
|
from .comparisons import get_comparison_func
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,8 +2,7 @@ import os
|
|||||||
import json
|
import json
|
||||||
import base64
|
import base64
|
||||||
|
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core.utils import BackendDict
|
|
||||||
from moto.dynamodb.models import dynamodb_backends, DynamoJsonEncoder
|
from moto.dynamodb.models import dynamodb_backends, DynamoJsonEncoder
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
"""EBSBackend class with methods for supported APIs."""
|
"""EBSBackend class with methods for supported APIs."""
|
||||||
|
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core.utils import BackendDict, unix_time
|
from moto.core.utils import unix_time
|
||||||
from moto.ec2 import ec2_backends
|
from moto.ec2 import ec2_backends
|
||||||
from moto.ec2.models.elastic_block_store import Snapshot
|
from moto.ec2.models.elastic_block_store import Snapshot
|
||||||
from moto.moto_api._internal import mock_random
|
from moto.moto_api._internal import mock_random
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
from moto.core import BaseBackend
|
from moto.core import BaseBackend, BackendDict
|
||||||
from moto.core.utils import BackendDict
|
|
||||||
from ..exceptions import (
|
from ..exceptions import (
|
||||||
EC2ClientError,
|
EC2ClientError,
|
||||||
InvalidID,
|
InvalidID,
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import json
|
import json
|
||||||
from moto.core import BaseBackend
|
from moto.core import BaseBackend, BackendDict
|
||||||
from moto.core.utils import BackendDict
|
|
||||||
|
|
||||||
|
|
||||||
class Ec2InstanceConnectBackend(BaseBackend):
|
class Ec2InstanceConnectBackend(BaseBackend):
|
||||||
|
@ -7,8 +7,8 @@ from typing import Dict, List
|
|||||||
|
|
||||||
from botocore.exceptions import ParamValidationError
|
from botocore.exceptions import ParamValidationError
|
||||||
|
|
||||||
from moto.core import BaseBackend, BaseModel, CloudFormationModel
|
from moto.core import BaseBackend, BackendDict, BaseModel, CloudFormationModel
|
||||||
from moto.core.utils import iso_8601_datetime_without_milliseconds, BackendDict
|
from moto.core.utils import iso_8601_datetime_without_milliseconds
|
||||||
from moto.ecr.exceptions import (
|
from moto.ecr.exceptions import (
|
||||||
ImageNotFoundException,
|
ImageNotFoundException,
|
||||||
RepositoryNotFoundException,
|
RepositoryNotFoundException,
|
||||||
|
@ -5,14 +5,9 @@ from typing import Any
|
|||||||
import pytz
|
import pytz
|
||||||
|
|
||||||
from moto import settings
|
from moto import settings
|
||||||
from moto.core import BaseBackend, BaseModel, CloudFormationModel
|
from moto.core import BaseBackend, BackendDict, BaseModel, CloudFormationModel
|
||||||
from moto.core.exceptions import JsonRESTError
|
from moto.core.exceptions import JsonRESTError
|
||||||
from moto.core.utils import (
|
from moto.core.utils import unix_time, pascal_to_camelcase, remap_nested_keys
|
||||||
unix_time,
|
|
||||||
pascal_to_camelcase,
|
|
||||||
remap_nested_keys,
|
|
||||||
BackendDict,
|
|
||||||
)
|
|
||||||
|
|
||||||
from ..ec2.utils import random_private_ip
|
from ..ec2.utils import random_private_ip
|
||||||
from moto.ec2 import ec2_backends
|
from moto.ec2 import ec2_backends
|
||||||
|
@ -8,12 +8,8 @@ import json
|
|||||||
import time
|
import time
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
|
|
||||||
from moto.core import BaseBackend, BaseModel, CloudFormationModel
|
from moto.core import BaseBackend, BackendDict, BaseModel, CloudFormationModel
|
||||||
from moto.core.utils import (
|
from moto.core.utils import camelcase_to_underscores, underscores_to_camelcase
|
||||||
camelcase_to_underscores,
|
|
||||||
underscores_to_camelcase,
|
|
||||||
BackendDict,
|
|
||||||
)
|
|
||||||
from moto.ec2 import ec2_backends
|
from moto.ec2 import ec2_backends
|
||||||
from moto.ec2.exceptions import InvalidSubnetIdError
|
from moto.ec2.exceptions import InvalidSubnetIdError
|
||||||
from moto.efs.exceptions import (
|
from moto.efs.exceptions import (
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from moto.core import BaseBackend
|
from moto.core import BaseBackend, BackendDict
|
||||||
from moto.core.utils import iso_8601_datetime_without_milliseconds, BackendDict
|
from moto.core.utils import iso_8601_datetime_without_milliseconds
|
||||||
from moto.moto_api._internal import mock_random as random
|
from moto.moto_api._internal import mock_random as random
|
||||||
|
|
||||||
from .exceptions import (
|
from .exceptions import (
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core.utils import BackendDict
|
|
||||||
|
|
||||||
from .exceptions import UserAlreadyExists, UserNotFound
|
from .exceptions import UserAlreadyExists, UserNotFound
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import weakref
|
import weakref
|
||||||
|
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core.utils import BackendDict
|
|
||||||
from .exceptions import InvalidParameterValueError, ResourceNotFoundException
|
from .exceptions import InvalidParameterValueError, ResourceNotFoundException
|
||||||
from .utils import make_arn
|
from .utils import make_arn
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core.utils import BackendDict
|
|
||||||
from moto.moto_api._internal import mock_random as random
|
from moto.moto_api._internal import mock_random as random
|
||||||
import string
|
import string
|
||||||
|
|
||||||
|
@ -3,8 +3,7 @@ import pytz
|
|||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from typing import List, Iterable
|
from typing import List, Iterable
|
||||||
|
|
||||||
from moto.core import BaseBackend, BaseModel, CloudFormationModel
|
from moto.core import BaseBackend, BackendDict, BaseModel, CloudFormationModel
|
||||||
from moto.core.utils import BackendDict
|
|
||||||
from moto.ec2.models import ec2_backends
|
from moto.ec2.models import ec2_backends
|
||||||
from moto.ec2.exceptions import InvalidInstanceIdError
|
from moto.ec2.exceptions import InvalidInstanceIdError
|
||||||
from moto.moto_api._internal import mock_random
|
from moto.moto_api._internal import mock_random
|
||||||
|
@ -5,11 +5,8 @@ from botocore.exceptions import ParamValidationError
|
|||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from typing import Any, List, Dict, Iterable, Optional
|
from typing import Any, List, Dict, Iterable, Optional
|
||||||
from moto.core.exceptions import RESTError
|
from moto.core.exceptions import RESTError
|
||||||
from moto.core import BaseBackend, BaseModel, CloudFormationModel
|
from moto.core import BaseBackend, BackendDict, BaseModel, CloudFormationModel
|
||||||
from moto.core.utils import (
|
from moto.core.utils import iso_8601_datetime_with_milliseconds
|
||||||
iso_8601_datetime_with_milliseconds,
|
|
||||||
BackendDict,
|
|
||||||
)
|
|
||||||
from moto.ec2.models import ec2_backends
|
from moto.ec2.models import ec2_backends
|
||||||
from moto.moto_api._internal import mock_random
|
from moto.moto_api._internal import mock_random
|
||||||
from moto.utilities.tagging_service import TaggingService
|
from moto.utilities.tagging_service import TaggingService
|
||||||
|
@ -5,8 +5,7 @@ import warnings
|
|||||||
|
|
||||||
import pytz
|
import pytz
|
||||||
from dateutil.parser import parse as dtparse
|
from dateutil.parser import parse as dtparse
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core.utils import BackendDict
|
|
||||||
from moto.emr.exceptions import (
|
from moto.emr.exceptions import (
|
||||||
InvalidRequestException,
|
InvalidRequestException,
|
||||||
ValidationException,
|
ValidationException,
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
import re
|
import re
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core.utils import iso_8601_datetime_without_milliseconds, BackendDict
|
from moto.core.utils import iso_8601_datetime_without_milliseconds
|
||||||
|
|
||||||
from .utils import random_cluster_id, random_job_id, get_partition, paginated_list
|
from .utils import random_cluster_id, random_job_id, get_partition, paginated_list
|
||||||
from .exceptions import ResourceNotFoundException
|
from .exceptions import ResourceNotFoundException
|
||||||
|
@ -3,8 +3,8 @@ import re
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import inspect
|
import inspect
|
||||||
|
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core.utils import BackendDict, iso_8601_datetime_without_milliseconds
|
from moto.core.utils import iso_8601_datetime_without_milliseconds
|
||||||
from .utils import (
|
from .utils import (
|
||||||
default_auto_start_configuration,
|
default_auto_start_configuration,
|
||||||
default_auto_stop_configuration,
|
default_auto_stop_configuration,
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core.utils import BackendDict
|
|
||||||
from moto.moto_api._internal import mock_random
|
from moto.moto_api._internal import mock_random
|
||||||
from .exceptions import DomainNotFound
|
from .exceptions import DomainNotFound
|
||||||
|
|
||||||
|
@ -12,12 +12,11 @@ from operator import lt, le, eq, ge, gt
|
|||||||
|
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from moto.core.exceptions import JsonRESTError
|
from moto.core.exceptions import JsonRESTError
|
||||||
from moto.core import BaseBackend, CloudFormationModel, BaseModel
|
from moto.core import BaseBackend, BackendDict, CloudFormationModel, BaseModel
|
||||||
from moto.core.utils import (
|
from moto.core.utils import (
|
||||||
unix_time,
|
unix_time,
|
||||||
unix_time_millis,
|
unix_time_millis,
|
||||||
iso_8601_datetime_without_milliseconds,
|
iso_8601_datetime_without_milliseconds,
|
||||||
BackendDict,
|
|
||||||
)
|
)
|
||||||
from moto.events.exceptions import (
|
from moto.events.exceptions import (
|
||||||
ValidationException,
|
ValidationException,
|
||||||
|
@ -25,8 +25,7 @@ import warnings
|
|||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core.utils import BackendDict
|
|
||||||
from moto.firehose.exceptions import (
|
from moto.firehose.exceptions import (
|
||||||
ConcurrentModificationException,
|
ConcurrentModificationException,
|
||||||
InvalidArgumentException,
|
InvalidArgumentException,
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import re
|
import re
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from moto.core import BaseBackend
|
from moto.core import BaseBackend, BackendDict
|
||||||
from moto.core.utils import iso_8601_datetime_without_milliseconds, BackendDict
|
from moto.core.utils import iso_8601_datetime_without_milliseconds
|
||||||
from .exceptions import (
|
from .exceptions import (
|
||||||
InvalidInputException,
|
InvalidInputException,
|
||||||
ResourceAlreadyExistsException,
|
ResourceAlreadyExistsException,
|
||||||
|
@ -2,8 +2,7 @@ import hashlib
|
|||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core.utils import BackendDict
|
|
||||||
from moto.utilities.utils import md5_hash
|
from moto.utilities.utils import md5_hash
|
||||||
|
|
||||||
from .utils import get_job_id
|
from .utils import get_job_id
|
||||||
|
@ -4,8 +4,7 @@ from datetime import datetime
|
|||||||
import re
|
import re
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core.utils import BackendDict
|
|
||||||
from moto.moto_api import state_manager
|
from moto.moto_api import state_manager
|
||||||
from moto.moto_api._internal import mock_random
|
from moto.moto_api._internal import mock_random
|
||||||
from moto.moto_api._internal.managed_state_model import ManagedState
|
from moto.moto_api._internal.managed_state_model import ManagedState
|
||||||
|
@ -3,8 +3,8 @@ from collections import OrderedDict
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core.utils import BackendDict, iso_8601_datetime_with_milliseconds
|
from moto.core.utils import iso_8601_datetime_with_milliseconds
|
||||||
from moto.moto_api._internal import mock_random
|
from moto.moto_api._internal import mock_random
|
||||||
from .exceptions import (
|
from .exceptions import (
|
||||||
GreengrassClientError,
|
GreengrassClientError,
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core.utils import BackendDict
|
|
||||||
from moto.moto_api._internal import mock_random
|
from moto.moto_api._internal import mock_random
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
@ -13,11 +13,16 @@ from jinja2 import Template
|
|||||||
from typing import List, Mapping
|
from typing import List, Mapping
|
||||||
from urllib import parse
|
from urllib import parse
|
||||||
from moto.core.exceptions import RESTError
|
from moto.core.exceptions import RESTError
|
||||||
from moto.core import DEFAULT_ACCOUNT_ID, BaseBackend, BaseModel, CloudFormationModel
|
from moto.core import (
|
||||||
|
DEFAULT_ACCOUNT_ID,
|
||||||
|
BaseBackend,
|
||||||
|
BaseModel,
|
||||||
|
CloudFormationModel,
|
||||||
|
BackendDict,
|
||||||
|
)
|
||||||
from moto.core.utils import (
|
from moto.core.utils import (
|
||||||
iso_8601_datetime_without_milliseconds,
|
iso_8601_datetime_without_milliseconds,
|
||||||
iso_8601_datetime_with_milliseconds,
|
iso_8601_datetime_with_milliseconds,
|
||||||
BackendDict,
|
|
||||||
unix_time,
|
unix_time,
|
||||||
)
|
)
|
||||||
from moto.iam.policy_validation import (
|
from moto.iam.policy_validation import (
|
||||||
@ -64,14 +69,16 @@ SERVICE_NAME_CONVERSION = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def get_account_id_from(access_key):
|
def get_account_id_from(access_key: str) -> str:
|
||||||
for account_id, account in iam_backends.items():
|
for account_id, account in iam_backends.items():
|
||||||
if access_key in account["global"].access_keys:
|
if access_key in account["global"].access_keys:
|
||||||
return account_id
|
return account_id
|
||||||
return DEFAULT_ACCOUNT_ID
|
return DEFAULT_ACCOUNT_ID
|
||||||
|
|
||||||
|
|
||||||
def mark_account_as_visited(account_id, access_key, service, region):
|
def mark_account_as_visited(
|
||||||
|
account_id: str, access_key: str, service: str, region: str
|
||||||
|
) -> None:
|
||||||
account = iam_backends[account_id]
|
account = iam_backends[account_id]
|
||||||
if access_key in account["global"].access_keys:
|
if access_key in account["global"].access_keys:
|
||||||
account["global"].access_keys[access_key].last_used = AccessKeyLastUsed(
|
account["global"].access_keys[access_key].last_used = AccessKeyLastUsed(
|
||||||
@ -3050,6 +3057,6 @@ class IAMBackend(BaseBackend):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
iam_backends: Mapping[str, Mapping[str, IAMBackend]] = BackendDict(
|
iam_backends = BackendDict(
|
||||||
IAMBackend, "iam", use_boto3_regions=False, additional_regions=["global"]
|
IAMBackend, "iam", use_boto3_regions=False, additional_regions=["global"]
|
||||||
)
|
)
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
from moto.core import BaseBackend
|
from moto.core import BaseBackend, BackendDict
|
||||||
from moto.core.utils import BackendDict
|
|
||||||
|
|
||||||
|
|
||||||
class InstanceMetadataBackend(BaseBackend):
|
class InstanceMetadataBackend(BaseBackend):
|
||||||
|
@ -11,8 +11,7 @@ from datetime import datetime, timedelta
|
|||||||
|
|
||||||
from .utils import PAGINATION_MODEL
|
from .utils import PAGINATION_MODEL
|
||||||
|
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core.utils import BackendDict
|
|
||||||
from moto.moto_api._internal import mock_random as random
|
from moto.moto_api._internal import mock_random as random
|
||||||
from moto.utilities.paginator import paginate
|
from moto.utilities.paginator import paginate
|
||||||
from .exceptions import (
|
from .exceptions import (
|
||||||
|
@ -2,8 +2,8 @@ import json
|
|||||||
import time
|
import time
|
||||||
import jsondiff
|
import jsondiff
|
||||||
|
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core.utils import merge_dicts, BackendDict
|
from moto.core.utils import merge_dicts
|
||||||
from moto.iot import iot_backends
|
from moto.iot import iot_backends
|
||||||
from .exceptions import (
|
from .exceptions import (
|
||||||
ConflictException,
|
ConflictException,
|
||||||
|
@ -5,8 +5,8 @@ import itertools
|
|||||||
|
|
||||||
from operator import attrgetter
|
from operator import attrgetter
|
||||||
|
|
||||||
from moto.core import BaseBackend, BaseModel, CloudFormationModel
|
from moto.core import BaseBackend, BackendDict, BaseModel, CloudFormationModel
|
||||||
from moto.core.utils import unix_time, BackendDict
|
from moto.core.utils import unix_time
|
||||||
from moto.utilities.paginator import paginate
|
from moto.utilities.paginator import paginate
|
||||||
from moto.utilities.utils import md5_hash
|
from moto.utilities.utils import md5_hash
|
||||||
from .exceptions import (
|
from .exceptions import (
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from .exceptions import ResourceNotFoundException, ResourceInUseException
|
from .exceptions import ResourceNotFoundException, ResourceInUseException
|
||||||
from moto.core.utils import BackendDict
|
|
||||||
from moto.moto_api._internal import mock_random as random
|
from moto.moto_api._internal import mock_random as random
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
from moto.core import BaseBackend
|
from moto.core import BaseBackend, BackendDict
|
||||||
from moto.core.utils import BackendDict
|
|
||||||
from moto.kinesisvideo import kinesisvideo_backends
|
from moto.kinesisvideo import kinesisvideo_backends
|
||||||
from moto.sts.utils import random_session_token
|
from moto.sts.utils import random_session_token
|
||||||
|
|
||||||
|
@ -8,8 +8,8 @@ from cryptography.hazmat.primitives import hashes
|
|||||||
|
|
||||||
from cryptography.hazmat.primitives.asymmetric import padding
|
from cryptography.hazmat.primitives.asymmetric import padding
|
||||||
|
|
||||||
from moto.core import BaseBackend, BaseModel, CloudFormationModel
|
from moto.core import BaseBackend, BackendDict, BaseModel, CloudFormationModel
|
||||||
from moto.core.utils import unix_time, BackendDict
|
from moto.core.utils import unix_time
|
||||||
from moto.moto_api._internal import mock_random
|
from moto.moto_api._internal import mock_random
|
||||||
from moto.utilities.tagging_service import TaggingService
|
from moto.utilities.tagging_service import TaggingService
|
||||||
from moto.core.exceptions import JsonRESTError
|
from moto.core.exceptions import JsonRESTError
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from typing import Any, Dict, List, Tuple, Optional
|
from typing import Any, Dict, List, Tuple, Optional
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core import CloudFormationModel
|
from moto.core import CloudFormationModel
|
||||||
from moto.core.utils import unix_time_millis, BackendDict
|
from moto.core.utils import unix_time_millis
|
||||||
from moto.logs.metric_filters import MetricFilters
|
from moto.logs.metric_filters import MetricFilters
|
||||||
from moto.logs.exceptions import (
|
from moto.logs.exceptions import (
|
||||||
ResourceNotFoundException,
|
ResourceNotFoundException,
|
||||||
|
@ -3,8 +3,7 @@ from __future__ import division
|
|||||||
import datetime
|
import datetime
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core.utils import BackendDict
|
|
||||||
|
|
||||||
from .exceptions import (
|
from .exceptions import (
|
||||||
BadRequestException,
|
BadRequestException,
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core.utils import BackendDict
|
|
||||||
from moto.mediaconnect.exceptions import NotFoundException
|
from moto.mediaconnect.exceptions import NotFoundException
|
||||||
from moto.moto_api._internal import mock_random as random
|
from moto.moto_api._internal import mock_random as random
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core.utils import BackendDict
|
|
||||||
from moto.moto_api._internal import mock_random
|
from moto.moto_api._internal import mock_random
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core.utils import BackendDict
|
|
||||||
|
|
||||||
from .exceptions import ClientError
|
from .exceptions import ClientError
|
||||||
|
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from datetime import date
|
from datetime import date
|
||||||
|
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core.utils import BackendDict
|
|
||||||
from .exceptions import (
|
from .exceptions import (
|
||||||
ContainerNotFoundException,
|
ContainerNotFoundException,
|
||||||
ResourceNotFoundException,
|
ResourceNotFoundException,
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import hashlib
|
import hashlib
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core.utils import BackendDict
|
|
||||||
from .exceptions import ClientError
|
from .exceptions import ClientError
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import collections
|
import collections
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.moto_api._internal import mock_random
|
from moto.moto_api._internal import mock_random
|
||||||
from moto.core.utils import BackendDict
|
|
||||||
|
|
||||||
|
|
||||||
class UsageRecord(BaseModel, dict):
|
class UsageRecord(BaseModel, dict):
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from moto.core import BaseBackend
|
from moto.core import BaseBackend, DEFAULT_ACCOUNT_ID
|
||||||
|
|
||||||
|
|
||||||
class MotoAPIBackend(BaseBackend):
|
class MotoAPIBackend(BaseBackend):
|
||||||
@ -31,4 +31,4 @@ class MotoAPIBackend(BaseBackend):
|
|||||||
state_manager.unset_transition(model_name)
|
state_manager.unset_transition(model_name)
|
||||||
|
|
||||||
|
|
||||||
moto_api_backend = MotoAPIBackend(region_name="global")
|
moto_api_backend = MotoAPIBackend(region_name="global", account_id=DEFAULT_ACCOUNT_ID)
|
||||||
|
@ -5,6 +5,7 @@ import os
|
|||||||
|
|
||||||
import requests
|
import requests
|
||||||
from botocore.awsrequest import AWSPreparedRequest
|
from botocore.awsrequest import AWSPreparedRequest
|
||||||
|
from typing import Any, Optional
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
|
|
||||||
@ -14,7 +15,7 @@ class Recorder:
|
|||||||
self._os_enabled = bool(os.environ.get("MOTO_ENABLE_RECORDING", False))
|
self._os_enabled = bool(os.environ.get("MOTO_ENABLE_RECORDING", False))
|
||||||
self._user_enabled = self._os_enabled
|
self._user_enabled = self._os_enabled
|
||||||
|
|
||||||
def _record_request(self, request, body=None):
|
def _record_request(self, request: Any, body: Optional[bytes] = None) -> None:
|
||||||
"""
|
"""
|
||||||
Record the current request
|
Record the current request
|
||||||
"""
|
"""
|
||||||
|
@ -16,8 +16,8 @@ except ImportError:
|
|||||||
|
|
||||||
import moto.backends as backends
|
import moto.backends as backends
|
||||||
import moto.backend_index as backend_index
|
import moto.backend_index as backend_index
|
||||||
from moto.core import DEFAULT_ACCOUNT_ID
|
from moto.core import BackendDict, DEFAULT_ACCOUNT_ID
|
||||||
from moto.core.utils import convert_to_flask_response, BackendDict
|
from moto.core.utils import convert_to_flask_response
|
||||||
|
|
||||||
from .utilities import AWSTestHelper, RegexConverter
|
from .utilities import AWSTestHelper, RegexConverter
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import base64
|
import base64
|
||||||
import xmltodict
|
import xmltodict
|
||||||
|
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core.utils import BackendDict, unix_time
|
from moto.core.utils import unix_time
|
||||||
from moto.moto_api._internal import mock_random
|
from moto.moto_api._internal import mock_random
|
||||||
from moto.utilities.tagging_service import TaggingService
|
from moto.utilities.tagging_service import TaggingService
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.ec2 import ec2_backends
|
from moto.ec2 import ec2_backends
|
||||||
from moto.core.utils import BackendDict
|
|
||||||
from moto.moto_api._internal import mock_random as random
|
from moto.moto_api._internal import mock_random as random
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
|
@ -2,9 +2,9 @@ import datetime
|
|||||||
import re
|
import re
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core.exceptions import RESTError
|
from moto.core.exceptions import RESTError
|
||||||
from moto.core.utils import unix_time, BackendDict
|
from moto.core.utils import unix_time
|
||||||
from moto.organizations import utils
|
from moto.organizations import utils
|
||||||
from moto.organizations.exceptions import (
|
from moto.organizations.exceptions import (
|
||||||
InvalidInputException,
|
InvalidInputException,
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
"""PersonalizeBackend class with methods for supported APIs."""
|
"""PersonalizeBackend class with methods for supported APIs."""
|
||||||
|
|
||||||
from .exceptions import ResourceNotFoundException
|
from .exceptions import ResourceNotFoundException
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core.utils import BackendDict, unix_time
|
from moto.core.utils import unix_time
|
||||||
|
|
||||||
|
|
||||||
class Schema(BaseModel):
|
class Schema(BaseModel):
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core.utils import BackendDict, unix_time
|
from moto.core.utils import unix_time
|
||||||
from moto.moto_api._internal import mock_random
|
from moto.moto_api._internal import mock_random
|
||||||
from moto.utilities.tagging_service import TaggingService
|
from moto.utilities.tagging_service import TaggingService
|
||||||
|
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
from xml.etree import ElementTree as ET
|
from xml.etree import ElementTree as ET
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core.utils import BackendDict
|
|
||||||
|
|
||||||
from .resources import VOICE_DATA
|
from .resources import VOICE_DATA
|
||||||
from .utils import make_arn_for_lexicon
|
from .utils import make_arn_for_lexicon
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
"""QuickSightBackend class with methods for supported APIs."""
|
"""QuickSightBackend class with methods for supported APIs."""
|
||||||
|
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core.utils import BackendDict
|
|
||||||
from .exceptions import ResourceNotFoundException
|
from .exceptions import ResourceNotFoundException
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,8 +2,8 @@ import re
|
|||||||
import string
|
import string
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core.utils import unix_time, BackendDict
|
from moto.core.utils import unix_time
|
||||||
from moto.moto_api._internal import mock_random as random
|
from moto.moto_api._internal import mock_random as random
|
||||||
from moto.organizations import organizations_backends
|
from moto.organizations import organizations_backends
|
||||||
from moto.ram.exceptions import (
|
from moto.ram.exceptions import (
|
||||||
|
@ -7,8 +7,8 @@ from collections import defaultdict
|
|||||||
from jinja2 import Template
|
from jinja2 import Template
|
||||||
from re import compile as re_compile
|
from re import compile as re_compile
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from moto.core import BaseBackend, BaseModel, CloudFormationModel
|
from moto.core import BaseBackend, BackendDict, BaseModel, CloudFormationModel
|
||||||
from moto.core.utils import iso_8601_datetime_with_milliseconds, BackendDict
|
from moto.core.utils import iso_8601_datetime_with_milliseconds
|
||||||
from moto.ec2.models import ec2_backends
|
from moto.ec2.models import ec2_backends
|
||||||
from moto.moto_api._internal import mock_random as random
|
from moto.moto_api._internal import mock_random as random
|
||||||
from .exceptions import (
|
from .exceptions import (
|
||||||
|
@ -2,8 +2,8 @@ import copy
|
|||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from moto.core import BaseBackend, BaseModel, CloudFormationModel
|
from moto.core import BaseBackend, BackendDict, BaseModel, CloudFormationModel
|
||||||
from moto.core.utils import iso_8601_datetime_with_milliseconds, BackendDict
|
from moto.core.utils import iso_8601_datetime_with_milliseconds
|
||||||
from moto.ec2 import ec2_backends
|
from moto.ec2 import ec2_backends
|
||||||
from moto.moto_api._internal import mock_random
|
from moto.moto_api._internal import mock_random
|
||||||
from .exceptions import (
|
from .exceptions import (
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import re
|
import re
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from moto.core import BaseBackend
|
from moto.core import BaseBackend, BackendDict
|
||||||
from moto.core.utils import BackendDict, iso_8601_datetime_without_milliseconds
|
from moto.core.utils import iso_8601_datetime_without_milliseconds
|
||||||
from moto.moto_api._internal import mock_random as random
|
from moto.moto_api._internal import mock_random as random
|
||||||
from moto.redshiftdata.exceptions import ValidationException, ResourceNotFoundException
|
from moto.redshiftdata.exceptions import ValidationException, ResourceNotFoundException
|
||||||
|
|
||||||
|
@ -2,8 +2,7 @@
|
|||||||
|
|
||||||
import string
|
import string
|
||||||
|
|
||||||
from moto.core import BaseBackend
|
from moto.core import BaseBackend, BackendDict
|
||||||
from moto.core.utils import BackendDict
|
|
||||||
from moto.moto_api._internal import mock_random as random
|
from moto.moto_api._internal import mock_random as random
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,8 +3,7 @@ from builtins import str
|
|||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core.utils import BackendDict
|
|
||||||
from .exceptions import BadRequestException
|
from .exceptions import BadRequestException
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
from moto.core import BaseBackend
|
from moto.core import BaseBackend, BackendDict
|
||||||
from moto.core.exceptions import RESTError
|
from moto.core.exceptions import RESTError
|
||||||
from moto.core.utils import BackendDict
|
|
||||||
from moto.moto_api._internal import mock_random
|
from moto.moto_api._internal import mock_random
|
||||||
|
|
||||||
from moto.s3 import s3_backends
|
from moto.s3 import s3_backends
|
||||||
|
@ -18,8 +18,7 @@ from moto.route53.exceptions import (
|
|||||||
PublicZoneVPCAssociation,
|
PublicZoneVPCAssociation,
|
||||||
QueryLoggingConfigAlreadyExists,
|
QueryLoggingConfigAlreadyExists,
|
||||||
)
|
)
|
||||||
from moto.core import BaseBackend, BaseModel, CloudFormationModel
|
from moto.core import BaseBackend, BackendDict, BaseModel, CloudFormationModel
|
||||||
from moto.core.utils import BackendDict
|
|
||||||
from moto.moto_api._internal import mock_random as random
|
from moto.moto_api._internal import mock_random as random
|
||||||
from moto.utilities.paginator import paginate
|
from moto.utilities.paginator import paginate
|
||||||
from .utils import PAGINATION_MODEL
|
from .utils import PAGINATION_MODEL
|
||||||
|
@ -4,8 +4,7 @@ from datetime import datetime, timezone
|
|||||||
from ipaddress import ip_address, ip_network, IPv4Address
|
from ipaddress import ip_address, ip_network, IPv4Address
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core.utils import BackendDict
|
|
||||||
from moto.ec2 import ec2_backends
|
from moto.ec2 import ec2_backends
|
||||||
from moto.ec2.exceptions import InvalidSubnetIdError
|
from moto.ec2.exceptions import InvalidSubnetIdError
|
||||||
from moto.ec2.exceptions import InvalidSecurityGroupNotFoundError
|
from moto.ec2.exceptions import InvalidSecurityGroupNotFoundError
|
||||||
|
@ -14,14 +14,13 @@ import urllib.parse
|
|||||||
|
|
||||||
from bisect import insort
|
from bisect import insort
|
||||||
from importlib import reload
|
from importlib import reload
|
||||||
from moto.core import BaseBackend, BaseModel, CloudFormationModel
|
from moto.core import BaseBackend, BaseModel, BackendDict, CloudFormationModel
|
||||||
from moto.core import CloudWatchMetricProvider
|
from moto.core import CloudWatchMetricProvider
|
||||||
from moto.core.utils import (
|
from moto.core.utils import (
|
||||||
iso_8601_datetime_without_milliseconds_s3,
|
iso_8601_datetime_without_milliseconds_s3,
|
||||||
rfc_1123_datetime,
|
rfc_1123_datetime,
|
||||||
unix_time,
|
unix_time,
|
||||||
unix_time_millis,
|
unix_time_millis,
|
||||||
BackendDict,
|
|
||||||
)
|
)
|
||||||
from moto.cloudwatch.models import MetricDatum
|
from moto.cloudwatch.models import MetricDatum
|
||||||
from moto.moto_api import state_manager
|
from moto.moto_api import state_manager
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||||
from moto.core.utils import BackendDict
|
|
||||||
from moto.moto_api._internal import mock_random
|
from moto.moto_api._internal import mock_random
|
||||||
from moto.s3.exceptions import (
|
from moto.s3.exceptions import (
|
||||||
WrongPublicAccessBlockAccountIdError,
|
WrongPublicAccessBlockAccountIdError,
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from moto.core import BaseBackend, BaseModel, CloudFormationModel
|
from moto.core import BaseBackend, BackendDict, BaseModel, CloudFormationModel
|
||||||
from moto.core.utils import BackendDict
|
|
||||||
from moto.sagemaker import validators
|
from moto.sagemaker import validators
|
||||||
from moto.utilities.paginator import paginate
|
from moto.utilities.paginator import paginate
|
||||||
from .exceptions import (
|
from .exceptions import (
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user