Admin: sorting imports with ruff (#7075)
This commit is contained in:
parent
ecf3de7851
commit
55c589072f
@ -5,3 +5,6 @@
|
||||
96e5b1993d7f2451443bfabff4265029ac6625af
|
||||
e00af2f73cb7d27c3755f18b2161b9acbd8ca8aa
|
||||
29d01c35bc06d5a8462487d614e33b9e8416ba96
|
||||
|
||||
# import sorting
|
||||
ca682c8e5647feacb26f8570f77f1bdb6b5d3b9a
|
||||
|
@ -1,15 +1,24 @@
|
||||
import importlib
|
||||
import sys
|
||||
from contextlib import ContextDecorator
|
||||
from typing import (
|
||||
TYPE_CHECKING,
|
||||
Any,
|
||||
Callable,
|
||||
List,
|
||||
Optional,
|
||||
TypeVar,
|
||||
Union,
|
||||
overload,
|
||||
)
|
||||
|
||||
from moto.core.models import BaseMockAWS, base_decorator, BaseDecorator
|
||||
from typing import Any, Callable, List, Optional, TypeVar, Union, overload
|
||||
from typing import TYPE_CHECKING
|
||||
from moto.core.models import BaseDecorator, BaseMockAWS, base_decorator
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from moto.xray import XRaySegment as xray_segment_type
|
||||
from typing_extensions import ParamSpec
|
||||
|
||||
from moto.xray import XRaySegment as xray_segment_type
|
||||
|
||||
P = ParamSpec("P")
|
||||
|
||||
|
||||
@ -255,9 +264,9 @@ __version__ = "4.2.11.dev"
|
||||
try:
|
||||
# Need to monkey-patch botocore requests back to underlying urllib3 classes
|
||||
from botocore.awsrequest import (
|
||||
HTTPSConnectionPool,
|
||||
HTTPConnectionPool,
|
||||
HTTPConnection,
|
||||
HTTPConnectionPool,
|
||||
HTTPSConnectionPool,
|
||||
VerifiedHTTPSConnection,
|
||||
)
|
||||
except ImportError:
|
||||
|
@ -1,5 +1,5 @@
|
||||
from .models import acm_backends
|
||||
from ..core.models import base_decorator
|
||||
from .models import acm_backends
|
||||
|
||||
acm_backend = acm_backends["us-east-1"]
|
||||
mock_acm = base_decorator(acm_backends)
|
||||
|
@ -1,25 +1,25 @@
|
||||
import base64
|
||||
import re
|
||||
import datetime
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from moto.core.utils import utcnow
|
||||
import re
|
||||
from typing import Any, Dict, Iterable, List, Optional, Set, Tuple
|
||||
|
||||
import cryptography.hazmat.primitives.asymmetric.rsa
|
||||
import cryptography.x509
|
||||
from cryptography.hazmat.backends import default_backend
|
||||
from cryptography.hazmat.primitives import hashes, serialization
|
||||
from cryptography.x509 import OID_COMMON_NAME, DNSName, NameOID
|
||||
|
||||
from moto import settings
|
||||
from typing import Any, Dict, List, Iterable, Optional, Tuple, Set
|
||||
from moto.core import BackendDict, BaseBackend, BaseModel
|
||||
from moto.core.utils import utcnow
|
||||
|
||||
from .exceptions import (
|
||||
AWSValidationException,
|
||||
AWSTooManyTagsException,
|
||||
AWSValidationException,
|
||||
CertificateNotFound,
|
||||
)
|
||||
from .utils import make_arn_for_certificate
|
||||
|
||||
import cryptography.x509
|
||||
from cryptography.x509 import OID_COMMON_NAME, NameOID, DNSName
|
||||
import cryptography.hazmat.primitives.asymmetric.rsa
|
||||
from cryptography.hazmat.primitives import serialization, hashes
|
||||
from cryptography.hazmat.backends import default_backend
|
||||
|
||||
|
||||
AWS_ROOT_CA = b"""-----BEGIN CERTIFICATE-----
|
||||
MIIESTCCAzGgAwIBAgITBntQXCplJ7wevi2i0ZmY7bibLDANBgkqhkiG9w0BAQsF
|
||||
ADA5MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6
|
||||
|
@ -1,11 +1,11 @@
|
||||
import json
|
||||
import base64
|
||||
import json
|
||||
from typing import Dict, List, Tuple, Union
|
||||
|
||||
from moto.core.responses import BaseResponse
|
||||
from typing import Dict, List, Tuple, Union
|
||||
from .models import acm_backends, AWSCertificateManagerBackend
|
||||
from .exceptions import AWSValidationException
|
||||
|
||||
from .exceptions import AWSValidationException
|
||||
from .models import AWSCertificateManagerBackend, acm_backends
|
||||
|
||||
GENERIC_RESPONSE_TYPE = Union[str, Tuple[str, Dict[str, int]]]
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
"""acmpca module initialization; sets value for base decorator."""
|
||||
from .models import acmpca_backends
|
||||
from ..core.models import base_decorator
|
||||
from .models import acmpca_backends
|
||||
|
||||
mock_acmpca = base_decorator(acmpca_backends)
|
||||
|
@ -1,18 +1,20 @@
|
||||
"""ACMPCABackend class with methods for supported APIs."""
|
||||
import base64
|
||||
from .exceptions import ResourceNotFoundException
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
import datetime
|
||||
from typing import Any, Dict, List, Optional, Tuple
|
||||
|
||||
import cryptography.hazmat.primitives.asymmetric.rsa
|
||||
import cryptography.x509
|
||||
from cryptography.hazmat.backends import default_backend
|
||||
from cryptography.hazmat.primitives import hashes, serialization
|
||||
from cryptography.x509 import Certificate, NameOID, load_pem_x509_certificate
|
||||
|
||||
from moto.core import BackendDict, BaseBackend, BaseModel
|
||||
from moto.core.utils import unix_time, utcnow
|
||||
from moto.moto_api._internal import mock_random
|
||||
from moto.utilities.tagging_service import TaggingService
|
||||
|
||||
import datetime
|
||||
import cryptography.x509
|
||||
from cryptography.x509 import NameOID, load_pem_x509_certificate, Certificate
|
||||
import cryptography.hazmat.primitives.asymmetric.rsa
|
||||
from cryptography.hazmat.primitives import serialization, hashes
|
||||
from cryptography.hazmat.backends import default_backend
|
||||
from typing import Any, Dict, List, Optional, Tuple
|
||||
from .exceptions import ResourceNotFoundException
|
||||
|
||||
|
||||
class CertificateAuthority(BaseModel):
|
||||
|
@ -3,7 +3,8 @@ import base64
|
||||
import json
|
||||
|
||||
from moto.core.responses import BaseResponse
|
||||
from .models import acmpca_backends, ACMPCABackend
|
||||
|
||||
from .models import ACMPCABackend, acmpca_backends
|
||||
|
||||
|
||||
class ACMPCAResponse(BaseResponse):
|
||||
|
@ -1,5 +1,5 @@
|
||||
"""amp module initialization; sets value for base decorator."""
|
||||
from .models import amp_backends
|
||||
from ..core.models import base_decorator
|
||||
from .models import amp_backends
|
||||
|
||||
mock_amp = base_decorator(amp_backends)
|
||||
|
@ -1,4 +1,5 @@
|
||||
import json
|
||||
|
||||
from moto.core.exceptions import JsonRESTError
|
||||
|
||||
|
||||
|
@ -1,11 +1,13 @@
|
||||
"""PrometheusServiceBackend class with methods for supported APIs."""
|
||||
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from typing import Any, Callable, Dict, List, Optional
|
||||
|
||||
from moto.core import BackendDict, BaseBackend, 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
|
||||
from typing import Any, Callable, Dict, List, Optional
|
||||
|
||||
from .exceptions import RuleGroupNamespaceNotFound, WorkspaceNotFound
|
||||
from .utils import PAGINATION_MODEL
|
||||
|
||||
|
@ -1,11 +1,12 @@
|
||||
"""Handles incoming amp requests, invokes methods, returns responses."""
|
||||
import json
|
||||
|
||||
from moto.core.responses import BaseResponse
|
||||
from .models import amp_backends, PrometheusServiceBackend
|
||||
from typing import Any
|
||||
from urllib.parse import unquote
|
||||
|
||||
from moto.core.responses import BaseResponse
|
||||
|
||||
from .models import PrometheusServiceBackend, amp_backends
|
||||
|
||||
|
||||
class PrometheusServiceResponse(BaseResponse):
|
||||
"""Handler for PrometheusService requests and responses."""
|
||||
|
@ -1,5 +1,5 @@
|
||||
from .models import apigateway_backends
|
||||
from ..core.models import base_decorator
|
||||
from .models import apigateway_backends
|
||||
|
||||
apigateway_backend = apigateway_backends["us-east-1"]
|
||||
mock_apigateway = base_decorator(apigateway_backends)
|
||||
|
@ -1,6 +1,7 @@
|
||||
from moto.core.exceptions import JsonRESTError
|
||||
from typing import Any
|
||||
|
||||
from moto.core.exceptions import JsonRESTError
|
||||
|
||||
|
||||
class ApiGatewayException(JsonRESTError):
|
||||
pass
|
||||
|
@ -1,6 +1,8 @@
|
||||
import abc
|
||||
from typing import Tuple, Union
|
||||
|
||||
from requests.models import PreparedRequest
|
||||
|
||||
from ..models import Integration
|
||||
|
||||
|
||||
|
@ -1,8 +1,9 @@
|
||||
from typing import Tuple, Union
|
||||
|
||||
import requests
|
||||
|
||||
from . import IntegrationParser
|
||||
from ..models import Integration
|
||||
from typing import Tuple, Union
|
||||
from . import IntegrationParser
|
||||
|
||||
|
||||
class TypeAwsParser(IntegrationParser):
|
||||
|
@ -1,8 +1,9 @@
|
||||
import requests
|
||||
from typing import Tuple, Union
|
||||
|
||||
from . import IntegrationParser
|
||||
import requests
|
||||
|
||||
from ..models import Integration
|
||||
from . import IntegrationParser
|
||||
|
||||
|
||||
class TypeHttpParser(IntegrationParser):
|
||||
|
@ -1,7 +1,9 @@
|
||||
import requests
|
||||
from typing import Tuple, Union
|
||||
from . import IntegrationParser
|
||||
|
||||
import requests
|
||||
|
||||
from ..models import Integration
|
||||
from . import IntegrationParser
|
||||
|
||||
|
||||
class TypeUnknownParser(IntegrationParser):
|
||||
|
@ -1,8 +1,8 @@
|
||||
from collections import defaultdict
|
||||
from datetime import datetime
|
||||
import re
|
||||
import string
|
||||
import time
|
||||
from collections import defaultdict
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Tuple, Union
|
||||
from urllib.parse import urlparse
|
||||
|
||||
@ -17,54 +17,56 @@ except ImportError:
|
||||
# (Also exists in 0.7.0, but throws a warning)
|
||||
from openapi_spec_validator import validate_spec as validate # type: ignore
|
||||
from openapi_spec_validator.validation.exceptions import OpenAPIValidationError
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel, CloudFormationModel
|
||||
from .utils import create_id, to_path
|
||||
|
||||
from moto.apigateway.exceptions import MethodNotFoundException
|
||||
from moto.core import BackendDict, BaseBackend, BaseModel, CloudFormationModel
|
||||
from moto.core.utils import path_url
|
||||
from moto.moto_api._internal import mock_random as random
|
||||
|
||||
from ..core.models import responses_mock
|
||||
from .exceptions import (
|
||||
BadRequestException,
|
||||
ConflictException,
|
||||
DeploymentNotFoundException,
|
||||
ApiKeyAlreadyExists,
|
||||
ApiKeyNotFoundException,
|
||||
UsagePlanNotFoundException,
|
||||
ApiKeyValueMinLength,
|
||||
AuthorizerNotFoundException,
|
||||
AwsProxyNotAllowed,
|
||||
BadRequestException,
|
||||
BasePathConflictException,
|
||||
BasePathNotFoundException,
|
||||
ConflictException,
|
||||
CrossAccountNotAllowed,
|
||||
DeploymentNotFoundException,
|
||||
DomainNameNotFound,
|
||||
GatewayResponseNotFound,
|
||||
IntegrationMethodNotDefined,
|
||||
InvalidArn,
|
||||
InvalidIntegrationArn,
|
||||
InvalidBasePathException,
|
||||
InvalidDomainName,
|
||||
InvalidHttpEndpoint,
|
||||
InvalidIntegrationArn,
|
||||
InvalidModelName,
|
||||
InvalidOpenAPIDocumentException,
|
||||
InvalidOpenApiDocVersionException,
|
||||
InvalidOpenApiModeException,
|
||||
InvalidResourcePathException,
|
||||
AuthorizerNotFoundException,
|
||||
StageNotFoundException,
|
||||
ResourceIdNotFoundException,
|
||||
RoleNotSpecified,
|
||||
InvalidRestApiId,
|
||||
InvalidRestApiIdForBasePathMappingException,
|
||||
InvalidStageException,
|
||||
ModelNotFound,
|
||||
NoIntegrationDefined,
|
||||
NoIntegrationResponseDefined,
|
||||
NoMethodDefined,
|
||||
ApiKeyAlreadyExists,
|
||||
DomainNameNotFound,
|
||||
InvalidDomainName,
|
||||
InvalidRestApiId,
|
||||
InvalidModelName,
|
||||
RestAPINotFound,
|
||||
RequestValidatorNotFound,
|
||||
ModelNotFound,
|
||||
ApiKeyValueMinLength,
|
||||
InvalidBasePathException,
|
||||
InvalidRestApiIdForBasePathMappingException,
|
||||
InvalidStageException,
|
||||
BasePathConflictException,
|
||||
BasePathNotFoundException,
|
||||
ResourceIdNotFoundException,
|
||||
RestAPINotFound,
|
||||
RoleNotSpecified,
|
||||
StageNotFoundException,
|
||||
StageStillActive,
|
||||
VpcLinkNotFound,
|
||||
UsagePlanNotFoundException,
|
||||
ValidationException,
|
||||
GatewayResponseNotFound,
|
||||
VpcLinkNotFound,
|
||||
)
|
||||
from ..core.models import responses_mock
|
||||
from moto.apigateway.exceptions import MethodNotFoundException
|
||||
from moto.moto_api._internal import mock_random as random
|
||||
from .utils import create_id, to_path
|
||||
|
||||
STAGE_URL = "https://{api_id}.execute-api.{region_name}.amazonaws.com/{stage_name}"
|
||||
|
||||
|
@ -2,11 +2,12 @@ import json
|
||||
from typing import Any, Dict, List
|
||||
from urllib.parse import unquote
|
||||
|
||||
from moto.core.responses import TYPE_RESPONSE, BaseResponse
|
||||
from moto.utilities.utils import merge_multiple_dicts
|
||||
from moto.core.responses import BaseResponse, TYPE_RESPONSE
|
||||
from .models import apigateway_backends, APIGatewayBackend
|
||||
from .utils import deserialize_body
|
||||
|
||||
from .exceptions import InvalidRequestInput
|
||||
from .models import APIGatewayBackend, apigateway_backends
|
||||
from .utils import deserialize_body
|
||||
|
||||
API_KEY_SOURCES = ["AUTHORIZER", "HEADER"]
|
||||
AUTHORIZER_TYPES = ["TOKEN", "REQUEST", "COGNITO_USER_POOLS"]
|
||||
|
@ -1,5 +1,5 @@
|
||||
from .responses import APIGatewayResponse
|
||||
from ..apigatewayv2.urls import url_paths as url_paths_v2
|
||||
from .responses import APIGatewayResponse
|
||||
|
||||
url_bases = [r"https?://apigateway\.(.+)\.amazonaws.com"]
|
||||
|
||||
|
@ -1,9 +1,11 @@
|
||||
import string
|
||||
import json
|
||||
import yaml
|
||||
from moto.moto_api._internal import mock_random as random
|
||||
import string
|
||||
from typing import Any, Dict
|
||||
|
||||
import yaml
|
||||
|
||||
from moto.moto_api._internal import mock_random as random
|
||||
|
||||
|
||||
def create_id() -> str:
|
||||
size = 10
|
||||
|
@ -1,5 +1,5 @@
|
||||
"""apigatewaymanagementapi module initialization; sets value for base decorator."""
|
||||
from .models import apigatewaymanagementapi_backends
|
||||
from ..core.models import base_decorator
|
||||
from .models import apigatewaymanagementapi_backends
|
||||
|
||||
mock_apigatewaymanagementapi = base_decorator(apigatewaymanagementapi_backends)
|
||||
|
@ -1,7 +1,8 @@
|
||||
"""ApiGatewayManagementApiBackend class with methods for supported APIs."""
|
||||
from collections import defaultdict
|
||||
from typing import Any, Dict
|
||||
from moto.core import BaseBackend, BackendDict
|
||||
|
||||
from moto.core import BackendDict, BaseBackend
|
||||
from moto.core.utils import unix_time
|
||||
|
||||
|
||||
|
@ -3,7 +3,8 @@ import json
|
||||
from typing import Any
|
||||
|
||||
from moto.core.responses import BaseResponse
|
||||
from .models import apigatewaymanagementapi_backends, ApiGatewayManagementApiBackend
|
||||
|
||||
from .models import ApiGatewayManagementApiBackend, apigatewaymanagementapi_backends
|
||||
|
||||
|
||||
class ApiGatewayManagementApiResponse(BaseResponse):
|
||||
|
@ -1,5 +1,5 @@
|
||||
"""apigatewayv2 module initialization; sets value for base decorator."""
|
||||
from .models import apigatewayv2_backends
|
||||
from ..core.models import base_decorator
|
||||
from .models import apigatewayv2_backends
|
||||
|
||||
mock_apigatewayv2 = base_decorator(apigatewayv2_backends)
|
||||
|
@ -1,10 +1,11 @@
|
||||
"""ApiGatewayV2Backend class with methods for supported APIs."""
|
||||
import hashlib
|
||||
import string
|
||||
import yaml
|
||||
from typing import Any, Dict, List, Optional, Union
|
||||
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
import yaml
|
||||
|
||||
from moto.core import BackendDict, BaseBackend, 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
|
||||
@ -14,15 +15,15 @@ from .exceptions import (
|
||||
ApiNotFound,
|
||||
AuthorizerNotFound,
|
||||
BadRequestException,
|
||||
ModelNotFound,
|
||||
RouteResponseNotFound,
|
||||
DomainNameAlreadyExists,
|
||||
DomainNameNotFound,
|
||||
IntegrationNotFound,
|
||||
IntegrationResponseNotFound,
|
||||
ModelNotFound,
|
||||
RouteNotFound,
|
||||
VpcLinkNotFound,
|
||||
DomainNameNotFound,
|
||||
DomainNameAlreadyExists,
|
||||
RouteResponseNotFound,
|
||||
StageNotFound,
|
||||
VpcLinkNotFound,
|
||||
)
|
||||
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
"""Handles incoming apigatewayv2 requests, invokes methods, returns responses."""
|
||||
import json
|
||||
|
||||
from moto.core.responses import BaseResponse, TYPE_RESPONSE
|
||||
from typing import Any
|
||||
from urllib.parse import unquote
|
||||
|
||||
from moto.core.responses import TYPE_RESPONSE, BaseResponse
|
||||
|
||||
from .exceptions import UnknownProtocol
|
||||
from .models import apigatewayv2_backends, ApiGatewayV2Backend
|
||||
from .models import ApiGatewayV2Backend, apigatewayv2_backends
|
||||
|
||||
|
||||
class ApiGatewayV2Response(BaseResponse):
|
||||
|
@ -1,5 +1,5 @@
|
||||
"""appconfig module initialization; sets value for base decorator."""
|
||||
from .models import appconfig_backends
|
||||
from ..core.models import base_decorator
|
||||
from .models import appconfig_backends
|
||||
|
||||
mock_appconfig = base_decorator(appconfig_backends)
|
||||
|
@ -1,7 +1,9 @@
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from typing import Any, Dict, Iterable, List, Optional
|
||||
|
||||
from moto.core import BackendDict, BaseBackend, BaseModel
|
||||
from moto.moto_api._internal import mock_random
|
||||
from moto.utilities.tagging_service import TaggingService
|
||||
from typing import Any, Dict, List, Iterable, Optional
|
||||
|
||||
from .exceptions import (
|
||||
AppNotFoundException,
|
||||
ConfigurationProfileNotFound,
|
||||
|
@ -1,10 +1,11 @@
|
||||
import json
|
||||
|
||||
from moto.core.responses import BaseResponse
|
||||
from .models import appconfig_backends, AppConfigBackend
|
||||
from typing import Any, Dict, Tuple
|
||||
from urllib.parse import unquote
|
||||
|
||||
from moto.core.responses import BaseResponse
|
||||
|
||||
from .models import AppConfigBackend, appconfig_backends
|
||||
|
||||
|
||||
class AppConfigResponse(BaseResponse):
|
||||
def tags(self, request: Any, full_url: str, headers: Any) -> str: # type: ignore[return]
|
||||
|
@ -1,4 +1,4 @@
|
||||
from .models import applicationautoscaling_backends
|
||||
from ..core.models import base_decorator
|
||||
from .models import applicationautoscaling_backends
|
||||
|
||||
mock_applicationautoscaling = base_decorator(applicationautoscaling_backends)
|
||||
|
@ -1,11 +1,13 @@
|
||||
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
|
||||
import time
|
||||
from collections import OrderedDict
|
||||
from enum import Enum, unique
|
||||
from typing import Dict, List, Union, Optional, Tuple
|
||||
import time
|
||||
from typing import Dict, List, Optional, Tuple, Union
|
||||
|
||||
from moto.core import BackendDict, BaseBackend, BaseModel
|
||||
from moto.ecs import ecs_backends
|
||||
from moto.moto_api._internal import mock_random
|
||||
|
||||
from .exceptions import AWSValidationException
|
||||
|
||||
|
||||
@unique
|
||||
|
@ -1,16 +1,18 @@
|
||||
from moto.core.responses import BaseResponse
|
||||
from typing import Any, Dict
|
||||
import json
|
||||
from typing import Any, Dict
|
||||
|
||||
from moto.core.responses import BaseResponse
|
||||
|
||||
from .exceptions import AWSValidationException
|
||||
from .models import (
|
||||
applicationautoscaling_backends,
|
||||
ApplicationAutoscalingBackend,
|
||||
FakeApplicationAutoscalingPolicy,
|
||||
FakeScalableTarget,
|
||||
FakeScheduledAction,
|
||||
ScalableDimensionValueSet,
|
||||
ServiceNamespaceValueSet,
|
||||
ApplicationAutoscalingBackend,
|
||||
FakeScalableTarget,
|
||||
FakeApplicationAutoscalingPolicy,
|
||||
FakeScheduledAction,
|
||||
applicationautoscaling_backends,
|
||||
)
|
||||
from .exceptions import AWSValidationException
|
||||
|
||||
|
||||
class ApplicationAutoScalingResponse(BaseResponse):
|
||||
|
@ -1,5 +1,5 @@
|
||||
"""appsync module initialization; sets value for base decorator."""
|
||||
from .models import appsync_backends
|
||||
from ..core.models import base_decorator
|
||||
from .models import appsync_backends
|
||||
|
||||
mock_appsync = base_decorator(appsync_backends)
|
||||
|
@ -1,4 +1,5 @@
|
||||
import json
|
||||
|
||||
from moto.core.exceptions import JsonRESTError
|
||||
|
||||
|
||||
|
@ -1,13 +1,14 @@
|
||||
import base64
|
||||
import json
|
||||
from datetime import timedelta, datetime, timezone
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from typing import Any, Dict, Iterable, List, Optional, Tuple
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
|
||||
from moto.core import BackendDict, BaseBackend, BaseModel
|
||||
from moto.core.utils import unix_time
|
||||
from moto.moto_api._internal import mock_random
|
||||
from moto.utilities.tagging_service import TaggingService
|
||||
|
||||
from .exceptions import GraphqlAPINotFound, GraphQLSchemaException, BadRequestException
|
||||
from .exceptions import BadRequestException, GraphqlAPINotFound, GraphQLSchemaException
|
||||
|
||||
# AWS custom scalars and directives
|
||||
# https://github.com/dotansimha/graphql-code-generator/discussions/4311#discussioncomment-2921796
|
||||
@ -65,8 +66,8 @@ class GraphqlSchema(BaseModel):
|
||||
def _parse_graphql_definition(self) -> None:
|
||||
try:
|
||||
from graphql import parse
|
||||
from graphql.language.ast import ObjectTypeDefinitionNode
|
||||
from graphql.error.graphql_error import GraphQLError
|
||||
from graphql.language.ast import ObjectTypeDefinitionNode
|
||||
|
||||
res = parse(self.definition)
|
||||
for definition in res.definitions:
|
||||
@ -79,10 +80,10 @@ class GraphqlSchema(BaseModel):
|
||||
|
||||
def get_introspection_schema(self, format_: str, include_directives: bool) -> str:
|
||||
from graphql import (
|
||||
print_schema,
|
||||
build_client_schema,
|
||||
introspection_from_schema,
|
||||
build_schema,
|
||||
introspection_from_schema,
|
||||
print_schema,
|
||||
)
|
||||
|
||||
schema = build_schema(self.definition + AWS_CUSTOM_GRAPHQL)
|
||||
|
@ -1,10 +1,11 @@
|
||||
"""Handles incoming appsync requests, invokes methods, returns responses."""
|
||||
import json
|
||||
|
||||
from moto.core.responses import BaseResponse, TYPE_RESPONSE
|
||||
from typing import Any
|
||||
from urllib.parse import unquote
|
||||
from .models import appsync_backends, AppSyncBackend
|
||||
|
||||
from moto.core.responses import TYPE_RESPONSE, BaseResponse
|
||||
|
||||
from .models import AppSyncBackend, appsync_backends
|
||||
|
||||
|
||||
class AppSyncResponse(BaseResponse):
|
||||
|
@ -1,5 +1,5 @@
|
||||
from .models import athena_backends
|
||||
from ..core.models import base_decorator
|
||||
from .models import athena_backends
|
||||
|
||||
athena_backend = athena_backends["us-east-1"]
|
||||
mock_athena = base_decorator(athena_backends)
|
||||
|
@ -1,4 +1,5 @@
|
||||
import json
|
||||
|
||||
from moto.core.exceptions import JsonRESTError
|
||||
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
from datetime import datetime
|
||||
import time
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from moto.core import BackendDict, BaseBackend, BaseModel
|
||||
from moto.moto_api._internal import mock_random
|
||||
from moto.utilities.paginator import paginate
|
||||
|
||||
|
@ -1,8 +1,9 @@
|
||||
import json
|
||||
from typing import Dict, Tuple, Union
|
||||
|
||||
from moto.core.responses import BaseResponse
|
||||
from .models import athena_backends, AthenaBackend
|
||||
from typing import Dict, Tuple, Union
|
||||
|
||||
from .models import AthenaBackend, athena_backends
|
||||
|
||||
|
||||
class AthenaResponse(BaseResponse):
|
||||
|
@ -1,5 +1,5 @@
|
||||
from .models import autoscaling_backends
|
||||
from ..core.models import base_decorator
|
||||
from .models import autoscaling_backends
|
||||
|
||||
autoscaling_backend = autoscaling_backends["us-east-1"]
|
||||
mock_autoscaling = base_decorator(autoscaling_backends)
|
||||
|
@ -1,26 +1,26 @@
|
||||
import itertools
|
||||
from collections import OrderedDict
|
||||
from typing import Any, Dict, List, Optional, Tuple, Union
|
||||
|
||||
from moto.packages.boto.ec2.blockdevicemapping import (
|
||||
BlockDeviceType,
|
||||
BlockDeviceMapping,
|
||||
)
|
||||
from moto.ec2.exceptions import InvalidInstanceIdError
|
||||
|
||||
from collections import OrderedDict
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel, CloudFormationModel
|
||||
from moto.core import BackendDict, BaseBackend, BaseModel, CloudFormationModel
|
||||
from moto.core.utils import camelcase_to_underscores
|
||||
from moto.ec2 import ec2_backends
|
||||
from moto.ec2.exceptions import InvalidInstanceIdError
|
||||
from moto.ec2.models import EC2Backend
|
||||
from moto.ec2.models.instances import Instance
|
||||
from moto.elb.models import elb_backends, ELBBackend
|
||||
from moto.elbv2.models import elbv2_backends, ELBv2Backend
|
||||
from moto.elb.exceptions import LoadBalancerNotFoundError
|
||||
from moto.elb.models import ELBBackend, elb_backends
|
||||
from moto.elbv2.models import ELBv2Backend, elbv2_backends
|
||||
from moto.moto_api._internal import mock_random as random
|
||||
from moto.packages.boto.ec2.blockdevicemapping import (
|
||||
BlockDeviceMapping,
|
||||
BlockDeviceType,
|
||||
)
|
||||
|
||||
from .exceptions import (
|
||||
AutoscalingClientError,
|
||||
ResourceContentionError,
|
||||
InvalidInstanceError,
|
||||
ResourceContentionError,
|
||||
ValidationError,
|
||||
)
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
from moto.core.responses import BaseResponse
|
||||
from moto.core.utils import iso_8601_datetime_with_milliseconds
|
||||
from moto.utilities.aws_headers import amz_crc32, amzn_request_id
|
||||
from .models import autoscaling_backends, AutoScalingBackend
|
||||
|
||||
from .models import AutoScalingBackend, autoscaling_backends
|
||||
|
||||
|
||||
class AutoScalingResponse(BaseResponse):
|
||||
|
@ -1,5 +1,5 @@
|
||||
from .models import lambda_backends
|
||||
from ..core.models import base_decorator
|
||||
from .models import lambda_backends
|
||||
|
||||
lambda_backend = lambda_backends["us-east-1"]
|
||||
mock_lambda = base_decorator(lambda_backends)
|
||||
|
@ -1,6 +1,7 @@
|
||||
from moto.core.exceptions import JsonRESTError
|
||||
from typing import Any
|
||||
|
||||
from moto.core.exceptions import JsonRESTError
|
||||
|
||||
|
||||
class LambdaClientError(JsonRESTError):
|
||||
def __init__(self, error: str, message: str):
|
||||
|
@ -1,50 +1,55 @@
|
||||
import base64
|
||||
import time
|
||||
from collections import defaultdict
|
||||
import calendar
|
||||
import copy
|
||||
from datetime import datetime
|
||||
from gzip import GzipFile
|
||||
from typing import Any, Dict, Iterable, List, Optional, Tuple, Union
|
||||
from sys import platform
|
||||
|
||||
import hashlib
|
||||
import io
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import json
|
||||
import re
|
||||
import zipfile
|
||||
import tarfile
|
||||
import calendar
|
||||
import threading
|
||||
import weakref
|
||||
import time
|
||||
import warnings
|
||||
import weakref
|
||||
import zipfile
|
||||
from collections import defaultdict
|
||||
from datetime import datetime
|
||||
from gzip import GzipFile
|
||||
from sys import platform
|
||||
from typing import Any, Dict, Iterable, List, Optional, Tuple, Union
|
||||
|
||||
import requests.exceptions
|
||||
|
||||
from moto import settings
|
||||
from moto.awslambda.policy import Policy
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel, CloudFormationModel
|
||||
from moto.core import BackendDict, BaseBackend, BaseModel, CloudFormationModel
|
||||
from moto.core.exceptions import RESTError
|
||||
from moto.core.utils import unix_time_millis, iso_8601_datetime_with_nanoseconds, utcnow
|
||||
from moto.utilities.utils import load_resource_as_bytes
|
||||
from moto.iam.models import iam_backends
|
||||
from moto.iam.exceptions import IAMNotFoundException
|
||||
from moto.core.utils import iso_8601_datetime_with_nanoseconds, unix_time_millis, utcnow
|
||||
from moto.dynamodb import dynamodb_backends
|
||||
from moto.dynamodbstreams import dynamodbstreams_backends
|
||||
from moto.ecr.exceptions import ImageNotFoundException
|
||||
from moto.ecr.models import ecr_backends
|
||||
from moto.iam.exceptions import IAMNotFoundException
|
||||
from moto.iam.models import iam_backends
|
||||
from moto.logs.models import logs_backends
|
||||
from moto.moto_api._internal import mock_random as random
|
||||
from moto.s3.models import s3_backends, FakeKey
|
||||
from moto.ecr.models import ecr_backends
|
||||
from moto.s3.exceptions import MissingBucket, MissingKey
|
||||
from moto import settings
|
||||
from moto.s3.models import FakeKey, s3_backends
|
||||
from moto.sqs import sqs_backends
|
||||
from moto.utilities.docker_utilities import DockerModel
|
||||
from moto.utilities.utils import load_resource_as_bytes
|
||||
|
||||
from .exceptions import (
|
||||
ConflictException,
|
||||
CrossAccountNotAllowed,
|
||||
FunctionUrlConfigNotFound,
|
||||
InvalidRoleFormat,
|
||||
InvalidParameterValueException,
|
||||
InvalidRoleFormat,
|
||||
UnknownAliasException,
|
||||
UnknownFunctionException,
|
||||
UnknownLayerException,
|
||||
UnknownLayerVersionException,
|
||||
UnknownFunctionException,
|
||||
UnknownAliasException,
|
||||
ValidationException,
|
||||
)
|
||||
from .utils import (
|
||||
@ -54,10 +59,6 @@ from .utils import (
|
||||
make_layer_ver_arn,
|
||||
split_layer_arn,
|
||||
)
|
||||
from moto.sqs import sqs_backends
|
||||
from moto.dynamodb import dynamodb_backends
|
||||
from moto.dynamodbstreams import dynamodbstreams_backends
|
||||
from moto.utilities.docker_utilities import DockerModel
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
import json
|
||||
from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, TypeVar
|
||||
|
||||
from moto.awslambda.exceptions import (
|
||||
PreconditionFailedException,
|
||||
UnknownPolicyException,
|
||||
)
|
||||
from moto.moto_api._internal import mock_random
|
||||
from typing import Any, Callable, Dict, List, Optional, TypeVar, TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .models import LambdaFunction
|
||||
|
@ -3,11 +3,12 @@ import sys
|
||||
from typing import Any, Dict, List, Tuple, Union
|
||||
from urllib.parse import unquote
|
||||
|
||||
from moto.core.responses import TYPE_RESPONSE, BaseResponse
|
||||
from moto.core.utils import path_url
|
||||
from moto.utilities.aws_headers import amz_crc32, amzn_request_id
|
||||
from moto.core.responses import BaseResponse, TYPE_RESPONSE
|
||||
|
||||
from .exceptions import FunctionAlreadyExists, UnknownFunctionException
|
||||
from .models import lambda_backends, LambdaBackend
|
||||
from .models import LambdaBackend, lambda_backends
|
||||
|
||||
|
||||
class LambdaResponse(BaseResponse):
|
||||
|
@ -1,5 +1,5 @@
|
||||
from .models import lambda_simple_backends
|
||||
from ..core.models import base_decorator
|
||||
from .models import lambda_simple_backends
|
||||
|
||||
lambda_simple_backend = lambda_simple_backends["us-east-1"]
|
||||
mock_lambda_simple = base_decorator(lambda_simple_backends)
|
||||
|
@ -1,10 +1,11 @@
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
from ..awslambda.models import (
|
||||
lambda_backends,
|
||||
BaseBackend,
|
||||
LambdaBackend,
|
||||
lambda_backends,
|
||||
)
|
||||
from ..core import BackendDict
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
|
||||
class LambdaSimpleBackend(BaseBackend):
|
||||
|
@ -1,5 +1,5 @@
|
||||
from ..awslambda.responses import LambdaResponse
|
||||
from .models import lambda_simple_backends, LambdaBackend
|
||||
from .models import LambdaBackend, lambda_simple_backends
|
||||
|
||||
|
||||
class LambdaSimpleResponse(LambdaResponse):
|
||||
|
@ -1,9 +1,9 @@
|
||||
import importlib
|
||||
import moto
|
||||
import sys
|
||||
from moto.core import BackendDict
|
||||
from typing import Iterable, Tuple
|
||||
|
||||
import moto
|
||||
from moto.core import BackendDict
|
||||
|
||||
decorators = [d for d in dir(moto) if d.startswith("mock_") and not d == "mock_all"]
|
||||
decorator_functions = [getattr(moto, f) for f in decorators]
|
||||
|
@ -1,5 +1,5 @@
|
||||
from .models import batch_backends
|
||||
from ..core.models import base_decorator
|
||||
from .models import batch_backends
|
||||
|
||||
batch_backend = batch_backends["us-east-1"]
|
||||
mock_batch = base_decorator(batch_backends)
|
||||
|
@ -1,42 +1,42 @@
|
||||
import datetime
|
||||
import dateutil.parser
|
||||
import logging
|
||||
import re
|
||||
import threading
|
||||
import time
|
||||
|
||||
from sys import platform
|
||||
from itertools import cycle
|
||||
from sys import platform
|
||||
from time import sleep
|
||||
from typing import Any, Dict, List, Tuple, Optional, Set
|
||||
from typing import Any, Dict, List, Optional, Set, Tuple
|
||||
|
||||
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
|
||||
from moto.ecs.models import ecs_backends, EC2ContainerServiceBackend
|
||||
from moto.logs.models import logs_backends, LogsBackend
|
||||
from moto.utilities.tagging_service import TaggingService
|
||||
import dateutil.parser
|
||||
|
||||
from .exceptions import InvalidParameterValueException, ClientException, ValidationError
|
||||
from .utils import (
|
||||
make_arn_for_compute_env,
|
||||
make_arn_for_job_queue,
|
||||
make_arn_for_job,
|
||||
make_arn_for_task_def,
|
||||
lowercase_first_key,
|
||||
JobStatus,
|
||||
)
|
||||
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 import settings
|
||||
from moto.core import BackendDict, BaseBackend, BaseModel, CloudFormationModel
|
||||
from moto.core.utils import unix_time_millis
|
||||
from moto.ec2.exceptions import InvalidSubnetIdError
|
||||
from moto.ec2.models import EC2Backend, ec2_backends
|
||||
from moto.ec2.models.instance_types import INSTANCE_FAMILIES as EC2_INSTANCE_FAMILIES
|
||||
from moto.ec2.models.instance_types import INSTANCE_TYPES as EC2_INSTANCE_TYPES
|
||||
from moto.ec2.models.instances import Instance
|
||||
from moto.ecs.models import EC2ContainerServiceBackend, ecs_backends
|
||||
from moto.iam.exceptions import IAMNotFoundException
|
||||
from moto.iam.models import IAMBackend, iam_backends
|
||||
from moto.logs.models import LogsBackend, logs_backends
|
||||
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
|
||||
from moto.utilities.docker_utilities import DockerModel
|
||||
from moto import settings
|
||||
from moto.utilities.tagging_service import TaggingService
|
||||
|
||||
from .exceptions import ClientException, InvalidParameterValueException, ValidationError
|
||||
from .utils import (
|
||||
JobStatus,
|
||||
lowercase_first_key,
|
||||
make_arn_for_compute_env,
|
||||
make_arn_for_job,
|
||||
make_arn_for_job_queue,
|
||||
make_arn_for_task_def,
|
||||
)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
COMPUTE_ENVIRONMENT_NAME_REGEX = re.compile(
|
||||
|
@ -1,9 +1,10 @@
|
||||
import json
|
||||
from urllib.parse import unquote, urlsplit
|
||||
|
||||
from moto.core.responses import BaseResponse
|
||||
from moto.utilities.aws_headers import amzn_request_id
|
||||
from .models import batch_backends, BatchBackend
|
||||
from urllib.parse import urlsplit, unquote
|
||||
|
||||
import json
|
||||
from .models import BatchBackend, batch_backends
|
||||
|
||||
|
||||
class BatchResponse(BaseResponse):
|
||||
|
@ -1,5 +1,5 @@
|
||||
from .models import batch_simple_backends
|
||||
from ..core.models import base_decorator
|
||||
from .models import batch_simple_backends
|
||||
|
||||
batch_backend = batch_simple_backends["us-east-1"]
|
||||
mock_batch_simple = base_decorator(batch_simple_backends)
|
||||
|
@ -1,17 +1,17 @@
|
||||
import datetime
|
||||
from os import getenv
|
||||
from time import sleep
|
||||
from typing import Any, Dict, List, Optional, Tuple
|
||||
|
||||
from ..batch.models import (
|
||||
batch_backends,
|
||||
BaseBackend,
|
||||
BatchBackend,
|
||||
ClientException,
|
||||
Job,
|
||||
batch_backends,
|
||||
)
|
||||
from ..core import BackendDict
|
||||
|
||||
import datetime
|
||||
from os import getenv
|
||||
from time import sleep
|
||||
from typing import Any, Dict, List, Tuple, Optional
|
||||
|
||||
|
||||
class BatchSimpleBackend(BaseBackend):
|
||||
"""
|
||||
|
@ -1,5 +1,5 @@
|
||||
from ..batch.responses import BatchResponse
|
||||
from .models import batch_simple_backends, BatchBackend
|
||||
from .models import BatchBackend, batch_simple_backends
|
||||
|
||||
|
||||
class BatchSimpleResponse(BatchResponse):
|
||||
|
@ -1,4 +1,4 @@
|
||||
from .models import budgets_backends
|
||||
from ..core.models import base_decorator
|
||||
from .models import budgets_backends
|
||||
|
||||
mock_budgets = base_decorator(budgets_backends)
|
||||
|
@ -1,9 +1,11 @@
|
||||
from collections import defaultdict
|
||||
from copy import deepcopy
|
||||
from datetime import datetime
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from moto.core.utils import unix_time
|
||||
from typing import Any, Dict, Iterable, List
|
||||
|
||||
from moto.core import BackendDict, BaseBackend, BaseModel
|
||||
from moto.core.utils import unix_time
|
||||
|
||||
from .exceptions import BudgetMissingLimit, DuplicateRecordException, NotFoundException
|
||||
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
import json
|
||||
|
||||
from moto.core.responses import BaseResponse
|
||||
from .models import budgets_backends, BudgetsBackend
|
||||
|
||||
from .models import BudgetsBackend, budgets_backends
|
||||
|
||||
|
||||
class BudgetsResponse(BaseResponse):
|
||||
|
@ -1,5 +1,5 @@
|
||||
"""ce module initialization; sets value for base decorator."""
|
||||
from .models import ce_backends
|
||||
from ..core.models import base_decorator
|
||||
from .models import ce_backends
|
||||
|
||||
mock_ce = base_decorator(ce_backends)
|
||||
|
@ -1,12 +1,14 @@
|
||||
"""CostExplorerBackend class with methods for supported APIs."""
|
||||
|
||||
from .exceptions import CostCategoryNotFound
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from moto.utilities.tagging_service import TaggingService
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Tuple
|
||||
|
||||
from moto.core import BackendDict, BaseBackend, BaseModel
|
||||
from moto.core.utils import iso_8601_datetime_without_milliseconds
|
||||
from moto.moto_api._internal import mock_random
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, List, Tuple, Optional
|
||||
from moto.utilities.tagging_service import TaggingService
|
||||
|
||||
from .exceptions import CostCategoryNotFound
|
||||
|
||||
|
||||
def first_day() -> str:
|
||||
|
@ -2,7 +2,8 @@
|
||||
import json
|
||||
|
||||
from moto.core.responses import BaseResponse
|
||||
from .models import ce_backends, CostExplorerBackend
|
||||
|
||||
from .models import CostExplorerBackend, ce_backends
|
||||
|
||||
|
||||
class CostExplorerResponse(BaseResponse):
|
||||
|
@ -1,5 +1,5 @@
|
||||
from .models import cloudformation_backends
|
||||
from ..core.models import base_decorator
|
||||
from .models import cloudformation_backends
|
||||
|
||||
cloudformation_backend = cloudformation_backends["us-east-1"]
|
||||
mock_cloudformation = base_decorator(cloudformation_backends)
|
||||
|
@ -3,8 +3,8 @@ import threading
|
||||
from typing import Any, Dict
|
||||
|
||||
from moto import settings
|
||||
from moto.core import CloudFormationModel
|
||||
from moto.awslambda import lambda_backends
|
||||
from moto.core import CloudFormationModel
|
||||
from moto.moto_api._internal import mock_random
|
||||
|
||||
|
||||
|
@ -1,7 +1,9 @@
|
||||
from moto.core.exceptions import RESTError
|
||||
from jinja2 import Template
|
||||
from typing import Optional
|
||||
|
||||
from jinja2 import Template
|
||||
|
||||
from moto.core.exceptions import RESTError
|
||||
|
||||
|
||||
class UnformattedGetAttTemplateException(Exception):
|
||||
description = (
|
||||
|
@ -1,34 +1,34 @@
|
||||
from datetime import datetime, timedelta
|
||||
import json
|
||||
import yaml
|
||||
|
||||
from collections import OrderedDict
|
||||
from typing import Any, Dict, List, Optional, Iterable, Tuple, Union, Type
|
||||
from datetime import datetime, timedelta
|
||||
from typing import Any, Dict, Iterable, List, Optional, Tuple, Type, Union
|
||||
|
||||
import yaml
|
||||
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, BackendDict, BaseModel, CloudFormationModel
|
||||
from moto.core import BackendDict, BaseBackend, BaseModel, CloudFormationModel
|
||||
from moto.core.utils import (
|
||||
iso_8601_datetime_with_milliseconds,
|
||||
iso_8601_datetime_without_milliseconds,
|
||||
utcnow,
|
||||
)
|
||||
from moto.moto_api._internal import mock_random
|
||||
from moto.organizations.models import OrganizationsBackend, organizations_backends
|
||||
from moto.sns.models import sns_backends
|
||||
from moto.organizations.models import organizations_backends, OrganizationsBackend
|
||||
|
||||
from .custom_model import CustomModel
|
||||
from .parsing import ResourceMap, Output, OutputMap, Export
|
||||
from .exceptions import StackSetNotEmpty, StackSetNotFoundException, ValidationError
|
||||
from .parsing import Export, Output, OutputMap, ResourceMap
|
||||
from .utils import (
|
||||
generate_changeset_id,
|
||||
generate_stack_id,
|
||||
generate_stackset_arn,
|
||||
generate_stackset_id,
|
||||
yaml_tag_constructor,
|
||||
validate_template_cfn_lint,
|
||||
get_stack_from_s3_url,
|
||||
validate_template_cfn_lint,
|
||||
yaml_tag_constructor,
|
||||
)
|
||||
from .exceptions import ValidationError, StackSetNotEmpty, StackSetNotFoundException
|
||||
|
||||
|
||||
class FakeStackSet(BaseModel):
|
||||
|
@ -1,24 +1,23 @@
|
||||
import string
|
||||
import collections.abc as collections_abc
|
||||
import copy
|
||||
import functools
|
||||
import json
|
||||
import logging
|
||||
import copy
|
||||
import warnings
|
||||
import re
|
||||
|
||||
import collections.abc as collections_abc
|
||||
import string
|
||||
import warnings
|
||||
from functools import lru_cache
|
||||
from typing import (
|
||||
Any,
|
||||
Dict,
|
||||
List,
|
||||
Union,
|
||||
Iterable,
|
||||
Iterator,
|
||||
List,
|
||||
Optional,
|
||||
Tuple,
|
||||
TypeVar,
|
||||
Type,
|
||||
TypeVar,
|
||||
Union,
|
||||
)
|
||||
|
||||
# This ugly section of imports is necessary because we
|
||||
@ -34,6 +33,9 @@ from moto.awslambda import models as lambda_models # noqa # pylint: disable=al
|
||||
from moto.batch import models as batch_models # noqa # pylint: disable=all
|
||||
from moto.cloudformation.custom_model import CustomModel
|
||||
from moto.cloudwatch import models as cw_models # noqa # pylint: disable=all
|
||||
|
||||
# End ugly list of imports
|
||||
from moto.core import CloudFormationModel
|
||||
from moto.datapipeline import models as data_models # noqa # pylint: disable=all
|
||||
from moto.dynamodb import models as ddb_models # noqa # pylint: disable=all
|
||||
from moto.ec2 import models as ec2_models
|
||||
@ -51,26 +53,23 @@ from moto.rds import models as rds_models # noqa # pylint: disable=all
|
||||
from moto.redshift import models as redshift_models # noqa # pylint: disable=all
|
||||
from moto.route53 import models as route53_models # noqa # pylint: disable=all
|
||||
from moto.s3 import models as s3_models # noqa # pylint: disable=all
|
||||
from moto.s3.models import s3_backends
|
||||
from moto.s3.utils import bucket_and_name_from_url
|
||||
from moto.sagemaker import models as sagemaker_models # noqa # pylint: disable=all
|
||||
from moto.sns import models as sns_models # noqa # pylint: disable=all
|
||||
from moto.sqs import models as sqs_models # noqa # pylint: disable=all
|
||||
from moto.stepfunctions import models as sfn_models # noqa # pylint: disable=all
|
||||
from moto.ssm import models as ssm_models # noqa # pylint: disable=all
|
||||
|
||||
# End ugly list of imports
|
||||
|
||||
from moto.core import CloudFormationModel
|
||||
from moto.s3.models import s3_backends
|
||||
from moto.s3.utils import bucket_and_name_from_url
|
||||
from moto.ssm import ssm_backends
|
||||
from .utils import random_suffix
|
||||
from moto.stepfunctions import models as sfn_models # noqa # pylint: disable=all
|
||||
|
||||
from .exceptions import (
|
||||
ExportNotFound,
|
||||
MissingParameterError,
|
||||
UnformattedGetAttTemplateException,
|
||||
ValidationError,
|
||||
UnsupportedAttribute,
|
||||
ValidationError,
|
||||
)
|
||||
from .utils import random_suffix
|
||||
|
||||
CF_MODEL = TypeVar("CF_MODEL", bound=CloudFormationModel)
|
||||
|
||||
|
@ -1,16 +1,18 @@
|
||||
import json
|
||||
import re
|
||||
from typing import Any, Dict, List, Optional, Tuple, Union
|
||||
|
||||
import yaml
|
||||
from typing import Any, Dict, Tuple, List, Optional, Union
|
||||
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.responses import BaseResponse
|
||||
from moto.s3.exceptions import S3ClientError
|
||||
from moto.utilities.aws_headers import amzn_request_id
|
||||
from .models import cloudformation_backends, CloudFormationBackend, FakeStack
|
||||
from .exceptions import ValidationError, MissingParameterError
|
||||
from .utils import yaml_tag_constructor, get_stack_from_s3_url
|
||||
|
||||
from .exceptions import MissingParameterError, ValidationError
|
||||
from .models import CloudFormationBackend, FakeStack, cloudformation_backends
|
||||
from .utils import get_stack_from_s3_url, yaml_tag_constructor
|
||||
|
||||
|
||||
def get_template_summary_response_from_template(template_body: str) -> Dict[str, Any]:
|
||||
|
@ -1,10 +1,12 @@
|
||||
import yaml
|
||||
import os
|
||||
import string
|
||||
from moto.moto_api._internal import mock_random as random
|
||||
from typing import Any, List
|
||||
from urllib.parse import urlparse
|
||||
|
||||
import yaml
|
||||
|
||||
from moto.moto_api._internal import mock_random as random
|
||||
|
||||
|
||||
def generate_stack_id(stack_name: str, region: str, account: str) -> str:
|
||||
random_id = random.uuid4()
|
||||
@ -56,7 +58,7 @@ def yaml_tag_constructor(loader: Any, tag: Any, node: Any) -> Any:
|
||||
|
||||
def validate_template_cfn_lint(template: str) -> List[Any]:
|
||||
# Importing cfnlint adds a significant overhead, so we keep it local
|
||||
from cfnlint import decode, core
|
||||
from cfnlint import core, decode
|
||||
|
||||
# Save the template to a temporary file -- cfn-lint requires a file
|
||||
filename = "file.tmp"
|
||||
|
@ -1,4 +1,4 @@
|
||||
from .models import cloudfront_backends
|
||||
from ..core.models import base_decorator
|
||||
from .models import cloudfront_backends
|
||||
|
||||
mock_cloudfront = base_decorator(cloudfront_backends)
|
||||
|
@ -1,6 +1,7 @@
|
||||
from moto.core.exceptions import RESTError
|
||||
from typing import Any
|
||||
|
||||
from moto.core.exceptions import RESTError
|
||||
|
||||
EXCEPTION_RESPONSE = """<?xml version="1.0"?>
|
||||
<ErrorResponse xmlns="http://cloudfront.amazonaws.com/doc/2020-05-31/">
|
||||
<Error>
|
||||
|
@ -1,21 +1,21 @@
|
||||
import string
|
||||
from typing import Any, Dict, Iterable, List, Optional, Tuple
|
||||
|
||||
from typing import Any, Dict, Iterable, List, Tuple, Optional
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from moto.core import BackendDict, BaseBackend, 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
|
||||
from moto.moto_api._internal.managed_state_model import ManagedState
|
||||
from moto.utilities.tagging_service import TaggingService
|
||||
|
||||
from .exceptions import (
|
||||
OriginDoesNotExist,
|
||||
InvalidOriginServer,
|
||||
DomainNameNotAnS3Bucket,
|
||||
DistributionAlreadyExists,
|
||||
DomainNameNotAnS3Bucket,
|
||||
InvalidIfMatchVersion,
|
||||
InvalidOriginServer,
|
||||
NoSuchDistribution,
|
||||
NoSuchOriginAccessControl,
|
||||
OriginDoesNotExist,
|
||||
)
|
||||
|
||||
|
||||
|
@ -1,10 +1,11 @@
|
||||
import xmltodict
|
||||
from typing import Any, Dict
|
||||
from urllib.parse import unquote
|
||||
|
||||
from moto.core.responses import BaseResponse, TYPE_RESPONSE
|
||||
from .models import cloudfront_backends, CloudFrontBackend
|
||||
import xmltodict
|
||||
|
||||
from moto.core.responses import TYPE_RESPONSE, BaseResponse
|
||||
|
||||
from .models import CloudFrontBackend, cloudfront_backends
|
||||
|
||||
XMLNS = "http://cloudfront.amazonaws.com/doc/2020-05-31/"
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
"""cloudfront base URL and path."""
|
||||
from .responses import CloudFrontResponse
|
||||
|
||||
|
||||
url_bases = [
|
||||
r"https?://cloudfront\.amazonaws\.com",
|
||||
]
|
||||
|
@ -1,5 +1,5 @@
|
||||
"""cloudtrail module initialization; sets value for base decorator."""
|
||||
from .models import cloudtrail_backends
|
||||
from ..core.models import base_decorator
|
||||
from .models import cloudtrail_backends
|
||||
|
||||
mock_cloudtrail = base_decorator(cloudtrail_backends)
|
||||
|
@ -1,19 +1,20 @@
|
||||
import re
|
||||
import time
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Iterable, Tuple
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from typing import Any, Dict, Iterable, List, Optional, Tuple
|
||||
|
||||
from moto.core import BackendDict, BaseBackend, BaseModel
|
||||
from moto.core.utils import iso_8601_datetime_without_milliseconds, utcnow
|
||||
from moto.utilities.tagging_service import TaggingService
|
||||
|
||||
from .exceptions import (
|
||||
S3BucketDoesNotExistException,
|
||||
InsufficientSnsTopicPolicyException,
|
||||
S3BucketDoesNotExistException,
|
||||
TrailNameInvalidChars,
|
||||
TrailNameNotEndingCorrectly,
|
||||
TrailNameNotStartingCorrectly,
|
||||
TrailNameTooLong,
|
||||
TrailNameTooShort,
|
||||
TrailNameNotStartingCorrectly,
|
||||
TrailNameNotEndingCorrectly,
|
||||
TrailNameInvalidChars,
|
||||
TrailNotFoundException,
|
||||
)
|
||||
|
||||
|
@ -1,9 +1,11 @@
|
||||
"""Handles incoming cloudtrail requests, invokes methods, returns responses."""
|
||||
import json
|
||||
from typing import Any, Dict
|
||||
|
||||
from moto.core.responses import BaseResponse
|
||||
from .models import cloudtrail_backends, CloudTrailBackend
|
||||
|
||||
from .exceptions import InvalidParameterCombinationException
|
||||
from .models import CloudTrailBackend, cloudtrail_backends
|
||||
|
||||
|
||||
class CloudTrailResponse(BaseResponse):
|
||||
|
@ -1,4 +1,4 @@
|
||||
from .models import cloudwatch_backends
|
||||
from ..core.models import base_decorator
|
||||
from .models import cloudwatch_backends
|
||||
|
||||
mock_cloudwatch = base_decorator(cloudwatch_backends)
|
||||
|
@ -1,4 +1,4 @@
|
||||
from typing import Any, Dict, List, Tuple, SupportsFloat
|
||||
from typing import Any, Dict, List, SupportsFloat, Tuple
|
||||
|
||||
|
||||
def parse_expression(
|
||||
|
@ -1,28 +1,29 @@
|
||||
import json
|
||||
from datetime import datetime, timedelta
|
||||
from typing import Any, Dict, Iterable, List, Optional, SupportsFloat, Tuple
|
||||
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel, CloudWatchMetricProvider
|
||||
from dateutil import parser
|
||||
from dateutil.tz import tzutc
|
||||
|
||||
from moto.core import BackendDict, BaseBackend, BaseModel, CloudWatchMetricProvider
|
||||
from moto.core.utils import (
|
||||
iso_8601_datetime_without_milliseconds,
|
||||
iso_8601_datetime_with_nanoseconds,
|
||||
iso_8601_datetime_without_milliseconds,
|
||||
utcnow,
|
||||
)
|
||||
from moto.moto_api._internal import mock_random
|
||||
from datetime import datetime, timedelta
|
||||
from dateutil.tz import tzutc
|
||||
|
||||
from ..utilities.tagging_service import TaggingService
|
||||
from .exceptions import (
|
||||
InvalidFormat,
|
||||
ResourceNotFound,
|
||||
ValidationError,
|
||||
InvalidParameterValue,
|
||||
ResourceNotFoundException,
|
||||
InvalidParameterCombination,
|
||||
InvalidParameterValue,
|
||||
ResourceNotFound,
|
||||
ResourceNotFoundException,
|
||||
ValidationError,
|
||||
)
|
||||
from .metric_data_expression_parser import parse_expression
|
||||
from .utils import make_arn_for_dashboard, make_arn_for_alarm
|
||||
from dateutil import parser
|
||||
from typing import Tuple, Optional, List, Iterable, Dict, Any, SupportsFloat
|
||||
from ..utilities.tagging_service import TaggingService
|
||||
from .utils import make_arn_for_alarm, make_arn_for_dashboard
|
||||
|
||||
_EMPTY_LIST: Any = tuple()
|
||||
|
||||
|
@ -1,20 +1,21 @@
|
||||
import json
|
||||
from typing import Dict, Iterable, List, Tuple, Union
|
||||
|
||||
from dateutil.parser import parse as dtparse
|
||||
from typing import Dict, List, Iterable, Tuple, Union
|
||||
|
||||
from moto.core.responses import BaseResponse
|
||||
from moto.utilities.aws_headers import amzn_request_id
|
||||
|
||||
from .exceptions import InvalidParameterCombination, ValidationError
|
||||
from .models import (
|
||||
cloudwatch_backends,
|
||||
CloudWatchBackend,
|
||||
MetricDataQuery,
|
||||
MetricStat,
|
||||
Metric,
|
||||
Dimension,
|
||||
FakeAlarm,
|
||||
Metric,
|
||||
MetricDataQuery,
|
||||
MetricStat,
|
||||
cloudwatch_backends,
|
||||
)
|
||||
from .exceptions import InvalidParameterCombination, ValidationError
|
||||
|
||||
|
||||
ERROR_RESPONSE = Tuple[str, Dict[str, int]]
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
from .models import codebuild_backends
|
||||
from ..core.models import base_decorator
|
||||
from .models import codebuild_backends
|
||||
|
||||
mock_codebuild = base_decorator(codebuild_backends)
|
||||
|
@ -1,10 +1,12 @@
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
import datetime
|
||||
from collections import defaultdict
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
from dateutil import parser
|
||||
|
||||
from moto.core import BackendDict, BaseBackend, 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
|
||||
from typing import Any, Dict, List, Optional
|
||||
import datetime
|
||||
|
||||
|
||||
class CodeBuildProjectMetadata(BaseModel):
|
||||
|
@ -1,13 +1,15 @@
|
||||
import json
|
||||
import re
|
||||
from typing import Any, Dict, List
|
||||
|
||||
from moto.core.responses import BaseResponse
|
||||
from .models import codebuild_backends, CodeBuildBackend
|
||||
|
||||
from .exceptions import (
|
||||
InvalidInputException,
|
||||
ResourceAlreadyExistsException,
|
||||
ResourceNotFoundException,
|
||||
)
|
||||
import json
|
||||
import re
|
||||
from typing import Any, Dict, List
|
||||
from .models import CodeBuildBackend, codebuild_backends
|
||||
|
||||
|
||||
def _validate_required_params_source(source: Dict[str, Any]) -> None:
|
||||
|
@ -1,4 +1,4 @@
|
||||
from .models import codecommit_backends
|
||||
from ..core.models import base_decorator
|
||||
from .models import codecommit_backends
|
||||
|
||||
mock_codecommit = base_decorator(codecommit_backends)
|
||||
|
@ -1,7 +1,9 @@
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from typing import Dict, List, Optional
|
||||
|
||||
from moto.core import BackendDict, BaseBackend, BaseModel
|
||||
from moto.core.utils import iso_8601_datetime_with_milliseconds
|
||||
from moto.moto_api._internal import mock_random
|
||||
from typing import Dict, List, Optional
|
||||
|
||||
from .exceptions import RepositoryDoesNotExistException, RepositoryNameExistsException
|
||||
|
||||
|
||||
|
@ -2,8 +2,9 @@ import json
|
||||
import re
|
||||
|
||||
from moto.core.responses import BaseResponse
|
||||
from .models import codecommit_backends, CodeCommitBackend
|
||||
|
||||
from .exceptions import InvalidRepositoryNameException
|
||||
from .models import CodeCommitBackend, codecommit_backends
|
||||
|
||||
|
||||
def _is_repository_name_valid(repository_name: str) -> bool:
|
||||
|
@ -1,4 +1,4 @@
|
||||
from .models import codepipeline_backends
|
||||
from ..core.models import base_decorator
|
||||
from .models import codepipeline_backends
|
||||
|
||||
mock_codepipeline = base_decorator(codepipeline_backends)
|
||||
|
@ -1,17 +1,17 @@
|
||||
import json
|
||||
from typing import Any, Dict, List, Tuple
|
||||
from moto.core.utils import iso_8601_datetime_with_milliseconds, utcnow
|
||||
from moto.iam.exceptions import IAMNotFoundException
|
||||
from moto.iam.models import iam_backends, IAMBackend
|
||||
|
||||
from moto.codepipeline.exceptions import (
|
||||
InvalidStructureException,
|
||||
InvalidTagsException,
|
||||
PipelineNotFoundException,
|
||||
ResourceNotFoundException,
|
||||
InvalidTagsException,
|
||||
TooManyTagsException,
|
||||
)
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from moto.core import BackendDict, BaseBackend, BaseModel
|
||||
from moto.core.utils import iso_8601_datetime_with_milliseconds, utcnow
|
||||
from moto.iam.exceptions import IAMNotFoundException
|
||||
from moto.iam.models import IAMBackend, iam_backends
|
||||
|
||||
|
||||
class CodePipeline(BaseModel):
|
||||
|
@ -1,7 +1,8 @@
|
||||
import json
|
||||
|
||||
from moto.core.responses import BaseResponse
|
||||
from .models import codepipeline_backends, CodePipelineBackend
|
||||
|
||||
from .models import CodePipelineBackend, codepipeline_backends
|
||||
|
||||
|
||||
class CodePipelineResponse(BaseResponse):
|
||||
|
@ -1,4 +1,4 @@
|
||||
from .models import cognitoidentity_backends
|
||||
from ..core.models import base_decorator
|
||||
from .models import cognitoidentity_backends
|
||||
|
||||
mock_cognitoidentity = base_decorator(cognitoidentity_backends)
|
||||
|
@ -1,11 +1,12 @@
|
||||
import datetime
|
||||
import json
|
||||
import re
|
||||
|
||||
from collections import OrderedDict
|
||||
from typing import Any, Dict, List, Optional
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
|
||||
from moto.core import BackendDict, BaseBackend, BaseModel
|
||||
from moto.core.utils import utcnow
|
||||
|
||||
from .exceptions import InvalidNameException, ResourceNotFoundError
|
||||
from .utils import get_random_identity_id
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
from moto.core.responses import BaseResponse
|
||||
from .models import cognitoidentity_backends, CognitoIdentityBackend
|
||||
|
||||
from .models import CognitoIdentityBackend, cognitoidentity_backends
|
||||
from .utils import get_random_identity_id
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
from .models import cognitoidp_backends
|
||||
from ..core.models import base_decorator
|
||||
from .models import cognitoidp_backends
|
||||
|
||||
mock_cognitoidp = base_decorator(cognitoidp_backends)
|
||||
|
@ -1,6 +1,7 @@
|
||||
from moto.core.exceptions import JsonRESTError
|
||||
from typing import Optional
|
||||
|
||||
from moto.core.exceptions import JsonRESTError
|
||||
|
||||
|
||||
class AliasExistsException(JsonRESTError):
|
||||
def __init__(self) -> None:
|
||||
|
@ -1,40 +1,43 @@
|
||||
import datetime
|
||||
import enum
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import time
|
||||
import typing
|
||||
import enum
|
||||
import re
|
||||
from jose import jws
|
||||
from collections import OrderedDict
|
||||
from typing import Any, Dict, List, Tuple, Optional, Set
|
||||
from moto.core import BaseBackend, BackendDict, BaseModel
|
||||
from typing import Any, Dict, List, Optional, Set, Tuple
|
||||
|
||||
from jose import jws
|
||||
|
||||
from moto.core import BackendDict, BaseBackend, BaseModel
|
||||
from moto.core.utils import utcnow
|
||||
from moto.moto_api._internal import mock_random as random
|
||||
from .exceptions import (
|
||||
AliasExistsException,
|
||||
GroupExistsException,
|
||||
NotAuthorizedError,
|
||||
ResourceNotFoundError,
|
||||
UserNotFoundError,
|
||||
UsernameExistsException,
|
||||
UserNotConfirmedException,
|
||||
InvalidParameterException,
|
||||
ExpiredCodeException,
|
||||
InvalidPasswordException,
|
||||
)
|
||||
from .utils import (
|
||||
create_id,
|
||||
check_secret_hash,
|
||||
generate_id,
|
||||
validate_username_format,
|
||||
flatten_attrs,
|
||||
expand_attrs,
|
||||
PAGINATION_MODEL,
|
||||
)
|
||||
from moto.utilities.paginator import paginate
|
||||
from moto.utilities.utils import md5_hash
|
||||
|
||||
from ..settings import get_cognito_idp_user_pool_id_strategy
|
||||
from .exceptions import (
|
||||
AliasExistsException,
|
||||
ExpiredCodeException,
|
||||
GroupExistsException,
|
||||
InvalidParameterException,
|
||||
InvalidPasswordException,
|
||||
NotAuthorizedError,
|
||||
ResourceNotFoundError,
|
||||
UsernameExistsException,
|
||||
UserNotConfirmedException,
|
||||
UserNotFoundError,
|
||||
)
|
||||
from .utils import (
|
||||
PAGINATION_MODEL,
|
||||
check_secret_hash,
|
||||
create_id,
|
||||
expand_attrs,
|
||||
flatten_attrs,
|
||||
generate_id,
|
||||
validate_username_format,
|
||||
)
|
||||
|
||||
|
||||
class UserStatus(str, enum.Enum):
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user