apytizer 0.0.1b1__py3-none-any.whl → 0.0.1b2__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.
- apytizer/apis/web_api.py +3 -4
- apytizer/connections/http_connection.py +28 -28
- apytizer/decorators/__init__.py +1 -1
- apytizer/endpoints/web_endpoint.py +27 -27
- apytizer/engines/http_engine.py +62 -20
- apytizer/utils/dictionaries.py +8 -7
- {apytizer-0.0.1b1.dist-info → apytizer-0.0.1b2.dist-info}/METADATA +1 -1
- {apytizer-0.0.1b1.dist-info → apytizer-0.0.1b2.dist-info}/RECORD +11 -11
- /apytizer/decorators/{json_response.py → json.py} +0 -0
- {apytizer-0.0.1b1.dist-info → apytizer-0.0.1b2.dist-info}/WHEEL +0 -0
- {apytizer-0.0.1b1.dist-info → apytizer-0.0.1b2.dist-info}/licenses/LICENSE +0 -0
apytizer/apis/web_api.py
CHANGED
|
@@ -20,7 +20,6 @@ from requests import Response
|
|
|
20
20
|
# Local Imports
|
|
21
21
|
from .abstract_api import AbstractAPI
|
|
22
22
|
from ..connections import HttpConnection
|
|
23
|
-
from ..endpoints import AbstractEndpoint
|
|
24
23
|
from ..endpoints import WebEndpoint
|
|
25
24
|
from ..engines import AbstractEngine
|
|
26
25
|
from ..routes import AbstractRoute
|
|
@@ -106,7 +105,7 @@ class WebAPI(AbstractAPI):
|
|
|
106
105
|
result = f"<{self.__class__.__name__!s} url={self.url!s}>"
|
|
107
106
|
return result
|
|
108
107
|
|
|
109
|
-
def __getitem__(self, path: str) ->
|
|
108
|
+
def __getitem__(self, path: str) -> WebEndpoint:
|
|
110
109
|
"""Get endpoint.
|
|
111
110
|
|
|
112
111
|
Args:
|
|
@@ -119,7 +118,7 @@ class WebAPI(AbstractAPI):
|
|
|
119
118
|
result = self.get_endpoint(path)
|
|
120
119
|
return result
|
|
121
120
|
|
|
122
|
-
def __truediv__(self, path: str) ->
|
|
121
|
+
def __truediv__(self, path: str) -> WebEndpoint:
|
|
123
122
|
"""Get endpoint.
|
|
124
123
|
|
|
125
124
|
Args:
|
|
@@ -132,7 +131,7 @@ class WebAPI(AbstractAPI):
|
|
|
132
131
|
result = self.get_endpoint(path)
|
|
133
132
|
return result
|
|
134
133
|
|
|
135
|
-
def get_endpoint(self, path: str) ->
|
|
134
|
+
def get_endpoint(self, path: str) -> WebEndpoint:
|
|
136
135
|
"""Get endpoint.
|
|
137
136
|
|
|
138
137
|
Arhs:
|
|
@@ -7,9 +7,10 @@ This module defines the base HTTP connection class implementation.
|
|
|
7
7
|
"""
|
|
8
8
|
|
|
9
9
|
# Standard Library Imports
|
|
10
|
+
from collections import ChainMap
|
|
10
11
|
import logging
|
|
11
12
|
from typing import Any
|
|
12
|
-
from typing import
|
|
13
|
+
from typing import MutableMapping
|
|
13
14
|
from typing import Optional
|
|
14
15
|
from typing import Tuple
|
|
15
16
|
from typing import Union
|
|
@@ -28,7 +29,6 @@ from ..http_methods import HTTPMethod
|
|
|
28
29
|
from ..sessions import AbstractSession
|
|
29
30
|
from ..sessions import sessionmaker
|
|
30
31
|
from .. import errors
|
|
31
|
-
from .. import utils
|
|
32
32
|
|
|
33
33
|
if TYPE_CHECKING:
|
|
34
34
|
from ..engines import HTTPEngine
|
|
@@ -66,14 +66,14 @@ class HttpConnection(AbstractConnection):
|
|
|
66
66
|
self._session_factory = session_factory
|
|
67
67
|
|
|
68
68
|
@property
|
|
69
|
-
def headers(self) ->
|
|
69
|
+
def headers(self) -> ChainMap[str, str]:
|
|
70
70
|
"""Connection headers."""
|
|
71
|
-
return
|
|
71
|
+
return self._engine.headers
|
|
72
72
|
|
|
73
73
|
@property
|
|
74
|
-
def params(self) ->
|
|
74
|
+
def params(self) -> ChainMap[str, Any]:
|
|
75
75
|
"""Connection parameters."""
|
|
76
|
-
return
|
|
76
|
+
return self._engine.params
|
|
77
77
|
|
|
78
78
|
@property
|
|
79
79
|
def session(self) -> Optional[AbstractSession]:
|
|
@@ -83,12 +83,12 @@ class HttpConnection(AbstractConnection):
|
|
|
83
83
|
@property
|
|
84
84
|
def timeout(self) -> Optional[Union[float, Tuple[float, float]]]:
|
|
85
85
|
"""Connection timeout."""
|
|
86
|
-
return
|
|
86
|
+
return self._engine.timeout
|
|
87
87
|
|
|
88
88
|
@property
|
|
89
89
|
def url(self) -> str:
|
|
90
90
|
"""Connection URL."""
|
|
91
|
-
return
|
|
91
|
+
return self._engine.url
|
|
92
92
|
|
|
93
93
|
@final
|
|
94
94
|
def __enter__(self) -> AbstractConnection:
|
|
@@ -116,8 +116,8 @@ class HttpConnection(AbstractConnection):
|
|
|
116
116
|
self,
|
|
117
117
|
route: Optional[str] = None,
|
|
118
118
|
*,
|
|
119
|
-
headers: Optional[
|
|
120
|
-
params: Optional[
|
|
119
|
+
headers: Optional[MutableMapping[str, str]] = None,
|
|
120
|
+
params: Optional[MutableMapping[str, Any]] = None,
|
|
121
121
|
**kwargs: Any,
|
|
122
122
|
) -> Optional[Response]:
|
|
123
123
|
"""Sends an HTTP HEAD request.
|
|
@@ -148,8 +148,8 @@ class HttpConnection(AbstractConnection):
|
|
|
148
148
|
self,
|
|
149
149
|
route: Optional[str] = None,
|
|
150
150
|
*,
|
|
151
|
-
headers: Optional[
|
|
152
|
-
params: Optional[
|
|
151
|
+
headers: Optional[MutableMapping[str, str]] = None,
|
|
152
|
+
params: Optional[MutableMapping[str, Any]] = None,
|
|
153
153
|
**kwargs: Any,
|
|
154
154
|
) -> Optional[Response]:
|
|
155
155
|
"""Sends an HTTP GET request.
|
|
@@ -180,8 +180,8 @@ class HttpConnection(AbstractConnection):
|
|
|
180
180
|
self,
|
|
181
181
|
route: Optional[str] = None,
|
|
182
182
|
*,
|
|
183
|
-
headers: Optional[
|
|
184
|
-
params: Optional[
|
|
183
|
+
headers: Optional[MutableMapping[str, str]] = None,
|
|
184
|
+
params: Optional[MutableMapping[str, Any]] = None,
|
|
185
185
|
**kwargs: Any,
|
|
186
186
|
) -> Optional[Response]:
|
|
187
187
|
"""Sends an HTTP POST request.
|
|
@@ -212,8 +212,8 @@ class HttpConnection(AbstractConnection):
|
|
|
212
212
|
self,
|
|
213
213
|
route: Optional[str] = None,
|
|
214
214
|
*,
|
|
215
|
-
headers: Optional[
|
|
216
|
-
params: Optional[
|
|
215
|
+
headers: Optional[MutableMapping[str, str]] = None,
|
|
216
|
+
params: Optional[MutableMapping[str, Any]] = None,
|
|
217
217
|
**kwargs: Any,
|
|
218
218
|
) -> Optional[Response]:
|
|
219
219
|
"""Sends an HTTP PUT request.
|
|
@@ -244,8 +244,8 @@ class HttpConnection(AbstractConnection):
|
|
|
244
244
|
self,
|
|
245
245
|
route: Optional[str] = None,
|
|
246
246
|
*,
|
|
247
|
-
headers: Optional[
|
|
248
|
-
params: Optional[
|
|
247
|
+
headers: Optional[MutableMapping[str, str]] = None,
|
|
248
|
+
params: Optional[MutableMapping[str, Any]] = None,
|
|
249
249
|
**kwargs: Any,
|
|
250
250
|
) -> Optional[Response]:
|
|
251
251
|
"""Sends an HTTP PATCH request.
|
|
@@ -276,8 +276,8 @@ class HttpConnection(AbstractConnection):
|
|
|
276
276
|
self,
|
|
277
277
|
route: Optional[str] = None,
|
|
278
278
|
*,
|
|
279
|
-
headers: Optional[
|
|
280
|
-
params: Optional[
|
|
279
|
+
headers: Optional[MutableMapping[str, str]] = None,
|
|
280
|
+
params: Optional[MutableMapping[str, Any]] = None,
|
|
281
281
|
**kwargs: Any,
|
|
282
282
|
) -> Optional[Response]:
|
|
283
283
|
"""Sends an HTTP DELETE request.
|
|
@@ -308,8 +308,8 @@ class HttpConnection(AbstractConnection):
|
|
|
308
308
|
self,
|
|
309
309
|
route: Optional[str] = None,
|
|
310
310
|
*,
|
|
311
|
-
headers: Optional[
|
|
312
|
-
params: Optional[
|
|
311
|
+
headers: Optional[MutableMapping[str, str]] = None,
|
|
312
|
+
params: Optional[MutableMapping[str, Any]] = None,
|
|
313
313
|
**kwargs: Any,
|
|
314
314
|
) -> Optional[Response]:
|
|
315
315
|
"""Sends an HTTP OPTIONS request.
|
|
@@ -340,8 +340,8 @@ class HttpConnection(AbstractConnection):
|
|
|
340
340
|
self,
|
|
341
341
|
route: Optional[str] = None,
|
|
342
342
|
*,
|
|
343
|
-
headers: Optional[
|
|
344
|
-
params: Optional[
|
|
343
|
+
headers: Optional[MutableMapping[str, str]] = None,
|
|
344
|
+
params: Optional[MutableMapping[str, Any]] = None,
|
|
345
345
|
**kwargs: Any,
|
|
346
346
|
) -> Optional[Response]:
|
|
347
347
|
"""Sends an HTTP TRACE request.
|
|
@@ -374,8 +374,8 @@ class HttpConnection(AbstractConnection):
|
|
|
374
374
|
/,
|
|
375
375
|
route: Optional[str] = None,
|
|
376
376
|
*,
|
|
377
|
-
headers: Optional[
|
|
378
|
-
params: Optional[
|
|
377
|
+
headers: Optional[MutableMapping[str, str]] = None,
|
|
378
|
+
params: Optional[MutableMapping[str, Any]] = None,
|
|
379
379
|
**kwargs: Any,
|
|
380
380
|
) -> Optional[Response]:
|
|
381
381
|
"""Sends an HTTP request.
|
|
@@ -397,8 +397,8 @@ class HttpConnection(AbstractConnection):
|
|
|
397
397
|
request = Request(
|
|
398
398
|
method.name,
|
|
399
399
|
urljoin(self.url, route),
|
|
400
|
-
headers=
|
|
401
|
-
params=
|
|
400
|
+
headers=self.headers.new_child(headers),
|
|
401
|
+
params=self.params.new_child(params),
|
|
402
402
|
**kwargs,
|
|
403
403
|
)
|
|
404
404
|
response = self.send(request)
|
apytizer/decorators/__init__.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
|
-
# src/apytizer/endpoints/
|
|
3
|
-
"""
|
|
2
|
+
# src/apytizer/endpoints/web_endpoint.py
|
|
3
|
+
"""Web Endpoint Class.
|
|
4
4
|
|
|
5
5
|
This module defines the web endpoint class implementation.
|
|
6
6
|
|
|
@@ -8,6 +8,7 @@ This module defines the web endpoint class implementation.
|
|
|
8
8
|
|
|
9
9
|
# Standard Library Imports
|
|
10
10
|
from __future__ import annotations
|
|
11
|
+
from collections import ChainMap
|
|
11
12
|
import logging
|
|
12
13
|
from typing import Any
|
|
13
14
|
from typing import Collection
|
|
@@ -29,7 +30,6 @@ from ..decorators import cache_response
|
|
|
29
30
|
from ..http_methods import HTTPMethod
|
|
30
31
|
from ..routes import Route
|
|
31
32
|
from .. import errors
|
|
32
|
-
from .. import utils
|
|
33
33
|
|
|
34
34
|
if TYPE_CHECKING:
|
|
35
35
|
from ..apis import WebAPI
|
|
@@ -83,16 +83,16 @@ class WebEndpoint(AbstractEndpoint):
|
|
|
83
83
|
/,
|
|
84
84
|
path: Union[int, Route, str],
|
|
85
85
|
*,
|
|
86
|
-
methods: Collection[HTTPMethod] = DEFAULT_METHODS,
|
|
86
|
+
methods: Optional[Collection[HTTPMethod]] = DEFAULT_METHODS,
|
|
87
87
|
headers: Optional[Dict[str, str]] = None,
|
|
88
88
|
params: Optional[Dict[str, Any]] = None,
|
|
89
89
|
cache: Optional[MutableMapping[str, Any]] = None,
|
|
90
90
|
) -> None:
|
|
91
91
|
self._api = __api
|
|
92
92
|
self._path = str(path).strip("/")
|
|
93
|
-
self._methods = set(methods)
|
|
94
|
-
self._headers = headers
|
|
95
|
-
self._params = params
|
|
93
|
+
self._methods: Set[HTTPMethod] = set(methods or [])
|
|
94
|
+
self._headers = ChainMap(headers or {})
|
|
95
|
+
self._params = ChainMap(params or {})
|
|
96
96
|
self._cache = cache
|
|
97
97
|
|
|
98
98
|
@property
|
|
@@ -122,12 +122,12 @@ class WebEndpoint(AbstractEndpoint):
|
|
|
122
122
|
return self._methods
|
|
123
123
|
|
|
124
124
|
@property
|
|
125
|
-
def headers(self) ->
|
|
125
|
+
def headers(self) -> ChainMap[str, str]:
|
|
126
126
|
"""Headers."""
|
|
127
127
|
return self._headers
|
|
128
128
|
|
|
129
129
|
@property
|
|
130
|
-
def params(self) ->
|
|
130
|
+
def params(self) -> ChainMap[str, Any]:
|
|
131
131
|
"""Parameters."""
|
|
132
132
|
return self._params
|
|
133
133
|
|
|
@@ -154,7 +154,7 @@ class WebEndpoint(AbstractEndpoint):
|
|
|
154
154
|
def __str__(self) -> str:
|
|
155
155
|
return self.path
|
|
156
156
|
|
|
157
|
-
def __getitem__(self, path: str) ->
|
|
157
|
+
def __getitem__(self, path: str) -> WebEndpoint:
|
|
158
158
|
"""Get endpoint.
|
|
159
159
|
|
|
160
160
|
Args:
|
|
@@ -168,7 +168,7 @@ class WebEndpoint(AbstractEndpoint):
|
|
|
168
168
|
result = self._api[route]
|
|
169
169
|
return result
|
|
170
170
|
|
|
171
|
-
def __truediv__(self, path: str) ->
|
|
171
|
+
def __truediv__(self, path: str) -> WebEndpoint:
|
|
172
172
|
"""Get endpoint.
|
|
173
173
|
|
|
174
174
|
Args:
|
|
@@ -218,8 +218,8 @@ class WebEndpoint(AbstractEndpoint):
|
|
|
218
218
|
|
|
219
219
|
response = self.connection.head(
|
|
220
220
|
self.path,
|
|
221
|
-
headers=
|
|
222
|
-
params=
|
|
221
|
+
headers=self.headers.new_child(headers),
|
|
222
|
+
params=self.params.new_child(params),
|
|
223
223
|
**kwargs,
|
|
224
224
|
)
|
|
225
225
|
return response
|
|
@@ -260,8 +260,8 @@ class WebEndpoint(AbstractEndpoint):
|
|
|
260
260
|
|
|
261
261
|
response = self.connection.get(
|
|
262
262
|
self.path,
|
|
263
|
-
headers=
|
|
264
|
-
params=
|
|
263
|
+
headers=self.headers.new_child(headers),
|
|
264
|
+
params=self.params.new_child(params),
|
|
265
265
|
**kwargs,
|
|
266
266
|
)
|
|
267
267
|
return response
|
|
@@ -302,8 +302,8 @@ class WebEndpoint(AbstractEndpoint):
|
|
|
302
302
|
|
|
303
303
|
response = self.connection.post(
|
|
304
304
|
self.path,
|
|
305
|
-
headers=
|
|
306
|
-
params=
|
|
305
|
+
headers=self.headers.new_child(headers),
|
|
306
|
+
params=self.params.new_child(params),
|
|
307
307
|
**kwargs,
|
|
308
308
|
)
|
|
309
309
|
return response
|
|
@@ -344,8 +344,8 @@ class WebEndpoint(AbstractEndpoint):
|
|
|
344
344
|
|
|
345
345
|
response = self.connection.put(
|
|
346
346
|
self.path,
|
|
347
|
-
headers=
|
|
348
|
-
params=
|
|
347
|
+
headers=self.headers.new_child(headers),
|
|
348
|
+
params=self.params.new_child(params),
|
|
349
349
|
**kwargs,
|
|
350
350
|
)
|
|
351
351
|
return response
|
|
@@ -386,8 +386,8 @@ class WebEndpoint(AbstractEndpoint):
|
|
|
386
386
|
|
|
387
387
|
response = self.connection.patch(
|
|
388
388
|
self.path,
|
|
389
|
-
headers=
|
|
390
|
-
params=
|
|
389
|
+
headers=self.headers.new_child(headers),
|
|
390
|
+
params=self.params.new_child(params),
|
|
391
391
|
**kwargs,
|
|
392
392
|
)
|
|
393
393
|
return response
|
|
@@ -428,8 +428,8 @@ class WebEndpoint(AbstractEndpoint):
|
|
|
428
428
|
|
|
429
429
|
response = self.connection.delete(
|
|
430
430
|
self.path,
|
|
431
|
-
headers=
|
|
432
|
-
params=
|
|
431
|
+
headers=self.headers.new_child(headers),
|
|
432
|
+
params=self.params.new_child(params),
|
|
433
433
|
**kwargs,
|
|
434
434
|
)
|
|
435
435
|
return response
|
|
@@ -470,8 +470,8 @@ class WebEndpoint(AbstractEndpoint):
|
|
|
470
470
|
|
|
471
471
|
response = self.connection.options(
|
|
472
472
|
self.path,
|
|
473
|
-
headers=
|
|
474
|
-
params=
|
|
473
|
+
headers=self.headers.new_child(headers),
|
|
474
|
+
params=self.params.new_child(params),
|
|
475
475
|
**kwargs,
|
|
476
476
|
)
|
|
477
477
|
return response
|
|
@@ -512,8 +512,8 @@ class WebEndpoint(AbstractEndpoint):
|
|
|
512
512
|
|
|
513
513
|
response = self.connection.trace(
|
|
514
514
|
self.path,
|
|
515
|
-
headers=
|
|
516
|
-
params=
|
|
515
|
+
headers=self.headers.new_child(headers),
|
|
516
|
+
params=self.params.new_child(params),
|
|
517
517
|
**kwargs,
|
|
518
518
|
)
|
|
519
519
|
return response
|
apytizer/engines/http_engine.py
CHANGED
|
@@ -7,8 +7,8 @@ This module defines the HTTP engine class implementation.
|
|
|
7
7
|
"""
|
|
8
8
|
|
|
9
9
|
# Standard Library Imports
|
|
10
|
+
from collections import ChainMap
|
|
10
11
|
from typing import Any
|
|
11
|
-
from typing import Dict
|
|
12
12
|
from typing import MutableMapping
|
|
13
13
|
from typing import Optional
|
|
14
14
|
from typing import Tuple
|
|
@@ -25,7 +25,6 @@ from .abstract_engine import AbstractEngine
|
|
|
25
25
|
from ..connections import HttpConnection
|
|
26
26
|
from ..protocols import Protocol
|
|
27
27
|
from ..protocols import get_protocol
|
|
28
|
-
from ..utils import errors
|
|
29
28
|
|
|
30
29
|
__all__ = ["HTTPEngine"]
|
|
31
30
|
|
|
@@ -40,7 +39,7 @@ class HTTPEngine(AbstractEngine):
|
|
|
40
39
|
Args:
|
|
41
40
|
url: Base URL.
|
|
42
41
|
adapters (optional): Connection adapters. Default ``None``.
|
|
43
|
-
|
|
42
|
+
auth (optional): Authentication header. default ``None``.
|
|
44
43
|
cert (optional): Client certificate. Default ``None``.
|
|
45
44
|
headers (optional): Headers to set globally. Default ``None``.
|
|
46
45
|
params (optional): Parameters to set globally. Default ``None``.
|
|
@@ -60,26 +59,26 @@ class HTTPEngine(AbstractEngine):
|
|
|
60
59
|
self,
|
|
61
60
|
url: str,
|
|
62
61
|
*,
|
|
63
|
-
adapters: Optional[
|
|
62
|
+
adapters: Optional[MutableMapping[Protocol, HTTPAdapter]] = None,
|
|
64
63
|
auth: Optional[Union[AuthBase, Tuple[str, str]]] = None,
|
|
65
64
|
cert: Optional[Union[str, Tuple[str, str]]] = None,
|
|
66
|
-
headers: Optional[
|
|
67
|
-
params: Optional[
|
|
65
|
+
headers: Optional[MutableMapping[str, str]] = None,
|
|
66
|
+
params: Optional[MutableMapping[str, Any]] = None,
|
|
68
67
|
proxies: Optional[MutableMapping[str, str]] = None,
|
|
69
68
|
stream: Optional[bool] = False,
|
|
70
69
|
timeout: Optional[Union[float, Tuple[float, float]]] = None,
|
|
71
70
|
verify: Optional[bool] = True,
|
|
72
71
|
) -> None:
|
|
73
|
-
self.
|
|
74
|
-
self.
|
|
75
|
-
self.
|
|
76
|
-
self.
|
|
77
|
-
self.
|
|
78
|
-
self.
|
|
79
|
-
self.
|
|
80
|
-
self.
|
|
81
|
-
self.
|
|
82
|
-
self.
|
|
72
|
+
self._url = standardize_url(url)
|
|
73
|
+
self._adapters = ChainMap(adapters or {})
|
|
74
|
+
self._auth = auth
|
|
75
|
+
self._cert = cert
|
|
76
|
+
self._headers = ChainMap(headers or {})
|
|
77
|
+
self._params = ChainMap(params or {})
|
|
78
|
+
self._proxies = ChainMap(proxies or {})
|
|
79
|
+
self._stream = stream or False
|
|
80
|
+
self._timeout = timeout
|
|
81
|
+
self._verify = verify
|
|
83
82
|
|
|
84
83
|
@property
|
|
85
84
|
def protocol(self) -> Optional[Protocol]:
|
|
@@ -92,10 +91,50 @@ class HTTPEngine(AbstractEngine):
|
|
|
92
91
|
"""Base URL."""
|
|
93
92
|
return self._url
|
|
94
93
|
|
|
95
|
-
@
|
|
96
|
-
def
|
|
97
|
-
|
|
98
|
-
self.
|
|
94
|
+
@property
|
|
95
|
+
def adapters(self) -> ChainMap[Protocol, HTTPAdapter]:
|
|
96
|
+
"""Connection adapters."""
|
|
97
|
+
return self._adapters
|
|
98
|
+
|
|
99
|
+
@property
|
|
100
|
+
def auth(self) -> Optional[Union[AuthBase, Tuple[str, str]]]:
|
|
101
|
+
"""Authentication header."""
|
|
102
|
+
return self._auth
|
|
103
|
+
|
|
104
|
+
@property
|
|
105
|
+
def cert(self) -> Optional[Union[str, Tuple[str, str]]]:
|
|
106
|
+
"""Certificate."""
|
|
107
|
+
return self._cert
|
|
108
|
+
|
|
109
|
+
@property
|
|
110
|
+
def headers(self) -> ChainMap[str, str]:
|
|
111
|
+
"""Headers."""
|
|
112
|
+
return self._headers
|
|
113
|
+
|
|
114
|
+
@property
|
|
115
|
+
def params(self) -> ChainMap[str, Any]:
|
|
116
|
+
"""Parameters."""
|
|
117
|
+
return self._params
|
|
118
|
+
|
|
119
|
+
@property
|
|
120
|
+
def proxies(self) -> ChainMap[str, str]:
|
|
121
|
+
"""Proxies."""
|
|
122
|
+
return self._proxies
|
|
123
|
+
|
|
124
|
+
@property
|
|
125
|
+
def stream(self) -> bool:
|
|
126
|
+
"""Whether response content will be streamed."""
|
|
127
|
+
return self._stream
|
|
128
|
+
|
|
129
|
+
@property
|
|
130
|
+
def timeout(self) -> Optional[Union[float, Tuple[float, float]]]:
|
|
131
|
+
"""How long before request times out."""
|
|
132
|
+
return self._timeout
|
|
133
|
+
|
|
134
|
+
@property
|
|
135
|
+
def verify(self) -> Optional[Union[float, Tuple[float, float]]]:
|
|
136
|
+
"""Whether certificate is verified."""
|
|
137
|
+
return self._verify
|
|
99
138
|
|
|
100
139
|
def __repr__(self) -> str:
|
|
101
140
|
return f"Engine({self.url!r})"
|
|
@@ -111,6 +150,9 @@ class HTTPEngine(AbstractEngine):
|
|
|
111
150
|
return result
|
|
112
151
|
|
|
113
152
|
|
|
153
|
+
# ----------------------------------------------------------------------------
|
|
154
|
+
# Helpers
|
|
155
|
+
# ----------------------------------------------------------------------------
|
|
114
156
|
def standardize_url(__url: Any, /) -> str:
|
|
115
157
|
"""Standardize URL.
|
|
116
158
|
|
apytizer/utils/dictionaries.py
CHANGED
|
@@ -31,7 +31,8 @@ __all__ = [
|
|
|
31
31
|
]
|
|
32
32
|
|
|
33
33
|
# Custom types:
|
|
34
|
-
|
|
34
|
+
K = TypeVar("K")
|
|
35
|
+
V = TypeVar("V")
|
|
35
36
|
|
|
36
37
|
|
|
37
38
|
def deep_get(
|
|
@@ -177,9 +178,9 @@ def iter_set(
|
|
|
177
178
|
|
|
178
179
|
|
|
179
180
|
def merge(
|
|
180
|
-
*args: Optional[Dict[
|
|
181
|
+
*args: Optional[Dict[K, V]],
|
|
181
182
|
overwrite: bool = True,
|
|
182
|
-
) -> Optional[Dict[
|
|
183
|
+
) -> Optional[Dict[K, V]]:
|
|
183
184
|
"""Combines dictionary objects into a single dictionary.
|
|
184
185
|
|
|
185
186
|
Args:
|
|
@@ -198,12 +199,12 @@ def merge(
|
|
|
198
199
|
raise TypeError("all arguments must be instances of 'dict'")
|
|
199
200
|
|
|
200
201
|
def _merge_dictionaries(
|
|
201
|
-
first: Dict[
|
|
202
|
-
second: Dict[
|
|
202
|
+
first: Dict[Any, Any],
|
|
203
|
+
second: Dict[Any, Any],
|
|
203
204
|
/,
|
|
204
205
|
path: Optional[List[str]] = None,
|
|
205
206
|
overwrite: bool = False,
|
|
206
|
-
) -> Dict[
|
|
207
|
+
) -> Dict[Any, Any]:
|
|
207
208
|
"""Merge two dictionaries.
|
|
208
209
|
|
|
209
210
|
Args:
|
|
@@ -257,7 +258,7 @@ def merge(
|
|
|
257
258
|
return first.union(second)
|
|
258
259
|
|
|
259
260
|
func = functools.partial(_merge_dictionaries, overwrite=overwrite)
|
|
260
|
-
result: Dict[
|
|
261
|
+
result: Dict[Any, Any] = functools.reduce(
|
|
261
262
|
lambda acc, cur: func(acc, cur) if cur else acc, args, {}
|
|
262
263
|
)
|
|
263
264
|
return result if result else None
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: apytizer
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.1b2
|
|
4
4
|
Summary: Implement wrappers quickly for REST APIs.
|
|
5
5
|
Project-URL: Homepage, https://github.com/seanssullivan/apytizer
|
|
6
6
|
Project-URL: Repository, https://github.com/seanssullivan/apytizer.git
|
|
@@ -7,22 +7,22 @@ apytizer/adapters/__init__.py,sha256=G4T4wWieL9Wo4kgIvzroxFtnjYr14jxcWqFHrUNaTto
|
|
|
7
7
|
apytizer/adapters/transport_adapter.py,sha256=OH8DoE9h9PKn_yFOFjPZYGB5U_Pk1o1mFJGI7AnXpmk,2296
|
|
8
8
|
apytizer/apis/__init__.py,sha256=5t4pmOxHb6XmVvmo0ECyO84Ph7SR-uQyEImuzZgqNCs,124
|
|
9
9
|
apytizer/apis/abstract_api.py,sha256=lygtd3NgoLVYySCMlsvXSJiEErNe2eiV6HRyJ3FWRkY,826
|
|
10
|
-
apytizer/apis/web_api.py,sha256=
|
|
10
|
+
apytizer/apis/web_api.py,sha256=PJSxHUz757BfJIWkMj3bITSVFI_0qTtVaUCKM7ACMVs,12906
|
|
11
11
|
apytizer/connections/__init__.py,sha256=wsaRficrSp-A8gCpL8CdLCf84TtNLSmKJnfo8AgYzkM,146
|
|
12
12
|
apytizer/connections/abstract_connection.py,sha256=3Q0PAhWF1Fr_GQm-yOu2m85AWb0lCWkuDfMd3snhcHg,646
|
|
13
|
-
apytizer/connections/http_connection.py,sha256=
|
|
14
|
-
apytizer/decorators/__init__.py,sha256=
|
|
13
|
+
apytizer/connections/http_connection.py,sha256=xXHTSIx5XbmVL0R2Y8MKPdjofhTlbd9_9v2WU8AFoNQ,12500
|
|
14
|
+
apytizer/decorators/__init__.py,sha256=wY-W8DuGwFFic78o02-wjJlIBAQ0Qc0G1syUZvSGj5s,158
|
|
15
15
|
apytizer/decorators/caching.py,sha256=mSTKorQfHzikIFm2KPvDr6l_tscAKVmC2K-Mpx-7aZI,2019
|
|
16
16
|
apytizer/decorators/chunking.py,sha256=yWtXcUV2396M9iuCeNxttT3w9IEfEL7KTOhgaG-j3uE,2690
|
|
17
17
|
apytizer/decorators/connection.py,sha256=iTclb0UuL-FeIXAZqVgCpop-XUDMwyCjzVFqWSVsLKk,1824
|
|
18
|
-
apytizer/decorators/
|
|
18
|
+
apytizer/decorators/json.py,sha256=06ofbA9vHZ54UlPABN6J4ZTH6zn_sdsmrlf8rfbtksY,1978
|
|
19
19
|
apytizer/decorators/pagination.py,sha256=wsaVf7h1NOTeEAeku6zD-hXxP2NJrHIEZNVrRmb1GBc,1936
|
|
20
20
|
apytizer/endpoints/__init__.py,sha256=HurARzunajUhxmyz1vxP-EJLybWLMJJDnjougREhZsA,139
|
|
21
21
|
apytizer/endpoints/abstract_endpoint.py,sha256=ASHZEDBTgx8fLntN7B72dyQrMTGkVQ9xZNodM9H9z58,919
|
|
22
|
-
apytizer/endpoints/web_endpoint.py,sha256=
|
|
22
|
+
apytizer/endpoints/web_endpoint.py,sha256=KNkTfvS9fOYSeSMQeywpMSuTNGkv2HurPaIUpppeiZM,15464
|
|
23
23
|
apytizer/engines/__init__.py,sha256=dkLBf3nNRJ0OcGXYeue_FE6E7Y4nGGJposbjtdy-mA4,134
|
|
24
24
|
apytizer/engines/abstract_engine.py,sha256=aljh99PCbD7giAkWgU8vk_ytJOnb3dk3UnlBZyagdDQ,959
|
|
25
|
-
apytizer/engines/http_engine.py,sha256=
|
|
25
|
+
apytizer/engines/http_engine.py,sha256=mvzjSEiDSa1yJ8-u5eYf2GWpt0SW8z-FvZuTVWhGJdw,4848
|
|
26
26
|
apytizer/factories/__init__.py,sha256=tV2VW2H4Fo8TrVNDsD9J-1Kl4IxuIy3fwoLtI9AlfFY,110
|
|
27
27
|
apytizer/factories/abstract_factory.py,sha256=XtvofT5-v824RCnBvD1Rqy_-ylXTw3XXXf6l4yteW50,361
|
|
28
28
|
apytizer/managers/__init__.py,sha256=wNg4SB_it89QYXLBv7dTNVP1DjmNwWW4F1F6Redkwno,311
|
|
@@ -48,13 +48,13 @@ apytizer/states/abstract_state.py,sha256=7wGAl0NWkUxjKsDKm6o_6nAIptiO1T2zl_qS3pF
|
|
|
48
48
|
apytizer/states/local_state.py,sha256=thLaTmCOAPAUwnPZ24bCKWfSDM8VxFwkSlNoJWwvvHk,2490
|
|
49
49
|
apytizer/utils/__init__.py,sha256=qTVMHm1Ub01zfxsbQLmaPwxiWPbEBdOPy_h158SI2f4,240
|
|
50
50
|
apytizer/utils/caching.py,sha256=bhAgZBDdhyPuUATkbYpYgVhwcuoPiu7zso4TaS9vIjg,837
|
|
51
|
-
apytizer/utils/dictionaries.py,sha256=
|
|
51
|
+
apytizer/utils/dictionaries.py,sha256=ZdkGac9AWvvKACLRH4Vua-Tf_dkcYeJaXXc_8-7vCTo,9561
|
|
52
52
|
apytizer/utils/errors.py,sha256=yGYgPB-IDvJ-zSpVNq6LVL-ppVDJTC33vSKo-QNJBzY,2803
|
|
53
53
|
apytizer/utils/iterables.py,sha256=aCxh_rfauIRUH_vvPfDLfBL7zgfIMtdC33ZHPi0yTO8,2314
|
|
54
54
|
apytizer/utils/objects.py,sha256=ev53gZuATc2GwLjR0zH0e7zqkL7mEpFeg6waxI8h-FI,3889
|
|
55
55
|
apytizer/utils/strings.py,sha256=Qu2wkjduMybibclhldJgHWVY5GMvsSZ3fUDtPXyzx5w,1588
|
|
56
56
|
apytizer/utils/typing.py,sha256=H2nVGreAEMdW1VzAbdaGVLOHVn2HUXXRhw4M47b47rI,709
|
|
57
|
-
apytizer-0.0.
|
|
58
|
-
apytizer-0.0.
|
|
59
|
-
apytizer-0.0.
|
|
60
|
-
apytizer-0.0.
|
|
57
|
+
apytizer-0.0.1b2.dist-info/METADATA,sha256=4NKAX4iGRjb9wclOLI0I0Vd2zfmup6rCOmsLp3-68dQ,1621
|
|
58
|
+
apytizer-0.0.1b2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
59
|
+
apytizer-0.0.1b2.dist-info/licenses/LICENSE,sha256=rwTrW8f9E015utDMKkNmSWxjW22qM-BDH6xSiLw0lGQ,10351
|
|
60
|
+
apytizer-0.0.1b2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|