@@ -253,7 +253,6 @@ class ApiClient(object):
253
253
post_params: Optional[List[Tuple[str, Any]]] = None,
254
254
files: Optional[Dict[str, List[io.FileIO]]] = None,
255
255
response_type: Optional[Tuple[Any]] = None,
256
- auth_settings: Optional[List[str]] = None,
257
256
async_req: Optional[bool] = None,
258
257
_return_http_data_only: Optional[bool] = None,
259
258
collection_formats: Optional[Dict[str, str]] = None,
@@ -275,7 +274,6 @@ class ApiClient(object):
275
274
:param body: Request body.
276
275
:param post_params dict: Request post form parameters,
277
276
for `application/x-www-form-urlencoded`, `multipart/form-data`.
278
- :param auth_settings list: Auth Settings names for the request.
279
277
:param response_type: For the response, a tuple containing:
280
278
valid classes
281
279
a list containing valid classes (for list schemas)
@@ -353,9 +351,6 @@ class ApiClient(object):
353
351
if body:
354
352
body = self.sanitize_for_serialization(body)
355
353
356
- # auth setting
357
- self.update_params_for_auth(header_params, query_params, auth_settings, resource_path, method, body)
358
-
359
354
# request url
360
355
if _host is None:
361
356
url = self.configuration.host + resource_path
@@ -494,35 +489,6 @@ class ApiClient(object):
494
489
else:
495
490
return content_types[0]
496
491
497
- def update_params_for_auth(self, headers, queries, auth_settings, resource_path, method, body):
498
- """Updates header and query params based on authentication setting.
499
-
500
- :param headers: Header parameters dict to be updated.
501
- :param queries: Query parameters tuple list to be updated.
502
- :param auth_settings: Authentication setting identifiers list.
503
- :param resource_path: A string representation of the HTTP request resource path.
504
- :param method: A string representation of the HTTP request method.
505
- :param body: A object representing the body of the HTTP request.
506
- The object type is the return value of _encoder.default().
507
- """
508
- if not auth_settings:
509
- return
510
-
511
- for auth in auth_settings:
512
- auth_setting = self.configuration.auth_settings().get(auth)
513
- if auth_setting:
514
- if auth_setting["in"] == "cookie":
515
- headers["Cookie"] = auth_setting["value"]
516
- elif auth_setting["in"] == "header":
517
- if auth_setting["type"] != "http-signature":
518
- if auth_setting["value"] is None:
519
- raise ApiValueError("Invalid authentication token for {}".format(auth_setting["key"]))
520
- headers[auth_setting["key"]] = auth_setting["value"]
521
- elif auth_setting["in"] == "query":
522
- queries.append((auth_setting["key"], auth_setting["value"]))
523
- else:
524
- raise ApiValueError("Authentication token must be in `query` or `header`")
525
-
526
492
527
493
class AsyncApiClient(ApiClient):
528
494
def _build_rest_client(self):
@@ -598,6 +564,7 @@ class Endpoint(object):
598
564
'operation_id' (str): endpoint string identifier
599
565
'http_method' (str): POST/PUT/PATCH/GET etc
600
566
'servers' (list): list of str servers that this endpoint is at
567
+ 'version' (str): the API version
601
568
:type settings: dict
602
569
:param params_map: See below key value pairs:
603
570
'required' (bool): whether the parameter is required
@@ -706,7 +673,8 @@ class Endpoint(object):
706
673
707
674
def call_with_http_info(self, **kwargs):
708
675
709
- is_unstable = self.api_client.configuration.unstable_operations.get(self.settings["operation_id"])
676
+ is_unstable = self.api_client.configuration.unstable_operations.get(
677
+ "{}.{}".format(self.settings["version"], self.settings["operation_id"]))
710
678
if is_unstable:
711
679
warnings.warn("Using unstable operation '{0}'".format(self.settings["operation_id"]))
712
680
elif is_unstable is False:
@@ -764,6 +732,8 @@ class Endpoint(object):
764
732
header_list = self.api_client.select_header_content_type(content_type_headers_list)
765
733
params["header"]["Content-Type"] = header_list
766
734
735
+ self.update_params_for_auth(params["header"], params["query"])
736
+
767
737
return self.api_client.call_api(
768
738
self.settings["endpoint_path"],
769
739
self.settings["http_method"],
@@ -774,7 +744,6 @@ class Endpoint(object):
774
744
post_params=params["form"],
775
745
files=params["file"],
776
746
response_type=self.settings["response_type"],
777
- auth_settings=self.settings["auth"],
778
747
async_req=kwargs["async_req"],
779
748
_check_type=kwargs["_check_return_type"],
780
749
_return_http_data_only=kwargs["_return_http_data_only"],
@@ -784,6 +753,30 @@ class Endpoint(object):
784
753
collection_formats=params["collection_format"],
785
754
)
786
755
756
+ def update_params_for_auth(self, headers, queries):
757
+ """Updates header and query params based on authentication setting.
758
+
759
+ :param headers: Header parameters dict to be updated.
760
+ :param queries: Query parameters tuple list to be updated.
761
+ """
762
+ if not self.settings["auth"]:
763
+ return
764
+
765
+ for auth in self.settings["auth"]:
766
+ auth_setting = self.api_client.configuration.auth_settings().get(auth)
767
+ if auth_setting:
768
+ if auth_setting["in"] == "cookie":
769
+ headers["Cookie"] = auth_setting["value"]
770
+ elif auth_setting["in"] == "header":
771
+ if auth_setting["type"] != "http-signature":
772
+ if auth_setting["value"] is None:
773
+ raise ApiValueError("Invalid authentication token for {}".format(auth_setting["key"]))
774
+ headers[auth_setting["key"]] = auth_setting["value"]
775
+ elif auth_setting["in"] == "query":
776
+ queries.append((auth_setting["key"], auth_setting["value"]))
777
+ else:
778
+ raise ApiValueError("Authentication token must be in `query` or `header`")
779
+
787
780
788
781
def user_agent():
789
782
"""Generate default User-Agent header."""
0 commit comments