package com.atlassian.bitbucket.internal.mirroring.upstream;

import com.atlassian.bitbucket.internal.mirroring.MirroringRequest;

import javax.annotation.Nonnull;

/**
 * Helper to manage interaction with atlassian-connect add-ons for coupled mirror instances.
 */
public interface MirrorAddonManager {

    /**
     * Installs an atlassian-connect add-on for the mirror instance described in the {@code request}
     *
     * @param request the request describing the mirror server to be installed as an add-on
     * @return information about the connect add-on that was installed
     * @throws com.atlassian.bitbucket.mirroring.upstream.MirrorIntegrationFailedException when the add-on installation
     *         fails
     */
    @Nonnull
    MirrorAddon install(@Nonnull MirroringRequest request);

    /**
     * @param addonKey the add-on key to check
     * @return {@code true} if the add-on is installed
     */
    boolean isInstalled(@Nonnull String addonKey);

    /**
     * Uninstalls the connect add-on for the mirror
     *
     * @param mirror the mirror to uninstall
     */
    void uninstall(@Nonnull InternalMirrorServer mirror);
}
