"""
Storage abstraction layer for training data.

Provides a unified interface for local filesystem, Azure Blob Storage, and AWS S3.
"""

from shared.storage.base import (
    FileNotFoundStorageError,
    PresignedUrlNotSupportedError,
    StorageBackend,
    StorageConfig,
    StorageError,
)
from shared.storage.factory import (
    create_storage_backend,
    create_storage_backend_from_env,
    create_storage_backend_from_file,
    get_default_storage_config,
    get_storage_backend,
)
from shared.storage.local import LocalStorageBackend
from shared.storage.prefixes import PREFIXES, StoragePrefixes

__all__ = [
    # Base classes and exceptions
    "StorageBackend",
    "StorageConfig",
    "StorageError",
    "FileNotFoundStorageError",
    "PresignedUrlNotSupportedError",
    # Backends
    "LocalStorageBackend",
    # Factory functions
    "create_storage_backend",
    "create_storage_backend_from_env",
    "create_storage_backend_from_file",
    "get_default_storage_config",
    "get_storage_backend",
    # Path prefixes
    "PREFIXES",
    "StoragePrefixes",
]


# Lazy imports to avoid dependencies when not using specific backends
def __getattr__(name: str):
    if name == "AzureBlobStorageBackend":
        from shared.storage.azure import AzureBlobStorageBackend

        return AzureBlobStorageBackend
    if name == "S3StorageBackend":
        from shared.storage.s3 import S3StorageBackend

        return S3StorageBackend
    if name == "load_storage_config":
        from shared.storage.config_loader import load_storage_config

        return load_storage_config
    raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
