from botocore.client import BaseClient, logger

from s3_manager.s3storage.session import s3_client_wrapper


@s3_client_wrapper
def s3_delete_files_mass(s3_client: BaseClient, keys: list[str], s3bucket: str):
    """
    Массовое удаление из S3 хранилища
    """
    if not keys:
        return None

    response = s3_client.delete_objects(
        Bucket=s3bucket,
        Delete={
            "Objects": [{"Key": key} for key in keys],
            "Quiet": True,
        },
    )

    status = (response.get("ResponseMetadata") or dict()).get("HTTPStatusCode")

    logger.info(f"Файлы удалены. Статус ответа от s3 - {status}.")

    return response
