@@ -33,7 +33,45 @@ class AuthType(Enum):
33
33
X_API_KEY = "X-API-Key"
34
34
35
35
36
+ class _ClientConfigDescriptor :
37
+ def __init__ (self , name ):
38
+ self .name = name
39
+
40
+ def __get__ (self , obj , cls ):
41
+ return obj .__dict__ [self .name ]
42
+
43
+ def __set__ (self , obj , value ) -> None :
44
+ obj .__dict__ [self .name ] = value
45
+
46
+
36
47
class ClientConfig :
48
+ remote_server_addr = _ClientConfigDescriptor ("_remote_server_addr" )
49
+ """Gets and Sets Remote Server"""
50
+ keep_alive = _ClientConfigDescriptor ("_keep_alive" )
51
+ """Gets and Sets Keep Alive value"""
52
+ proxy = _ClientConfigDescriptor ("_proxy" )
53
+ """Gets and Sets the proxy used for communicating to the driver/server."""
54
+ ignore_certificates = _ClientConfigDescriptor ("_ignore_certificates" )
55
+ """Gets and Sets the ignore certificate check value."""
56
+ init_args_for_pool_manager = _ClientConfigDescriptor ("_init_args_for_pool_manager" )
57
+ """Gets and Sets the ignore certificate check."""
58
+ timeout = _ClientConfigDescriptor ("_timeout" )
59
+ """Gets and Sets the timeout (in seconds) used for communicating to the driver/server"""
60
+ ca_certs = _ClientConfigDescriptor ("_ca_certs" )
61
+ """Gets and Sets the path to bundle of CA certificates."""
62
+ username = _ClientConfigDescriptor ("_username" )
63
+ """Gets and Sets the username used for basic authentication to the remote"""
64
+ password = _ClientConfigDescriptor ("_password" )
65
+ """Gets and Sets the password used for basic authentication to the remote"""
66
+ auth_type = _ClientConfigDescriptor ("_auth_type" )
67
+ """Gets and Sets the type of authentication to the remote server."""
68
+ token = _ClientConfigDescriptor ("_token" )
69
+ """Gets and Sets the token used for authentication to the remote server"""
70
+ user_agent = _ClientConfigDescriptor ("_user_agent" )
71
+ """Gets and Sets user agent to be added to the request headers."""
72
+ extra_headers = _ClientConfigDescriptor ("_extra_headers" )
73
+ """Gets and Sets extra headers to be added to the request."""
74
+
37
75
def __init__ (
38
76
self ,
39
77
remote_server_addr : str ,
@@ -79,179 +117,11 @@ def __init__(
79
117
else ca_certs
80
118
)
81
119
82
- @property
83
- def remote_server_addr (self ) -> str :
84
- """:Returns: The address of the remote server."""
85
- return self ._remote_server_addr
86
-
87
- @remote_server_addr .setter
88
- def remote_server_addr (self , value : str ) -> None :
89
- """Provides the address of the remote server."""
90
- self ._remote_server_addr = value
91
-
92
- @property
93
- def keep_alive (self ) -> bool :
94
- """:Returns: The keep alive value."""
95
- return self ._keep_alive
96
-
97
- @keep_alive .setter
98
- def keep_alive (self , value : bool ) -> None :
99
- """Toggles the keep alive value.
100
-
101
- :Args:
102
- - value: whether to keep the http connection alive
103
- """
104
- self ._keep_alive = value
105
-
106
- @property
107
- def proxy (self ) -> Proxy :
108
- """:Returns: The proxy used for communicating to the driver/server."""
109
- return self ._proxy
110
-
111
- @proxy .setter
112
- def proxy (self , proxy : Proxy ) -> None :
113
- """Provides the information for communicating with the driver or
114
- server.
115
- For example: Proxy(raw={"proxyType": ProxyType.SYSTEM})
116
-
117
- :Args:
118
- - value: the proxy information to use to communicate with the driver or server
119
- """
120
- self ._proxy = proxy
121
-
122
- @property
123
- def ignore_certificates (self ) -> bool :
124
- """:Returns: The ignore certificate check value."""
125
- return self ._ignore_certificates
126
-
127
- @ignore_certificates .setter
128
- def ignore_certificates (self , ignore_certificates : bool ) -> None :
129
- """Toggles the ignore certificate check.
130
-
131
- :Args:
132
- - value: value of ignore certificate check
133
- """
134
- self ._ignore_certificates = ignore_certificates
135
-
136
- @property
137
- def init_args_for_pool_manager (self ) -> dict :
138
- """:Returns: The dictionary of arguments will be appended while
139
- initializing the pool manager."""
140
- return self ._init_args_for_pool_manager
141
-
142
- @init_args_for_pool_manager .setter
143
- def init_args_for_pool_manager (self , init_args_for_pool_manager : dict ) -> None :
144
- """Provides dictionary of arguments will be appended while initializing the pool manager.
145
- For example: {"init_args_for_pool_manager": {"retries": 3, "block": True}}
146
-
147
- :Args:
148
- - value: the dictionary of arguments will be appended while initializing the pool manager
149
- """
150
- self ._init_args_for_pool_manager = init_args_for_pool_manager
151
-
152
- @property
153
- def timeout (self ) -> int :
154
- """:Returns: The timeout (in seconds) used for communicating to the
155
- driver/server."""
156
- return self ._timeout
157
-
158
- @timeout .setter
159
- def timeout (self , timeout : int ) -> None :
160
- """Provides the timeout (in seconds) for communicating with the driver
161
- or server.
162
-
163
- :Args:
164
- - value: the timeout (in seconds) to use to communicate with the driver or server
165
- """
166
- self ._timeout = timeout
167
120
168
121
def reset_timeout (self ) -> None :
169
122
"""Resets the timeout to the default value of socket."""
170
123
self ._timeout = socket .getdefaulttimeout ()
171
124
172
- @property
173
- def ca_certs (self ) -> str :
174
- """:Returns: The path to bundle of CA certificates."""
175
- return self ._ca_certs
176
-
177
- @ca_certs .setter
178
- def ca_certs (self , ca_certs : str ) -> None :
179
- """Provides the path to bundle of CA certificates for establishing
180
- secure connections.
181
-
182
- :Args:
183
- - value: the path to bundle of CA certificates for establishing secure connections
184
- """
185
- self ._ca_certs = ca_certs
186
-
187
- @property
188
- def username (self ) -> str :
189
- """Returns the username used for basic authentication to the remote
190
- server."""
191
- return self ._username
192
-
193
- @username .setter
194
- def username (self , value : str ) -> None :
195
- """Sets the username used for basic authentication to the remote
196
- server."""
197
- self ._username = value
198
-
199
- @property
200
- def password (self ) -> str :
201
- """Returns the password used for basic authentication to the remote
202
- server."""
203
- return self ._password
204
-
205
- @password .setter
206
- def password (self , value : str ) -> None :
207
- """Sets the password used for basic authentication to the remote
208
- server."""
209
- self ._password = value
210
-
211
- @property
212
- def auth_type (self ) -> AuthType :
213
- """Returns the type of authentication to the remote server."""
214
- return self ._auth_type
215
-
216
- @auth_type .setter
217
- def auth_type (self , value : AuthType ) -> None :
218
- """Sets the type of authentication to the remote server if it is not
219
- using basic with username and password.
220
-
221
- :Args: value - AuthType enum value. For others, please use `extra_headers` instead
222
- """
223
- self ._auth_type = value
224
-
225
- @property
226
- def token (self ) -> str :
227
- """Returns the token used for authentication to the remote server."""
228
- return self ._token
229
-
230
- @token .setter
231
- def token (self , value : str ) -> None :
232
- """Sets the token used for authentication to the remote server if
233
- auth_type is not basic."""
234
- self ._token = value
235
-
236
- @property
237
- def user_agent (self ) -> str :
238
- """Returns user agent to be added to the request headers."""
239
- return self ._user_agent
240
-
241
- @user_agent .setter
242
- def user_agent (self , value : str ) -> None :
243
- """Sets user agent to be added to the request headers."""
244
- self ._user_agent = value
245
-
246
- @property
247
- def extra_headers (self ) -> dict :
248
- """Returns extra headers to be added to the request."""
249
- return self ._extra_headers
250
-
251
- @extra_headers .setter
252
- def extra_headers (self , value : dict ) -> None :
253
- """Sets extra headers to be added to the request."""
254
- self ._extra_headers = value
255
125
256
126
def get_proxy_url (self ) -> Optional [str ]:
257
127
"""Returns the proxy URL to use for the connection."""
0 commit comments