def request(self, method, url, query_params=None, headers=None,<EOL>body=None, post_params=None, _preload_content=True, _request_timeout=None):
method = method.upper()<EOL>assert method in ['<STR_LIT:GET>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT:POST>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>']<EOL>if post_params and body:<EOL><INDENT>raise ValueError(<EOL>"<STR_LIT>"<EOL>)<EOL><DEDENT>post_params = post_params or {}<EOL>headers = headers or {}<EOL>timeout = None<EOL>if _request_timeout:<EOL><INDENT>if isinstance(_request_timeout, (int, ) if PY3 else (int, long)):<EOL><INDENT>timeout = urllib3.Timeout(total=_request_timeout)<EOL><DEDENT>elif isinstance(_request_timeout, tuple) and len(_request_timeout) == <NUM_LIT:2>:<EOL><INDENT>timeout = urllib3.Timeout(connect=_request_timeout[<NUM_LIT:0>], read=_request_timeout[<NUM_LIT:1>])<EOL><DEDENT><DEDENT>if '<STR_LIT:Content-Type>' not in headers:<EOL><INDENT>headers['<STR_LIT:Content-Type>'] = '<STR_LIT:application/json>'<EOL><DEDENT>try:<EOL><INDENT>if method in ['<STR_LIT:POST>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>if query_params:<EOL><INDENT>url += '<STR_LIT:?>' + urlencode(query_params)<EOL><DEDENT>if re.search('<STR_LIT>', headers['<STR_LIT:Content-Type>'], re.IGNORECASE):<EOL><INDENT>if headers['<STR_LIT:Content-Type>'] == '<STR_LIT>':<EOL><INDENT>if not isinstance(body, list):<EOL><INDENT>headers['<STR_LIT:Content-Type>'] ='<STR_LIT>'<EOL><DEDENT><DEDENT>request_body = None<EOL>if body is not None:<EOL><INDENT>request_body = json.dumps(body)<EOL><DEDENT>r = self.pool_manager.request(method, url,<EOL>body=request_body,<EOL>preload_content=_preload_content,<EOL>timeout=timeout,<EOL>headers=headers)<EOL><DEDENT>elif headers['<STR_LIT:Content-Type>'] == '<STR_LIT>':<EOL><INDENT>r = self.pool_manager.request(method, url,<EOL>fields=post_params,<EOL>encode_multipart=False,<EOL>preload_content=_preload_content,<EOL>timeout=timeout,<EOL>headers=headers)<EOL><DEDENT>elif headers['<STR_LIT:Content-Type>'] == '<STR_LIT>':<EOL><INDENT>del headers['<STR_LIT:Content-Type>']<EOL>r = self.pool_manager.request(method, url,<EOL>fields=post_params,<EOL>encode_multipart=True,<EOL>preload_content=_preload_content,<EOL>timeout=timeout,<EOL>headers=headers)<EOL><DEDENT>elif isinstance(body, str):<EOL><INDENT>request_body = body<EOL>r = self.pool_manager.request(method, url,<EOL>body=request_body,<EOL>preload_content=_preload_content,<EOL>timeout=timeout,<EOL>headers=headers)<EOL><DEDENT>else:<EOL><INDENT>msg = """<STR_LIT>"""<EOL>raise ApiException(status=<NUM_LIT:0>, reason=msg)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>r = self.pool_manager.request(method, url,<EOL>fields=query_params,<EOL>preload_content=_preload_content,<EOL>timeout=timeout,<EOL>headers=headers)<EOL><DEDENT><DEDENT>except urllib3.exceptions.SSLError as e:<EOL><INDENT>msg = "<STR_LIT>".format(type(e).__name__, str(e))<EOL>raise ApiException(status=<NUM_LIT:0>, reason=msg)<EOL><DEDENT>if _preload_content:<EOL><INDENT>r = RESTResponse(r)<EOL>if PY3:<EOL><INDENT>r.data = r.data.decode('<STR_LIT:utf8>')<EOL><DEDENT>logger.debug("<STR_LIT>", r.data)<EOL><DEDENT>if not <NUM_LIT:200> <= r.status <= <NUM_LIT>:<EOL><INDENT>raise ApiException(http_resp=r)<EOL><DEDENT>return r<EOL>
:param method: http request method
:param url: http request url
:param query_params: query parameters in the url
:param headers: http request headers
:param body: request json body, for `application/json`
:param post_params: request post parameters,
                    `application/x-www-form-urlencoded`
                    and `multipart/form-data`
:param _preload_content: if False, the urllib3.HTTPResponse object will be returned without
                         reading/decoding response data. Default is True.
:param _request_timeout: timeout setting for this request. If one number provided, it will be total request
                         timeout. It can also be a pair (tuple) of (connection, read) timeouts.