Skip to content

Commit

Permalink
Merge pull request #34 from demisto/fix_base_url
Browse files Browse the repository at this point in the history
Fix base url
  • Loading branch information
gal-berger authored Mar 22, 2020
2 parents b2e71e0 + 199fb88 commit 95655a4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
[PyPI History][1]

[1]: https://pypi.org/project/demisto-py/#history
## 2.0.10
* Enabled host and path parameters to function with trailing or leading slashes.

## 2.0.9
Improved error message when missing authentication parameters.
* Improved error message when missing authentication parameters.

## 2.0.8
* Added `ssl_ca_cert` configuration option to specify an alternate certificate bundle.
Expand Down
8 changes: 8 additions & 0 deletions demisto_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ def configure(base_url=None, api_key=None, verify_ssl=None, proxy=None, username
configuration = Configuration()
configuration.api_key['Authorization'] = api_key
configuration.host = base_url or os.getenv('DEMISTO_BASE_URL', None)
if isinstance(configuration.host, str):
configuration.host = configuration.host.rstrip('/')
configuration.verify_ssl = verify_ssl
configuration.proxy = proxy
configuration.debug = debug
Expand Down Expand Up @@ -87,6 +89,8 @@ def configure(base_url=None, api_key=None, verify_ssl=None, proxy=None, username
def login(base_url=None, username=None, password=None, verify_ssl=True, proxy=None, debug=False):
configuration_orig = Configuration()
configuration_orig.host = base_url or os.getenv('DEMISTO_BASE_URL', None)
if isinstance(configuration_orig.host, str):
configuration_orig.host = configuration_orig.host.rstrip('/')
configuration_orig.verify_ssl = verify_ssl
configuration_orig.proxy = proxy
configuration_orig.debug = debug
Expand All @@ -105,6 +109,8 @@ def login(base_url=None, username=None, password=None, verify_ssl=True, proxy=No
xsrf_token = xsrf_token_raw.replace('XSRF-TOKEN=', '')
configuration = Configuration()
configuration.host = base_url or os.getenv('DEMISTO_BASE_URL', None)
if isinstance(configuration.host, str):
configuration.host = configuration.host.rstrip('/')
configuration.verify_ssl = verify_ssl
configuration.proxy = proxy
configuration.debug = debug
Expand Down Expand Up @@ -177,6 +183,8 @@ def generic_request_func(self, path, method, body=None, **kwargs):
:return: tuple of (response_data, response_code, headers).
"""
if not path.startswith('/'):
path = '/' + path

all_params = [''] # noqa: E501
all_params.append('async_req')
Expand Down

0 comments on commit 95655a4

Please sign in to comment.