def _request(self, method, uri, path_params=None, flatten_params=True, **kwargs): if path_params: # Ensure path param is encoded. path_params = { key: quote(str(value), safe=u'') for key, value in path_params.items() } uri %= path_params # Custom nested object flattening if flatten_params and 'params' in kwargs: kwargs['params'] = self._flatten_param(kwargs['params']) full_uri = self._endpoint + uri response = self._session.request(method, full_uri, **kwargs) log_message = format_request(response) logging.info(log_message) if not 200 <= response.status_code <= 299: logging.error(log_message) return response
def _request(self, method, uri, path_params=None, **kwargs): if path_params: # Ensure path param is encoded. path_params = {key: quote(str(value), safe=u'') for key, value in path_params.items()} uri %= path_params full_uri = self._endpoint + uri response = requests.request(method, full_uri, headers=self._headers, **kwargs) log_message = format_request(response) logging.info(log_message) if not 200 <= response.status_code <= 299: logging.error(log_message) return response