package com.atlassian.bitbucket.mirroring.upstream;

import com.atlassian.bitbucket.util.Page;
import com.atlassian.bitbucket.util.PageRequest;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

/**
 * @since 4.3
 */
public interface MirrorService {
    /**
     * @param pageRequest describes the page of mirrors to be retrieved
     * @return a page of mirror servers
     */
    @Nonnull
    Page<MirrorServer> findAll(@Nonnull PageRequest pageRequest);

    /**
     * @param mirrorId the ID of the mirror server
     * @return the mirror, or {@code null} if not found
     */
    @Nullable
    MirrorServer getById(@Nonnull String mirrorId);

    /**
     * @return {@code true} if at least one mirror is connected to the instance, {@code false} otherwise.
     */
    boolean hasAny();

    /**
     * Removes a mirror server
     *
     * @param mirrorId the ID of the mirror server
     */
    void remove(@Nonnull String mirrorId);
}
