from typing import Any

from botocore.client import BaseClient

from s3_manager.s3storage.session import s3_client_wrapper


@s3_client_wrapper
def s3_get_list(s3_client: BaseClient, folder_path: str, s3bucket: str) -> list[Any]:
    """
    Получить список файлов
    """
    paginator = s3_client.get_paginator("list_objects")
    prefix = folder_path if folder_path.endswith("/") else f"{folder_path}/"

    paginate_iterator = paginator.paginate(Bucket=s3bucket, Prefix=prefix)

    return [prefix for prefix in paginate_iterator.search("Contents")]
