core-https 2.0.1__tar.gz → 2.0.3__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 (31) hide show
  1. core_https-2.0.3/PKG-INFO +183 -0
  2. core_https-2.0.3/README.rst +144 -0
  3. {core_https-2.0.1 → core_https-2.0.3}/core_https/exceptions.py +2 -1
  4. core_https-2.0.3/core_https/requesters/aiohttp_rate_limit.py +60 -0
  5. core_https-2.0.3/core_https/requesters/aiohttp_throttle.py +54 -0
  6. {core_https-2.0.1 → core_https-2.0.3}/core_https/tests/base.py +2 -4
  7. core_https-2.0.3/core_https.egg-info/PKG-INFO +183 -0
  8. {core_https-2.0.1 → core_https-2.0.3}/core_https.egg-info/SOURCES.txt +2 -0
  9. {core_https-2.0.1 → core_https-2.0.3}/core_https.egg-info/requires.txt +6 -7
  10. {core_https-2.0.1 → core_https-2.0.3}/pyproject.toml +11 -8
  11. core_https-2.0.1/PKG-INFO +0 -112
  12. core_https-2.0.1/README.rst +0 -74
  13. core_https-2.0.1/core_https.egg-info/PKG-INFO +0 -112
  14. {core_https-2.0.1 → core_https-2.0.3}/LICENSE +0 -0
  15. {core_https-2.0.1 → core_https-2.0.3}/core_https/__init__.py +0 -0
  16. {core_https-2.0.1 → core_https-2.0.3}/core_https/py.typed +0 -0
  17. {core_https-2.0.1 → core_https-2.0.3}/core_https/requesters/__init__.py +0 -0
  18. {core_https-2.0.1 → core_https-2.0.3}/core_https/requesters/aiohttp_.py +0 -0
  19. {core_https-2.0.1 → core_https-2.0.3}/core_https/requesters/base.py +0 -0
  20. {core_https-2.0.1 → core_https-2.0.3}/core_https/requesters/requests_.py +0 -0
  21. {core_https-2.0.1 → core_https-2.0.3}/core_https/requesters/urllib3_.py +0 -0
  22. {core_https-2.0.1 → core_https-2.0.3}/core_https/tests/__init__.py +0 -0
  23. {core_https-2.0.1 → core_https-2.0.3}/core_https/tests/aiohttp_.py +0 -0
  24. {core_https-2.0.1 → core_https-2.0.3}/core_https/tests/decorators.py +0 -0
  25. {core_https-2.0.1 → core_https-2.0.3}/core_https/tests/requests_.py +0 -0
  26. {core_https-2.0.1 → core_https-2.0.3}/core_https/tests/urllib3_.py +0 -0
  27. {core_https-2.0.1 → core_https-2.0.3}/core_https/utils.py +0 -0
  28. {core_https-2.0.1 → core_https-2.0.3}/core_https.egg-info/dependency_links.txt +0 -0
  29. {core_https-2.0.1 → core_https-2.0.3}/core_https.egg-info/top_level.txt +0 -0
  30. {core_https-2.0.1 → core_https-2.0.3}/setup.cfg +0 -0
  31. {core_https-2.0.1 → core_https-2.0.3}/setup.py +0 -0
