package com.atlassian.bitbucket.internal.defaultreviewers;

import com.atlassian.bitbucket.internal.defaultreviewers.model.PullRequestCondition;
import com.atlassian.bitbucket.repository.Ref;
import com.atlassian.bitbucket.repository.Repository;
import com.atlassian.bitbucket.repository.ref.restriction.RefMatcher;
import com.atlassian.bitbucket.user.ApplicationUser;
import com.atlassian.bitbucket.util.Page;
import com.atlassian.bitbucket.util.PageRequest;

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

/**
 * Service that provides a way to get and set reviewers that have been designated as
 * default reviewers for pull requests in a repository.
 *
 * @since 1.0
 */
public interface PullRequestConditionService {

    @Nonnull
    Page<PullRequestCondition> getPullRequestConditions(@Nonnull Repository repository, @Nonnull PageRequest pageRequest);

    @Nonnull
    Set<ApplicationUser> getReviewers(@Nonnull Repository repository, @Nonnull Ref fromRef, @Nonnull Ref toRef);

    @Nonnull
    PullRequestCondition createPullRequestCondition(@Nonnull Repository repository,
                                                    @Nonnull RefMatcher sourceMatcher,
                                                    @Nonnull RefMatcher targetMatcher,
                                                    @Nonnull Collection<ApplicationUser> reviewers,
                                                    @Nonnull Integer requiredApprovals);

    @Nonnull
    PullRequestCondition updatePullRequestCondition(int pullRequestConditionId,
                                                    @Nonnull Repository newRepository,
                                                    @Nonnull RefMatcher newSourceMatcher,
                                                    @Nonnull RefMatcher newTargetMatcher,
                                                    @Nonnull Collection<ApplicationUser> newReviewers,
                                                    @Nonnull Integer newRequiredApprovals);

    void removePullRequestCondition(Repository repository, int pullRequestConditionId);

}