Browse Source

CLI: Fix errors with the REST client

* Fix error in instantiating Session object: attributes "verify",
  "headers" must be passed on after creating the session
* Fix error in computing the API URL from the server's base URL

Change-Id: Id80956e7026db5ed7192fbc4c2dff3afbbd3c9a8
changes/61/728061/8
Matthieu Huin 1 year ago
parent
commit
2793d27b12
  1. 11
      zuul/cmd/client.py

11
zuul/cmd/client.py

@ -36,12 +36,15 @@ class ZuulRESTClient(object):
"""Basic client for Zuul's REST API"""
def __init__(self, url, verify=False, auth_token=None):
self.url = url
if not self.url.endswith('/'):
self.url += '/'
self.auth_token = auth_token
self.base_url = urllib.parse.urljoin(self.url, '/api/')
self.verify = verify
self.session = requests.Session(
verify=self.verify,
headers={'Authorization': 'Bearer %s' % self.auth_token})
self.base_url = urllib.parse.urljoin(self.url, 'api/')
self.session = requests.Session()
self.session.verify = self.verify
self.session.headers = dict(
Authorization='Bearer %s' % self.auth_token)
def _check_status(self, req):
try:

Loading…
Cancel
Save