from __future__ import annotations from collections.abc import Sequence __all__ = [ "AuthenticationError", "InvalidArgumentError", "JsonValue", "NotFoundError", "OpenstatusError", "PermissionDeniedError", "RateLimitError", "ServiceUnavailableError", ] JsonScalar = str | int | float | bool | None JsonValue = JsonScalar | list["JsonValue"] | dict[str, "JsonValue"] class OpenstatusError(Exception): """Base class for all Openstatus SDK errors raised by the HTTP transport.""" def __init__( self, message: str, *, connect_code: str = "unknown", http_status: int = 0, details: Sequence[JsonValue] = (), raw_body: str = "", ) -> None: super().__init__(message) self.connect_code: str = connect_code self.http_status: int = http_status self.details: list[JsonValue] = list(details) self.raw_body: str = raw_body class AuthenticationError(OpenstatusError): """Raised when the API rejects the supplied credentials (`unauthenticated`).""" class NotFoundError(OpenstatusError): """Raised when the API cannot locate the requested resource (`not_found`).""" class InvalidArgumentError(OpenstatusError): """Raised when the request payload is malformed (`invalid_argument`).""" class PermissionDeniedError(OpenstatusError): """Raised when the caller is not allowed to perform the action (`permission_denied`).""" class RateLimitError(OpenstatusError): """Raised when the caller has exceeded a quota (`resource_exhausted`).""" class ServiceUnavailableError(OpenstatusError): """Raised when the service is temporarily unreachable or returns a non-RPC body."""