Exemple #1
0
    def list_keys(self, prefix=None, after=None, limit=None) -> Response:
        """
        Used to get a list of keys matching a certain prefix.

        @param prefix: specifies what you want to get a list of.
        @param after: the item specified as a return value from this function last time you called it.
        @param limit: defaults to 1000 keys returned.
        @return: Response within key_count, next_after, and keys.
        """
        kwargs = {'domain': self._domain}
        if prefix is not None:
            kwargs['prefix'] = prefix
        if after is not None:
            kwargs['after'] = after
        if limit is not None:
            kwargs['limit'] = limit
        try:
            return self._do_request(backend.ListKeysConfig, **kwargs)
        except Exception as exception:
            if exception.code == 'none_match':
                # Empty result set from this list call should not result
                # in an exception. Return a mocked Mogile response instead.
                response = Response('OK \r\n', backend.ListKeysConfig)
                response.data = {
                    'key_count': 0,
                    'next_after': None,
                    'keys': {},
                }
                return response
            raise exception
Exemple #2
0
 def list_keys(self, prefix=None, after=None, limit=None):
     kwargs = {'domain': self._domain}
     if prefix is not None:
         kwargs['prefix'] = prefix
     if after is not None:
         kwargs['after'] = after
     if limit is not None:
         kwargs['limit'] = limit
     try:
         return self._do_request(backend.ListKeysConfig, **kwargs)
     except Exception as exception:
         if exception.code == 'none_match':
             # Empty result set from this list call should not result
             # in an exception. Return a mocked Mogile response instead.
             response = Response('OK \r\n', backend.ListKeysConfig)
             response.data = {
                 'key_count': 0,
                 'next_after': None,
                 'keys': {},
             }
             return response
         raise exception