def api_execute(self, path, method, params=None, timeout=None):
""" Executes the query. """
url = self._base_url + path
validate_cert = True if self.cert_options else False
if (method == self._MGET) or (method == self._MDELETE):
if params:
url = url_concat(url, params)
body = None
elif (method == self._MPUT) or (method == self._MPOST):
body = urlencode(params)
else:
raise etcdexcept.EtcdException(
'HTTP method {} not supported'.format(method))
request = HTTPRequest(url, method=method,
request_timeout=timeout,
headers=self._get_default_headers(method),
follow_redirects=self.allow_redirect,
body=body,
validate_cert=validate_cert,
ca_certs=self.cert_options.get('ca_certs', None),
client_key=self.cert_options.get('client_key', None),
client_cert=self.cert_options.get('client_cert', None),
auth_username=self.username,
auth_password=self.password)
_log.debug("Request %s %s %s" % (path, method, request.body))
return self.http.fetch(request)
评论列表
文章目录