wexample-api 6.0.28__tar.gz → 6.1.0__tar.gz

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 (28) hide show
  1. {wexample_api-6.0.28 → wexample_api-6.1.0}/PKG-INFO +4 -4
  2. {wexample_api-6.0.28 → wexample_api-6.1.0}/README.md +2 -2
  3. {wexample_api-6.0.28 → wexample_api-6.1.0}/pyproject.toml +2 -2
  4. {wexample_api-6.0.28 → wexample_api-6.1.0}/src/wexample_api/common/abstract_gateway.py +33 -0
  5. {wexample_api-6.0.28 → wexample_api-6.1.0}/src/wexample_api/__init__.py +0 -0
  6. {wexample_api-6.0.28 → wexample_api-6.1.0}/src/wexample_api/__pycache__/__init__.py +0 -0
  7. {wexample_api-6.0.28 → wexample_api-6.1.0}/src/wexample_api/common/__init__.py +0 -0
  8. {wexample_api-6.0.28 → wexample_api-6.1.0}/src/wexample_api/common/__pycache__/__init__.py +0 -0
  9. {wexample_api-6.0.28 → wexample_api-6.1.0}/src/wexample_api/common/http_request_payload.py +0 -0
  10. {wexample_api-6.0.28 → wexample_api-6.1.0}/src/wexample_api/const/__init__.py +0 -0
  11. {wexample_api-6.0.28 → wexample_api-6.1.0}/src/wexample_api/const/__pycache__/__init__.py +0 -0
  12. {wexample_api-6.0.28 → wexample_api-6.1.0}/src/wexample_api/const/http.py +0 -0
  13. {wexample_api-6.0.28 → wexample_api-6.1.0}/src/wexample_api/demo/__init__.py +0 -0
  14. {wexample_api-6.0.28 → wexample_api-6.1.0}/src/wexample_api/demo/demo_simple_gateway.py +0 -0
  15. {wexample_api-6.0.28 → wexample_api-6.1.0}/src/wexample_api/enums/__init__.py +0 -0
  16. {wexample_api-6.0.28 → wexample_api-6.1.0}/src/wexample_api/enums/__pycache__/__init__.py +0 -0
  17. {wexample_api-6.0.28 → wexample_api-6.1.0}/src/wexample_api/enums/http.py +0 -0
  18. {wexample_api-6.0.28 → wexample_api-6.1.0}/src/wexample_api/errors/__init__.py +0 -0
  19. {wexample_api-6.0.28 → wexample_api-6.1.0}/src/wexample_api/errors/gateway_authentication_error.py +0 -0
  20. {wexample_api-6.0.28 → wexample_api-6.1.0}/src/wexample_api/errors/gateway_connexion_error.py +0 -0
  21. {wexample_api-6.0.28 → wexample_api-6.1.0}/src/wexample_api/middleware/__init__.py +0 -0
  22. {wexample_api-6.0.28 → wexample_api-6.1.0}/src/wexample_api/models/__init__.py +0 -0
  23. {wexample_api-6.0.28 → wexample_api-6.1.0}/src/wexample_api/py.typed +0 -0
  24. {wexample_api-6.0.28 → wexample_api-6.1.0}/tests/common/__init__.py +0 -0
  25. {wexample_api-6.0.28 → wexample_api-6.1.0}/tests/common/test_http_request_payload.py +0 -0
  26. {wexample_api-6.0.28 → wexample_api-6.1.0}/tests/demo/__init__.py +0 -0
  27. {wexample_api-6.0.28 → wexample_api-6.1.0}/tests/demo/test_demo_simple_gateway.py +0 -0
  28. {wexample_api-6.0.28 → wexample_api-6.1.0}/tests/new_architecture/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: wexample-api
3
- Version: 6.0.28
3
+ Version: 6.1.0
4
4
  Summary: Some python basic helpers for apis.
5
5
  Author-Email: weeger <contact@wexample.com>
6
6
  License: MIT
@@ -12,7 +12,7 @@ Requires-Python: >=3.10
12
12
  Requires-Dist: attrs>=23.1.0
13
13
  Requires-Dist: cattrs>=23.1.0
14
14
  Requires-Dist: requests
