Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,10 @@ class {{classname}}(object):
_host_index (int/None): specifies the index of the server
that we want to use.
Default is read from the configuration.
_request_auths (list): set to override the auth_settings for an a single
request; this effectively ignores the authentication
in the spec for a single request.
Default is None
async_req (bool): execute request asynchronously

Returns:
Expand Down Expand Up @@ -311,6 +315,7 @@ class {{classname}}(object):
kwargs['_content_type'] = kwargs.get(
'_content_type')
kwargs['_host_index'] = kwargs.get('_host_index')
kwargs['_request_auths'] = kwargs.get('_request_auths', None)
{{#requiredParams}}
kwargs['{{paramName}}'] = \
{{paramName}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ class ApiClient(object):
_request_timeout: typing.Optional[typing.Union[int, float, typing.Tuple]] = None,
_host: typing.Optional[str] = None,
_check_type: typing.Optional[bool] = None,
_content_type: typing.Optional[str] = None
_content_type: typing.Optional[str] = None,
_request_auths: typing.Optional[typing.List[typing.Dict[str, typing.Any]]] = None
):

config = self.configuration
Expand Down Expand Up @@ -180,7 +181,8 @@ class ApiClient(object):

# auth setting
self.update_params_for_auth(header_params, query_params,
auth_settings, resource_path, method, body)
auth_settings, resource_path, method, body,
request_auths=_request_auths)

# request url
if _host is None:
Expand Down Expand Up @@ -362,7 +364,8 @@ class ApiClient(object):
_preload_content: bool = True,
_request_timeout: typing.Optional[typing.Union[int, float, typing.Tuple]] = None,
_host: typing.Optional[str] = None,
_check_type: typing.Optional[bool] = None
_check_type: typing.Optional[bool] = None,
_request_auths: typing.Optional[typing.List[typing.Dict[str, typing.Any]]] = None
):
"""Makes the HTTP request (synchronous) and returns deserialized data.

Expand Down Expand Up @@ -410,6 +413,10 @@ class ApiClient(object):
:param _check_type: boolean describing if the data back from the server
should have its type checked.
:type _check_type: bool, optional
:param _request_auths: set to override the auth_settings for an a single
request; this effectively ignores the authentication
in the spec for a single request.
:type _request_auths: list, optional
:return:
If async_req parameter is True,
the request will be called asynchronously.
Expand All @@ -424,7 +431,7 @@ class ApiClient(object):
response_type, auth_settings,
_return_http_data_only, collection_formats,
_preload_content, _request_timeout, _host,
_check_type)
_check_type, _request_auths=_request_auths)

return self.pool.apply_async(self.__call_api, (resource_path,
method, path_params,
Expand All @@ -437,7 +444,7 @@ class ApiClient(object):
collection_formats,
_preload_content,
_request_timeout,
_host, _check_type))
_host, _check_type, None, _request_auths))

def request(self, method, url, query_params=None, headers=None,
post_params=None, body=None, _preload_content=True,
Expand Down Expand Up @@ -609,7 +616,7 @@ class ApiClient(object):
return content_types[0]

def update_params_for_auth(self, headers, queries, auth_settings,
resource_path, method, body):
resource_path, method, body, request_auths=None):
"""Updates header and query params based on authentication setting.

:param headers: Header parameters dict to be updated.
Expand All @@ -619,33 +626,43 @@ class ApiClient(object):
:param method: A string representation of the HTTP request method.
:param body: A object representing the body of the HTTP request.
The object type is the return value of _encoder.default().
:param request_auths: if set, the provided settings will
override the token in the configuration.
"""
if not auth_settings:
return

if request_auths:
for auth_setting in request_auths:
self._apply_auth_params(headers, queries, resource_path, method, body, auth_setting)
return

for auth in auth_settings:
auth_setting = self.configuration.auth_settings().get(auth)
if auth_setting:
if auth_setting['in'] == 'cookie':
headers['Cookie'] = auth_setting['value']
elif auth_setting['in'] == 'header':
if auth_setting['type'] != 'http-signature':
headers[auth_setting['key']] = auth_setting['value']
self._apply_auth_params(headers, queries, resource_path, method, body, auth_setting)

def _apply_auth_params(self, headers, queries, resource_path, method, body, auth_setting):
if auth_setting['in'] == 'cookie':
headers['Cookie'] = auth_setting['value']
elif auth_setting['in'] == 'header':
if auth_setting['type'] != 'http-signature':
headers[auth_setting['key']] = auth_setting['value']
{{#hasHttpSignatureMethods}}
else:
# The HTTP signature scheme requires multiple HTTP headers
# that are calculated dynamically.
signing_info = self.configuration.signing_info
auth_headers = signing_info.get_http_signature_headers(
resource_path, method, headers, body, queries)
headers.update(auth_headers)
else:
# The HTTP signature scheme requires multiple HTTP headers
# that are calculated dynamically.
signing_info = self.configuration.signing_info
auth_headers = signing_info.get_http_signature_headers(
resource_path, method, headers, body, queries)
headers.update(auth_headers)
{{/hasHttpSignatureMethods}}
elif auth_setting['in'] == 'query':
queries.append((auth_setting['key'], auth_setting['value']))
else:
raise ApiValueError(
'Authentication token must be in `query` or `header`'
)
elif auth_setting['in'] == 'query':
queries.append((auth_setting['key'], auth_setting['value']))
else:
raise ApiValueError(
'Authentication token must be in `query` or `header`'
)


class Endpoint(object):
Expand Down Expand Up @@ -695,7 +712,8 @@ class Endpoint(object):
'_check_input_type',
'_check_return_type',
'_content_type',
'_spec_property_naming'
'_spec_property_naming',
'_request_auths'
])
self.params_map['nullable'].extend(['_request_timeout'])
self.validations = root_map['validations']
Expand All @@ -710,7 +728,8 @@ class Endpoint(object):
'_check_input_type': (bool,),
'_check_return_type': (bool,),
'_spec_property_naming': (bool,),
'_content_type': (none_type, str)
'_content_type': (none_type, str),
'_request_auths': (none_type, list)
}
self.openapi_types.update(extra_types)
self.attribute_map = root_map['attribute_map']
Expand Down Expand Up @@ -885,4 +904,5 @@ class Endpoint(object):
_preload_content=kwargs['_preload_content'],
_request_timeout=kwargs['_request_timeout'],
_host=_host,
_request_auths=kwargs['_request_auths'],
collection_formats=params['collection_format'])
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ def call_123_test_special_tags(
_host_index (int/None): specifies the index of the server
that we want to use.
Default is read from the configuration.
_request_auths (list): set to override the auth_settings for an a single
request; this effectively ignores the authentication
in the spec for a single request.
Default is None
async_req (bool): execute request asynchronously

Returns:
Expand Down Expand Up @@ -160,6 +164,7 @@ def call_123_test_special_tags(
kwargs['_content_type'] = kwargs.get(
'_content_type')
kwargs['_host_index'] = kwargs.get('_host_index')
kwargs['_request_auths'] = kwargs.get('_request_auths', None)
kwargs['body'] = \
body
return self.call_123_test_special_tags_endpoint.call_with_http_info(**kwargs)
Expand Down
Loading