def _api_request(self, endpoint, http_method, *args, **kwargs):
logger.debug('<STR_LIT>' % endpoint)<EOL>auth = self._build_http_auth()<EOL>headers = self._build_request_headers(kwargs.get('<STR_LIT>'))<EOL>logger.debug('<STR_LIT>' % headers)<EOL>path = self._build_request_path(endpoint)<EOL>logger.debug('<STR_LIT>' % path)<EOL>data = self._build_payload(kwargs.get('<STR_LIT>'))<EOL>if not data:<EOL><INDENT>data = kwargs.get('<STR_LIT:data>')<EOL><DEDENT>logger.debug('<STR_LIT>' % data)<EOL>req_kw = dict(<EOL>auth=auth,<EOL>headers=headers,<EOL>timeout=kwargs.get('<STR_LIT>', self.DEFAULT_TIMEOUT)<EOL>)<EOL>if (http_method == self.HTTP_POST):<EOL><INDENT>if (data):<EOL><INDENT>r = requests.post(path, data=data, **req_kw)<EOL><DEDENT>else:<EOL><INDENT>r = requests.post(path, **req_kw)<EOL><DEDENT><DEDENT>elif http_method == self.HTTP_PUT:<EOL><INDENT>if (data):<EOL><INDENT>r = requests.put(path, data=data, **req_kw)<EOL><DEDENT>else:<EOL><INDENT>r = requests.put(path, **req_kw)<EOL><DEDENT><DEDENT>elif http_method == self.HTTP_DELETE:<EOL><INDENT>r = requests.delete(path, **req_kw)<EOL><DEDENT>else:<EOL><INDENT>r = requests.get(path, **req_kw)<EOL><DEDENT>logger.debug('<STR_LIT>' % r.status_code)<EOL>try:<EOL><INDENT>logger.debug('<STR_LIT>' % r.json())<EOL><DEDENT>except:<EOL><INDENT>logger.debug('<STR_LIT>' % r.content)<EOL><DEDENT>return self._parse_response(r)<EOL>
Private method for api requests