@@ -0,0 +1,183 @@
1
+ Metadata-Version: 2.4
2
+ Name: core-https
3
+ Version: 2.0.3
4
+ Summary: This project/library contains common elements related to HTTP & API services...
5
+ Author-email: Alejandro Cora González <alek.cora.glez@gmail.com>
6
+ Maintainer: Alejandro Cora González
7
+ License-Expression: MIT
8
+ Project-URL: Homepage, https://gitlab.com/bytecode-solutions/core/core-https
9
+ Project-URL: Repository, https://gitlab.com/bytecode-solutions/core/core-https
10
+ Project-URL: Documentation, https://core-https.readthedocs.io/en/latest/
11
+ Project-URL: Issues, https://gitlab.com/bytecode-solutions/core/core-https/-/issues
12
+ Project-URL: Changelog, https://gitlab.com/bytecode-solutions/core/core-https/-/blob/master/CHANGELOG.md
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Development Status :: 5 - Production/Stable
15
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
16
+ Classifier: Topic :: Utilities
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3 :: Only
19
+ Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Programming Language :: Python :: 3.13
24
+ Requires-Python: >=3.9
25
+ Description-Content-Type: text/x-rst
26
+ License-File: LICENSE
27
+ Requires-Dist: aiohttp<4.0.0,>=3.12.0
28
+ Requires-Dist: core-mixins>=2.2.2
29
+ Requires-Dist: requests<3.0.0,>=2.32.3
30
+ Requires-Dist: urllib3<3.0.0,>=2.2.3
31
+ Provides-Extra: dev
32
+ Requires-Dist: aiolimiter<2.0.0,>=1.2.1; extra == "dev"
33
+ Requires-Dist: core-dev-tools>=1.0.1; extra == "dev"
34
+ Requires-Dist: core-tests>=2.0.2; extra == "dev"
35
+ Requires-Dist: types-requests>=2.32.0.20250602; extra == "dev"
36
+ Provides-Extra: extras
37
+ Requires-Dist: aiolimiter<2.0.0,>=1.2.1; extra == "extras"
38
+ Dynamic: license-file
39
+
40
+ core-https
41
+ ===============================================================================
42
+
43
+ This project/library contains common elements related to HTTP...
44
+
45
+ ===============================================================================
46
+
47
+ .. image:: https://img.shields.io/pypi/pyversions/core-https.svg
48
+ :target: https://pypi.org/project/core-https/
49
+ :alt: Python Versions
50
+
51
+ .. image:: https://img.shields.io/badge/license-MIT-blue.svg
52
+ :target: https://gitlab.com/bytecode-solutions/core/core-https/-/blob/main/LICENSE
53
+ :alt: License
54
+
55
+ .. image:: https://gitlab.com/bytecode-solutions/core/core-https/badges/release/pipeline.svg
56
+ :target: https://gitlab.com/bytecode-solutions/core/core-https/-/pipelines
57
+ :alt: Pipeline Status
58
+
59
+ .. image:: https://readthedocs.org/projects/core-https/badge/?version=latest
60
+ :target: https://readthedocs.org/projects/core-https/
61
+ :alt: Docs Status
62
+
63
+ .. image:: https://img.shields.io/badge/security-bandit-yellow.svg
64
+ :target: https://github.com/PyCQA/bandit
65
+ :alt: Security
66
+
67
+ |
68
+
69
+
70
+ Installation
71
+ ===============================================================================
72
+
73
+ Install from PyPI using pip:
74
+
75
+ .. code-block:: bash
76
+
77
+ pip install core-https
78
+ uv pip install core-https # Or using UV...
79
+
80
+
81
+ Features
82
+ ===============================================================================
83
+
84
+ * **HTTP Status Codes & Methods** - Comprehensive enums with backward compatibility for Python < 3.11, including utility methods for status checking (is_success, is_error, etc.) and method properties (is_safe, is_idempotent, is_cacheable)
85
+ * **Status Classification** - ``StatusInfo`` enum for categorizing HTTP responses as success (1xx-3xx), error (4xx), or failure (5xx)
86
+ * **Exception Hierarchy** - Structured exception classes for handling HTTP errors with automatic status code mapping: ``AuthenticationException`` (401), ``AuthorizationException`` (403), ``RateLimitException`` (429), and ``RetryableException`` for temporary failures
87
+ * **HTTP Requesters** - Abstract interface (``IRequester``) with concrete implementations for multiple HTTP libraries (``requests``, ``urllib3``, ``aiohttp``), supporting connection pooling, timeouts, retries, and backoff strategies
88
+ * **Testing Utilities** - Base test classes and decorators for mocking HTTP requests/responses across different HTTP client libraries
89
+
90
+
91
+ Quick Start
92
+ ===============================================================================
93
+
94
+ Installation
95
+ -------------------------------------------------------------------------------
96
+
97
+ Install the package:
98
+
99
+ .. code-block:: bash
100
+
101
+ pip install core-https
102
+ uv pip install core-https # Or using UV...
103
+ pip install -e ".[dev]" # For development...
104
+
105
+ Setting Up Environment
106
+ -------------------------------------------------------------------------------
107
+
108
+ 1. Install required libraries:
109
+
110
+ .. code-block:: bash
111
+
112
+ pip install --upgrade pip
113
+ pip install virtualenv
114
+
115
+ 2. Create Python virtual environment:
116
+
117
+ .. code-block:: bash
118
+
119
+ virtualenv --python=python3.12 .venv
120
+
121
+ 3. Activate the virtual environment:
122
+
123
+ .. code-block:: bash
124
+
125
+ source .venv/bin/activate
126
+
127
+ Install packages
128
+ -------------------------------------------------------------------------------
129
+
130
+ .. code-block:: bash
131
+
132
+ pip install .
133
+ pip install -e ".[dev]"
134
+
135
+ Check tests and coverage
136
+ -------------------------------------------------------------------------------
137
+
138
+ .. code-block:: shell
139
+
140
+ python manager.py run-tests
141
+ python manager.py run-coverage
142
+
143
+
144
+ Contributing
145
+ ===============================================================================
146
+
147
+ Contributions are welcome! Please:
148
+
149
+ 1. Fork the repository
150
+ 2. Create a feature branch
151
+ 3. Write tests for new functionality
152
+ 4. Ensure all tests pass: ``pytest -n auto``
153
+ 5. Run linting: ``pylint core_https``
154
+ 6. Run security checks: ``bandit -r core_https``
155
+ 7. Submit a pull request
156
+
157
+
158
+ License
159
+ ===============================================================================
160
+
161
+ This project is licensed under the MIT License. See the LICENSE file for details.
162
+
163
+
164
+ Links
165
+ ===============================================================================
166
+
167
+ * **Documentation:** https://core-https.readthedocs.io/en/latest/
168
+ * **Repository:** https://gitlab.com/bytecode-solutions/core/core-https
169
+ * **Issues:** https://gitlab.com/bytecode-solutions/core/core-https/-/issues
170
+ * **Changelog:** https://gitlab.com/bytecode-solutions/core/core-https/-/blob/master/CHANGELOG.md
171
+ * **PyPI:** https://pypi.org/project/core-https/
172
+
173
+
174
+ Support
175
+ ===============================================================================
176
+
177
+ For questions or support, please open an issue on GitLab or contact the maintainers.
178
+
179
+
180
+ Authors
181
+ ===============================================================================
182
+
183
+ * **Alejandro Cora González** - *Initial work* - alek.cora.glez@gmail.com
@@ -0,0 +1,144 @@
1
+ core-https
2
+ ===============================================================================
3
+
4
+ This project/library contains common elements related to HTTP...
5
+
6
+ ===============================================================================
7
+
8
+ .. image:: https://img.shields.io/pypi/pyversions/core-https.svg
9
+ :target: https://pypi.org/project/core-https/
10
+ :alt: Python Versions
11
+
12
+ .. image:: https://img.shields.io/badge/license-MIT-blue.svg
13
+ :target: https://gitlab.com/bytecode-solutions/core/core-https/-/blob/main/LICENSE
14
+ :alt: License
15
+
16
+ .. image:: https://gitlab.com/bytecode-solutions/core/core-https/badges/release/pipeline.svg
17
+ :target: https://gitlab.com/bytecode-solutions/core/core-https/-/pipelines
18
+ :alt: Pipeline Status
19
+
20
+ .. image:: https://readthedocs.org/projects/core-https/badge/?version=latest
21
+ :target: https://readthedocs.org/projects/core-https/
22
+ :alt: Docs Status
23
+
24
+ .. image:: https://img.shields.io/badge/security-bandit-yellow.svg
25
+ :target: https://github.com/PyCQA/bandit
26
+ :alt: Security
27
+
28
+ |
29
+
30
+
31
+ Installation
32
+ ===============================================================================
33
+
34
+ Install from PyPI using pip:
35
+
36
+ .. code-block:: bash
37
+
38
+ pip install core-https
39
+ uv pip install core-https # Or using UV...
40
+
41
+
42
+ Features
43
+ ===============================================================================
44
+
45
+ * **HTTP Status Codes & Methods** - Comprehensive enums with backward compatibility for Python < 3.11, including utility methods for status checking (is_success, is_error, etc.) and method properties (is_safe, is_idempotent, is_cacheable)
46
+ * **Status Classification** - ``StatusInfo`` enum for categorizing HTTP responses as success (1xx-3xx), error (4xx), or failure (5xx)
47
+ * **Exception Hierarchy** - Structured exception classes for handling HTTP errors with automatic status code mapping: ``AuthenticationException`` (401), ``AuthorizationException`` (403), ``RateLimitException`` (429), and ``RetryableException`` for temporary failures
48
+ * **HTTP Requesters** - Abstract interface (``IRequester``) with concrete implementations for multiple HTTP libraries (``requests``, ``urllib3``, ``aiohttp``), supporting connection pooling, timeouts, retries, and backoff strategies
49
+ * **Testing Utilities** - Base test classes and decorators for mocking HTTP requests/responses across different HTTP client libraries
50
+
51
+
52
+ Quick Start
53
+ ===============================================================================
54
+
55
+ Installation
56
+ -------------------------------------------------------------------------------
57
+
58
+ Install the package:
59
+
60
+ .. code-block:: bash
61
+
62
+ pip install core-https
63
+ uv pip install core-https # Or using UV...
64
+ pip install -e ".[dev]" # For development...
65
+
66
+ Setting Up Environment
67
+ -------------------------------------------------------------------------------
68
+
69
+ 1. Install required libraries:
70
+
71
+ .. code-block:: bash
72
+
73
+ pip install --upgrade pip
74
+ pip install virtualenv
75
+
76
+ 2. Create Python virtual environment:
77
+
78
+ .. code-block:: bash
79
+
80
+ virtualenv --python=python3.12 .venv
81
+
82
+ 3. Activate the virtual environment:
83
+
84
+ .. code-block:: bash
85
+
86
+ source .venv/bin/activate
87
+
88
+ Install packages
89
+ -------------------------------------------------------------------------------
90
+
91
+ .. code-block:: bash
92
+
93
+ pip install .
94
+ pip install -e ".[dev]"
95
+
96
+ Check tests and coverage
97
+ -------------------------------------------------------------------------------
98
+
99
+ .. code-block:: shell
100
+
101
+ python manager.py run-tests
102
+ python manager.py run-coverage
103
+
104
+
105
+ Contributing
106
+ ===============================================================================
107
+
108
+ Contributions are welcome! Please:
109
+
110
+ 1. Fork the repository
111
+ 2. Create a feature branch
112
+ 3. Write tests for new functionality
113
+ 4. Ensure all tests pass: ``pytest -n auto``
114
+ 5. Run linting: ``pylint core_https``
115
+ 6. Run security checks: ``bandit -r core_https``
116
+ 7. Submit a pull request
117
+
118
+
119
+ License
120
+ ===============================================================================
121
+
122
+ This project is licensed under the MIT License. See the LICENSE file for details.
123
+
124
+
125
+ Links
126
+ ===============================================================================
127
+
128
+ * **Documentation:** https://core-https.readthedocs.io/en/latest/
129
+ * **Repository:** https://gitlab.com/bytecode-solutions/core/core-https
130
+ * **Issues:** https://gitlab.com/bytecode-solutions/core/core-https/-/issues
131
+ * **Changelog:** https://gitlab.com/bytecode-solutions/core/core-https/-/blob/master/CHANGELOG.md
132
+ * **PyPI:** https://pypi.org/project/core-https/
133
+
134
+
135
+ Support
136
+ ===============================================================================
137
+
138
+ For questions or support, please open an issue on GitLab or contact the maintainers.
139
+
140
+
141
+ Authors
142
+ ===============================================================================
143
+
144
+ * **Alejandro Cora González** - *Initial work* - alek.cora.glez@gmail.com
@@ -8,7 +8,8 @@ HTTP-related errors in a structured and consistent manner. The exception
8
8
  hierarchy is designed to allow for fine-grained error handling while
