[Python] Add "servers" support in path, operation (#2052)

* add servers to path, operation

* add path/operation server support to python client

* update python samples

* fix index

* fix python code style
This commit is contained in:
William Cheng
2019-02-08 11:48:37 +08:00
committed by GitHub
parent 7cee2b62e4
commit 36fa7102dd
24 changed files with 170 additions and 64 deletions

View File

@@ -109,7 +109,7 @@ class ApiClient(object):
query_params=None, header_params=None, body=None, post_params=None,
files=None, response_type=None, auth_settings=None,
_return_http_data_only=None, collection_formats=None,
_preload_content=True, _request_timeout=None):
_preload_content=True, _request_timeout=None, _host=None):
config = self.configuration
@@ -156,7 +156,11 @@ class ApiClient(object):
body = self.sanitize_for_serialization(body)
# request url
url = self.configuration.host + resource_path
if _host is None:
url = self.configuration.host + resource_path
else:
# use server/host defined in path or operation instead
url = _host + resource_path
# perform request and return response
response_data = self.request(
@@ -289,7 +293,7 @@ class ApiClient(object):
body=None, post_params=None, files=None,
response_type=None, auth_settings=None, async_req=None,
_return_http_data_only=None, collection_formats=None,
_preload_content=True, _request_timeout=None):
_preload_content=True, _request_timeout=None, _host=None):
"""Makes the HTTP request (synchronous) and returns deserialized data.
To make an async_req request, set the async_req parameter.
@@ -332,7 +336,7 @@ class ApiClient(object):
body, post_params, files,
response_type, auth_settings,
_return_http_data_only, collection_formats,
_preload_content, _request_timeout)
_preload_content, _request_timeout, _host)
else:
thread = self.pool.apply_async(self.__call_api, (resource_path,
method, path_params, query_params,
@@ -341,7 +345,9 @@ class ApiClient(object):
response_type, auth_settings,
_return_http_data_only,
collection_formats,
_preload_content, _request_timeout))
_preload_content,
_request_timeout,
_host))
return thread
def request(self, method, url, query_params=None, headers=None,