44
55from __future__ import absolute_import
66
7+ { {#asyncio} }
8+ import aiohttp
9+ { {/asyncio} }
710import copy
811import logging
12+ { {^asyncio} }{ {^tornado} }
913import multiprocessing
14+ { {/asyncio} }{ {/tornado} }
1015import sys
16+ { {^asyncio} }
1117import urllib3
18+ { {/asyncio} }
19+
1220
1321import six
1422from six.moves import http_client as httplib
@@ -60,7 +68,12 @@ class Configuration(six.with_metaclass(TypeWithDefault, object)):
6068 # Logging Settings
6169 self.logger = { }
6270 self.logger["package_logger"] = logging.getLogger("{ {packageName} }")
71+ { {#asyncio} }
72+ self.logger["aiohttp"] = logging.getLogger("aiohttp.client")
73+ { {/asyncio} }
74+ { {^asyncio} }
6375 self.logger["urllib3_logger"] = logging.getLogger("urllib3")
76+ { {/asyncio} }
6477 # Log format
6578 self.logger_format = '%(asctime)s %(levelname)s %(message)s'
6679 # Log stream handler
@@ -84,14 +97,14 @@ class Configuration(six.with_metaclass(TypeWithDefault, object)):
8497 self.key_file = None
8598 # Set this to True/False to enable/disable SSL hostname verification.
8699 self.assert_hostname = None
87-
100+ { {^asyncio } } { {^tornado } }
88101 # urllib3 connection pool's maximum number of connections saved
89102 # per pool. urllib3 uses 1 connection as default value, but this is
90103 # not the best value when you are making a lot of possibly parallel
91104 # requests to the same host, which is often the case here.
92105 # cpu_count * 5 is used as default value to increase performance.
93106 self.connection_pool_maxsize = multiprocessing.cpu_count() * 5
94-
107+ { {/tornado } } { {/asyncio } }
95108 # Proxy URL
96109 self.proxy = None
97110 # Safe chars for path_param
@@ -193,14 +206,14 @@ class Configuration(six.with_metaclass(TypeWithDefault, object)):
193206 self.__logger_format = value
194207 self.logger_formatter = logging.Formatter(self.__logger_format)
195208
196- def get_api_key_with_prefix(self, identifier):
209+ { {#asyncio } }async { {/asyncio } } def get_api_key_with_prefix(self, identifier):
197210 """Gets API key (with prefix if set).
198211
199212 :param identifier: The identifier of apiKey.
200213 :return: The token for api key authentication.
201214 """
202215 if self.refresh_api_key_hook:
203- self.refresh_api_key_hook(self)
216+ { {#asyncio } }await { {/asyncio } } self.refresh_api_key_hook(self)
204217
205218 key = self.api_key.get(identifier)
206219 if key:
@@ -217,12 +230,18 @@ class Configuration(six.with_metaclass(TypeWithDefault, object)):
217230 """
218231 token = ""
219232 if self.username or self.password:
233+ { {#asyncio} }
234+ token = aiohttp.BasicAuth(
235+ self.username, self.password).encode()
236+ { {/asyncio} }
237+ { {^asyncio} }
220238 token = urllib3.util.make_headers(
221239 basic_auth=self.username + ':' + self.password
222240 ).get('authorization')
241+ { {/asyncio} }
223242 return token
224243
225- def auth_settings(self):
244+ { {#asyncio } }async { {/asyncio } } def auth_settings(self):
226245 """Gets Auth Settings dict for api client.
227246
228247 :return: The Auth Settings information dict.
@@ -235,7 +254,7 @@ class Configuration(six.with_metaclass(TypeWithDefault, object)):
235254 ' type' : ' api_key' ,
236255 ' in' : {{#isKeyInHeader} }'header'{ {/isKeyInHeader} }{ {#isKeyInQuery} }'query'{ {/isKeyInQuery} },
237256 'key': '{ {keyParamName} }',
238- 'value': self.get_api_key_with_prefix('{ {keyParamName} }')
257+ 'value': { {#asyncio } }await { {/asyncio } } self.get_api_key_with_prefix('{ {keyParamName} }')
239258 },
240259{ {/isApiKey} }
241260{ {#isBasic} }
0 commit comments