#
# This file was generated from the asynchronous client at invenio/transfer/base.py by generate_synchronous_client.sh
# Do not edit this file directly, instead edit the original file and regenerate this file.
#


"""Transfer protocols."""
from __future__ import annotations

from typing import TYPE_CHECKING, Protocol

if TYPE_CHECKING:
    from yarl import URL

    from ....progress import ProgressBar
    from ...connection import SyncConnection
    from ..files import File
    from ..source import DataSource


class Transfer(Protocol):
    """Protocol for transferring files to the repository."""

    def prepare(
        self,
        connection: SyncConnection,
        files_link: URL,
        transfer_payload: dict,
        source: DataSource,
    ) -> None:
        """Prepare the transfer.

        :param connection:              connection to the repository
        :param files_link:              link where the files are to be uploaded
        :param transfer_payload:        extra payload for the transfer, might be freely modified by this method
        """
        ...

    def upload(
        self,
        connection: SyncConnection,
        initialized_upload: File,
        source: DataSource,
        progress_bar: ProgressBar,
    ) -> None:
        """Upload the file.

        :param connection:              connection to the repository
        :param initialized_upload:      initialized upload as returned from the repository
        :param file:                    file to be uploaded
        """
        ...

    def get_commit_payload(self, initialized_upload: File) -> dict:
        """Finalize the successful upload.

        There is no method to discard an unsuccessful upload,
        just use the "delete" operation on the failed file.

        :param initialized_upload:      initialized upload as returned from the repository
        :return:                        metadata of the upload as returned from the repository
        """
        ...

