def request(self, method, url, body=None, headers=None): headers.update({'X-LC-Request-ID': str(id(self))}) if self.log is not None: pre = "# -------- begin %d request ----------\n" % id(self) self.log.write(pre + self._log_curl(method, url, body, headers) + "\n") self.log.flush() return LibcloudHTTPSConnection.request(self, method, url, body, headers)
def request_consumer_key(self, user_id): action = self.request_path + '/auth/credential' data = json.dumps({ 'accessRules': DEFAULT_ACCESS_RULES, 'redirection': 'http://runabove.com', }) headers = { 'Content-Type': 'application/json', 'X-Ra-Application': user_id, } httpcon = LibcloudHTTPSConnection(self.host) httpcon.request(method='POST', url=action, body=data, headers=headers) response = httpcon.getresponse() if response.status == httplib.UNAUTHORIZED: raise InvalidCredsError() body = response.read() json_response = json.loads(body) httpcon.close() return json_response
def request(self, method, url, body=None, headers=None): headers.update({'X-LC-Request-ID': str(id(self))}) if self.log is not None: pre = "# -------- begin %d request ----------\n" % id(self) self.log.write(pre + self._log_curl(method, url, body, headers) + "\n") self.log.flush() if self.enable_requests_stats: full_url = self._get_url(path=url) obj = {'method': method, 'url': full_url} REQUESTS_LOG.append(obj) return LibcloudHTTPSConnection.request(self, method, url, body, headers)