Exemple #1
0
 def _get_reserved_keywords(cls):
     """
     Get a list of reserved keywords of DynamoDB
     """
     reserved_keywords = load_resource(
         __name__, "reserved_keywords.txt", as_json=False
     )
     return reserved_keywords.split()
Exemple #2
0
    MalformedAMIIdError,
    InvalidTaggableResourceType,
    UnvailableAMIIdError,
)
from .core import TaggedEC2Resource
from ..utils import (
    random_ami_id,
    generic_filter,
    utc_date_and_time,
)

if "MOTO_AMIS_PATH" in environ:
    with open(environ.get("MOTO_AMIS_PATH"), "r", encoding="utf-8") as f:
        AMIS = json.load(f)
else:
    AMIS = load_resource(__name__, "../resources/amis.json")


class Ami(TaggedEC2Resource):
    def __init__(
        self,
        ec2_backend,
        ami_id,
        instance=None,
        source_ami=None,
        name=None,
        description=None,
        owner_id=get_account_id(),
        owner_alias=None,
        public=False,
        virtualization_type=None,
Exemple #3
0
from moto.core import BaseBackend
from moto.utilities.utils import load_resource
import datetime
import random


checks_json = "resources/describe_trusted_advisor_checks.json"
ADVISOR_CHECKS = load_resource(__name__, checks_json)


class SupportCase(object):
    def __init__(self, **kwargs):
        self.case_id = kwargs.get("case_id")
        self.display_id = "foo_display_id"
        self.subject = kwargs.get("subject")
        self.status = "opened"
        self.service_code = kwargs.get("service_code")
        self.category_code = kwargs.get("category_code")
        self.severity_code = kwargs.get("severity_code")
        self.submitted_by = "*****@*****.**"
        self.time_created = self.get_datetime()
        self.attachment_set_id = kwargs.get("attachment_set_id")
        self.communication_body = kwargs.get("communication_body")
        self.language = kwargs.get("language")
        self.cc_email_addresses = kwargs.get("cc_email_addresses")
        self.communications = {
            "recentCommunications": {
                "communications": [
                    {
                        "caseId": self.case_id,
                        "body": self.communication_body,
Exemple #4
0
    def __init__(self, path):
        spec = load_resource("botocore", path)

        self.metadata = spec["metadata"]
        self.operations = spec["operations"]
        self.shapes = spec["shapes"]
Exemple #5
0
import pathlib

from os import listdir

from moto.utilities.utils import load_resource
from ..exceptions import InvalidInstanceTypeError

INSTANCE_TYPES = load_resource(__name__, "../resources/instance_types.json")
INSTANCE_FAMILIES = list(set([i.split(".")[0] for i in INSTANCE_TYPES.keys()]))

root = pathlib.Path(__file__).parent
offerings_path = "../resources/instance_type_offerings"
INSTANCE_TYPE_OFFERINGS = {}
for location_type in listdir(root / offerings_path):
    INSTANCE_TYPE_OFFERINGS[location_type] = {}
    for _region in listdir(root / offerings_path / location_type):
        full_path = offerings_path + "/" + location_type + "/" + _region
        res = load_resource(__name__, full_path)
        for instance in res:
            instance["LocationType"] = location_type
        INSTANCE_TYPE_OFFERINGS[location_type][_region.replace(".json", "")] = res


class InstanceTypeBackend(object):
    def __init__(self):
        super().__init__()

    def describe_instance_types(self, instance_types=None):
        matches = INSTANCE_TYPES.values()
        if instance_types:
            matches = [t for t in matches if t.get("InstanceType") in instance_types]