Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
docs:
poetry install --with dev
poetry run sphinx-apidoc -o docs src/imednet \
src/imednet/core/__init__.py src/imednet/models/base.py
src/imednet/errors/__init__.py src/imednet/models/base.py
poetry run sphinx-build -b html --keep-going docs docs/_build/html
12 changes: 6 additions & 6 deletions docs/api_overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ HTTP methods and errors
The API primarily supports ``GET`` and ``POST`` requests. Non‐successful status
codes raise typed exceptions:

* ``400`` – :class:`~imednet.core.exceptions.ValidationError`
* ``401`` – :class:`~imednet.core.exceptions.AuthenticationError`
* ``403`` – :class:`~imednet.core.exceptions.AuthorizationError`
* ``404`` – :class:`~imednet.core.exceptions.NotFoundError`
* ``429`` – :class:`~imednet.core.exceptions.RateLimitError`
* ``5xx`` – :class:`~imednet.core.exceptions.ServerError`
* ``400`` – :class:`~imednet.errors.ValidationError`
* ``401`` – :class:`~imednet.errors.AuthenticationError`
* ``403`` – :class:`~imednet.errors.AuthorizationError`
* ``404`` – :class:`~imednet.errors.NotFoundError`
* ``429`` – :class:`~imednet.errors.RateLimitError`
* ``5xx`` – :class:`~imednet.errors.ServerError`

See :doc:`retry_policy` for examples of handling these errors and configuring
custom retry logic.
Expand Down
9 changes: 1 addition & 8 deletions docs/imednet.core.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,6 @@ HTTPX requests used by the SDK:
:show-inheritance:
:noindex:

imednet.core.exceptions module
------------------------------

.. automodule:: imednet.core.exceptions
:members:
:undoc-members:
:show-inheritance:

imednet.core.paginator module
-----------------------------
Expand All @@ -87,7 +80,7 @@ requests should be retried. The SDK uses

from imednet.core.client import Client
from imednet.core.retry import RetryPolicy, RetryState
from imednet.core.exceptions import ServerError
from imednet.errors import ServerError

class ServerRetry(RetryPolicy):
def should_retry(self, state: RetryState) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion docs/quick_start.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Custom retry logic can be provided via a ``RetryPolicy``:
.. code-block:: python

from imednet.core.retry import RetryPolicy, RetryState
from imednet.core.exceptions import ServerError
from imednet.errors import ServerError

class ServerRetry(RetryPolicy):
def should_retry(self, state: RetryState) -> bool:
Expand Down
4 changes: 2 additions & 2 deletions docs/retry_policy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Use typed exceptions to respond to different failure modes:
.. code-block:: python

from imednet import ImednetSDK
from imednet.core.exceptions import RateLimitError, ServerError, NotFoundError
from imednet.errors import RateLimitError, ServerError, NotFoundError

sdk = ImednetSDK()
try:
Expand All @@ -35,7 +35,7 @@ Retry policies decide if a request should be retried. To retry on

from imednet.core.client import Client
from imednet.core.retry import RetryPolicy, RetryState
from imednet.core.exceptions import RateLimitError, ServerError
from imednet.errors import RateLimitError, ServerError

class RateLimitServerRetry(RetryPolicy):
def should_retry(self, state: RetryState) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion docs/schema_validation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ submitting it to the API. The validator checks that all variables exist,
required fields are present, and that values match the expected types.
If the variable metadata for a form is missing, ``SchemaValidator`` automatically
loads it from the API using :class:`~imednet.endpoints.variables.VariablesEndpoint`.
Any problems raise :class:`~imednet.core.exceptions.ValidationError` before the
Any problems raise :class:`~imednet.errors.ValidationError` before the
record is sent to the server.

``SchemaValidator`` works with both synchronous and asynchronous SDK clients.
Expand Down
8 changes: 4 additions & 4 deletions examples/custom_retry.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@

import httpx

from imednet.auth.strategy import AuthStrategy
from imednet.core.client import Client
from imednet.core.exceptions import RateLimitError, ServerError
from imednet.core.retry import RetryPolicy, RetryState
from imednet.errors import RateLimitError, ServerError
from imednet.utils import configure_json_logging

"""Demonstrate custom retry logic with simulated rate limit and server errors.
Expand Down Expand Up @@ -49,14 +50,13 @@ def responder(_: httpx.Request) -> httpx.Response:


class MockClient(Client):
def _create_client(self, api_key: str, security_key: str) -> httpx.Client: # type: ignore[override]
def _create_client(self, auth: AuthStrategy) -> httpx.Client: # type: ignore[override]
return httpx.Client(
base_url=self.base_url,
headers={
"Accept": "application/json",
"Content-Type": "application/json",
"x-api-key": api_key,
"x-imn-security-key": security_key,
**auth.get_headers(),
},
timeout=self.timeout,
transport=httpx.MockTransport(responder),
Expand Down
Loading