Skip to content

Commit 5d12993

Browse files
authored
Merge pull request #153 from ithaka/json-retry-spec
Enhance JsonEndpoint to support configurable timeouts, retries, and return of raw response
2 parents fc52df8 + b3a8ec0 commit 5d12993

File tree

4 files changed

+28
-1
lines changed

4 files changed

+28
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
## [9.1.0] - 2025-09-15
10+
### Added
11+
- Added support for a configurable timeout and retry spec, and raw response return for `JsonEndpoint`
12+
913
## [9.0.0] - 2025-08-19
1014
### Removed
1115
- apiron no longer supports Python 3.9, which reaches end of life on 2025-10-31

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "apiron"
7-
version = "9.0.0"
7+
version = "9.1.0"
88
description = "apiron helps you cook a tasty client for RESTful APIs. Just don't wash it with SOAP."
99
authors = [
1010
{ name = "Ithaka Harbors, Inc.", email = "opensource@ithaka.org" },

src/apiron/endpoint/json.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
from collections.abc import Iterable
33
from typing import Any
44

5+
from urllib3.util import retry
6+
7+
from apiron import Timeout
58
from apiron.endpoint.endpoint import Endpoint
69

710

@@ -18,12 +21,18 @@ def __init__(
1821
default_params: dict[str, Any] | None = None,
1922
required_params: Iterable[str] | None = None,
2023
preserve_order: bool = False,
24+
return_raw_response_object: bool = False,
25+
timeout_spec: Timeout | None = None,
26+
retry_spec: retry.Retry | None = None,
2127
):
2228
super().__init__(
2329
path=path,
2430
default_method=default_method,
2531
default_params=default_params,
2632
required_params=required_params,
33+
return_raw_response_object=return_raw_response_object,
34+
timeout_spec=timeout_spec,
35+
retry_spec=retry_spec,
2736
)
2837
self.preserve_order = preserve_order
2938

tests/test_endpoint.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from unittest import mock
33

44
import pytest
5+
from urllib3.util import retry
56

67
import apiron
78

@@ -149,6 +150,19 @@ def test_repr_method(self):
149150
foo = apiron.JsonEndpoint(path="/bar/baz")
150151
assert repr(foo) == "JsonEndpoint(path='/bar/baz')"
151152

153+
def test_timeout_spec_parameter(self):
154+
timeout_spec = apiron.Timeout(connection_timeout=5, read_timeout=10)
155+
foo = apiron.JsonEndpoint(timeout_spec=timeout_spec)
156+
assert foo.timeout_spec == timeout_spec
157+
158+
def test_retry_spec_parameter(self):
159+
retry_spec = retry.Retry(total=3, backoff_factor=1)
160+
foo = apiron.JsonEndpoint(retry_spec=retry_spec)
161+
assert foo.retry_spec == retry_spec
162+
163+
def test_return_raw_response_object_parameter(self):
164+
foo = apiron.JsonEndpoint(return_raw_response_object=True)
165+
assert foo.return_raw_response_object is True
152166

153167
class TestStreamingEndpoint:
154168
def test_format_response(self):

0 commit comments

Comments
 (0)