MCPcopy Create free account
hub / github.com/bundesAPI/smard-api / RESTClientObject

Class RESTClientObject

python-client/deutschland/smard/rest.py:50–396  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48
49
50class RESTClientObject(object):
51 def __init__(self, configuration, pools_size=4, maxsize=None):
52 # urllib3.PoolManager will pass all kw parameters to connectionpool
53 # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/poolmanager.py#L75 # noqa: E501
54 # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/connectionpool.py#L680 # noqa: E501
55 # maxsize is the number of requests to host that are allowed in parallel # noqa: E501
56 # Custom SSL certificates and client certificates: http://urllib3.readthedocs.io/en/latest/advanced-usage.html # noqa: E501
57
58 # cert_reqs
59 if configuration.verify_ssl:
60 cert_reqs = ssl.CERT_REQUIRED
61 else:
62 cert_reqs = ssl.CERT_NONE
63
64 addition_pool_args = {}
65 if configuration.assert_hostname is not None:
66 addition_pool_args[
67 "assert_hostname"
68 ] = configuration.assert_hostname # noqa: E501
69
70 if configuration.retries is not None:
71 addition_pool_args["retries"] = configuration.retries
72
73 if configuration.socket_options is not None:
74 addition_pool_args["socket_options"] = configuration.socket_options
75
76 if maxsize is None:
77 if configuration.connection_pool_maxsize is not None:
78 maxsize = configuration.connection_pool_maxsize
79 else:
80 maxsize = 4
81
82 # https pool manager
83 if configuration.proxy and not should_bypass_proxies(
84 configuration.host, no_proxy=configuration.no_proxy or ""
85 ):
86 self.pool_manager = urllib3.ProxyManager(
87 num_pools=pools_size,
88 maxsize=maxsize,
89 cert_reqs=cert_reqs,
90 ca_certs=configuration.ssl_ca_cert,
91 cert_file=configuration.cert_file,
92 key_file=configuration.key_file,
93 proxy_url=configuration.proxy,
94 proxy_headers=configuration.proxy_headers,
95 **addition_pool_args
96 )
97 else:
98 self.pool_manager = urllib3.PoolManager(
99 num_pools=pools_size,
100 maxsize=maxsize,
101 cert_reqs=cert_reqs,
102 ca_certs=configuration.ssl_ca_cert,
103 cert_file=configuration.cert_file,
104 key_file=configuration.key_file,
105 **addition_pool_args
106 )
107

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected