package com.atlassian.bitbucket.hook.repository;

import com.atlassian.bitbucket.hook.PostReceiveHook;
import com.atlassian.bitbucket.repository.RefChange;
import com.atlassian.bitbucket.auth.AuthenticationContext;

import javax.annotation.Nonnull;
import java.util.Collection;

/**
 * Configured and enabled Repository Hook that is called after a push request is completed.
 * <p>
 * This is used in preference over {@link PostReceiveHook} in circumstances where a standard
 * configuration is required. This hook can also be enabled/disabled at the repository level.
 */
public interface AsyncPostReceiveRepositoryHook extends RepositoryHookImplementor {

    /**
     * Callback method that is called just after a push is completed (or a pull request accepted).
     * This hook executes <i>after</i> the processing of a push and will not block the user client.
     * <p />
     * Despite being asynchronous, the user who initiated this change is still available from
     * {@link AuthenticationContext}.
     *
     * @param context    the context which the hook is being run with
     * @param refChanges the refs that have just been updated
     */
    void postReceive(@Nonnull RepositoryHookContext context, @Nonnull Collection<RefChange> refChanges);
}
