"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

from .r9serror import R9SError
from typing import TYPE_CHECKING
from importlib import import_module
import builtins
import sys

if TYPE_CHECKING:
    from .authenticationerror import (
        AuthenticationError,
        AuthenticationErrorData,
        Error,
        ErrorTypedDict,
        Status,
    )
    from .badrequesterror import (
        BadRequestError,
        BadRequestErrorData,
        SchemasBadRequestErrorError,
        SchemasBadRequestErrorErrorTypedDict,
        SchemasBadRequestErrorStatus,
    )
    from .internalservererror import (
        InternalServerError,
        InternalServerErrorData,
        SchemasInternalServerErrorError,
        SchemasInternalServerErrorErrorTypedDict,
        SchemasInternalServerErrorStatus,
    )
    from .no_response_error import NoResponseError
    from .notfounderror import (
        NotFoundError,
        NotFoundErrorData,
        SchemasNotFoundErrorError,
        SchemasNotFoundErrorErrorTypedDict,
        SchemasNotFoundErrorStatus,
    )
    from .permissiondeniederror import (
        PermissionDeniedError,
        PermissionDeniedErrorData,
        SchemasError,
        SchemasErrorTypedDict,
        SchemasStatus,
    )
    from .r9sdefaulterror import R9SDefaultError
    from .ratelimiterror import (
        RateLimitError,
        RateLimitErrorData,
        SchemasRateLimitErrorError,
        SchemasRateLimitErrorErrorTypedDict,
        SchemasRateLimitErrorStatus,
    )
    from .responsevalidationerror import ResponseValidationError
    from .serviceunavailableerror import (
        SchemasServiceUnavailableErrorError,
        SchemasServiceUnavailableErrorErrorTypedDict,
        SchemasServiceUnavailableErrorStatus,
        ServiceUnavailableError,
        ServiceUnavailableErrorData,
    )
    from .unprocessableentityerror import (
        SchemasUnprocessableEntityErrorError,
        SchemasUnprocessableEntityErrorErrorTypedDict,
        SchemasUnprocessableEntityErrorStatus,
        UnprocessableEntityError,
        UnprocessableEntityErrorData,
    )

__all__ = [
    "AuthenticationError",
    "AuthenticationErrorData",
    "BadRequestError",
    "BadRequestErrorData",
    "Error",
    "ErrorTypedDict",
    "InternalServerError",
    "InternalServerErrorData",
    "NoResponseError",
    "NotFoundError",
    "NotFoundErrorData",
    "PermissionDeniedError",
    "PermissionDeniedErrorData",
    "R9SDefaultError",
    "R9SError",
    "RateLimitError",
    "RateLimitErrorData",
    "ResponseValidationError",
    "SchemasBadRequestErrorError",
    "SchemasBadRequestErrorErrorTypedDict",
    "SchemasBadRequestErrorStatus",
    "SchemasError",
    "SchemasErrorTypedDict",
    "SchemasInternalServerErrorError",
    "SchemasInternalServerErrorErrorTypedDict",
    "SchemasInternalServerErrorStatus",
    "SchemasNotFoundErrorError",
    "SchemasNotFoundErrorErrorTypedDict",
    "SchemasNotFoundErrorStatus",
    "SchemasRateLimitErrorError",
    "SchemasRateLimitErrorErrorTypedDict",
    "SchemasRateLimitErrorStatus",
    "SchemasServiceUnavailableErrorError",
    "SchemasServiceUnavailableErrorErrorTypedDict",
    "SchemasServiceUnavailableErrorStatus",
    "SchemasStatus",
    "SchemasUnprocessableEntityErrorError",
    "SchemasUnprocessableEntityErrorErrorTypedDict",
    "SchemasUnprocessableEntityErrorStatus",
    "ServiceUnavailableError",
    "ServiceUnavailableErrorData",
    "Status",
    "UnprocessableEntityError",
    "UnprocessableEntityErrorData",
]

