From 800079d29b5a814e2fbd07bc3c662c4811360c72 Mon Sep 17 00:00:00 2001 From: Evan Slawski Date: Mon, 15 Sep 2025 13:42:40 -0400 Subject: [PATCH 1/6] Enhance JsonEndpoint to support configurable timeout, retry policies, and raw response return --- src/apiron/endpoint/json.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/apiron/endpoint/json.py b/src/apiron/endpoint/json.py index 2a03745..47b139b 100644 --- a/src/apiron/endpoint/json.py +++ b/src/apiron/endpoint/json.py @@ -2,7 +2,9 @@ from collections.abc import Iterable from typing import Any +from apiron import Timeout from apiron.endpoint.endpoint import Endpoint +from urllib3.util import retry class JsonEndpoint(Endpoint): @@ -18,12 +20,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 From 0f8f3ed772a1642cec49c780503f677b145a7e68 Mon Sep 17 00:00:00 2001 From: Evan Slawski Date: Mon, 15 Sep 2025 13:49:02 -0400 Subject: [PATCH 2/6] Version and changelog --- CHANGELOG.md | 4 ++++ pyproject.toml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 126ab67..02aaba0 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 configurable a timeout, retry policy, 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" }, From 73d8714111e3ca416cfa2132619ee8287c483922 Mon Sep 17 00:00:00 2001 From: Evan Slawski Date: Mon, 15 Sep 2025 14:01:29 -0400 Subject: [PATCH 3/6] Unit test for validation passthrough of new parameters --- tests/test_endpoint.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/test_endpoint.py b/tests/test_endpoint.py index 05e93f6..458a70d 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,22 @@ def test_repr_method(self): foo = apiron.JsonEndpoint(path="/bar/baz") assert repr(foo) == "JsonEndpoint(path='/bar/baz')" + def test_timeout_spec_parameter(self): + """Test that JsonEndpoint accepts and stores timeout_spec parameter""" + 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): + """Test that JsonEndpoint accepts and stores retry_spec parameter""" + 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): + """Test that JsonEndpoint accepts and stores return_raw_response_object parameter""" + foo = apiron.JsonEndpoint(return_raw_response_object=True) + assert foo.return_raw_response_object is True class TestStreamingEndpoint: def test_format_response(self): From 2871da11388da46cf1abdf841aeb812c06b05ff6 Mon Sep 17 00:00:00 2001 From: Evan Slawski Date: Mon, 15 Sep 2025 14:01:54 -0400 Subject: [PATCH 4/6] Update CHANGELOG.md Co-authored-by: Dane Hillard --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 02aaba0..ab14254 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [9.1.0] - 2025-09-15 ### Added -- Added support configurable a timeout, retry policy, and raw response return for `JsonEndpoint` +- Added support for a configurable timeout and retry spec, and raw response return for `JsonEndpoint` ## [9.0.0] - 2025-08-19 ### Removed From a7bca1f6e0ccf1980dfeaf338cd9a383d50b7aef Mon Sep 17 00:00:00 2001 From: Evan Slawski Date: Mon, 15 Sep 2025 15:01:27 -0400 Subject: [PATCH 5/6] Remove comments --- tests/test_endpoint.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/test_endpoint.py b/tests/test_endpoint.py index 458a70d..10772c7 100644 --- a/tests/test_endpoint.py +++ b/tests/test_endpoint.py @@ -151,19 +151,16 @@ def test_repr_method(self): assert repr(foo) == "JsonEndpoint(path='/bar/baz')" def test_timeout_spec_parameter(self): - """Test that JsonEndpoint accepts and stores timeout_spec parameter""" 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): - """Test that JsonEndpoint accepts and stores retry_spec parameter""" 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): - """Test that JsonEndpoint accepts and stores return_raw_response_object parameter""" foo = apiron.JsonEndpoint(return_raw_response_object=True) assert foo.return_raw_response_object is True From b3a8ec071f5f565e112520b9972f325f0468423e Mon Sep 17 00:00:00 2001 From: Evan Slawski Date: Mon, 15 Sep 2025 15:07:01 -0400 Subject: [PATCH 6/6] Fix linting --- src/apiron/endpoint/json.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/apiron/endpoint/json.py b/src/apiron/endpoint/json.py index 47b139b..caf6775 100644 --- a/src/apiron/endpoint/json.py +++ b/src/apiron/endpoint/json.py @@ -2,9 +2,10 @@ from collections.abc import Iterable from typing import Any +from urllib3.util import retry + from apiron import Timeout from apiron.endpoint.endpoint import Endpoint -from urllib3.util import retry class JsonEndpoint(Endpoint):