TechDebt: Move BackendDict to base_backend (#5645)
This commit is contained in:
parent
3a66ef567f
commit
ea8718d402
@ -1,8 +1,7 @@
|
||||
import base64
|
||||
import re
|
||||
import datetime
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core.utils import BackendDict
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from moto import settings
|
||||
from typing import Any, Dict, List, Iterable, Optional, Tuple, Set
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
"""PrometheusServiceBackend class with methods for supported APIs."""
|
||||
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core.utils import BackendDict, unix_time
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from moto.core.utils import unix_time
|
||||
from moto.moto_api._internal import mock_random
|
||||
from moto.utilities.paginator import paginate
|
||||
from moto.utilities.tagging_service import TaggingService
|
||||
|
@ -15,9 +15,9 @@ try:
|
||||
except ImportError:
|
||||
# OpenAPI Spec Validator < 0.5.0
|
||||
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 moto.core.utils import path_url, BackendDict
|
||||
from moto.core.utils import path_url
|
||||
from .exceptions import (
|
||||
ConflictException,
|
||||
DeploymentNotFoundException,
|
||||
|
@ -3,8 +3,8 @@ import string
|
||||
import yaml
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core.utils import BackendDict, unix_time
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from moto.core.utils import unix_time
|
||||
from moto.moto_api._internal import mock_random as random
|
||||
from moto.utilities.tagging_service import TaggingService
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core.utils import BackendDict
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from moto.ecs import ecs_backends
|
||||
from moto.moto_api._internal import mock_random
|
||||
from .exceptions import AWSValidationException
|
||||
|
@ -1,8 +1,8 @@
|
||||
import base64
|
||||
from datetime import timedelta, datetime, timezone
|
||||
from typing import Any, Dict, Iterable, List, Optional, Tuple
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core.utils import BackendDict, unix_time
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from moto.core.utils import unix_time
|
||||
from moto.moto_api._internal import mock_random
|
||||
from moto.utilities.tagging_service import TaggingService
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
import time
|
||||
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core.utils import BackendDict
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from moto.moto_api._internal import mock_random
|
||||
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 collections import OrderedDict
|
||||
from moto.core import BaseBackend, BaseModel, CloudFormationModel
|
||||
from moto.core.utils import camelcase_to_underscores, BackendDict
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel, CloudFormationModel
|
||||
from moto.core.utils import camelcase_to_underscores
|
||||
from moto.ec2 import ec2_backends
|
||||
from moto.ec2.models import EC2Backend
|
||||
from moto.ec2.models.instances import Instance
|
||||
@ -398,7 +398,7 @@ class FakeAutoScalingGroup(CloudFormationModel):
|
||||
load_balancers: List[str],
|
||||
target_group_arns: List[str],
|
||||
placement_group: str,
|
||||
termination_policies: str,
|
||||
termination_policies: List[str],
|
||||
autoscaling_backend: "AutoScalingBackend",
|
||||
ec2_backend: EC2Backend,
|
||||
tags: List[Dict[str, str]],
|
||||
@ -824,7 +824,7 @@ class AutoScalingBackend(BaseBackend):
|
||||
self.elbv2_backend: ELBv2Backend = elbv2_backends[self.account_id][region_name]
|
||||
|
||||
@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."""
|
||||
return BaseBackend.default_vpc_endpoint_service_factory(
|
||||
service_region, zones, "autoscaling"
|
||||
@ -980,7 +980,7 @@ class AutoScalingBackend(BaseBackend):
|
||||
load_balancers: List[str],
|
||||
target_group_arns: List[str],
|
||||
placement_group: str,
|
||||
termination_policies: str,
|
||||
termination_policies: List[str],
|
||||
tags: List[Dict[str, str]],
|
||||
capacity_rebalance: bool = False,
|
||||
new_instances_protected_from_scale_in: bool = False,
|
||||
@ -1223,7 +1223,7 @@ class AutoScalingBackend(BaseBackend):
|
||||
return lifecycle_hook
|
||||
|
||||
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]:
|
||||
return [
|
||||
lifecycle_hook
|
||||
|
@ -22,20 +22,20 @@ class AutoScalingResponse(BaseResponse):
|
||||
instance_monitoring = False
|
||||
params = self._get_params()
|
||||
self.autoscaling_backend.create_launch_configuration(
|
||||
name=params.get("LaunchConfigurationName"),
|
||||
image_id=params.get("ImageId"),
|
||||
name=params.get("LaunchConfigurationName"), # type: ignore[arg-type]
|
||||
image_id=params.get("ImageId"), # type: ignore[arg-type]
|
||||
key_name=params.get("KeyName"),
|
||||
ramdisk_id=params.get("RamdiskId"),
|
||||
kernel_id=params.get("KernelId"),
|
||||
ramdisk_id=params.get("RamdiskId"), # type: ignore[arg-type]
|
||||
kernel_id=params.get("KernelId"), # type: ignore[arg-type]
|
||||
security_groups=self._get_multi_param("SecurityGroups.member"),
|
||||
user_data=params.get("UserData"),
|
||||
instance_type=params.get("InstanceType"),
|
||||
user_data=params.get("UserData"), # type: ignore[arg-type]
|
||||
instance_type=params.get("InstanceType"), # type: ignore[arg-type]
|
||||
instance_monitoring=instance_monitoring,
|
||||
instance_profile_name=params.get("IamInstanceProfile"),
|
||||
spot_price=params.get("SpotPrice"),
|
||||
ebs_optimized=params.get("EbsOptimized"),
|
||||
associate_public_ip_address=params.get("AssociatePublicIpAddress"),
|
||||
block_device_mappings=params.get("BlockDeviceMappings"),
|
||||
ebs_optimized=params.get("EbsOptimized"), # type: ignore[arg-type]
|
||||
associate_public_ip_address=params.get("AssociatePublicIpAddress"), # type: ignore[arg-type]
|
||||
block_device_mappings=params.get("BlockDeviceMappings"), # type: ignore[arg-type]
|
||||
instance_id=params.get("InstanceId"),
|
||||
metadata_options=params.get("MetadataOptions"),
|
||||
classic_link_vpc_id=params.get("ClassicLinkVPCId"),
|
||||
@ -311,17 +311,17 @@ class AutoScalingResponse(BaseResponse):
|
||||
def put_scaling_policy(self) -> str:
|
||||
params = self._get_params()
|
||||
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"),
|
||||
metric_aggregation_type=params.get("MetricAggregationType"),
|
||||
adjustment_type=params.get("AdjustmentType"),
|
||||
as_name=params.get("AutoScalingGroupName"),
|
||||
min_adjustment_magnitude=params.get("MinAdjustmentMagnitude"),
|
||||
metric_aggregation_type=params.get("MetricAggregationType"), # type: ignore[arg-type]
|
||||
adjustment_type=params.get("AdjustmentType"), # type: ignore[arg-type]
|
||||
as_name=params.get("AutoScalingGroupName"), # type: ignore[arg-type]
|
||||
min_adjustment_magnitude=params.get("MinAdjustmentMagnitude"), # type: ignore[arg-type]
|
||||
scaling_adjustment=self._get_int_param("ScalingAdjustment"),
|
||||
cooldown=self._get_int_param("Cooldown"),
|
||||
target_tracking_config=params.get("TargetTrackingConfiguration", {}),
|
||||
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(
|
||||
"PredictiveScalingConfiguration", {}
|
||||
),
|
||||
@ -480,7 +480,7 @@ class AutoScalingResponse(BaseResponse):
|
||||
def enable_metrics_collection(self) -> str:
|
||||
group_name = self._get_param("AutoScalingGroupName")
|
||||
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)
|
||||
return template.render()
|
||||
|
||||
|
@ -23,9 +23,9 @@ import weakref
|
||||
import requests.exceptions
|
||||
|
||||
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.utils import unix_time_millis, BackendDict
|
||||
from moto.core.utils import unix_time_millis
|
||||
from moto.iam.models import iam_backends
|
||||
from moto.iam.exceptions import IAMNotFoundException
|
||||
from moto.logs.models import logs_backends
|
||||
|
@ -1,7 +1,7 @@
|
||||
import importlib
|
||||
import moto
|
||||
import sys
|
||||
from moto.core.utils import BackendDict
|
||||
from moto.core import BackendDict
|
||||
from typing import Iterable, Tuple
|
||||
|
||||
|
||||
|
@ -9,7 +9,7 @@ import threading
|
||||
import dateutil.parser
|
||||
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.ec2.models import ec2_backends, EC2Backend
|
||||
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_FAMILIES as EC2_INSTANCE_FAMILIES
|
||||
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._internal import mock_random
|
||||
from moto.moto_api._internal.managed_state_model import ManagedState
|
||||
|
@ -5,7 +5,7 @@ from ..batch.models import (
|
||||
ClientException,
|
||||
BatchBackend,
|
||||
)
|
||||
from ..core.utils import BackendDict
|
||||
from ..core import BackendDict
|
||||
|
||||
import datetime
|
||||
from typing import Any, Dict, List, Tuple, Optional
|
||||
|
@ -1,8 +1,8 @@
|
||||
from collections import defaultdict
|
||||
from copy import deepcopy
|
||||
from datetime import datetime
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core.utils import unix_time, BackendDict
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from moto.core.utils import unix_time
|
||||
from typing import Any, Dict, Iterable, List
|
||||
from .exceptions import BudgetMissingLimit, DuplicateRecordException, NotFoundException
|
||||
|
||||
|
@ -1,8 +1,7 @@
|
||||
"""CostExplorerBackend class with methods for supported APIs."""
|
||||
|
||||
from .exceptions import CostCategoryNotFound
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core.utils import BackendDict
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from moto.utilities.tagging_service import TaggingService
|
||||
from moto.moto_api._internal import mock_random
|
||||
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.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 (
|
||||
iso_8601_datetime_with_milliseconds,
|
||||
iso_8601_datetime_without_milliseconds,
|
||||
BackendDict,
|
||||
)
|
||||
from moto.moto_api._internal import mock_random
|
||||
from moto.sns.models import sns_backends
|
||||
@ -117,7 +116,7 @@ class FakeStackSet(BaseModel):
|
||||
self.execution_role = execution_role or self.execution_role
|
||||
|
||||
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_id=operation_id,
|
||||
@ -158,7 +157,7 @@ class FakeStackSet(BaseModel):
|
||||
)
|
||||
|
||||
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]:
|
||||
operation_id = str(mock_random.uuid4())
|
||||
|
||||
@ -208,7 +207,7 @@ class FakeStackInstances(BaseModel):
|
||||
self,
|
||||
accounts: List[str],
|
||||
regions: List[str],
|
||||
parameters: Optional[Dict[str, str]],
|
||||
parameters: Optional[List[Dict[str, Any]]],
|
||||
) -> Any:
|
||||
for account in accounts:
|
||||
for region in regions:
|
||||
@ -655,7 +654,7 @@ class CloudFormationBackend(BaseBackend):
|
||||
stackset_name: str,
|
||||
accounts: List[str],
|
||||
regions: List[str],
|
||||
parameters: Dict[str, str],
|
||||
parameters: List[Dict[str, Any]],
|
||||
) -> Dict[str, Any]:
|
||||
stack_set = self.get_stack_set(stackset_name)
|
||||
return stack_set.update_instances(accounts, regions, parameters)
|
||||
|
@ -2,8 +2,8 @@ import string
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, Iterable, List, Tuple, Optional
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core.utils import BackendDict, iso_8601_datetime_with_milliseconds
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from moto.core.utils import iso_8601_datetime_with_milliseconds
|
||||
from moto.moto_api import state_manager
|
||||
from moto.moto_api._internal.managed_state_model import ManagedState
|
||||
from moto.moto_api._internal import mock_random as random
|
||||
|
@ -3,8 +3,8 @@ import time
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Iterable, Tuple
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core.utils import iso_8601_datetime_without_milliseconds, BackendDict
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from moto.core.utils import iso_8601_datetime_without_milliseconds
|
||||
from moto.utilities.tagging_service import TaggingService
|
||||
from .exceptions import (
|
||||
S3BucketDoesNotExistException,
|
||||
|
@ -1,11 +1,10 @@
|
||||
import json
|
||||
import statistics
|
||||
|
||||
from moto.core import BaseBackend, BaseModel, CloudWatchMetricProvider
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel, CloudWatchMetricProvider
|
||||
from moto.core.utils import (
|
||||
iso_8601_datetime_without_milliseconds,
|
||||
iso_8601_datetime_with_nanoseconds,
|
||||
BackendDict,
|
||||
)
|
||||
from moto.moto_api._internal import mock_random
|
||||
from datetime import datetime, timedelta
|
||||
|
@ -1,5 +1,5 @@
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core.utils import iso_8601_datetime_with_milliseconds, BackendDict
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from moto.core.utils import iso_8601_datetime_with_milliseconds
|
||||
from moto.moto_api._internal import mock_random
|
||||
from collections import defaultdict
|
||||
from dateutil import parser
|
||||
|
@ -1,5 +1,5 @@
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core.utils import iso_8601_datetime_with_milliseconds, BackendDict
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from moto.core.utils import iso_8601_datetime_with_milliseconds
|
||||
from moto.moto_api._internal import mock_random
|
||||
from datetime import datetime
|
||||
from typing import Dict, List, Optional
|
||||
|
@ -1,7 +1,7 @@
|
||||
import json
|
||||
from datetime import datetime
|
||||
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.models import iam_backends, IAMBackend
|
||||
|
||||
@ -12,7 +12,7 @@ from moto.codepipeline.exceptions import (
|
||||
InvalidTagsException,
|
||||
TooManyTagsException,
|
||||
)
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
|
||||
|
||||
class CodePipeline(BaseModel):
|
||||
|
@ -4,8 +4,8 @@ import re
|
||||
|
||||
from collections import OrderedDict
|
||||
from typing import Any, Dict, List, Optional
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core.utils import iso_8601_datetime_with_milliseconds, BackendDict
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from moto.core.utils import iso_8601_datetime_with_milliseconds
|
||||
from .exceptions import InvalidNameException, ResourceNotFoundError
|
||||
from .utils import get_random_identity_id
|
||||
|
||||
|
@ -7,8 +7,7 @@ import enum
|
||||
from jose import jws
|
||||
from collections import OrderedDict
|
||||
from typing import Any, Dict, List, Tuple, Optional, Set
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core.utils import BackendDict
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from moto.moto_api._internal import mock_random as random
|
||||
from .exceptions import (
|
||||
GroupExistsException,
|
||||
|
@ -1,7 +1,6 @@
|
||||
"""ComprehendBackend class with methods for supported APIs."""
|
||||
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core.utils import BackendDict
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from moto.utilities.tagging_service import TaggingService
|
||||
from .exceptions import ResourceNotFound
|
||||
from typing import Any, Dict, List, Iterable
|
||||
|
@ -48,10 +48,9 @@ from moto.config.exceptions import (
|
||||
MissingRequiredConfigRuleParameterException,
|
||||
)
|
||||
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from moto.core.common_models import ConfigQueryModel
|
||||
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.moto_api._internal import mock_random as random
|
||||
from moto.s3.config import s3_config_query
|
||||
@ -1382,7 +1381,7 @@ class ConfigBackend(BaseBackend):
|
||||
:param next_token:
|
||||
:return:
|
||||
"""
|
||||
identifiers = []
|
||||
identifiers: List[Dict[str, Any]] = []
|
||||
new_token = None
|
||||
|
||||
limit = limit or DEFAULT_PAGE_SIZE
|
||||
@ -1437,7 +1436,7 @@ class ConfigBackend(BaseBackend):
|
||||
|
||||
resource_identifiers.append(item)
|
||||
|
||||
result = {"resourceIdentifiers": resource_identifiers}
|
||||
result: Dict[str, Any] = {"resourceIdentifiers": resource_identifiers}
|
||||
|
||||
if new_token:
|
||||
result["nextToken"] = new_token
|
||||
@ -1469,7 +1468,7 @@ class ConfigBackend(BaseBackend):
|
||||
if not self.config_aggregators.get(aggregator_name):
|
||||
raise NoSuchConfigurationAggregatorException()
|
||||
|
||||
identifiers = []
|
||||
identifiers: List[Dict[str, Any]] = []
|
||||
new_token = None
|
||||
filters = filters or {}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
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 CloudFormationModel, CloudWatchMetricProvider # noqa
|
||||
from .models import patch_client, patch_resource # noqa
|
||||
|
@ -1,15 +1,20 @@
|
||||
from boto3 import Session
|
||||
import re
|
||||
import string
|
||||
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
|
||||
|
||||
|
||||
model_data = defaultdict(dict)
|
||||
model_data: Dict[str, Dict[str, object]] = defaultdict(dict)
|
||||
|
||||
|
||||
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)
|
||||
if name == "BaseModel":
|
||||
return cls
|
||||
@ -17,30 +22,30 @@ class InstanceTrackerMeta(type):
|
||||
service = cls.__module__.split(".")[1]
|
||||
if name not in model_data[service]:
|
||||
model_data[service][name] = cls
|
||||
cls.instances = []
|
||||
cls.instances: ClassVar[List[Any]] = [] # type: ignore
|
||||
return cls
|
||||
|
||||
|
||||
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.account_id = account_id
|
||||
|
||||
def _reset_model_refs(self):
|
||||
def _reset_model_refs(self) -> None:
|
||||
# Remove all references to the models stored
|
||||
for models in model_data.values():
|
||||
for model in models.values():
|
||||
model.instances = []
|
||||
model.instances = [] # type: ignore[attr-defined]
|
||||
|
||||
def reset(self) -> None:
|
||||
region_name = self.region_name
|
||||
account_id = self.account_id
|
||||
self._reset_model_refs()
|
||||
self.__dict__ = {}
|
||||
self.__init__(region_name, account_id)
|
||||
self.__init__(region_name, account_id) # type: ignore[misc]
|
||||
|
||||
@property
|
||||
def _url_module(self):
|
||||
def _url_module(self) -> Any: # type: ignore[misc]
|
||||
backend_module = self.__class__.__module__
|
||||
backend_urls_module_name = backend_module.replace("models", "urls")
|
||||
backend_urls_module = __import__(
|
||||
@ -49,7 +54,7 @@ class BaseBackend:
|
||||
return backend_urls_module
|
||||
|
||||
@property
|
||||
def urls(self):
|
||||
def urls(self) -> Dict[str, str]:
|
||||
"""
|
||||
A dictionary of the urls to be mocked with this service and the handlers
|
||||
that should be called in their place
|
||||
@ -71,7 +76,7 @@ class BaseBackend:
|
||||
return urls
|
||||
|
||||
@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
|
||||
the handlers that should be called in their place
|
||||
@ -86,14 +91,14 @@ class BaseBackend:
|
||||
return paths
|
||||
|
||||
@property
|
||||
def url_bases(self):
|
||||
def url_bases(self) -> List[str]:
|
||||
"""
|
||||
A list containing the url_bases extracted from urls.py
|
||||
"""
|
||||
return self._url_module.url_bases
|
||||
|
||||
@property
|
||||
def flask_paths(self):
|
||||
def flask_paths(self) -> Dict[str, str]:
|
||||
"""
|
||||
The url paths that will be used for the flask server
|
||||
"""
|
||||
@ -106,29 +111,29 @@ class BaseBackend:
|
||||
|
||||
@staticmethod
|
||||
def default_vpc_endpoint_service(
|
||||
service_region, zones
|
||||
): # pylint: disable=unused-argument
|
||||
service_region: str, zones: List[str] # pylint: disable=unused-argument
|
||||
) -> List[Dict[str, str]]:
|
||||
"""Invoke the factory method for any VPC endpoint(s) services."""
|
||||
return None
|
||||
return []
|
||||
|
||||
@staticmethod
|
||||
def vpce_random_number():
|
||||
def vpce_random_number() -> str:
|
||||
from moto.moto_api._internal import mock_random as random
|
||||
|
||||
"""Return random number for a VPC endpoint service ID."""
|
||||
return "".join([random.choice(string.hexdigits.lower()) for i in range(17)])
|
||||
|
||||
@staticmethod
|
||||
def default_vpc_endpoint_service_factory(
|
||||
service_region,
|
||||
zones,
|
||||
service="",
|
||||
service_type="Interface",
|
||||
private_dns_names=True,
|
||||
special_service_name="",
|
||||
policy_supported=True,
|
||||
base_endpoint_dns_names=None,
|
||||
) -> List[Dict[str, str]]: # pylint: disable=too-many-arguments
|
||||
def default_vpc_endpoint_service_factory( # type: ignore[misc]
|
||||
service_region: str,
|
||||
zones: List[str],
|
||||
service: str = "",
|
||||
service_type: str = "Interface",
|
||||
private_dns_names: bool = True,
|
||||
special_service_name: str = "",
|
||||
policy_supported: bool = True,
|
||||
base_endpoint_dns_names: Optional[List[str]] = None,
|
||||
) -> List[Dict[str, Any]]: # pylint: disable=too-many-arguments
|
||||
"""List of dicts representing default VPC endpoints for this service."""
|
||||
if 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):
|
||||
# """For AWS Config. This will list all of the resources of the given type and optional resource name and region"""
|
||||
# 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 moto import settings
|
||||
from moto.core.utils import BackendDict
|
||||
from moto.core.base_backend import BackendDict
|
||||
from .botocore_stubber import BotocoreStubber
|
||||
from .custom_responses_mock import (
|
||||
get_response_mock,
|
||||
|
@ -1,15 +1,9 @@
|
||||
from functools import lru_cache
|
||||
|
||||
import datetime
|
||||
import inspect
|
||||
import re
|
||||
from botocore.exceptions import ClientError
|
||||
from boto3 import Session
|
||||
from moto.settings import allow_unknown_region
|
||||
from threading import RLock
|
||||
from typing import Any, Optional, List
|
||||
from typing import Optional
|
||||
from urllib.parse import urlparse
|
||||
from uuid import uuid4
|
||||
|
||||
|
||||
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)]
|
||||
|
||||
|
||||
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
|
||||
"""
|
||||
@ -308,118 +302,3 @@ def extract_region_from_aws_authorization(string):
|
||||
if region == auth:
|
||||
return None
|
||||
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
|
||||
from datetime import datetime
|
||||
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core.utils import BackendDict
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from moto.core.utils import underscores_to_camelcase
|
||||
from moto.core.utils import camelcase_to_pascal
|
||||
|
||||
|
@ -1,8 +1,7 @@
|
||||
import datetime
|
||||
|
||||
from collections import OrderedDict
|
||||
from moto.core import BaseBackend, BaseModel, CloudFormationModel
|
||||
from moto.core.utils import BackendDict
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel, CloudFormationModel
|
||||
from .utils import get_random_pipeline_id, remove_capitalization_of_dict_keys
|
||||
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
from collections import OrderedDict
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core.utils import BackendDict
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
|
||||
from .exceptions import InvalidRequestException
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
"""DAXBackend class with methods for supported APIs."""
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core.utils import BackendDict, unix_time
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from moto.core.utils import unix_time
|
||||
from moto.moto_api import state_manager
|
||||
from moto.moto_api._internal import mock_random as random
|
||||
from moto.moto_api._internal.managed_state_model import ManagedState
|
||||
|
@ -1,8 +1,7 @@
|
||||
import json
|
||||
|
||||
from datetime import datetime
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core.utils import BackendDict
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
|
||||
from .exceptions import (
|
||||
InvalidResourceStateFault,
|
||||
|
@ -1,8 +1,7 @@
|
||||
"""DirectoryServiceBackend class with methods for supported APIs."""
|
||||
from datetime import datetime, timezone
|
||||
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core.utils import BackendDict
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from moto.ds.exceptions import (
|
||||
ClientException,
|
||||
DirectoryLimitExceededException,
|
||||
|
@ -6,8 +6,8 @@ import json
|
||||
import re
|
||||
|
||||
from collections import OrderedDict
|
||||
from moto.core import BaseBackend, BaseModel, CloudFormationModel
|
||||
from moto.core.utils import unix_time, unix_time_millis, BackendDict
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel, CloudFormationModel
|
||||
from moto.core.utils import unix_time, unix_time_millis
|
||||
from moto.core.exceptions import JsonRESTError
|
||||
from moto.dynamodb.comparisons import get_filter_expression
|
||||
from moto.dynamodb.comparisons import get_expected
|
||||
|
@ -3,8 +3,8 @@ import datetime
|
||||
import json
|
||||
|
||||
from collections import OrderedDict
|
||||
from moto.core import BaseBackend, BaseModel, CloudFormationModel
|
||||
from moto.core.utils import unix_time, BackendDict
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel, CloudFormationModel
|
||||
from moto.core.utils import unix_time
|
||||
from .comparisons import get_comparison_func
|
||||
|
||||
|
||||
|
@ -2,8 +2,7 @@ import os
|
||||
import json
|
||||
import base64
|
||||
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core.utils import BackendDict
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from moto.dynamodb.models import dynamodb_backends, DynamoJsonEncoder
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
"""EBSBackend class with methods for supported APIs."""
|
||||
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core.utils import BackendDict, unix_time
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from moto.core.utils import unix_time
|
||||
from moto.ec2 import ec2_backends
|
||||
from moto.ec2.models.elastic_block_store import Snapshot
|
||||
from moto.moto_api._internal import mock_random
|
||||
|
@ -1,5 +1,4 @@
|
||||
from moto.core import BaseBackend
|
||||
from moto.core.utils import BackendDict
|
||||
from moto.core import BaseBackend, BackendDict
|
||||
from ..exceptions import (
|
||||
EC2ClientError,
|
||||
InvalidID,
|
||||
|
@ -1,6 +1,5 @@
|
||||
import json
|
||||
from moto.core import BaseBackend
|
||||
from moto.core.utils import BackendDict
|
||||
from moto.core import BaseBackend, BackendDict
|
||||
|
||||
|
||||
class Ec2InstanceConnectBackend(BaseBackend):
|
||||
|
@ -7,8 +7,8 @@ from typing import Dict, List
|
||||
|
||||
from botocore.exceptions import ParamValidationError
|
||||
|
||||
from moto.core import BaseBackend, BaseModel, CloudFormationModel
|
||||
from moto.core.utils import iso_8601_datetime_without_milliseconds, BackendDict
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel, CloudFormationModel
|
||||
from moto.core.utils import iso_8601_datetime_without_milliseconds
|
||||
from moto.ecr.exceptions import (
|
||||
ImageNotFoundException,
|
||||
RepositoryNotFoundException,
|
||||
|
@ -5,14 +5,9 @@ from typing import Any
|
||||
import pytz
|
||||
|
||||
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.utils import (
|
||||
unix_time,
|
||||
pascal_to_camelcase,
|
||||
remap_nested_keys,
|
||||
BackendDict,
|
||||
)
|
||||
from moto.core.utils import unix_time, pascal_to_camelcase, remap_nested_keys
|
||||
|
||||
from ..ec2.utils import random_private_ip
|
||||
from moto.ec2 import ec2_backends
|
||||
|
@ -8,12 +8,8 @@ import json
|
||||
import time
|
||||
from copy import deepcopy
|
||||
|
||||
from moto.core import BaseBackend, BaseModel, CloudFormationModel
|
||||
from moto.core.utils import (
|
||||
camelcase_to_underscores,
|
||||
underscores_to_camelcase,
|
||||
BackendDict,
|
||||
)
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel, CloudFormationModel
|
||||
from moto.core.utils import camelcase_to_underscores, underscores_to_camelcase
|
||||
from moto.ec2 import ec2_backends
|
||||
from moto.ec2.exceptions import InvalidSubnetIdError
|
||||
from moto.efs.exceptions import (
|
||||
|
@ -1,7 +1,7 @@
|
||||
from datetime import datetime
|
||||
|
||||
from moto.core import BaseBackend
|
||||
from moto.core.utils import iso_8601_datetime_without_milliseconds, BackendDict
|
||||
from moto.core import BaseBackend, BackendDict
|
||||
from moto.core.utils import iso_8601_datetime_without_milliseconds
|
||||
from moto.moto_api._internal import mock_random as random
|
||||
|
||||
from .exceptions import (
|
||||
|
@ -1,5 +1,4 @@
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core.utils import BackendDict
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
|
||||
from .exceptions import UserAlreadyExists, UserNotFound
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
import weakref
|
||||
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core.utils import BackendDict
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from .exceptions import InvalidParameterValueError, ResourceNotFoundException
|
||||
from .utils import make_arn
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core.utils import BackendDict
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from moto.moto_api._internal import mock_random as random
|
||||
import string
|
||||
|
||||
|
@ -3,8 +3,7 @@ import pytz
|
||||
from collections import OrderedDict
|
||||
from typing import List, Iterable
|
||||
|
||||
from moto.core import BaseBackend, BaseModel, CloudFormationModel
|
||||
from moto.core.utils import BackendDict
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel, CloudFormationModel
|
||||
from moto.ec2.models import ec2_backends
|
||||
from moto.ec2.exceptions import InvalidInstanceIdError
|
||||
from moto.moto_api._internal import mock_random
|
||||
|
@ -5,11 +5,8 @@ from botocore.exceptions import ParamValidationError
|
||||
from collections import OrderedDict
|
||||
from typing import Any, List, Dict, Iterable, Optional
|
||||
from moto.core.exceptions import RESTError
|
||||
from moto.core import BaseBackend, BaseModel, CloudFormationModel
|
||||
from moto.core.utils import (
|
||||
iso_8601_datetime_with_milliseconds,
|
||||
BackendDict,
|
||||
)
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel, CloudFormationModel
|
||||
from moto.core.utils import iso_8601_datetime_with_milliseconds
|
||||
from moto.ec2.models import ec2_backends
|
||||
from moto.moto_api._internal import mock_random
|
||||
from moto.utilities.tagging_service import TaggingService
|
||||
|
@ -5,8 +5,7 @@ import warnings
|
||||
|
||||
import pytz
|
||||
from dateutil.parser import parse as dtparse
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core.utils import BackendDict
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from moto.emr.exceptions import (
|
||||
InvalidRequestException,
|
||||
ValidationException,
|
||||
|
@ -2,8 +2,8 @@
|
||||
import re
|
||||
from datetime import datetime
|
||||
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core.utils import iso_8601_datetime_without_milliseconds, BackendDict
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from moto.core.utils import iso_8601_datetime_without_milliseconds
|
||||
|
||||
from .utils import random_cluster_id, random_job_id, get_partition, paginated_list
|
||||
from .exceptions import ResourceNotFoundException
|
||||
|
@ -3,8 +3,8 @@ import re
|
||||
from datetime import datetime
|
||||
import inspect
|
||||
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core.utils import BackendDict, iso_8601_datetime_without_milliseconds
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from moto.core.utils import iso_8601_datetime_without_milliseconds
|
||||
from .utils import (
|
||||
default_auto_start_configuration,
|
||||
default_auto_stop_configuration,
|
||||
|
@ -1,5 +1,4 @@
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core.utils import BackendDict
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from moto.moto_api._internal import mock_random
|
||||
from .exceptions import DomainNotFound
|
||||
|
||||
|
@ -12,12 +12,11 @@ from operator import lt, le, eq, ge, gt
|
||||
|
||||
from collections import OrderedDict
|
||||
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 (
|
||||
unix_time,
|
||||
unix_time_millis,
|
||||
iso_8601_datetime_without_milliseconds,
|
||||
BackendDict,
|
||||
)
|
||||
from moto.events.exceptions import (
|
||||
ValidationException,
|
||||
|
@ -25,8 +25,7 @@ import warnings
|
||||
|
||||
import requests
|
||||
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core.utils import BackendDict
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from moto.firehose.exceptions import (
|
||||
ConcurrentModificationException,
|
||||
InvalidArgumentException,
|
||||
|
@ -1,8 +1,8 @@
|
||||
import re
|
||||
from datetime import datetime
|
||||
|
||||
from moto.core import BaseBackend
|
||||
from moto.core.utils import iso_8601_datetime_without_milliseconds, BackendDict
|
||||
from moto.core import BaseBackend, BackendDict
|
||||
from moto.core.utils import iso_8601_datetime_without_milliseconds
|
||||
from .exceptions import (
|
||||
InvalidInputException,
|
||||
ResourceAlreadyExistsException,
|
||||
|
@ -2,8 +2,7 @@ import hashlib
|
||||
|
||||
import datetime
|
||||
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core.utils import BackendDict
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from moto.utilities.utils import md5_hash
|
||||
|
||||
from .utils import get_job_id
|
||||
|
@ -4,8 +4,7 @@ from datetime import datetime
|
||||
import re
|
||||
from typing import List
|
||||
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core.utils import BackendDict
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from moto.moto_api import state_manager
|
||||
from moto.moto_api._internal import mock_random
|
||||
from moto.moto_api._internal.managed_state_model import ManagedState
|
||||
|
@ -3,8 +3,8 @@ from collections import OrderedDict
|
||||
from datetime import datetime
|
||||
import re
|
||||
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core.utils import BackendDict, iso_8601_datetime_with_milliseconds
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from moto.core.utils import iso_8601_datetime_with_milliseconds
|
||||
from moto.moto_api._internal import mock_random
|
||||
from .exceptions import (
|
||||
GreengrassClientError,
|
||||
|
@ -1,6 +1,5 @@
|
||||
from __future__ import unicode_literals
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core.utils import BackendDict
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from moto.moto_api._internal import mock_random
|
||||
from datetime import datetime
|
||||
|
||||
|
@ -13,11 +13,16 @@ from jinja2 import Template
|
||||
from typing import List, Mapping
|
||||
from urllib import parse
|
||||
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 (
|
||||
iso_8601_datetime_without_milliseconds,
|
||||
iso_8601_datetime_with_milliseconds,
|
||||
BackendDict,
|
||||
unix_time,
|
||||
)
|
||||
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():
|
||||
if access_key in account["global"].access_keys:
|
||||
return 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]
|
||||
if access_key in account["global"].access_keys:
|
||||
account["global"].access_keys[access_key].last_used = AccessKeyLastUsed(
|
||||
@ -3050,6 +3057,6 @@ class IAMBackend(BaseBackend):
|
||||
return True
|
||||
|
||||
|
||||
iam_backends: Mapping[str, Mapping[str, IAMBackend]] = BackendDict(
|
||||
iam_backends = BackendDict(
|
||||
IAMBackend, "iam", use_boto3_regions=False, additional_regions=["global"]
|
||||
)
|
||||
|
@ -1,5 +1,4 @@
|
||||
from moto.core import BaseBackend
|
||||
from moto.core.utils import BackendDict
|
||||
from moto.core import BaseBackend, BackendDict
|
||||
|
||||
|
||||
class InstanceMetadataBackend(BaseBackend):
|
||||
|
@ -11,8 +11,7 @@ from datetime import datetime, timedelta
|
||||
|
||||
from .utils import PAGINATION_MODEL
|
||||
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core.utils import BackendDict
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from moto.moto_api._internal import mock_random as random
|
||||
from moto.utilities.paginator import paginate
|
||||
from .exceptions import (
|
||||
|
@ -2,8 +2,8 @@ import json
|
||||
import time
|
||||
import jsondiff
|
||||
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core.utils import merge_dicts, BackendDict
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from moto.core.utils import merge_dicts
|
||||
from moto.iot import iot_backends
|
||||
from .exceptions import (
|
||||
ConflictException,
|
||||
|
@ -5,8 +5,8 @@ import itertools
|
||||
|
||||
from operator import attrgetter
|
||||
|
||||
from moto.core import BaseBackend, BaseModel, CloudFormationModel
|
||||
from moto.core.utils import unix_time, BackendDict
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel, CloudFormationModel
|
||||
from moto.core.utils import unix_time
|
||||
from moto.utilities.paginator import paginate
|
||||
from moto.utilities.utils import md5_hash
|
||||
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 .exceptions import ResourceNotFoundException, ResourceInUseException
|
||||
from moto.core.utils import BackendDict
|
||||
from moto.moto_api._internal import mock_random as random
|
||||
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
from moto.core import BaseBackend
|
||||
from moto.core.utils import BackendDict
|
||||
from moto.core import BaseBackend, BackendDict
|
||||
from moto.kinesisvideo import kinesisvideo_backends
|
||||
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 moto.core import BaseBackend, BaseModel, CloudFormationModel
|
||||
from moto.core.utils import unix_time, BackendDict
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel, CloudFormationModel
|
||||
from moto.core.utils import unix_time
|
||||
from moto.moto_api._internal import mock_random
|
||||
from moto.utilities.tagging_service import TaggingService
|
||||
from moto.core.exceptions import JsonRESTError
|
||||
|
@ -1,8 +1,8 @@
|
||||
from datetime import datetime, timedelta
|
||||
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.utils import unix_time_millis, BackendDict
|
||||
from moto.core.utils import unix_time_millis
|
||||
from moto.logs.metric_filters import MetricFilters
|
||||
from moto.logs.exceptions import (
|
||||
ResourceNotFoundException,
|
||||
|
@ -3,8 +3,7 @@ from __future__ import division
|
||||
import datetime
|
||||
import re
|
||||
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core.utils import BackendDict
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
|
||||
from .exceptions import (
|
||||
BadRequestException,
|
||||
|
@ -1,7 +1,6 @@
|
||||
from collections import OrderedDict
|
||||
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core.utils import BackendDict
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from moto.mediaconnect.exceptions import NotFoundException
|
||||
from moto.moto_api._internal import mock_random as random
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
from collections import OrderedDict
|
||||
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core.utils import BackendDict
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from moto.moto_api._internal import mock_random
|
||||
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
from collections import OrderedDict
|
||||
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core.utils import BackendDict
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
|
||||
from .exceptions import ClientError
|
||||
|
||||
|
@ -1,8 +1,7 @@
|
||||
from collections import OrderedDict
|
||||
from datetime import date
|
||||
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core.utils import BackendDict
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from .exceptions import (
|
||||
ContainerNotFoundException,
|
||||
ResourceNotFoundException,
|
||||
|
@ -1,8 +1,7 @@
|
||||
import hashlib
|
||||
from collections import OrderedDict
|
||||
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core.utils import BackendDict
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from .exceptions import ClientError
|
||||
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
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.core.utils import BackendDict
|
||||
|
||||
|
||||
class UsageRecord(BaseModel, dict):
|
||||
|
@ -1,4 +1,4 @@
|
||||
from moto.core import BaseBackend
|
||||
from moto.core import BaseBackend, DEFAULT_ACCOUNT_ID
|
||||
|
||||
|
||||
class MotoAPIBackend(BaseBackend):
|
||||
@ -31,4 +31,4 @@ class MotoAPIBackend(BaseBackend):
|
||||
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
|
||||
from botocore.awsrequest import AWSPreparedRequest
|
||||
from typing import Any, Optional
|
||||
from urllib.parse import urlparse
|
||||
|
||||
|
||||
@ -14,7 +15,7 @@ class Recorder:
|
||||
self._os_enabled = bool(os.environ.get("MOTO_ENABLE_RECORDING", False))
|
||||
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
|
||||
"""
|
||||
|
@ -16,8 +16,8 @@ except ImportError:
|
||||
|
||||
import moto.backends as backends
|
||||
import moto.backend_index as backend_index
|
||||
from moto.core import DEFAULT_ACCOUNT_ID
|
||||
from moto.core.utils import convert_to_flask_response, BackendDict
|
||||
from moto.core import BackendDict, DEFAULT_ACCOUNT_ID
|
||||
from moto.core.utils import convert_to_flask_response
|
||||
|
||||
from .utilities import AWSTestHelper, RegexConverter
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
import base64
|
||||
import xmltodict
|
||||
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core.utils import BackendDict, unix_time
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from moto.core.utils import unix_time
|
||||
from moto.moto_api._internal import mock_random
|
||||
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.core.utils import BackendDict
|
||||
from moto.moto_api._internal import mock_random as random
|
||||
import datetime
|
||||
|
||||
|
@ -2,9 +2,9 @@ import datetime
|
||||
import re
|
||||
import json
|
||||
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
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.exceptions import (
|
||||
InvalidInputException,
|
||||
|
@ -1,8 +1,8 @@
|
||||
"""PersonalizeBackend class with methods for supported APIs."""
|
||||
|
||||
from .exceptions import ResourceNotFoundException
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core.utils import BackendDict, unix_time
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from moto.core.utils import unix_time
|
||||
|
||||
|
||||
class Schema(BaseModel):
|
||||
|
@ -1,6 +1,6 @@
|
||||
from datetime import datetime
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core.utils import BackendDict, unix_time
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from moto.core.utils import unix_time
|
||||
from moto.moto_api._internal import mock_random
|
||||
from moto.utilities.tagging_service import TaggingService
|
||||
|
||||
|
@ -1,8 +1,7 @@
|
||||
from xml.etree import ElementTree as ET
|
||||
import datetime
|
||||
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core.utils import BackendDict
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
|
||||
from .resources import VOICE_DATA
|
||||
from .utils import make_arn_for_lexicon
|
||||
|
@ -1,7 +1,6 @@
|
||||
"""QuickSightBackend class with methods for supported APIs."""
|
||||
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core.utils import BackendDict
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from .exceptions import ResourceNotFoundException
|
||||
|
||||
|
||||
|
@ -2,8 +2,8 @@ import re
|
||||
import string
|
||||
from datetime import datetime
|
||||
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core.utils import unix_time, BackendDict
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from moto.core.utils import unix_time
|
||||
from moto.moto_api._internal import mock_random as random
|
||||
from moto.organizations import organizations_backends
|
||||
from moto.ram.exceptions import (
|
||||
|
@ -7,8 +7,8 @@ from collections import defaultdict
|
||||
from jinja2 import Template
|
||||
from re import compile as re_compile
|
||||
from collections import OrderedDict
|
||||
from moto.core import BaseBackend, BaseModel, CloudFormationModel
|
||||
from moto.core.utils import iso_8601_datetime_with_milliseconds, BackendDict
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel, CloudFormationModel
|
||||
from moto.core.utils import iso_8601_datetime_with_milliseconds
|
||||
from moto.ec2.models import ec2_backends
|
||||
from moto.moto_api._internal import mock_random as random
|
||||
from .exceptions import (
|
||||
|
@ -2,8 +2,8 @@ import copy
|
||||
import datetime
|
||||
|
||||
from collections import OrderedDict
|
||||
from moto.core import BaseBackend, BaseModel, CloudFormationModel
|
||||
from moto.core.utils import iso_8601_datetime_with_milliseconds, BackendDict
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel, CloudFormationModel
|
||||
from moto.core.utils import iso_8601_datetime_with_milliseconds
|
||||
from moto.ec2 import ec2_backends
|
||||
from moto.moto_api._internal import mock_random
|
||||
from .exceptions import (
|
||||
|
@ -1,8 +1,8 @@
|
||||
import re
|
||||
from datetime import datetime
|
||||
|
||||
from moto.core import BaseBackend
|
||||
from moto.core.utils import BackendDict, iso_8601_datetime_without_milliseconds
|
||||
from moto.core import BaseBackend, BackendDict
|
||||
from moto.core.utils import iso_8601_datetime_without_milliseconds
|
||||
from moto.moto_api._internal import mock_random as random
|
||||
from moto.redshiftdata.exceptions import ValidationException, ResourceNotFoundException
|
||||
|
||||
|
@ -2,8 +2,7 @@
|
||||
|
||||
import string
|
||||
|
||||
from moto.core import BaseBackend
|
||||
from moto.core.utils import BackendDict
|
||||
from moto.core import BaseBackend, BackendDict
|
||||
from moto.moto_api._internal import mock_random as random
|
||||
|
||||
|
||||
|
@ -3,8 +3,7 @@ from builtins import str
|
||||
import json
|
||||
import re
|
||||
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core.utils import BackendDict
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
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.utils import BackendDict
|
||||
from moto.moto_api._internal import mock_random
|
||||
|
||||
from moto.s3 import s3_backends
|
||||
|
@ -18,8 +18,7 @@ from moto.route53.exceptions import (
|
||||
PublicZoneVPCAssociation,
|
||||
QueryLoggingConfigAlreadyExists,
|
||||
)
|
||||
from moto.core import BaseBackend, BaseModel, CloudFormationModel
|
||||
from moto.core.utils import BackendDict
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel, CloudFormationModel
|
||||
from moto.moto_api._internal import mock_random as random
|
||||
from moto.utilities.paginator import paginate
|
||||
from .utils import PAGINATION_MODEL
|
||||
|
@ -4,8 +4,7 @@ from datetime import datetime, timezone
|
||||
from ipaddress import ip_address, ip_network, IPv4Address
|
||||
import re
|
||||
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core.utils import BackendDict
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from moto.ec2 import ec2_backends
|
||||
from moto.ec2.exceptions import InvalidSubnetIdError
|
||||
from moto.ec2.exceptions import InvalidSecurityGroupNotFoundError
|
||||
|
@ -14,14 +14,13 @@ import urllib.parse
|
||||
|
||||
from bisect import insort
|
||||
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.utils import (
|
||||
iso_8601_datetime_without_milliseconds_s3,
|
||||
rfc_1123_datetime,
|
||||
unix_time,
|
||||
unix_time_millis,
|
||||
BackendDict,
|
||||
)
|
||||
from moto.cloudwatch.models import MetricDatum
|
||||
from moto.moto_api import state_manager
|
||||
|
@ -1,7 +1,6 @@
|
||||
from collections import defaultdict
|
||||
from datetime import datetime
|
||||
from moto.core import BaseBackend, BaseModel
|
||||
from moto.core.utils import BackendDict
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from moto.moto_api._internal import mock_random
|
||||
from moto.s3.exceptions import (
|
||||
WrongPublicAccessBlockAccountIdError,
|
||||
|
@ -1,8 +1,7 @@
|
||||
import json
|
||||
import os
|
||||
from datetime import datetime
|
||||
from moto.core import BaseBackend, BaseModel, CloudFormationModel
|
||||
from moto.core.utils import BackendDict
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel, CloudFormationModel
|
||||
from moto.sagemaker import validators
|
||||
from moto.utilities.paginator import paginate
|
||||
from .exceptions import (
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user