9
9
  maintaining compatibility with standard HTTP status codes.
10
10
 
11
- Exception Hierarchy:
11
+ Exception Hierarchy::
12
+
12
13
  Exception
13
14
  └── InternalServerError (base for all HTTP errors)
14
15
  ├── ServiceException (handled service errors)
@@ -0,0 +1,60 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ from aiohttp import ClientResponse
4
+ from aiolimiter import AsyncLimiter
5
+
6
+ from core_https.requesters.aiohttp_throttle import AioHttpThrottleRequester
7
+
8
+
9
+ class AioHttpRateLimitRequester(AioHttpThrottleRequester):
10
+ """
11
+ An HTTP requester that enforces a simple *rate limit* using
12
+ :class:`aiolimiter.AsyncLimiter`. This class restricts how many
13
+ requests may be *started* within a given time window. It does **not**
14
+ limit concurrency; multiple requests may still run in parallel
15
+ if they acquire permission within the same window.
16
+ """
17
+
18
+ def __init__(
19
+ self,
20
+ max_concurrency: int,
21
+ max_rate: int,
22
+ time_period: float,
23
+ **kwargs
24
+ ) -> None:
25
+ """
26
+ Initialize the rate-limited requester.
27
+
28
+ :param max_rate: Maximum number of requests allowed within the time window.
29
+ :param time_period: Duration (in seconds) of the rate-limiting window.
30
+ :param kwargs: Additional keyword arguments passed to :class:`AioHttpRequester`.
31
+ """
32
+
33
+ if max_rate <= 0:
34
+ raise ValueError("`max_rate` must be positive!")
35
+
36
+ if time_period <= 0:
37
+ raise ValueError("`time_period` must be positive!")
38
+
39
+ super().__init__(max_concurrency=max_concurrency, **kwargs)
40
+
41
+ self.max_rate = max_rate
42
+ self.time_period = time_period
43
+
44
+ self._limiter = AsyncLimiter(
45
+ max_rate=self.max_rate,
46
+ time_period=self.time_period,
47
+ )
48
+
49
+ async def request(self, *args, **kwargs) -> ClientResponse:
50
+ """
51
+ Execute an HTTP request subject to the configured rate limit. The
52
+ coroutine will wait (non-blocking) until a rate slot becomes available,
53
+ and then delegate the call to the base :class:`AioHttpRequester`.
54
+
55
+ :return: The HTTP response object.
56
+ :raises Exception: Any exception raised by the underlying HTTP client.
57
+ """
58
+
59
+ async with self._limiter:
60
+ return await super().request(*args, **kwargs)
@@ -0,0 +1,54 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ import asyncio
4
+
5
+ from aiohttp import ClientResponse
6
+
7
+ from core_https.requesters.aiohttp_ import AioHttpRequester
8
+
9
+
10
+ class AioHttpThrottleRequester(AioHttpRequester):
11
+ """
12
+ An `AioHttpRequester` implementation that limits the number of
13
+ concurrent in-flight HTTP requests using an `asyncio.Semaphore`. This
14
+ throttler enforces *max_concurrency* at the coroutine level within a
15
+ single event loop. Each call to :meth:`request` must acquire a semaphore
16
+ permit before dispatching the actual HTTP request.
17
+
18
+ **Notes:**
19
+
20
+ - The throttling mechanism limits only concurrent *coroutine execution*. It
21
+ does not enforce rate limiting (requests per second).
22
+ - If you override :meth:`request` in a subclass, be aware that
23
+ `await super().request(...)` calls the parent implementation (so the parent
24
+ semaphore *will* be used for the actual HTTP call). However, any code you
25
+ run **before** or **after** that `super()` call executes outside the parent's
26
+ semaphore (and therefore is not throttled).
27
+ """
28
+
29
+ def __init__(self, max_concurrency: int, **kwargs) -> None:
30
+ """
31
+ :param max_concurrency: Maximum number of concurrent requests allowed.
32
+ :param kwargs: Passed through to :class:`AioHttpRequester`.
33
+ """
34
+
35
+ super().__init__(**kwargs)
36
+ self.max_concurrency = max_concurrency
37
+ self._semaphore = asyncio.Semaphore(self.max_concurrency)
38
+
39
+ @classmethod
40
+ def registration_key(cls) -> str:
41
+ return cls.__name__
42
+
43
+ async def request(self, *args, **kwargs) -> ClientResponse:
44
+ """
45
+ Execute an HTTP request with concurrency throttling. It acquires
46
+ a semaphore permit before delegating the actual request to the
47
+ underlying :class:`AioHttpRequester` implementation.
48
+
49
+ :returns: The aiohttp response object.
50
+ :raises: Any exception raised by the underlying session.
51
+ """
52
+
53
+ async with self._semaphore:
54
+ return await super().request(*args, **kwargs)
@@ -45,10 +45,6 @@ class BaseHttpTestCases(TestCase):
45
45
  the code_mapper attribute, which can be used in test assertions and