15
- Requires-Dist: wexample-helpers>=6.9.0
15
+ Requires-Dist: wexample-helpers>=6.12.0
16
16
  Requires-Dist: wexample-prompt>=6.1.0
17
17
  Provides-Extra: dev
18
18
  Requires-Dist: pytest; extra == "dev"
@@ -21,7 +21,7 @@ Description-Content-Type: text/markdown
21
21
 
22
22
  # api
23
23
 
24
- Version: 6.0.28
24
+ Version: 6.1.0
25
25
 
26
26
  Some python basic helpers for apis.
27
27
 
@@ -104,7 +104,7 @@ Visit the [Wexample Suite documentation](https://docs.wexample.com) for the comp
104
104
  - attrs: >=23.1.0
105
105
  - cattrs: >=23.1.0
106
106
  - requests:
107
- - wexample-helpers: >=6.9.0
107
+ - wexample-helpers: >=6.12.0
108
108
  - wexample-prompt: >=6.1.0
109
109
 
110
110
  ## Versioning & Compatibility Policy
@@ -1,6 +1,6 @@
1
1
  # api
2
2
 
3
- Version: 6.0.28
3
+ Version: 6.1.0
4
4
 
5
5
  Some python basic helpers for apis.
6
6
 
@@ -83,7 +83,7 @@ Visit the [Wexample Suite documentation](https://docs.wexample.com) for the comp
83
83
  - attrs: >=23.1.0
84
84
  - cattrs: >=23.1.0
85
85
  - requests:
86
- - wexample-helpers: >=6.9.0
86
+ - wexample-helpers: >=6.12.0
87
87
  - wexample-prompt: >=6.1.0
88
88
 
89
89
  ## Versioning & Compatibility Policy
@@ -6,7 +6,7 @@ build-backend = "pdm.backend"
6
6
 
7
7
  [project]
8
8
  name = "wexample-api"
9
- version = "6.0.28"
9
+ version = "6.1.0"
10
10
  description = "Some python basic helpers for apis."
11
11
  authors = [
12
12
  { name = "weeger", email = "contact@wexample.com" },
@@ -21,7 +21,7 @@ dependencies = [
21
21
  "attrs>=23.1.0",
22
22
  "cattrs>=23.1.0",
23
23
  "requests",
24
- "wexample-helpers>=6.9.0",
24
+ "wexample-helpers>=6.12.0",
25
25
  "wexample-prompt>=6.1.0",
26
26
  ]
27
27
 
@@ -163,9 +163,42 @@ class AbstractGateway(
163
163
  stream: bool = False,
164
164
  timeout: int | None = None,
165
165
  raise_exceptions: bool = False,
166
+ retries: int = 0,
166
167
  ) -> requests.Response | None:
167
168
  from wexample_helpers.errors.gateway_error import GatewayError
168
169
 
170
+ if retries > 0:
171
+ from wexample_helpers.helpers.retryable_callback_manager import (
172
+ RetryableCallbackManager,
173
+ )
174
+
175
+ return RetryableCallbackManager(
176
+ callback=lambda: self.make_request(
177
+ endpoint=endpoint,
178
+ method=method,
179
+ data=data,
180
+ query_params=query_params,
181
+ headers=headers,
182
+ files=files,
183
+ call_origin=call_origin,
184
+ expected_status_codes=expected_status_codes,
185
+ fatal_if_unexpected=fatal_if_unexpected,
186
+ quiet=quiet,
187
+ stream=stream,
188
+ timeout=timeout,
189
+ raise_exceptions=True,
190
+ retries=0,
191
+ ),
192
+ max_attempts=retries + 1,
193
+ backoff_base_seconds=3,
194
+ should_retry_callback=lambda exc, msg, attempt, max_a: isinstance(
195
+ exc, GatewayError
196
+ ),
197
+ on_retry_callback=lambda attempt, max_a, delay, exc, msg: self.io.log(
198
+ f"Request failed ({msg}), retry {attempt}/{max_a} in {delay}s…"
199
+ ),
200
+ ).run()
201
+
169
202
  from wexample_api.common.http_request_payload import HttpRequestPayload
170
203
  from wexample_api.enums.http import Header
171
204