diff --git a/elydora/async_client.py b/elydora/async_client.py index 958f303..3e80523 100644 --- a/elydora/async_client.py +++ b/elydora/async_client.py @@ -130,9 +130,11 @@ class AsyncElydoraClient: headers=build_headers(self.token), ) - async def _get_public(self, path: str) -> Any: + async def _get_public(self, path: str, *, accept_status: Optional[int] = None) -> Any: session = await self._get_session() async with session.get(f"{self.base_url}{path}", timeout=TIMEOUT) as response: + if accept_status is not None and response.status == accept_status: + return await response.json() return await self._handle_response(response) @staticmethod @@ -349,4 +351,5 @@ class AsyncElydoraClient: return await self._get_public("/v1/health") async def deep_health(self) -> DeepHealthResponse: - return await self._get_public("/v1/health/deep") + """503 carries the degraded report, not an error.""" + return await self._get_public("/v1/health/deep", accept_status=503) diff --git a/elydora/client.py b/elydora/client.py index d8f8f2e..53a69d0 100644 --- a/elydora/client.py +++ b/elydora/client.py @@ -119,8 +119,10 @@ class ElydoraClient: headers=build_headers(self.token), ) - def _get_public(self, path: str) -> Any: + def _get_public(self, path: str, *, accept_status: Optional[int] = None) -> Any: response = self._session.get(f"{self.base_url}{path}", timeout=REQUEST_TIMEOUT_SECONDS) + if accept_status is not None and response.status_code == accept_status: + return response.json() return self._handle_response(response) @staticmethod @@ -324,4 +326,5 @@ class ElydoraClient: return self._get_public("/v1/health") def deep_health(self) -> DeepHealthResponse: - return self._get_public("/v1/health/deep") + """503 carries the degraded report, not an error.""" + return self._get_public("/v1/health/deep", accept_status=503)