"""
Конфигурация взаимодействия с S3
"""

from functools import lru_cache

from pydantic_settings import BaseSettings, SettingsConfigDict


class S3Config(BaseSettings):
    """
    S3 main config
    """

    model_config = SettingsConfigDict(env_prefix="APP_S3_")

    ACCESS_KEY: str
    SECRET_KEY: str
    ENDPOINT: str = "http://minio:9000"
    BUCKET: str

    SSL_CA_BUNDLE_PATH: str | None = None


@lru_cache
def get_s3_client_config(params: dict = None) -> S3Config:
    """Получение конфига"""
    if params is None:
        return S3Config()
    return S3Config(**params)


OPERATIONS_NEEDING_MD5_HEADER = {
    "PutObject",
    "DeleteObjects",
    "CopyObject",
    "CompleteMultipartUpload",
    "UploadPart",
}
