forked from loafle/openapi-generator-original
[python] add socket_options to configuration for the rest client (#7795)
* [python] add socket_options to configuration for the rest client * (python-experimental) add socket_options to configuration for the rest client This mirrors work done on the python generator * (python-experimental) add test to cover socket_options is passed on from configuration Co-authored-by: steve brazier <steve.brazier@trioptima.com>
This commit is contained in:
parent
44f5f2bdd8
commit
ea2cdd23c2
@ -302,6 +302,10 @@ conf = {{{packageName}}}.Configuration(
|
||||
# Enable client side validation
|
||||
self.client_side_validation = True
|
||||
|
||||
self.socket_options = None
|
||||
"""Options to pass down to the underlying urllib3 socket
|
||||
"""
|
||||
|
||||
def __deepcopy__(self, memo):
|
||||
cls = self.__class__
|
||||
result = cls.__new__(cls)
|
||||
|
@ -299,6 +299,9 @@ conf = {{{packageName}}}.Configuration(
|
||||
# Enable client side validation
|
||||
self.client_side_validation = True
|
||||
|
||||
# Options to pass down to the underlying urllib3 socket
|
||||
self.socket_options = None
|
||||
|
||||
def __deepcopy__(self, memo):
|
||||
cls = self.__class__
|
||||
result = cls.__new__(cls)
|
||||
|
@ -64,6 +64,9 @@ class RESTClientObject(object):
|
||||
if configuration.retries is not None:
|
||||
addition_pool_args['retries'] = configuration.retries
|
||||
|
||||
if configuration.socket_options is not None:
|
||||
addition_pool_args['socket_options'] = configuration.socket_options
|
||||
|
||||
if maxsize is None:
|
||||
if configuration.connection_pool_maxsize is not None:
|
||||
maxsize = configuration.connection_pool_maxsize
|
||||
|
@ -68,6 +68,9 @@ class RESTClientObject(object):
|
||||
if configuration.retries is not None:
|
||||
addition_pool_args['retries'] = configuration.retries
|
||||
|
||||
if configuration.socket_options is not None:
|
||||
addition_pool_args['socket_options'] = configuration.socket_options
|
||||
|
||||
if maxsize is None:
|
||||
if configuration.connection_pool_maxsize is not None:
|
||||
maxsize = configuration.connection_pool_maxsize
|
||||
|
@ -226,6 +226,10 @@ conf = petstore_api.Configuration(
|
||||
# Enable client side validation
|
||||
self.client_side_validation = True
|
||||
|
||||
self.socket_options = None
|
||||
"""Options to pass down to the underlying urllib3 socket
|
||||
"""
|
||||
|
||||
def __deepcopy__(self, memo):
|
||||
cls = self.__class__
|
||||
result = cls.__new__(cls)
|
||||
|
@ -227,6 +227,9 @@ conf = petstore_api.Configuration(
|
||||
# Enable client side validation
|
||||
self.client_side_validation = True
|
||||
|
||||
# Options to pass down to the underlying urllib3 socket
|
||||
self.socket_options = None
|
||||
|
||||
def __deepcopy__(self, memo):
|
||||
cls = self.__class__
|
||||
result = cls.__new__(cls)
|
||||
|
@ -72,6 +72,9 @@ class RESTClientObject(object):
|
||||
if configuration.retries is not None:
|
||||
addition_pool_args['retries'] = configuration.retries
|
||||
|
||||
if configuration.socket_options is not None:
|
||||
addition_pool_args['socket_options'] = configuration.socket_options
|
||||
|
||||
if maxsize is None:
|
||||
if configuration.connection_pool_maxsize is not None:
|
||||
maxsize = configuration.connection_pool_maxsize
|
||||
|
@ -230,6 +230,10 @@ conf = petstore_api.Configuration(
|
||||
# Enable client side validation
|
||||
self.client_side_validation = True
|
||||
|
||||
self.socket_options = None
|
||||
"""Options to pass down to the underlying urllib3 socket
|
||||
"""
|
||||
|
||||
def __deepcopy__(self, memo):
|
||||
cls = self.__class__
|
||||
result = cls.__new__(cls)
|
||||
|
@ -230,6 +230,10 @@ conf = petstore_api.Configuration(
|
||||
# Enable client side validation
|
||||
self.client_side_validation = True
|
||||
|
||||
self.socket_options = None
|
||||
"""Options to pass down to the underlying urllib3 socket
|
||||
"""
|
||||
|
||||
def __deepcopy__(self, memo):
|
||||
cls = self.__class__
|
||||
result = cls.__new__(cls)
|
||||
|
@ -76,6 +76,9 @@ class RESTClientObject(object):
|
||||
if configuration.retries is not None:
|
||||
addition_pool_args['retries'] = configuration.retries
|
||||
|
||||
if configuration.socket_options is not None:
|
||||
addition_pool_args['socket_options'] = configuration.socket_options
|
||||
|
||||
if maxsize is None:
|
||||
if configuration.connection_pool_maxsize is not None:
|
||||
maxsize = configuration.connection_pool_maxsize
|
||||
|
@ -208,6 +208,9 @@ conf = x_auth_id_alias.Configuration(
|
||||
# Enable client side validation
|
||||
self.client_side_validation = True
|
||||
|
||||
# Options to pass down to the underlying urllib3 socket
|
||||
self.socket_options = None
|
||||
|
||||
def __deepcopy__(self, memo):
|
||||
cls = self.__class__
|
||||
result = cls.__new__(cls)
|
||||
|
@ -72,6 +72,9 @@ class RESTClientObject(object):
|
||||
if configuration.retries is not None:
|
||||
addition_pool_args['retries'] = configuration.retries
|
||||
|
||||
if configuration.socket_options is not None:
|
||||
addition_pool_args['socket_options'] = configuration.socket_options
|
||||
|
||||
if maxsize is None:
|
||||
if configuration.connection_pool_maxsize is not None:
|
||||
maxsize = configuration.connection_pool_maxsize
|
||||
|
@ -188,6 +188,9 @@ class Configuration(object):
|
||||
# Enable client side validation
|
||||
self.client_side_validation = True
|
||||
|
||||
# Options to pass down to the underlying urllib3 socket
|
||||
self.socket_options = None
|
||||
|
||||
def __deepcopy__(self, memo):
|
||||
cls = self.__class__
|
||||
result = cls.__new__(cls)
|
||||
|
@ -72,6 +72,9 @@ class RESTClientObject(object):
|
||||
if configuration.retries is not None:
|
||||
addition_pool_args['retries'] = configuration.retries
|
||||
|
||||
if configuration.socket_options is not None:
|
||||
addition_pool_args['socket_options'] = configuration.socket_options
|
||||
|
||||
if maxsize is None:
|
||||
if configuration.connection_pool_maxsize is not None:
|
||||
maxsize = configuration.connection_pool_maxsize
|
||||
|
@ -274,6 +274,9 @@ conf = petstore_api.Configuration(
|
||||
# Enable client side validation
|
||||
self.client_side_validation = True
|
||||
|
||||
# Options to pass down to the underlying urllib3 socket
|
||||
self.socket_options = None
|
||||
|
||||
def __deepcopy__(self, memo):
|
||||
cls = self.__class__
|
||||
result = cls.__new__(cls)
|
||||
|
@ -72,6 +72,9 @@ class RESTClientObject(object):
|
||||
if configuration.retries is not None:
|
||||
addition_pool_args['retries'] = configuration.retries
|
||||
|
||||
if configuration.socket_options is not None:
|
||||
addition_pool_args['socket_options'] = configuration.socket_options
|
||||
|
||||
if maxsize is None:
|
||||
if configuration.connection_pool_maxsize is not None:
|
||||
maxsize = configuration.connection_pool_maxsize
|
||||
|
@ -1,15 +0,0 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIICXgIBAAKBgQDCFENGw33yGihy92pDjZQhl0C36rPJj+CvfSC8+q28hxA161QF
|
||||
NUd13wuCTUcq0Qd2qsBe/2hFyc2DCJJg0h1L78+6Z4UMR7EOcpfdUE9Hf3m/hs+F
|
||||
UR45uBJeDK1HSFHD8bHKD6kv8FPGfJTotc+2xjJwoYi+1hqp1fIekaxsyQIDAQAB
|
||||
AoGBAJR8ZkCUvx5kzv+utdl7T5MnordT1TvoXXJGXK7ZZ+UuvMNUCdN2QPc4sBiA
|
||||
QWvLw1cSKt5DsKZ8UETpYPy8pPYnnDEz2dDYiaew9+xEpubyeW2oH4Zx71wqBtOK
|
||||
kqwrXa/pzdpiucRRjk6vE6YY7EBBs/g7uanVpGibOVAEsqH1AkEA7DkjVH28WDUg
|
||||
f1nqvfn2Kj6CT7nIcE3jGJsZZ7zlZmBmHFDONMLUrXR/Zm3pR5m0tCmBqa5RK95u
|
||||
412jt1dPIwJBANJT3v8pnkth48bQo/fKel6uEYyboRtA5/uHuHkZ6FQF7OUkGogc
|
||||
mSJluOdc5t6hI1VsLn0QZEjQZMEOWr+wKSMCQQCC4kXJEsHAve77oP6HtG/IiEn7
|
||||
kpyUXRNvFsDE0czpJJBvL/aRFUJxuRK91jhjC68sA7NsKMGg5OXb5I5Jj36xAkEA
|
||||
gIT7aFOYBFwGgQAQkWNKLvySgKbAZRTeLBacpHMuQdl1DfdntvAyqpAZ0lY0RKmW
|
||||
G6aFKaqQfOXKCyWoUiVknQJAXrlgySFci/2ueKlIE1QqIiLSZ8V8OlpFLRnb1pzI
|
||||
7U1yQXnTAEFYM560yJlzUpOb1V4cScGd365tiSMvxLOvTA==
|
||||
-----END RSA PRIVATE KEY-----
|
@ -0,0 +1,61 @@
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
import petstore_api
|
||||
|
||||
|
||||
class StubPoolManager(object):
|
||||
actual_kwargs = None
|
||||
|
||||
def __init__(self, num_pools=10, headers=None, **kwargs):
|
||||
# Matches the contract of urllib3.PoolManager
|
||||
self.actual_kwargs = kwargs
|
||||
|
||||
|
||||
class StubProxyManager:
|
||||
actual_kwargs = None
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
proxy_url,
|
||||
num_pools=10,
|
||||
headers=None,
|
||||
proxy_headers=None,
|
||||
**kwargs
|
||||
):
|
||||
# Matches the contract of urllib3.ProxyManager
|
||||
self.actual_kwargs = kwargs
|
||||
|
||||
|
||||
class TestExtraOptionsForPools(unittest.TestCase):
|
||||
|
||||
def test_socket_options_get_passed_to_pool_manager(self):
|
||||
|
||||
socket_options = ["extra", "socket", "options"]
|
||||
|
||||
config = petstore_api.Configuration(host="HOST")
|
||||
config.socket_options = socket_options
|
||||
|
||||
with patch("petstore_api.rest.urllib3.PoolManager", StubPoolManager):
|
||||
api_client = petstore_api.ApiClient(config)
|
||||
|
||||
# urllib3.PoolManager promises to pass socket_options in kwargs
|
||||
# to the underlying socket. So asserting that our manager
|
||||
# gets it is a good start
|
||||
assert api_client.rest_client.pool_manager.actual_kwargs["socket_options"] == socket_options
|
||||
|
||||
def test_socket_options_get_passed_to_proxy_manager(self):
|
||||
|
||||
socket_options = ["extra", "socket", "options"]
|
||||
|
||||
config = petstore_api.Configuration(host="HOST")
|
||||
config.socket_options = socket_options
|
||||
config.proxy = True
|
||||
|
||||
with patch("petstore_api.rest.urllib3.ProxyManager", StubProxyManager):
|
||||
api_client = petstore_api.ApiClient(config)
|
||||
|
||||
# urllib3.ProxyManager promises to pass socket_options in kwargs
|
||||
# to the underlying socket. So asserting that our manager
|
||||
# gets it is a good start
|
||||
assert api_client.rest_client.pool_manager.actual_kwargs["socket_options"] == socket_options
|
@ -277,6 +277,10 @@ conf = petstore_api.Configuration(
|
||||
# Enable client side validation
|
||||
self.client_side_validation = True
|
||||
|
||||
self.socket_options = None
|
||||
"""Options to pass down to the underlying urllib3 socket
|
||||
"""
|
||||
|
||||
def __deepcopy__(self, memo):
|
||||
cls = self.__class__
|
||||
result = cls.__new__(cls)
|
||||
|
@ -76,6 +76,9 @@ class RESTClientObject(object):
|
||||
if configuration.retries is not None:
|
||||
addition_pool_args['retries'] = configuration.retries
|
||||
|
||||
if configuration.socket_options is not None:
|
||||
addition_pool_args['socket_options'] = configuration.socket_options
|
||||
|
||||
if maxsize is None:
|
||||
if configuration.connection_pool_maxsize is not None:
|
||||
maxsize = configuration.connection_pool_maxsize
|
||||
|
Loading…
x
Reference in New Issue
Block a user