package com.atlassian.bitbucket.mesh.git.porcelain;

import com.atlassian.bitbucket.mesh.git.Reflog;
import com.atlassian.bitbucket.mesh.git.ref.Ref;
import com.atlassian.bitbucket.mesh.repository.RepositorySize;
import com.atlassian.bitbucket.mesh.util.SatiableConsumer;

import javax.annotation.Nonnull;
import java.io.IOException;
import java.nio.file.Path;

public interface GitPorcelain {

    /**
     * @param parameters parameters describing what to count
     * @return the repository size
     */
    @Nonnull
    RepositorySize countObjects(@Nonnull CountObjectsParameters parameters);

    /**
     * @param parameters parameters describing the ref to fetch
     */
    void fetchRef(@Nonnull FetchRefParameters parameters);

    /**
     * @param parameters parameters describing which reflogs to stream
     * @param callback   the callback the reflog details should be sent to
     * @throws IOException if an I/O error occurs
     */
    void streamReflogs(@Nonnull StreamReflogsParameters parameters,
                       @Nonnull SatiableConsumer<Reflog> callback) throws IOException;

    /**
     * @param parameters parameters describing which refs to stream
     * @param callback   the callback the refs should be sent to
     */
    void streamRefs(@Nonnull StreamRefsParameters parameters,
                    @Nonnull SatiableConsumer<Ref> callback) throws IOException;

    /**
     * @param parameters parameters describing how the work tree should be created
     * @return the created work tree, <i>which must be cleaned up by the caller</i>
     */
    @Nonnull
    Path workTree(@Nonnull WorkTreeParameters parameters);
}
