core-https 1.1.0__tar.gz → 1.1.2__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.
- {core_https-1.1.0 → core_https-1.1.2}/PKG-INFO +2 -1
- {core_https-1.1.0 → core_https-1.1.2}/core_https/__init__.py +1 -1
- {core_https-1.1.0 → core_https-1.1.2}/core_https/utils.py +0 -15
- {core_https-1.1.0 → core_https-1.1.2}/core_https.egg-info/PKG-INFO +2 -1
- {core_https-1.1.0 → core_https-1.1.2}/core_https.egg-info/SOURCES.txt +0 -2
- {core_https-1.1.0 → core_https-1.1.2}/core_https.egg-info/requires.txt +1 -0
- {core_https-1.1.0 → core_https-1.1.2}/pyproject.toml +2 -1
- core_https-1.1.0/core_https/decorators/__init__.py +0 -3
- core_https-1.1.0/core_https/decorators/response_wrapper.py +0 -85
- {core_https-1.1.0 → core_https-1.1.2}/LICENSE +0 -0
- {core_https-1.1.0 → core_https-1.1.2}/README.md +0 -0
- {core_https-1.1.0 → core_https-1.1.2}/core_https/exceptions.py +0 -0
- {core_https-1.1.0 → core_https-1.1.2}/core_https/requesters/__init__.py +0 -0
- {core_https-1.1.0 → core_https-1.1.2}/core_https/requesters/base.py +0 -0
- {core_https-1.1.0 → core_https-1.1.2}/core_https/requesters/url_lib3.py +0 -0
- {core_https-1.1.0 → core_https-1.1.2}/core_https.egg-info/dependency_links.txt +0 -0
- {core_https-1.1.0 → core_https-1.1.2}/core_https.egg-info/top_level.txt +0 -0
- {core_https-1.1.0 → core_https-1.1.2}/setup.cfg +0 -0
- {core_https-1.1.0 → core_https-1.1.2}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: core-https
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.2
|
|
4
4
|
Summary: This project/library contains common elements related to HTTP & API services...
|
|
5
5
|
Author-email: Alejandro Cora González <alek.cora.glez@gmail.com>
|
|
6
6
|
Maintainer: Alejandro Cora González
|
|
@@ -25,6 +25,7 @@ Classifier: Programming Language :: Python :: 3.13
|
|
|
25
25
|
Requires-Python: >=3.7
|
|
26
26
|
Description-Content-Type: text/markdown
|
|
27
27
|
License-File: LICENSE
|
|
28
|
+
Requires-Dist: core-mixins>=1.1.2
|
|
28
29
|
Requires-Dist: core-tests>=1.1.0
|
|
29
30
|
Requires-Dist: urllib3>=2.2.3; python_version >= "3.8"
|
|
30
31
|
Requires-Dist: urllib3>=1.26.20; python_version >= "3.7" and python_version < "3.8"
|
|
@@ -145,18 +145,3 @@ class HTTPMethod(Enum):
|
|
|
145
145
|
return http_method
|
|
146
146
|
|
|
147
147
|
raise ValueError(f"No HTTPMethod found for name: {name}")
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
class StrEnum(str, Enum):
|
|
151
|
-
"""
|
|
152
|
-
For backward compatibility because StrEnum class
|
|
153
|
-
was added in Python 3.11...
|
|
154
|
-
"""
|
|
155
|
-
|
|
156
|
-
def __new__(cls, value, *args, **kwargs):
|
|
157
|
-
if not isinstance(value, str):
|
|
158
|
-
raise TypeError(f"{value} is not a string")
|
|
159
|
-
|
|
160
|
-
obj = str.__new__(cls, value)
|
|
161
|
-
obj._value_ = value
|
|
162
|
-
return obj
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: core-https
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.2
|
|
4
4
|
Summary: This project/library contains common elements related to HTTP & API services...
|
|
5
5
|
Author-email: Alejandro Cora González <alek.cora.glez@gmail.com>
|
|
6
6
|
Maintainer: Alejandro Cora González
|
|
@@ -25,6 +25,7 @@ Classifier: Programming Language :: Python :: 3.13
|
|
|
25
25
|
Requires-Python: >=3.7
|
|
26
26
|
Description-Content-Type: text/markdown
|
|
27
27
|
License-File: LICENSE
|
|
28
|
+
Requires-Dist: core-mixins>=1.1.2
|
|
28
29
|
Requires-Dist: core-tests>=1.1.0
|
|
29
30
|
Requires-Dist: urllib3>=2.2.3; python_version >= "3.8"
|
|
30
31
|
Requires-Dist: urllib3>=1.26.20; python_version >= "3.7" and python_version < "3.8"
|
|
@@ -10,8 +10,6 @@ core_https.egg-info/SOURCES.txt
|
|
|
10
10
|
core_https.egg-info/dependency_links.txt
|
|
11
11
|
core_https.egg-info/requires.txt
|
|
12
12
|
core_https.egg-info/top_level.txt
|
|
13
|
-
core_https/decorators/__init__.py
|
|
14
|
-
core_https/decorators/response_wrapper.py
|
|
15
13
|
core_https/requesters/__init__.py
|
|
16
14
|
core_https/requesters/base.py
|
|
17
15
|
core_https/requesters/url_lib3.py
|
|
@@ -9,7 +9,7 @@ build-backend = "setuptools.build_meta"
|
|
|
9
9
|
[project]
|
|
10
10
|
name = "core-https"
|
|
11
11
|
description = "This project/library contains common elements related to HTTP & API services..."
|
|
12
|
-
version = "1.1.
|
|
12
|
+
version = "1.1.2"
|
|
13
13
|
|
|
14
14
|
authors = [
|
|
15
15
|
{name = "Alejandro Cora González", email = "alek.cora.glez@gmail.com"}
|
|
@@ -41,6 +41,7 @@ classifiers = [
|
|
|
41
41
|
]
|
|
42
42
|
|
|
43
43
|
dependencies = [
|
|
44
|
+
"core-mixins>=1.1.2",
|
|
44
45
|
"core-tests>=1.1.0",
|
|
45
46
|
"urllib3>=2.2.3; python_version >= '3.8'",
|
|
46
47
|
"urllib3>=1.26.20; python_version >= '3.7' and python_version < '3.8'",
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
|
|
3
|
-
from functools import wraps
|
|
4
|
-
from typing import Any, Callable, Tuple
|
|
5
|
-
|
|
6
|
-
try:
|
|
7
|
-
from http import HTTPStatus
|
|
8
|
-
|
|
9
|
-
except ImportError:
|
|
10
|
-
from core_https.utils import HTTPStatus
|
|
11
|
-
|
|
12
|
-
from core_https import StatusInfo
|
|
13
|
-
from core_https.exceptions import AuthorizationException
|
|
14
|
-
from core_https.exceptions import InternalServerError
|
|
15
|
-
from core_https.exceptions import ServiceException
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
def wrapp_response(fnc: Callable[..., Tuple[HTTPStatus, Any]]):
|
|
19
|
-
"""
|
|
20
|
-
This decorator provides a generic mechanism to return the response payload
|
|
21
|
-
for the endpoints in the same format. This way each router or controller does not
|
|
22
|
-
need to take care of it. It returns the response into the below format...
|
|
23
|
-
|
|
24
|
-
Response payload:
|
|
25
|
-
{
|
|
26
|
-
"code": 2XX | 4XX | 5XX,
|
|
27
|
-
"status": "success" | "error" | "failure",
|
|
28
|
-
"result": ...
|
|
29
|
-
"error": ...,
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
Where:
|
|
33
|
-
code:
|
|
34
|
-
- 2XX -> For success responses.
|
|
35
|
-
- 4XX -> For service-managed errors.
|
|
36
|
-
- 5XX -> For unmanaged or internal server errors.
|
|
37
|
-
|
|
38
|
-
status:
|
|
39
|
-
Contains the text: "success", "failure", or "error". Where "failure" is for HTTP status
|
|
40
|
-
response values from 500 to 599, "error" is for statuses from 400 to 499, and "success" is
|
|
41
|
-
for everything else (e.g. 1XX, 2XX and 3XX responses).
|
|
42
|
-
|
|
43
|
-
result:
|
|
44
|
-
Contains the result.
|
|
45
|
-
|
|
46
|
-
error:
|
|
47
|
-
Only used for "failure" and "error" statuses, and it contains the error information.
|
|
48
|
-
"""
|
|
49
|
-
|
|
50
|
-
@wraps(fnc)
|
|
51
|
-
def wrapper(*args, **kwargs):
|
|
52
|
-
try:
|
|
53
|
-
code, result = fnc(*args, **kwargs)
|
|
54
|
-
|
|
55
|
-
return {
|
|
56
|
-
"code": code,
|
|
57
|
-
"result": result,
|
|
58
|
-
"status": StatusInfo.SUCCESS
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
except (AuthorizationException, ServiceException) as error:
|
|
62
|
-
return {
|
|
63
|
-
"code": error.status_code,
|
|
64
|
-
"status": StatusInfo.ERROR,
|
|
65
|
-
"error": error.get_error_info()
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
except InternalServerError as error:
|
|
69
|
-
return {
|
|
70
|
-
"code": error.status_code,
|
|
71
|
-
"status": StatusInfo.FAILURE,
|
|
72
|
-
"error": error.get_error_info()
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
except Exception as error:
|
|
76
|
-
return {
|
|
77
|
-
"code": HTTPStatus.INTERNAL_SERVER_ERROR,
|
|
78
|
-
"status": StatusInfo.FAILURE,
|
|
79
|
-
"error": {
|
|
80
|
-
"type": error.__class__.__name__,
|
|
81
|
-
"details": str(error)
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return wrapper
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|