Example #1
0
 def _cache_store(self, token, data):
     serialized_data = jsonutils.dumps(data)
     cache_key = CACHE_KEY_TEMPLATE % token
     try:
         self._cache.set(cache_key,
                         serialized_data,
                         time = self.token_cache_time)
     except KeyError:
         self._cache.set(cache_key,
                         serialized_data,
                         timeout = self.token_cache_time)
Example #2
0
 def _cache_store(self, token, data):
     serialized_data = jsonutils.dumps(data)
     cache_key = CACHE_KEY_TEMPLATE % token
     try:
         self._cache.set(cache_key,
                         serialized_data,
                         time=self.token_cache_time)
     except KeyError:
         self._cache.set(cache_key,
                         serialized_data,
                         timeout=self.token_cache_time)
Example #3
0
 def _json_request(self, method, path, body=None, additional_headers=None):
     kwargs = {
         'headers':{
             'Content-type': 'application/json',
             'Accept': 'application/json'
                 }
             }
     
     if additional_headers:
         kwargs['headers'].update(additional_headers)
     if body:
         kwargs['body'] = jsonutils.dumps(body)
     path = self.auth_admin_prefix + path
     response, body = self._http_request(method, path, **kwargs)
     try:
         data = json.loads(body)
     except ValueError:
         data = {}
     return response, data
Example #4
0
    def _json_request(self, method, path, body=None, additional_headers=None):
        kwargs = {
            'headers': {
                'Content-type': 'application/json',
                'Accept': 'application/json'
            }
        }

        if additional_headers:
            kwargs['headers'].update(additional_headers)
        if body:
            kwargs['body'] = jsonutils.dumps(body)
        path = self.auth_admin_prefix + path
        response, body = self._http_request(method, path, **kwargs)
        try:
            data = json.loads(body)
        except ValueError:
            data = {}
        return response, data