46
46
  mock response creation.
47
47
 
48
- Attributes:
49
- code_mapper: Dictionary mapping HTTP status codes (int) to their
50
- corresponding reason phrases (str). Generated from HTTPStatus enum.
51
-
52
48
  Example:
53
49
  Basic usage in test methods::
54
50
 
@@ -85,4 +81,6 @@ class BaseHttpTestCases(TestCase):
85
81
  - HTTPStatus: The enum class providing status code definitions
86
82
  """
87
83
 
84
+ # Dictionary mapping HTTP status codes to their reason phrases.
85
+ # Generated from :class:`HTTPStatus` enum.
88
86
  code_mapper: Dict[int, str] = HTTPStatus.as_dict()
@@ -0,0 +1,183 @@
1
+ Metadata-Version: 2.4
2
+ Name: core-https
3
+ Version: 2.0.3
4
+ Summary: This project/library contains common elements related to HTTP & API services...
5
+ Author-email: Alejandro Cora González <alek.cora.glez@gmail.com>
6
+ Maintainer: Alejandro Cora González
7
+ License-Expression: MIT
8
+ Project-URL: Homepage, https://gitlab.com/bytecode-solutions/core/core-https
9
+ Project-URL: Repository, https://gitlab.com/bytecode-solutions/core/core-https
10
+ Project-URL: Documentation, https://core-https.readthedocs.io/en/latest/
11
+ Project-URL: Issues, https://gitlab.com/bytecode-solutions/core/core-https/-/issues
12
+ Project-URL: Changelog, https://gitlab.com/bytecode-solutions/core/core-https/-/blob/master/CHANGELOG.md
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Development Status :: 5 - Production/Stable
15
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
16
+ Classifier: Topic :: Utilities
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3 :: Only
19
+ Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Programming Language :: Python :: 3.13
24
+ Requires-Python: >=3.9
25
+ Description-Content-Type: text/x-rst
26
+ License-File: LICENSE
27
+ Requires-Dist: aiohttp<4.0.0,>=3.12.0
28
+ Requires-Dist: core-mixins>=2.2.2
29
+ Requires-Dist: requests<3.0.0,>=2.32.3
30
+ Requires-Dist: urllib3<3.0.0,>=2.2.3
31
+ Provides-Extra: dev
32
+ Requires-Dist: aiolimiter<2.0.0,>=1.2.1; extra == "dev"
33
+ Requires-Dist: core-dev-tools>=1.0.1; extra == "dev"
34
+ Requires-Dist: core-tests>=2.0.2; extra == "dev"
35
+ Requires-Dist: types-requests>=2.32.0.20250602; extra == "dev"
36
+ Provides-Extra: extras
37
+ Requires-Dist: aiolimiter<2.0.0,>=1.2.1; extra == "extras"
38
+ Dynamic: license-file
39
+
40
+ core-https
41
+ ===============================================================================
42
+
43
+ This project/library contains common elements related to HTTP...
44
+
45
+ ===============================================================================
46
+
47
+ .. image:: https://img.shields.io/pypi/pyversions/core-https.svg
48
+ :target: https://pypi.org/project/core-https/
49
+ :alt: Python Versions
50
+
51
+ .. image:: https://img.shields.io/badge/license-MIT-blue.svg
52
+ :target: https://gitlab.com/bytecode-solutions/core/core-https/-/blob/main/LICENSE
53
+ :alt: License
54
+
55
+ .. image:: https://gitlab.com/bytecode-solutions/core/core-https/badges/release/pipeline.svg
56
+ :target: https://gitlab.com/bytecode-solutions/core/core-https/-/pipelines
57
+ :alt: Pipeline Status
58
+
59
+ .. image:: https://readthedocs.org/projects/core-https/badge/?version=latest
60
+ :target: https://readthedocs.org/projects/core-https/
61
+ :alt: Docs Status
62
+
63
+ .. image:: https://img.shields.io/badge/security-bandit-yellow.svg
64
+ :target: https://github.com/PyCQA/bandit
65
+ :alt: Security
66
+
67
+ |
68
+
69
+
70
+ Installation
71
+ ===============================================================================
72
+
73
+ Install from PyPI using pip:
74
+
75
+ .. code-block:: bash
76
+
77
+ pip install core-https
78
+ uv pip install core-https # Or using UV...
79
+
80
+
81
+ Features
82
+ ===============================================================================
83
+
84
+ * **HTTP Status Codes & Methods** - Comprehensive enums with backward compatibility for Python < 3.11, including utility methods for status checking (is_success, is_error, etc.) and method properties (is_safe, is_idempotent, is_cacheable)
85
+ * **Status Classification** - ``StatusInfo`` enum for categorizing HTTP responses as success (1xx-3xx), error (4xx), or failure (5xx)
86
+ * **Exception Hierarchy** - Structured exception classes for handling HTTP errors with automatic status code mapping: ``AuthenticationException`` (401), ``AuthorizationException`` (403), ``RateLimitException`` (429), and ``RetryableException`` for temporary failures
87
+ * **HTTP Requesters** - Abstract interface (``IRequester``) with concrete implementations for multiple HTTP libraries (``requests``, ``urllib3``, ``aiohttp``), supporting connection pooling, timeouts, retries, and backoff strategies
88
+ * **Testing Utilities** - Base test classes and decorators for mocking HTTP requests/responses across different HTTP client libraries
89
+
90
+
91
+ Quick Start
92
+ ===============================================================================
93
+
94
+ Installation
95
+ -------------------------------------------------------------------------------
96
+
97
+ Install the package:
98
+
99
+ .. code-block:: bash
100
+
101
+ pip install core-https
102
+ uv pip install core-https # Or using UV...
103
+ pip install -e ".[dev]" # For development...
104
+
105
+ Setting Up Environment
106
+ -------------------------------------------------------------------------------
107
+
108
+ 1. Install required libraries:
109
+
110
+ .. code-block:: bash
111
+
112
+ pip install --upgrade pip
113
+ pip install virtualenv
114
+
115
+ 2. Create Python virtual environment:
116
+
117
+ .. code-block:: bash
118
+
119
+ virtualenv --python=python3.12 .venv
120
+
121
+ 3. Activate the virtual environment:
122
+
123
+ .. code-block:: bash
124
+
125
+ source .venv/bin/activate
126
+
127
+ Install packages
128
+ -------------------------------------------------------------------------------
129
+
130
+ .. code-block:: bash
131
+
132
+ pip install .
133
+ pip install -e ".[dev]"
134
+
135
+ Check tests and coverage
136
+ -------------------------------------------------------------------------------
137
+
138
+ .. code-block:: shell
139
+
140
+ python manager.py run-tests
141
+ python manager.py run-coverage
142
+
143
+
144
+ Contributing
145
+ ===============================================================================
146
+
147
+ Contributions are welcome! Please:
148
+
149
+ 1. Fork the repository
150
+ 2. Create a feature branch
151
+ 3. Write tests for new functionality
152
+ 4. Ensure all tests pass: ``pytest -n auto``
153
+ 5. Run linting: ``pylint core_https``
154
+ 6. Run security checks: ``bandit -r core_https``
155
+ 7. Submit a pull request
156
+
157
+
158
+ License
159
+ ===============================================================================
160
+
161
+ This project is licensed under the MIT License. See the LICENSE file for details.
162
+
163
+
164
+ Links
165
+ ===============================================================================
166
+
167
+ * **Documentation:** https://core-https.readthedocs.io/en/latest/
168
+ * **Repository:** https://gitlab.com/bytecode-solutions/core/core-https
169
+ * **Issues:** https://gitlab.com/bytecode-solutions/core/core-https/-/issues
170
+ * **Changelog:** https://gitlab.com/bytecode-solutions/core/core-https/-/blob/master/CHANGELOG.md
171
+ * **PyPI:** https://pypi.org/project/core-https/
172
+
173
+
174
+ Support
175
+ ===============================================================================
176
+
177
+ For questions or support, please open an issue on GitLab or contact the maintainers.
178
+
179
+
180
+ Authors
181
+ ===============================================================================
182
+
183
+ * **Alejandro Cora González** - *Initial work* - alek.cora.glez@gmail.com
@@ -13,6 +13,8 @@ core_https.egg-info/requires.txt
13
13
  core_https.egg-info/top_level.txt
14
14
  core_https/requesters/__init__.py
15
15
  core_https/requesters/aiohttp_.py
16
+ core_https/requesters/aiohttp_rate_limit.py
17
+ core_https/requesters/aiohttp_throttle.py
16
18
  core_https/requesters/base.py
17
19
  core_https/requesters/requests_.py
18
20
  core_https/requesters/urllib3_.py
@@ -1,14 +1,13 @@
1
- core-mixins>=2.2.2
2
- core-tests>=2.0.2
3
-
4
- [:python_version >= "3.9"]
5
1
  aiohttp<4.0.0,>=3.12.0
2
+ core-mixins>=2.2.2
6
3
  requests<3.0.0,>=2.32.3
7
4
  urllib3<3.0.0,>=2.2.3
8
5
 
9
- [:python_version >= "3.9" and python_version < "3.11"]
10
- typing-extensions>=4.8.0
11
-
12
6
  [dev]
7
+ aiolimiter<2.0.0,>=1.2.1
13
8
  core-dev-tools>=1.0.1
9
+ core-tests>=2.0.2
14
10
  types-requests>=2.32.0.20250602
11
+
12
+ [extras]
13
+ aiolimiter<2.0.0,>=1.2.1
@@ -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 = "2.0.1"
12
+ version = "2.0.3"
13
13
 
14
14
  authors = [
15
15
  {name = "Alejandro Cora González", email = "alek.cora.glez@gmail.com"}
@@ -20,12 +20,11 @@ maintainers = [
20
20
  ]
21
21
 
22
22
  requires-python = ">=3.9"
23
- license = {text = "MIT"}
23
+ license = "MIT"
24
24
  readme = "README.rst"
25
25
 
26
26
  classifiers = [
27
27
  # Classifiers -> https://pypi.org/classifiers/
28
- "License :: OSI Approved :: MIT License",
29
28
  "Intended Audience :: Developers",
30
29
  "Development Status :: 5 - Production/Stable",
31
30
  "Topic :: Software Development :: Libraries :: Python Modules",
@@ -40,20 +39,24 @@ classifiers = [
40
39
  ]
41
40
 
42
41
  dependencies = [
43
- "aiohttp>=3.12.0,<4.0.0; python_version >= '3.9'",
42
+ "aiohttp>=3.12.0,<4.0.0",
44
43
  "core-mixins>=2.2.2",
45
- "core-tests>=2.0.2",
46
- "requests>=2.32.3,<3.0.0; python_version >= '3.9'",
47
- "typing-extensions>=4.8.0; python_version >= '3.9' and python_version < '3.11'",
48
- "urllib3>=2.2.3,<3.0.0; python_version >= '3.9'",
44
+ "requests>=2.32.3,<3.0.0",
45
+ "urllib3>=2.2.3,<3.0.0",
49
46
  ]
50
47
 
51
48
  [project.optional-dependencies]
52
49
  dev = [
50
+ "aiolimiter>=1.2.1,<2.0.0",
53
51
  "core-dev-tools>=1.0.1",
52
+ "core-tests>=2.0.2",
54
53
  "types-requests>=2.32.0.20250602",
55
54
  ]
56
55
 
56
+ extras = [
57
+ "aiolimiter>=1.2.1,<2.0.0",
58
+ ]
59
+
57
60
  [project.urls]
58
61
  Homepage = "https://gitlab.com/bytecode-solutions/core/core-https"
59
62
  Repository = "https://gitlab.com/bytecode-solutions/core/core-https"
core_https-2.0.1/PKG-INFO DELETED
@@ -1,112 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: core-https
3
- Version: 2.0.1
4
- Summary: This project/library contains common elements related to HTTP & API services...
5
- Author-email: Alejandro Cora González <alek.cora.glez@gmail.com>
6
- Maintainer: Alejandro Cora González
7
- License: MIT
8
- Project-URL: Homepage, https://gitlab.com/bytecode-solutions/core/core-https
9
- Project-URL: Repository, https://gitlab.com/bytecode-solutions/core/core-https
10
- Project-URL: Documentation, https://core-https.readthedocs.io/en/latest/
11
- Project-URL: Issues, https://gitlab.com/bytecode-solutions/core/core-https/-/issues
12
- Project-URL: Changelog, https://gitlab.com/bytecode-solutions/core/core-https/-/blob/master/CHANGELOG.md
13
- Classifier: License :: OSI Approved :: MIT License
14
- Classifier: Intended Audience :: Developers
15
- Classifier: Development Status :: 5 - Production/Stable
16
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
17
- Classifier: Topic :: Utilities
18
- Classifier: Programming Language :: Python :: 3
19
- Classifier: Programming Language :: Python :: 3 :: Only
20
- Classifier: Programming Language :: Python :: 3.9
21
- Classifier: Programming Language :: Python :: 3.10
22
- Classifier: Programming Language :: Python :: 3.11
23
- Classifier: Programming Language :: Python :: 3.12
24
- Classifier: Programming Language :: Python :: 3.13
25
- Requires-Python: >=3.9
26
- Description-Content-Type: text/x-rst
27
- License-File: LICENSE
28
- Requires-Dist: aiohttp<4.0.0,>=3.12.0; python_version >= "3.9"
29
- Requires-Dist: core-mixins>=2.2.2
30
- Requires-Dist: core-tests>=2.0.2
31
- Requires-Dist: requests<3.0.0,>=2.32.3; python_version >= "3.9"
32
- Requires-Dist: typing-extensions>=4.8.0; python_version >= "3.9" and python_version < "3.11"
33
- Requires-Dist: urllib3<3.0.0,>=2.2.3; python_version >= "3.9"
34
- Provides-Extra: dev
35
- Requires-Dist: core-dev-tools>=1.0.1; extra == "dev"
36
- Requires-Dist: types-requests>=2.32.0.20250602; extra == "dev"
37
- Dynamic: license-file
38
-
39
- core-https
40
- ===============================================================================
41
-
42
- This project/library contains common elements related to HTTP...
43
-
44
- ===============================================================================
45
-
46
- .. image:: https://img.shields.io/pypi/pyversions/core-https.svg
47
- :target: https://pypi.org/project/core-https/
48
- :alt: Python Versions
49
-
50
- .. image:: https://img.shields.io/badge/license-MIT-blue.svg
51
- :target: https://gitlab.com/bytecode-solutions/core/core-https/-/blob/main/LICENSE
52
- :alt: License
53
-
54
- .. image:: https://gitlab.com/bytecode-solutions/core/core-https/badges/release/pipeline.svg
55
- :target: https://gitlab.com/bytecode-solutions/core/core-https/-/pipelines
56
- :alt: Pipeline Status
57
-
58
- .. image:: https://readthedocs.org/projects/core-https/badge/?version=latest
59
- :target: https://readthedocs.org/projects/core-https/
60
- :alt: Docs Status
61
-
62
- .. image:: https://img.shields.io/badge/security-bandit-yellow.svg
63
- :target: https://github.com/PyCQA/bandit
64
- :alt: Security
65
-
66
- |
67
-
68
- Execution Environment
69
- ---------------------------------------
70
-
71
- Install libraries
72
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
73
-
74
- .. code-block:: shell
75
-
76
- pip install --upgrade pip
77
- pip install virtualenv
78
- ..
79
-
80
- Create the Python Virtual Environment.
81
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
82
-
83
- .. code-block:: shell
84
-
85
- virtualenv --python={{python-version}} .venv
86
- virtualenv --python=python3.11 .venv
87
- ..
88
-
89
- Activate the Virtual Environment.
90
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
91
-
92
- .. code-block:: shell
93
-
94
- source .venv/bin/activate
95
- ..
96
-
97
- Install required libraries.
98
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
99
-
100
- .. code-block:: shell
101
-
102
- pip install .
103
- ..
104
-
105
- Check tests and coverage.
106
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
107
-
108
- .. code-block:: shell
109
-
110
- python manager.py run-tests
111
- python manager.py run-coverage
112
- ..
@@ -1,74 +0,0 @@
1
- core-https
2
- ===============================================================================
3
-
4
- This project/library contains common elements related to HTTP...
5
-
6
- ===============================================================================
7
-
8
- .. image:: https://img.shields.io/pypi/pyversions/core-https.svg
9
- :target: https://pypi.org/project/core-https/
10
- :alt: Python Versions
11
-
12
- .. image:: https://img.shields.io/badge/license-MIT-blue.svg
13
- :target: https://gitlab.com/bytecode-solutions/core/core-https/-/blob/main/LICENSE
14
- :alt: License
15
-
16
- .. image:: https://gitlab.com/bytecode-solutions/core/core-https/badges/release/pipeline.svg
17
- :target: https://gitlab.com/bytecode-solutions/core/core-https/-/pipelines
18
- :alt: Pipeline Status
19
-
20
- .. image:: https://readthedocs.org/projects/core-https/badge/?version=latest
21
- :target: https://readthedocs.org/projects/core-https/
22
- :alt: Docs Status
23
-
24
- .. image:: https://img.shields.io/badge/security-bandit-yellow.svg
25
- :target: https://github.com/PyCQA/bandit
26
- :alt: Security
27
-
28
- |
29
-
30
- Execution Environment
31
- ---------------------------------------
32
-
33
- Install libraries
34
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
35
-
36
- .. code-block:: shell
37
-
38
- pip install --upgrade pip
39
- pip install virtualenv
40
- ..
41
-
42
- Create the Python Virtual Environment.
43
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
44
-
45
- .. code-block:: shell
46
-
47
- virtualenv --python={{python-version}} .venv
48
- virtualenv --python=python3.11 .venv
49
- ..
50
-
51
- Activate the Virtual Environment.
52
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
53
-
54
- .. code-block:: shell
55
-
56
- source .venv/bin/activate
57
- ..
58
-
59
- Install required libraries.
60
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
61
-
62
- .. code-block:: shell
63
-
64
- pip install .
65
- ..
66
-
67
- Check tests and coverage.
68
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
69
-
70
- .. code-block:: shell
71
-
72
- python manager.py run-tests
73
- python manager.py run-coverage
74
- ..
@@ -1,112 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: core-https
3
- Version: 2.0.1
4
- Summary: This project/library contains common elements related to HTTP & API services...
5
- Author-email: Alejandro Cora González <alek.cora.glez@gmail.com>
6
- Maintainer: Alejandro Cora González
7
- License: MIT
8
- Project-URL: Homepage, https://gitlab.com/bytecode-solutions/core/core-https
9
- Project-URL: Repository, https://gitlab.com/bytecode-solutions/core/core-https
10
- Project-URL: Documentation, https://core-https.readthedocs.io/en/latest/
11
- Project-URL: Issues, https://gitlab.com/bytecode-solutions/core/core-https/-/issues
12
- Project-URL: Changelog, https://gitlab.com/bytecode-solutions/core/core-https/-/blob/master/CHANGELOG.md
13
- Classifier: License :: OSI Approved :: MIT License
14
- Classifier: Intended Audience :: Developers
15
- Classifier: Development Status :: 5 - Production/Stable
16
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
17
- Classifier: Topic :: Utilities
18
- Classifier: Programming Language :: Python :: 3
19
- Classifier: Programming Language :: Python :: 3 :: Only
20
- Classifier: Programming Language :: Python :: 3.9
21
- Classifier: Programming Language :: Python :: 3.10
22
- Classifier: Programming Language :: Python :: 3.11
23
- Classifier: Programming Language :: Python :: 3.12
24
- Classifier: Programming Language :: Python :: 3.13
25
- Requires-Python: >=3.9
26
- Description-Content-Type: text/x-rst
27
- License-File: LICENSE
28
- Requires-Dist: aiohttp<4.0.0,>=3.12.0; python_version >= "3.9"
29
- Requires-Dist: core-mixins>=2.2.2
30
- Requires-Dist: core-tests>=2.0.2
31
- Requires-Dist: requests<3.0.0,>=2.32.3; python_version >= "3.9"
32
- Requires-Dist: typing-extensions>=4.8.0; python_version >= "3.9" and python_version < "3.11"
33
- Requires-Dist: urllib3<3.0.0,>=2.2.3; python_version >= "3.9"
34
- Provides-Extra: dev
35
- Requires-Dist: core-dev-tools>=1.0.1; extra == "dev"
36
- Requires-Dist: types-requests>=2.32.0.20250602; extra == "dev"
37
- Dynamic: license-file
38
-
39
- core-https
40
- ===============================================================================
41
-
42
- This project/library contains common elements related to HTTP...
43
-
44
- ===============================================================================
45
-
46
- .. image:: https://img.shields.io/pypi/pyversions/core-https.svg
47
- :target: https://pypi.org/project/core-https/
48
- :alt: Python Versions
49
-
50
- .. image:: https://img.shields.io/badge/license-MIT-blue.svg
51
- :target: https://gitlab.com/bytecode-solutions/core/core-https/-/blob/main/LICENSE
52
- :alt: License
53
-
54
- .. image:: https://gitlab.com/bytecode-solutions/core/core-https/badges/release/pipeline.svg
55
- :target: https://gitlab.com/bytecode-solutions/core/core-https/-/pipelines
56
- :alt: Pipeline Status
57
-
58
- .. image:: https://readthedocs.org/projects/core-https/badge/?version=latest
59
- :target: https://readthedocs.org/projects/core-https/
60
- :alt: Docs Status
61
-
62
- .. image:: https://img.shields.io/badge/security-bandit-yellow.svg
63
- :target: https://github.com/PyCQA/bandit
64
- :alt: Security
65
-
66
- |
67
-
68
- Execution Environment
69
- ---------------------------------------
70
-
71
- Install libraries
72
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
73
-
74
- .. code-block:: shell
75
-
76
- pip install --upgrade pip
77
- pip install virtualenv
78
- ..
79
-
80
- Create the Python Virtual Environment.
81
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
82
-
83
- .. code-block:: shell
84
-
85
- virtualenv --python={{python-version}} .venv
86
- virtualenv --python=python3.11 .venv
87
- ..
88
-
89
- Activate the Virtual Environment.
90
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
91
-
92
- .. code-block:: shell
93
-
94
- source .venv/bin/activate
95
- ..
96
-
97
- Install required libraries.
98
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
99
-
100
- .. code-block:: shell
101
-
102
- pip install .
103
- ..
104
-
105
- Check tests and coverage.
106
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
107
-
108
- .. code-block:: shell
109
-
110
- python manager.py run-tests
111
- python manager.py run-coverage
112
- ..
File without changes
File without changes
File without changes