def list_subscriptions(self, topic_arn=None, next_token=None): if topic_arn: topic = self.get_topic(topic_arn) filtered = OrderedDict([ (sub.arn, sub) for sub in self._get_topic_subscriptions(topic) ]) return self._get_values_nexttoken(filtered, next_token) else: return self._get_values_nexttoken(self.subscriptions, next_token)
def list_subscriptions(self, topic_arn=None, next_token=None): if topic_arn: topic = self.get_topic(topic_arn) filtered = OrderedDict([(k, sub) for k, sub in self.subscriptions.items() if sub.topic == topic]) return self._get_values_nexttoken(filtered, next_token) else: return self._get_values_nexttoken(self.subscriptions, next_token)
def __init__(self, region, application, custom_user_data, token, attributes): self.region = region self.application = application self.custom_user_data = custom_user_data self.token = token self.attributes = attributes self.id = uuid.uuid4() self.messages = OrderedDict() self.__fixup_attributes()
def __init__(self, region_name): super(SNSBackend, self).__init__() self.topics = OrderedDict() self.subscriptions = OrderedDict() self.applications = {} self.platform_endpoints = {} self.region_name = region_name self.sms_attributes = {} self.sms_messages = OrderedDict() self.opt_out_numbers = [ "+447420500600", "+447420505401", "+447632960543", "+447632960028", "+447700900149", "+447700900550", "+447700900545", "+447700900907", ]
def __init__(self, region, name, extended_config): self.region = region self.id = "{}_{}".format(self.region, str(uuid.uuid4().hex)) self.name = name self.status = None self.extended_config = extended_config or {} self.creation_date = datetime.datetime.utcnow() self.last_modified_date = datetime.datetime.utcnow() self.clients = OrderedDict() self.identity_providers = OrderedDict() self.users = OrderedDict() self.refresh_tokens = {} self.access_tokens = {} self.id_tokens = {} with open( os.path.join(os.path.dirname(__file__), "resources/jwks-private.json")) as f: self.json_web_key = json.loads(f.read())
def __init__(self, name, security_groups, subnets, vpc_id, arn, dns_name, scheme='internet-facing'): self.name = name self.created_time = datetime.datetime.now() self.scheme = scheme self.security_groups = security_groups self.subnets = subnets or [] self.vpc_id = vpc_id self.listeners = OrderedDict() self.tags = {} self.arn = arn self.dns_name = dns_name
def __init__(self, ec2_backend): self.clusters = {} self.subnet_groups = {} self.security_groups = { "Default": SecurityGroup("Default", "Default Redshift Security Group") } self.parameter_groups = { "default.redshift-1.0": ParameterGroup( "default.redshift-1.0", "redshift-1.0", "Default Redshift parameter group", ) } self.ec2_backend = ec2_backend self.snapshots = OrderedDict()
def __init__( self, name, arn, vpc_id, protocol, port, healthcheck_protocol=None, healthcheck_port=None, healthcheck_path=None, healthcheck_interval_seconds=None, healthcheck_timeout_seconds=None, healthy_threshold_count=None, unhealthy_threshold_count=None, matcher=None, target_type=None, ): # TODO: default values differs when you add Network Load balancer self.name = name self.arn = arn self.vpc_id = vpc_id self.protocol = protocol self.port = port self.healthcheck_protocol = healthcheck_protocol or "HTTP" self.healthcheck_port = healthcheck_port or str(self.port) self.healthcheck_path = healthcheck_path or "/" self.healthcheck_interval_seconds = healthcheck_interval_seconds or 30 self.healthcheck_timeout_seconds = healthcheck_timeout_seconds or 5 self.healthy_threshold_count = healthy_threshold_count or 5 self.unhealthy_threshold_count = unhealthy_threshold_count or 2 self.load_balancer_arns = [] self.tags = {} if matcher is None: self.matcher = {"HttpCode": "200"} else: self.matcher = matcher self.target_type = target_type self.attributes = { "deregistration_delay.timeout_seconds": 300, "stickiness.enabled": "false", } self.targets = OrderedDict()
def __init__( self, load_balancer_arn, arn, protocol, port, ssl_policy, certificate, default_actions, ): self.load_balancer_arn = load_balancer_arn self.arn = arn self.protocol = protocol.upper() self.port = port self.ssl_policy = ssl_policy self.certificate = certificate self.certificates = [certificate] if certificate is not None else [] self.default_actions = default_actions self.rules = OrderedDict()
def __init__(self, name, security_groups, subnets, vpc_id, arn, dns_name, scheme='internet-facing'): self.name = name self.created_time = datetime.datetime.now() self.scheme = scheme self.security_groups = security_groups self.subnets = subnets or [] self.vpc_id = vpc_id self.listeners = OrderedDict() self.tags = {} self.arn = arn self.dns_name = dns_name self.stack = 'ipv4' self.attrs = { 'access_logs.s3.enabled': 'false', 'access_logs.s3.bucket': None, 'access_logs.s3.prefix': None, 'deletion_protection.enabled': 'false', 'idle_timeout.timeout_seconds': '60' }
def transform(value, spec): """Apply transformations to make the output JSON comply with the expected form. This function applies: (1) Type cast to nodes with "type" property (e.g., 'true' to True). XML field values are all in text so this step is necessary to convert it to valid JSON objects. (2) Squashes "member" nodes to lists. """ if len(spec) == 1: return from_str(value, spec) od = OrderedDict() for k, v in value.items(): if k.startswith('@') or v is None: continue if spec[k]['type'] == 'list': if len(spec[k]['member']) == 1: if isinstance(v['member'], list): od[k] = transform(v['member'], spec[k]['member']) else: od[k] = [transform(v['member'], spec[k]['member'])] elif isinstance(v['member'], list): od[k] = [ transform(o, spec[k]['member']) for o in v['member'] ] elif isinstance(v['member'], OrderedDict): od[k] = [transform(v['member'], spec[k]['member'])] else: raise ValueError('Malformatted input') elif spec[k]['type'] == 'map': key = from_str(v['entry']['key'], spec[k]['key']) val = from_str(v['entry']['value'], spec[k]['value']) od[k] = {key: val} else: od[k] = transform(v, spec[k]) return od
def __init__(self, name, arn, vpc_id, protocol, port, healthcheck_protocol, healthcheck_port, healthcheck_path, healthcheck_interval_seconds, healthcheck_timeout_seconds, healthy_threshold_count, unhealthy_threshold_count, matcher=None, target_type=None): self.name = name self.arn = arn self.vpc_id = vpc_id self.protocol = protocol self.port = port self.healthcheck_protocol = healthcheck_protocol self.healthcheck_port = healthcheck_port self.healthcheck_path = healthcheck_path self.healthcheck_interval_seconds = healthcheck_interval_seconds self.healthcheck_timeout_seconds = healthcheck_timeout_seconds self.healthy_threshold_count = healthy_threshold_count self.unhealthy_threshold_count = unhealthy_threshold_count self.load_balancer_arns = [] self.tags = {} self.matcher = matcher self.target_type = target_type self.attributes = { 'deregistration_delay.timeout_seconds': 300, 'stickiness.enabled': 'false', } self.targets = OrderedDict()
def __init__(self, ec2_backend, region_name): self.region = region_name self.clusters = {} self.subnet_groups = {} self.security_groups = { "Default": SecurityGroup("Default", "Default Redshift Security Group", self.region) } self.parameter_groups = { "default.redshift-1.0": ParameterGroup("default.redshift-1.0", "redshift-1.0", "Default Redshift parameter group", self.region) } self.ec2_backend = ec2_backend self.snapshots = OrderedDict() self.RESOURCE_TYPE_MAP = { 'cluster': self.clusters, 'parametergroup': self.parameter_groups, 'securitygroup': self.security_groups, 'snapshot': self.snapshots, 'subnetgroup': self.subnet_groups }
def __init__(self, database_name, region_name): self.name = database_name self.tables = OrderedDict() self.region_name = region_name
def __init__(self): self.tables = OrderedDict()
def __init__(self): self.stacks = OrderedDict() self.stacksets = OrderedDict() self.deleted_stacks = {} self.exports = OrderedDict() self.change_sets = OrderedDict()
def transform(value, spec): """Apply transformations to make the output JSON comply with the expected form. This function applies: (1) Type cast to nodes with "type" property (e.g., 'true' to True). XML field values are all in text so this step is necessary to convert it to valid JSON objects. (2) Squashes "member" nodes to lists. """ if len(spec) == 1: return from_str(value, spec) od = OrderedDict() for k, v in value.items(): if k.startswith('@'): continue if k not in spec: # this can happen when with an older version of # botocore for which the node in XML template is not # defined in service spec. log.warning( 'Field %s is not defined by the botocore version in use', k) continue if spec[k]['type'] == 'list': if v is None: od[k] = [] elif len(spec[k]['member']) == 1: if isinstance(v['member'], list): od[k] = transform(v['member'], spec[k]['member']) else: od[k] = [transform(v['member'], spec[k]['member'])] elif isinstance(v['member'], list): od[k] = [ transform(o, spec[k]['member']) for o in v['member'] ] elif isinstance(v['member'], OrderedDict): od[k] = [transform(v['member'], spec[k]['member'])] else: raise ValueError('Malformatted input') elif spec[k]['type'] == 'map': if v is None: od[k] = {} else: items = ([v['entry']] if not isinstance(v['entry'], list) else v['entry']) for item in items: key = from_str(item['key'], spec[k]['key']) val = from_str(item['value'], spec[k]['value']) if k not in od: od[k] = {} od[k][key] = val else: if v is None: od[k] = None else: od[k] = transform(v, spec[k]) return od
def __init__(self): self.databases = OrderedDict()
def __init__(self): self.stacks = OrderedDict() self.deleted_stacks = {}
def __init__(self): self.pipelines = OrderedDict()
def __init__(self, region): super(CognitoIdentityBackend, self).__init__() self.region = region self.identity_pools = OrderedDict()
def __init__(self, shard_id, starting_hash, ending_hash): self._shard_id = shard_id self.starting_hash = starting_hash self.ending_hash = ending_hash self.records = OrderedDict()
def setup_class(self, request, full_url, headers): querystring = OrderedDict() if hasattr(request, "body"): # Boto self.body = request.body else: # Flask server # FIXME: At least in Flask==0.10.1, request.data is an empty string # and the information we want is in request.form. Keeping self.body # definition for back-compatibility self.body = request.data querystring = OrderedDict() for key, value in request.form.items(): querystring[key] = [value] raw_body = self.body if isinstance(self.body, six.binary_type): self.body = self.body.decode("utf-8") if not querystring: querystring.update( parse_qs(urlparse(full_url).query, keep_blank_values=True)) if not querystring: if "json" in request.headers.get("content-type", []): # No-op case here for dynamodb to avoid tring to qs parse a json body if self.aws_service_spec: decoded = json.loads(self.body) target = request.headers.get( "x-amz-target") or request.headers.get("X-Amz-Target") service, method = target.split(".") input_spec = self.aws_service_spec.input_spec(method) flat = flatten_json_request_body("", decoded, input_spec) for key, value in flat.items(): querystring[key] = [value] elif self.body: try: querystring.update( OrderedDict((key, [value]) for key, value in parse_qsl( raw_body, keep_blank_values=True))) except UnicodeEncodeError: pass # ignore encoding errors, as the body may not contain a legitimate querystring if not querystring: querystring.update(headers) try: querystring = _decode_dict(querystring) except UnicodeDecodeError: pass # ignore decoding errors, as the body may not contain a legitimate querystring self.uri = full_url self.path = urlparse(full_url).path self.querystring = querystring self.data = querystring self.method = request.method self.region = self.get_region_from_url(request, full_url) self.uri_match = None self.headers = request.headers if "host" not in self.headers: self.headers["host"] = urlparse(full_url).netloc self.response_headers = {"server": "amazon.com"}
def __init__(self): self.streams = OrderedDict() self.delivery_streams = {}
def __init__(self, region): super(CognitoIdpBackend, self).__init__() self.region = region self.user_pools = OrderedDict() self.user_pool_domains = OrderedDict() self.sessions = {}
def __init__(self, database_name, table_name, table_input): self.database_name = database_name self.name = table_name self.partitions = OrderedDict() self.versions = [] self.update(table_input)
def __init__(self, region_name=None): self.region_name = region_name self.load_balancers = OrderedDict()
def __init__(self, database_name): self.name = database_name self.tables = OrderedDict()
def __init__(self, region_name=None): self.region_name = region_name self.tables = OrderedDict()
def __init__(self, shard_id): self.shard_id = shard_id self.records = OrderedDict()