Perform lookup on an enumerable of keys.

        Args:
            api_name: a string name of the API. Keys and values are segmented by api_name.
            keys: an enumerable of string keys.
770322
def bulk_lookup(self, api_name, keys):
        
        cached_data = {}

        for key in keys:
            value = self.lookup_value(api_name, key)
            if value is not None:
                cached_data[key] = value
        return cached_data
523097
def _reference_keys(self, reference):
        
        if not isinstance(reference, six.string_types):
            raise TypeError(
                'When using ~ to reference dynamic attributes ref must be a str. a {0} was provided.'.format(type(reference).__name__)
            )

        if '~' in reference:
            reference = reference[1:]

            scheme = self._scheme_references.get(reference)
            if not scheme:
                # TODO: need to create nice error here as well and print pretty message.
                raise LookupError(
                    "Was unable to find {0} in the scheme references. "
                    "available references {1}".format(reference, ', '.join(self._scheme_references.keys()))
                )

            return scheme['keys']
        else:
            raise AttributeError('references must start with ~. Please update {0} and retry.'.format(reference))
163031
def api_key(request, response, verify_user, context=None, **kwargs):
    
    api_key = request.get_header('X-Api-Key')

    if api_key:
        try:
            user = verify_user(api_key)
        except TypeError:
            user = verify_user(api_key, context)
        if user:
            return user
        else:
            return False
    else:
        return None
764411
def find(cls, api_name):
        
        if api_name in cls.apis_by_name:
            return cls.apis_by_name[api_name]
        api = cls(api_name)
        api._fetch_from_aws()
        if api.exists_in_aws:
            api._fetch_resources()
        cls.apis_by_name[api_name] = api
        return api
82884
def find_by_user(user: str) -> List['ApiKey']:
        
        return [ApiKey.from_db(key) for key in db.get_keys(qb.from_dict({'user': user}))]
136218
def keys(cls, name, hash_key, range_key=None, throughput=None):
        
        return cls(cls.KEYS, name, hash_key, range_key,
                   throughput=throughput)
967842
def create_api_key(awsclient, api_name, api_key_name):
    
    _sleep()
    client_api = awsclient.get_client('apigateway')
    print('create api key: %s' % api_key_name)

    response = client_api.create_api_key(
        name=api_key_name,
        description='Created for ' + api_name,
        enabled=True
    )

    #print(json2table(response))

    print('Add this api key \'%s\' to your api.conf' % response['id'])
    return response['id']
446425
def _find_usage_api_keys(self):
        
        logger.debug('Finding usage for API Keys')
        key_count = 0
        paginator = self.conn.get_paginator('get_api_keys')
        for resp in paginator.paginate():
            key_count += len(resp['items'])
        self.limits['API keys per account']._add_current_usage(
            key_count, aws_type='AWS::ApiGateway::ApiKey'
        )
40258
def list_api_keys(awsclient):
    
    _sleep()
    client_api = awsclient.get_client('apigateway')
    print('listing api keys')

    response = client_api.get_api_keys()['items']

    for item in response:
        print(json2table(item))
1095371
def get_sdc_by_name(self, name):
        
        for sdc in self.sdc:
            if sdc.name == name:
                return sdc
        raise KeyError("SDC of that name not found")
699228
def get_type(self, name, api=None):
        
        k = (name, api)
        if k in self.types:
            return self.types[k]
        else:
            return self.types[(name, None)]
428173
def _get_api_key_ops():
    """"""
    auth_header = request.authorization
    if not auth_header:
        logging.debug('API request lacks authorization header')
        abort(flask.Response(
            'API key required', 401,
            {'WWW-Authenticate': 'Basic realm="API key required"'}))

    return operations.ApiKeyOps(auth_header.username, auth_header.password)
6534
def find_by_id(key: str, user: str=None) -> Optional['ApiKey']:
        
        return ApiKey.from_db(db.get_key(key, user))
1234403
def from_name(api_url, name, dry_run=False):
        
        return DataSet(
            '/'.join([api_url, name]).rstrip('/'),
            token=None,
            dry_run=dry_run
        )
562111
def _get_key_values(self, name):
        
        results = {}

        for key, value in self.qs.items():
            try:
                if not key.startswith(name):
                    continue

                key_start = key.index('[') + 1
                key_end = key.index(']')
                item_key = key[key_start:key_end]

                if ',' in value:
                    item_value = value.split(',')
                else:
                    item_value = value
                results.update({item_key: item_value})
            except Exception:
                raise BadRequest("Parse error", source={'parameter': key})

        return results
722930
@Override
  public List<ApiType> byIndex(String indexName, String indexKey) {
    lock.lock();
    try {
      if (!this.indexers.containsKey(indexName)) {
        throw new IllegalArgumentException(String.format("index %s doesn't exist!", indexName));
      }
      Map<String, Set<String>> index = this.indices.get(indexName);
      Set<String> set = index.get(indexKey);
      if (set == null) {
        return Arrays.asList();
      }
      List<ApiType> items = new ArrayList<>(set.size());
      for (String key : set) {
        items.add(this.items.get(key));
      }
      return items;
    } finally {
      lock.unlock();
    }
  }
332886
def get_service_key(self, service_name, key_name):
        
        for key in self._get_service_keys(service_name)['resources']:
            if key_name == key['entity']['name']:
                guid = key['metadata']['guid']

                uri = "/v2/service_keys/%s" % (guid)
                return self.api.get(uri)

        return None