rxfoundry.clients.swifty-receiver-api 0.1.1034__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,259 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Swifty Receiver API
5
+
6
+ API for the Swifty Receiver
7
+
8
+ The version of the OpenAPI document: 0.1.DEV-0
9
+ Contact: paul.tindall@rxfoundry.com
10
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
11
+
12
+ Do not edit the class manually.
13
+ """ # noqa: E501
14
+
15
+
16
+ import io
17
+ import json
18
+ import re
19
+ import ssl
20
+
21
+ import urllib3
22
+
23
+ from rxfoundry.clients.swifty_receiver_api.exceptions import ApiException, ApiValueError
24
+
25
+ SUPPORTED_SOCKS_PROXIES = {"socks5", "socks5h", "socks4", "socks4a"}
26
+ RESTResponseType = urllib3.HTTPResponse
27
+
28
+
29
+ def is_socks_proxy_url(url):
30
+ if url is None:
31
+ return False
32
+ split_section = url.split("://")
33
+ if len(split_section) < 2:
34
+ return False
35
+ else:
36
+ return split_section[0].lower() in SUPPORTED_SOCKS_PROXIES
37
+
38
+
39
+ class RESTResponse(io.IOBase):
40
+
41
+ def __init__(self, resp) -> None:
42
+ self.response = resp
43
+ self.status = resp.status
44
+ self.reason = resp.reason
45
+ self.data = None
46
+
47
+ def read(self):
48
+ if self.data is None:
49
+ self.data = self.response.data
50
+ return self.data
51
+
52
+ def getheaders(self):
53
+ """Returns a dictionary of the response headers."""
54
+ return self.response.headers
55
+
56
+ def getheader(self, name, default=None):
57
+ """Returns a given response header."""
58
+ return self.response.headers.get(name, default)
59
+
60
+
61
+ class RESTClientObject:
62
+
63
+ def __init__(self, configuration) -> None:
64
+ # urllib3.PoolManager will pass all kw parameters to connectionpool
65
+ # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/poolmanager.py#L75 # noqa: E501
66
+ # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/connectionpool.py#L680 # noqa: E501
67
+ # Custom SSL certificates and client certificates: http://urllib3.readthedocs.io/en/latest/advanced-usage.html # noqa: E501
68
+
69
+ # cert_reqs
70
+ if configuration.verify_ssl:
71
+ cert_reqs = ssl.CERT_REQUIRED
72
+ else:
73
+ cert_reqs = ssl.CERT_NONE
74
+
75
+ pool_args = {
76
+ "cert_reqs": cert_reqs,
77
+ "ca_certs": configuration.ssl_ca_cert,
78
+ "cert_file": configuration.cert_file,
79
+ "key_file": configuration.key_file,
80
+ "ca_cert_data": configuration.ca_cert_data,
81
+ }
82
+ if configuration.assert_hostname is not None:
83
+ pool_args['assert_hostname'] = (
84
+ configuration.assert_hostname
85
+ )
86
+
87
+ if configuration.retries is not None:
88
+ pool_args['retries'] = configuration.retries
89
+
90
+ if configuration.tls_server_name:
91
+ pool_args['server_hostname'] = configuration.tls_server_name
92
+
93
+
94
+ if configuration.socket_options is not None:
95
+ pool_args['socket_options'] = configuration.socket_options
96
+
97
+ if configuration.connection_pool_maxsize is not None:
98
+ pool_args['maxsize'] = configuration.connection_pool_maxsize
99
+
100
+ # https pool manager
101
+ self.pool_manager: urllib3.PoolManager
102
+
103
+ if configuration.proxy:
104
+ if is_socks_proxy_url(configuration.proxy):
105
+ from urllib3.contrib.socks import SOCKSProxyManager
106
+ pool_args["proxy_url"] = configuration.proxy
107
+ pool_args["headers"] = configuration.proxy_headers
108
+ self.pool_manager = SOCKSProxyManager(**pool_args)
109
+ else:
110
+ pool_args["proxy_url"] = configuration.proxy
111
+ pool_args["proxy_headers"] = configuration.proxy_headers
112
+ self.pool_manager = urllib3.ProxyManager(**pool_args)
113
+ else:
114
+ self.pool_manager = urllib3.PoolManager(**pool_args)
115
+
116
+ def request(
117
+ self,
118
+ method,
119
+ url,
120
+ headers=None,
121
+ body=None,
122
+ post_params=None,
123
+ _request_timeout=None
124
+ ):
125
+ """Perform requests.
126
+
127
+ :param method: http request method
128
+ :param url: http request url
129
+ :param headers: http request headers
130
+ :param body: request json body, for `application/json`
131
+ :param post_params: request post parameters,
132
+ `application/x-www-form-urlencoded`
133
+ and `multipart/form-data`
134
+ :param _request_timeout: timeout setting for this request. If one
135
+ number provided, it will be total request
136
+ timeout. It can also be a pair (tuple) of
137
+ (connection, read) timeouts.
138
+ """
139
+ method = method.upper()
140
+ assert method in [
141
+ 'GET',
142
+ 'HEAD',
143
+ 'DELETE',
144
+ 'POST',
145
+ 'PUT',
146
+ 'PATCH',
147
+ 'OPTIONS'
148
+ ]
149
+
150
+ if post_params and body:
151
+ raise ApiValueError(
152
+ "body parameter cannot be used with post_params parameter."
153
+ )
154
+
155
+ post_params = post_params or {}
156
+ headers = headers or {}
157
+
158
+ timeout = None
159
+ if _request_timeout:
160
+ if isinstance(_request_timeout, (int, float)):
161
+ timeout = urllib3.Timeout(total=_request_timeout)
162
+ elif (
163
+ isinstance(_request_timeout, tuple)
164
+ and len(_request_timeout) == 2
165
+ ):
166
+ timeout = urllib3.Timeout(
167
+ connect=_request_timeout[0],
168
+ read=_request_timeout[1]
169
+ )
170
+
171
+ try:
172
+ # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE`
173
+ if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']:
174
+
175
+ # no content type provided or payload is json
176
+ content_type = headers.get('Content-Type')
177
+ if (
178
+ not content_type
179
+ or re.search('json', content_type, re.IGNORECASE)
180
+ ):
181
+ request_body = None
182
+ if body is not None:
183
+ request_body = json.dumps(body)
184
+ r = self.pool_manager.request(
185
+ method,
186
+ url,
187
+ body=request_body,
188
+ timeout=timeout,
189
+ headers=headers,
190
+ preload_content=False
191
+ )
192
+ elif content_type == 'application/x-www-form-urlencoded':
193
+ r = self.pool_manager.request(
194
+ method,
195
+ url,
196
+ fields=post_params,
197
+ encode_multipart=False,
198
+ timeout=timeout,
199
+ headers=headers,
200
+ preload_content=False
201
+ )
202
+ elif content_type == 'multipart/form-data':
203
+ # must del headers['Content-Type'], or the correct
204
+ # Content-Type which generated by urllib3 will be
205
+ # overwritten.
206
+ del headers['Content-Type']
207
+ # Ensures that dict objects are serialized
208
+ post_params = [(a, json.dumps(b)) if isinstance(b, dict) else (a,b) for a, b in post_params]
209
+ r = self.pool_manager.request(
210
+ method,
211
+ url,
212
+ fields=post_params,
213
+ encode_multipart=True,
214
+ timeout=timeout,
215
+ headers=headers,
216
+ preload_content=False
217
+ )
218
+ # Pass a `string` parameter directly in the body to support
219
+ # other content types than JSON when `body` argument is
220
+ # provided in serialized form.
221
+ elif isinstance(body, str) or isinstance(body, bytes):
222
+ r = self.pool_manager.request(
223
+ method,
224
+ url,
225
+ body=body,
226
+ timeout=timeout,
227
+ headers=headers,
228
+ preload_content=False
229
+ )
230
+ elif headers['Content-Type'].startswith('text/') and isinstance(body, bool):
231
+ request_body = "true" if body else "false"
232
+ r = self.pool_manager.request(
233
+ method,
234
+ url,
235
+ body=request_body,
236
+ preload_content=False,
237
+ timeout=timeout,
238
+ headers=headers)
239
+ else:
240
+ # Cannot generate the request from given parameters
241
+ msg = """Cannot prepare a request message for provided
242
+ arguments. Please check that your arguments match
243
+ declared content type."""
244
+ raise ApiException(status=0, reason=msg)
245
+ # For `GET`, `HEAD`
246
+ else:
247
+ r = self.pool_manager.request(
248
+ method,
249
+ url,
250
+ fields={},
251
+ timeout=timeout,
252
+ headers=headers,
253
+ preload_content=False
254
+ )
255
+ except urllib3.exceptions.SSLError as e:
256
+ msg = "\n".join([type(e).__name__, str(e)])
257
+ raise ApiException(status=0, reason=msg)
258
+
259
+ return RESTResponse(r)
@@ -0,0 +1,23 @@
1
+ Metadata-Version: 2.4
2
+ Name: rxfoundry.clients.swifty-receiver-api
3
+ Version: 0.1.1034
4
+ Summary: Swifty Receiver API
5
+ Home-page:
6
+ Author: RxFoundry Team
7
+ Author-email: paul.tindall@rxfoundry.com
8
+ Keywords: OpenAPI,OpenAPI-Generator,Swifty Receiver API
9
+ Description-Content-Type: text/markdown
10
+ Requires-Dist: urllib3<3.0.0,>=2.1.0
11
+ Requires-Dist: python-dateutil>=2.8.2
12
+ Requires-Dist: pydantic>=2
13
+ Requires-Dist: typing-extensions>=4.7.1
14
+ Dynamic: author
15
+ Dynamic: author-email
16
+ Dynamic: description
17
+ Dynamic: description-content-type
18
+ Dynamic: keywords
19
+ Dynamic: requires-dist
20
+ Dynamic: summary
21
+
22
+ API for the Swifty Receiver
23
+
@@ -0,0 +1,20 @@
1
+ rxfoundry/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ rxfoundry/clients/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ rxfoundry/clients/swifty_receiver_api/__init__.py,sha256=UnOu-ewR74T__qHs9g-Qk_d8_a2j78-4ASns2d3fNHk,1493
4
+ rxfoundry/clients/swifty_receiver_api/api_client.py,sha256=nEKawj_Kyh7OlKFUtRI5Ijvr18ndVRyIKoNy5viuZUw,27590
5
+ rxfoundry/clients/swifty_receiver_api/api_response.py,sha256=eMxw1mpmJcoGZ3gs9z6jM4oYoZ10Gjk333s9sKxGv7s,652
6
+ rxfoundry/clients/swifty_receiver_api/configuration.py,sha256=ABfQ39vU3dzV8ZbY2T-VByPHz5SwLvwKU6kuayEQVX0,18268
7
+ rxfoundry/clients/swifty_receiver_api/exceptions.py,sha256=n5w_Et-JibUev5lDGcRGDHUrmega7ikcoTAy8Da8l80,6449
8
+ rxfoundry/clients/swifty_receiver_api/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
+ rxfoundry/clients/swifty_receiver_api/rest.py,sha256=1mah7cr3819ydK5U-Jt0ApatiGkAmovdZPZ_FUMaOzw,9469
10
+ rxfoundry/clients/swifty_receiver_api/api/__init__.py,sha256=tLuuBcpcuv8oPB68d1pWjrvE103E21mGum3ve4-U86A,198
11
+ rxfoundry/clients/swifty_receiver_api/api/async_api.py,sha256=0REfU0yOGTVidu2XyXFFgrItw-Fx9H0cTVnc1BYCKLc,11472
12
+ rxfoundry/clients/swifty_receiver_api/api/version_api.py,sha256=JexyiRKQZlhSvvpuxPB7xpq2W0eHV7hKl-OxH6SJRSI,10283
13
+ rxfoundry/clients/swifty_receiver_api/models/__init__.py,sha256=eF6sLcC2OrkiKFXBTmt0BM3jCxA7xmJpach0OswPTSM,592
14
+ rxfoundry/clients/swifty_receiver_api/models/asynchronous_response.py,sha256=qysZWyu-OGx1ynKS3Csh539mPglmEbQxYg1HdW9wxHA,2816
15
+ rxfoundry/clients/swifty_receiver_api/models/message.py,sha256=XYpxYp4MV7N4hf_g7ZgbjzOwqLdAIotwDNfeCG9RgDs,3863
16
+ rxfoundry/clients/swifty_receiver_api/models/version.py,sha256=qH9jewj0myA6carIMa5aXRDDHG4hCS7LfVoTlIr-j2M,2461
17
+ rxfoundry_clients_swifty_receiver_api-0.1.1034.dist-info/METADATA,sha256=jFj-IYX6iPQTUb9GyrpZyIarhFFnNljX8ZOc-vZIkf8,617
18
+ rxfoundry_clients_swifty_receiver_api-0.1.1034.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
19
+ rxfoundry_clients_swifty_receiver_api-0.1.1034.dist-info/top_level.txt,sha256=x7AlWW4imWljpZ91S0V0Pq8YFe0UFn8rBgeIQhJ5q5A,10
20
+ rxfoundry_clients_swifty_receiver_api-0.1.1034.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.10.2)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+