apytizer 0.0.1a0__py3-none-any.whl → 0.0.1b1__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.
Files changed (76) hide show
  1. apytizer/__init__.py +2 -12
  2. apytizer/adapters/__init__.py +2 -3
  3. apytizer/adapters/transport_adapter.py +91 -0
  4. apytizer/apis/__init__.py +6 -0
  5. apytizer/apis/abstract_api.py +36 -0
  6. apytizer/apis/web_api.py +461 -0
  7. apytizer/connections/__init__.py +6 -0
  8. apytizer/connections/abstract_connection.py +28 -0
  9. apytizer/connections/http_connection.py +431 -0
  10. apytizer/decorators/__init__.py +5 -5
  11. apytizer/decorators/caching.py +60 -9
  12. apytizer/decorators/chunking.py +105 -0
  13. apytizer/decorators/connection.py +55 -20
  14. apytizer/decorators/json_response.py +93 -0
  15. apytizer/decorators/pagination.py +50 -32
  16. apytizer/endpoints/__init__.py +6 -0
  17. apytizer/endpoints/abstract_endpoint.py +38 -0
  18. apytizer/endpoints/web_endpoint.py +519 -0
  19. apytizer/engines/__init__.py +6 -0
  20. apytizer/engines/abstract_engine.py +45 -0
  21. apytizer/engines/http_engine.py +129 -0
  22. apytizer/errors.py +34 -0
  23. apytizer/factories/__init__.py +5 -0
  24. apytizer/factories/abstract_factory.py +17 -0
  25. apytizer/http_methods.py +34 -0
  26. apytizer/managers/__init__.py +12 -0
  27. apytizer/managers/abstract_manager.py +80 -0
  28. apytizer/managers/base_manager.py +116 -0
  29. apytizer/mappers/__init__.py +6 -0
  30. apytizer/mappers/abstract_mapper.py +48 -0
  31. apytizer/mappers/base_mapper.py +78 -0
  32. apytizer/media_types.py +118 -0
  33. apytizer/models/__init__.py +6 -0
  34. apytizer/models/abstract_model.py +119 -0
  35. apytizer/models/base_model.py +85 -0
  36. apytizer/protocols.py +38 -0
  37. apytizer/repositories/__init__.py +6 -0
  38. apytizer/repositories/abstract_repository.py +81 -0
  39. apytizer/repositories/managed_repository.py +92 -0
  40. apytizer/routes/__init__.py +6 -0
  41. apytizer/routes/abstract_route.py +32 -0
  42. apytizer/routes/base_route.py +138 -0
  43. apytizer/sessions/__init__.py +33 -0
  44. apytizer/sessions/abstract_session.py +63 -0
  45. apytizer/sessions/requests_session.py +125 -0
  46. apytizer/states/__init__.py +6 -0
  47. apytizer/states/abstract_state.py +71 -0
  48. apytizer/states/local_state.py +99 -0
  49. apytizer/utils/__init__.py +9 -4
  50. apytizer/utils/caching.py +39 -0
  51. apytizer/utils/dictionaries.py +375 -0
  52. apytizer/utils/errors.py +104 -0
  53. apytizer/utils/iterables.py +91 -0
  54. apytizer/utils/objects.py +145 -0
  55. apytizer/utils/strings.py +69 -0
  56. apytizer/utils/typing.py +29 -0
  57. apytizer-0.0.1b1.dist-info/METADATA +41 -0
  58. apytizer-0.0.1b1.dist-info/RECORD +60 -0
  59. {apytizer-0.0.1a0.dist-info → apytizer-0.0.1b1.dist-info}/WHEEL +1 -2
  60. apytizer/abstracts/__init__.py +0 -8
  61. apytizer/abstracts/api.py +0 -147
  62. apytizer/abstracts/endpoint.py +0 -177
  63. apytizer/abstracts/model.py +0 -50
  64. apytizer/abstracts/session.py +0 -39
  65. apytizer/adapters/transport.py +0 -40
  66. apytizer/base/__init__.py +0 -8
  67. apytizer/base/api.py +0 -510
  68. apytizer/base/endpoint.py +0 -443
  69. apytizer/base/model.py +0 -119
  70. apytizer/decorators/json.py +0 -35
  71. apytizer/utils/generate_key.py +0 -18
  72. apytizer/utils/merge.py +0 -19
  73. apytizer-0.0.1a0.dist-info/METADATA +0 -27
  74. apytizer-0.0.1a0.dist-info/RECORD +0 -25
  75. apytizer-0.0.1a0.dist-info/top_level.txt +0 -1
  76. {apytizer-0.0.1a0.dist-info → apytizer-0.0.1b1.dist-info/licenses}/LICENSE +0 -0
