diff --git a/CHANGELOG.md b/CHANGELOG.md index 126ab67..ab14254 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [9.1.0] - 2025-09-15 +### Added +- Added support for a configurable timeout and retry spec, and raw response return for `JsonEndpoint` + ## [9.0.0] - 2025-08-19 ### Removed - apiron no longer supports Python 3.9, which reaches end of life on 2025-10-31 diff --git a/pyproject.toml b/pyproject.toml index 5af5b96..ccee5c4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "apiron" -version = "9.0.0" +version = "9.1.0" description = "apiron helps you cook a tasty client for RESTful APIs. Just don't wash it with SOAP." authors = [ { name = "Ithaka Harbors, Inc.", email = "opensource@ithaka.org" }, diff --git a/src/apiron/endpoint/json.py b/src/apiron/endpoint/json.py index 2a03745..caf6775 100644 --- a/src/apiron/endpoint/json.py +++ b/src/apiron/endpoint/json.py @@ -2,6 +2,9 @@ from collections.abc import Iterable from typing import Any +from urllib3.util import retry + +from apiron import Timeout from apiron.endpoint.endpoint import Endpoint @@ -18,12 +21,18 @@ def __init__( default_params: dict[str, Any] | None = None, required_params: Iterable[str] | None = None, preserve_order: bool = False, + return_raw_response_object: bool = False, + timeout_spec: Timeout | None = None, + retry_spec: retry.Retry | None = None, ): super().__init__( path=path, default_method=default_method, default_params=default_params, required_params=required_params, + return_raw_response_object=return_raw_response_object, + timeout_spec=timeout_spec, + retry_spec=retry_spec, ) self.preserve_order = preserve_order diff --git a/tests/test_endpoint.py b/tests/test_endpoint.py index 05e93f6..10772c7 100644 --- a/tests/test_endpoint.py +++ b/tests/test_endpoint.py @@ -2,6 +2,7 @@ from unittest import mock import pytest +from urllib3.util import retry import apiron @@ -149,6 +150,19 @@ def test_repr_method(self): foo = apiron.JsonEndpoint(path="/bar/baz") assert repr(foo) == "JsonEndpoint(path='/bar/baz')" + def test_timeout_spec_parameter(self): + timeout_spec = apiron.Timeout(connection_timeout=5, read_timeout=10) + foo = apiron.JsonEndpoint(timeout_spec=timeout_spec) + assert foo.timeout_spec == timeout_spec + + def test_retry_spec_parameter(self): + retry_spec = retry.Retry(total=3, backoff_factor=1) + foo = apiron.JsonEndpoint(retry_spec=retry_spec) + assert foo.retry_spec == retry_spec + + def test_return_raw_response_object_parameter(self): + foo = apiron.JsonEndpoint(return_raw_response_object=True) + assert foo.return_raw_response_object is True class TestStreamingEndpoint: def test_format_response(self):