_dynamic_imports: dict[str, str] = {
    "AuthenticationError": ".authenticationerror",
    "AuthenticationErrorData": ".authenticationerror",
    "Error": ".authenticationerror",
    "ErrorTypedDict": ".authenticationerror",
    "Status": ".authenticationerror",
    "BadRequestError": ".badrequesterror",
    "BadRequestErrorData": ".badrequesterror",
    "SchemasBadRequestErrorError": ".badrequesterror",
    "SchemasBadRequestErrorErrorTypedDict": ".badrequesterror",
    "SchemasBadRequestErrorStatus": ".badrequesterror",
    "InternalServerError": ".internalservererror",
    "InternalServerErrorData": ".internalservererror",
    "SchemasInternalServerErrorError": ".internalservererror",
    "SchemasInternalServerErrorErrorTypedDict": ".internalservererror",
    "SchemasInternalServerErrorStatus": ".internalservererror",
    "NoResponseError": ".no_response_error",
    "NotFoundError": ".notfounderror",
    "NotFoundErrorData": ".notfounderror",
    "SchemasNotFoundErrorError": ".notfounderror",
    "SchemasNotFoundErrorErrorTypedDict": ".notfounderror",
    "SchemasNotFoundErrorStatus": ".notfounderror",
    "PermissionDeniedError": ".permissiondeniederror",
    "PermissionDeniedErrorData": ".permissiondeniederror",
    "SchemasError": ".permissiondeniederror",
    "SchemasErrorTypedDict": ".permissiondeniederror",
    "SchemasStatus": ".permissiondeniederror",
    "R9SDefaultError": ".r9sdefaulterror",
    "RateLimitError": ".ratelimiterror",
    "RateLimitErrorData": ".ratelimiterror",
    "SchemasRateLimitErrorError": ".ratelimiterror",
    "SchemasRateLimitErrorErrorTypedDict": ".ratelimiterror",
    "SchemasRateLimitErrorStatus": ".ratelimiterror",
    "ResponseValidationError": ".responsevalidationerror",
    "SchemasServiceUnavailableErrorError": ".serviceunavailableerror",
    "SchemasServiceUnavailableErrorErrorTypedDict": ".serviceunavailableerror",
    "SchemasServiceUnavailableErrorStatus": ".serviceunavailableerror",
    "ServiceUnavailableError": ".serviceunavailableerror",
    "ServiceUnavailableErrorData": ".serviceunavailableerror",
    "SchemasUnprocessableEntityErrorError": ".unprocessableentityerror",
    "SchemasUnprocessableEntityErrorErrorTypedDict": ".unprocessableentityerror",
    "SchemasUnprocessableEntityErrorStatus": ".unprocessableentityerror",
    "UnprocessableEntityError": ".unprocessableentityerror",
    "UnprocessableEntityErrorData": ".unprocessableentityerror",
}


def dynamic_import(modname, retries=3):
    for attempt in range(retries):
        try:
            return import_module(modname, __package__)
        except KeyError:
            # Clear any half-initialized module and retry
            sys.modules.pop(modname, None)
            if attempt == retries - 1:
                break
    raise KeyError(f"Failed to import module '{modname}' after {retries} attempts")


def __getattr__(attr_name: str) -> object:
    module_name = _dynamic_imports.get(attr_name)
    if module_name is None:
        raise AttributeError(
            f"No {attr_name} found in _dynamic_imports for module name -> {__name__} "
        )

    try:
        module = dynamic_import(module_name)
        result = getattr(module, attr_name)
        return result
    except ImportError as e:
        raise ImportError(
            f"Failed to import {attr_name} from {module_name}: {e}"
        ) from e
    except AttributeError as e:
        raise AttributeError(
            f"Failed to get {attr_name} from {module_name}: {e}"
        ) from e


def __dir__():
    lazy_attrs = builtins.list(_dynamic_imports.keys())
    return builtins.sorted(lazy_attrs)