@@ -1,177 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """Abstract endpoint class interface.
3
-
4
- This module defines an abstract endpoint class which provides an interface
5
- for subclasses to implement. Each of the abstract methods represents
6
- a standard HTTP request method.
7
-
8
- """
9
-
10
- # Third-Party Imports
11
- import abc
12
- from urllib.parse import urljoin
13
-
14
- # Third-Party Imports
15
- from requests import Response
16
-
17
- # Local Imports
18
- from .api import AbstractAPI
19
-
20
-
21
- class AbstractEndpoint(abc.ABC):
22
- """
23
- Represents an abstract endpoint.
24
-
25
- Attributes:
26
- api: Instance of an API subclass.
27
- path: Relative path to API endpoint.
28
-
29
- """
30
- api: AbstractAPI
31
- path: str
32
-
33
- @property
34
- def uri(self) -> str:
35
- """Retrieve the endpoint URI."""
36
- return urljoin(self.api.url, self.path)
37
-
38
- @property
39
- def url(self) -> str:
40
- return self.uri
41
-
42
- def __hash__(self) -> int:
43
- return hash(self.uri)
44
-
45
- def __repr__(self) -> str:
46
- return f'<{self.__class__.__name__!s} uri={self.uri!s}>'
47
-
48
- def __str__(self) -> str:
49
- return f'{self.uri!s}'
50
-
51
- @abc.abstractmethod
52
- def head(self, *args, **kwargs) -> Response:
53
- """
54
- Abstract method for sending an HTTP HEAD request.
55
-
56
- This method must call the `head` method on the component API instance.
57
-
58
- Returns:
59
- Response object.
60
-
61
- .. _MDN Web Docs:
62
- https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/HEAD
63
-
64
- """
65
- raise NotImplementedError
66
-
67
- @abc.abstractmethod
68
- def get(self, *args, **kwargs) -> Response:
69
- """
70
- Abstract method for sending an HTTP GET request.
71
-
72
- This method must call the `get` method on the component API instance.
73
-
74
- Returns:
75
- Response object.
76
-
77
- .. _MDN Web Docs:
78
- https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET
79
-
80
- """
81
- raise NotImplementedError
82
-
83
- @abc.abstractmethod
84
- def post(self, *args, **kwargs) -> Response:
85
- """
86
- Abstract method for sending an HTTP POST request.
87
-
88
- This method must call the `post` method on the component API instance.
89
-
90
- Returns:
91
- Response object.
92
-
93
- .. _MDN Web Docs:
94
- https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST
95
-
96
- """
97
- raise NotImplementedError
98
-
99
- @abc.abstractmethod
100
- def put(self, *args, **kwargs) -> Response:
101
- """
102
- Abstract method for sending an HTTP PUT request.
103
-
104
- This method must call the `put` method on the component API instance.
105
-
106
- Returns:
107
- Response object.
108
-
109
- .. _MDN Web Docs:
110
- https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PUT
111
-
112
- """
113
- raise NotImplementedError
114
-
115
- @abc.abstractmethod
116
- def patch(self, *args, **kwargs) -> Response:
117
- """
118
- Abstract method for sending an HTTP PATCH request.
119
-
120
- This method must call the `patch` method on the component API instance.
121
-
122
- Returns:
123
- Response object.
124
-
125
- .. _MDN Web Docs:
126
- https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PATCH
127
-
128
- """
129
- raise NotImplementedError
130
-
131
- @abc.abstractmethod
132
- def delete(self, *args, **kwargs) -> Response:
133
- """
134
- Abstract method for sending an HTTP DELETE request.
135
-
136
- This method must call the `delete` method on the component API instance.
137
-
138
- Returns:
139
- Response object.
140
-
141
- .. _MDN Web Docs:
142
- https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/DELETE
143
-
144
- """
145
- raise NotImplementedError
146
-
147
- @abc.abstractmethod
148
- def options(self, *args, **kwargs) -> Response:
149
- """
150
- Abstract method for sending an HTTP OPTIONS request.
151
-
152
- This method must call the `options` method on the component API instance.
153
-
154
- Returns:
155
- Response object.
156
-
157
- .. _MDN Web Docs:
158
- https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/OPTIONS
159
-
160
- """
161
- raise NotImplementedError
162
-
163
- @abc.abstractmethod
164
- def trace(self, *args, **kwargs) -> Response:
165
- """
166
- Abstract method for sending an HTTP TRACE request.
167
-
168
- This method must call the `trace` method on the component API instance.
169
-
170
- Returns:
171
- Response object.
172
-
173
- .. _MDN Web Docs:
174
- https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/TRACE
175
-
176
- """
177
- raise NotImplementedError
@@ -1,50 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """Abstract model class interface.
3
-
4
- This module defines an abstract model class which provides an interface
5
- for subclasses to implement.
6
-
7
- """
8
-
9
- # Standard Library Imports
10
- from __future__ import annotations
11
- import abc
12
- from typing import Mapping
13
-
14
-
15
- class AbstractModel(abc.ABC):
16
- """
17
- Represents an abstract model.
18
-
19
- """
20
- state: Mapping
21
-
22
- @abc.abstractmethod
23
- def __eq__(self, other: AbstractModel) -> bool:
24
- """
25
- Abstract method for determining whether model is equal to another.
26
-
27
- Returns:
28
- Whether models are equal.
29
-
30
- """
31
- raise NotImplementedError
32
-
33
- @abc.abstractmethod
34
- def get(self, keys: str, default = None):
35
- """
36
- Abstract method for getting model property from state.
37
-
38
- Returns:
39
- Value of property in model state.
40
-
41
- """
42
- raise NotImplementedError
43
-
44
- @abc.abstractmethod
45
- def update(self, __m: Mapping = None, **kwargs) -> None:
46
- """
47
- Abstract method for updating model state.
48
-
49
- """
50
- raise NotImplementedError
@@ -1,39 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """Abstract session class interface.
3
-
4
- This module defines an abstract session class which provides an interface
5
- for subclasses to implement.
6
-
7
- """
8
-
9
- # Third-Party Imports
10
- from __future__ import annotations
11
- import abc
12
-
13
-
14
- class AbstractSession(abc.ABC):
15
- """
16
- Represents an abstract session.
17
- """
18
-
19
- def __enter__(self):
20
- """
21
- Starts the session as a context manager.
22
- """
23
- self.start()
24
-
25
- def __exit__(self, *args):
26
- """
27
- Closes the session as context manager.
28
- """
29
- self.close(*args)
30
-
31
- @abc.abstractmethod
32
- def start(self):
33
- """Starts the session."""
34
- raise NotImplementedError
35
-
36
- @abc.abstractmethod
37
- def close(self):
38
- """Closes the session."""
39
- raise NotImplementedError
@@ -1,40 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """Transport Adapter.
3
-
4
- This module defines a transport adapter class: an implementation of an
5
- HTTPAdapter which handles exponential backoff for retrying requests and
6
- provides default values for rate limiting and request timeout.
7
-
8
- """
9
-
10
- # Standard Library Imports
11
- from urllib3.util import Retry
12
-
13
- # Third-Party Imports
14
- from requests import PreparedRequest
15
- from requests import Response
16
- from requests.adapters import HTTPAdapter
17
-
18
-
19
- class TransportAdapter(HTTPAdapter):
20
- """
21
- Implementation of a transport adaptor.
22
-
23
- Transport adapters define methods for interacting with HTTP services,
24
- enabling the use of per-service configurations.
25
-
26
- """
27
-
28
- def __init__(self, *args, **kwargs):
29
- kwargs.setdefault('max_retries', Retry(
30
- total=10,
31
- status_forcelist=[413, 429, 500, 502, 503, 504],
32
- allowed_methods=["HEAD", "GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "TRACE"],
33
- backoff_factor=kwargs.pop('rate_limit', 1)
34
- ))
35
- self.timeout = kwargs.pop('timeout', 5)
36
- super().__init__(*args, **kwargs)
37
-
38
- def send(self, request: PreparedRequest, **kwargs) -> Response:
39
- kwargs.setdefault('timeout', self.timeout)
40
- return super().send(request, **kwargs)
apytizer/base/__init__.py DELETED
@@ -1,8 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- # pylint: skip-file
4
-
5
- from .api import BasicAPI
6
- from .api import SessionAPI
7
- from .endpoint import BasicEndpoint
8
- from .model import BasicModel