/// <summary>
        /// Specify teams (in addition to Administrators) allowed to push to this branch. Required status checks will still prevent these people from merging if the checks fail
        /// </summary>
        /// <param name="teams">Teams allowed to push to this branch</param>
        public BranchProtectionPushRestrictionsUpdate(BranchProtectionTeamCollection teams)
        {
            Ensure.ArgumentNotNull(teams, "teams");

            Teams = teams;
            Users = new BranchProtectionUserCollection();
        }
        /// <summary>
        /// Restrict dismissing reviews to the specified people (in addition to Administrators).
        /// </summary>
        /// <param name="users">Users allowed to dismiss reviews</param>
        public BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(BranchProtectionUserCollection users)
        {
            Ensure.ArgumentNotNull(users, nameof(users));

            Teams = new BranchProtectionTeamCollection();
            Users = users;
        }
        /// <summary>
        /// Specify people (in addition to Administrators) allowed to push to this branch. Required status checks will still prevent these people from merging if the checks fail
        /// </summary>
        /// <param name="users">Users allowed to push to this branch</param>
        public BranchProtectionPushRestrictionsUpdate(BranchProtectionUserCollection users)
        {
            Ensure.ArgumentNotNull(users, nameof(users));

            Teams = new BranchProtectionTeamCollection();
            Users = users;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Restrict dismissing reviews to the specified teams (in addition to Administrators).
        /// </summary>
        /// <param name="teams">Teams allowed to dismiss reviews</param>
        public BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(BranchProtectionTeamCollection teams)
        {
            Ensure.ArgumentNotNull(teams, "teams");

            Teams = teams;
            Users = new BranchProtectionUserCollection();
        }
        /// <summary>
        /// Specify teams and/or people (in addition to Administrators) allowed to push to this branch. Required status checks will still prevent these people from merging if the checks fail
        /// </summary>
        /// <param name="teams">Teams allowed to push to this branch</param>
        /// <param name="users">Users allowed to push to this branch</param>
        public BranchProtectionPushRestrictionsUpdate(BranchProtectionTeamCollection teams, BranchProtectionUserCollection users)
        {
            Ensure.ArgumentNotNull(teams, "teams");
            Ensure.ArgumentNotNull(users, "users");

            Teams = teams;
            Users = users;
        }
 /// <summary>
 /// Specify whether dismissing reviews is restricted or not
 /// </summary>
 /// <param name="enabled">True to restrict review dismissal to Administrators, false to disable restrictions</param>
 public BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(bool enabled)
 {
     if (enabled)
     {
         // Empty Teams/Users list means restrictions are enabled with only Admins being able to dismiss reviews
         Teams = new BranchProtectionTeamCollection();
         Users = new BranchProtectionUserCollection();
     }
     else
     {
         // To disable the review dismissal restriction, the API requires an object with empty members to be passed
         Teams = null;
         Users = null;
     }
 }
 /// <summary>
 /// Specify only administrators are allowed to push to this branch. Required status checks will still prevent these people from merging if the checks fail
 /// </summary>
 public BranchProtectionPushRestrictionsUpdate()
 {
     Teams = new BranchProtectionTeamCollection();
     Users = new BranchProtectionUserCollection();
 }
        /// <summary>
        /// Remove user restrictions for the specified branch (applies only to Organization owned repositories)
        /// </summary>
        /// <remarks>
        /// See the <a href="https://developer.github.com/v3/repos/branches/#remove-user-restrictions-of-protected-branch">API documentation</a> for more details
        /// </remarks>
        /// <param name="repositoryId">The Id of the repository</param>
        /// <param name="branch">The name of the branch</param>
        /// <param name="users">List of users with push access to remove</param>
        public Task <IReadOnlyList <User> > DeleteProtectedBranchUserRestrictions(long repositoryId, string branch, BranchProtectionUserCollection users)
        {
            Ensure.ArgumentNotNullOrEmptyString(branch, "branch");
            Ensure.ArgumentNotNull(users, "users");

            return(ApiConnection.Delete <IReadOnlyList <User> >(ApiUrls.RepoRestrictionsUsers(repositoryId, branch), users, AcceptHeaders.ProtectedBranchesApiPreview));
        }
        /// <summary>
        /// Add user restrictions for the specified branch (applies only to Organization owned repositories)
        /// </summary>
        /// <remarks>
        /// See the <a href="https://developer.github.com/v3/repos/branches/#add-user-restrictions-of-protected-branch">API documentation</a> for more details
        /// </remarks>
        /// <param name="owner">The owner of the repository</param>
        /// <param name="name">The name of the repository</param>
        /// <param name="branch">The name of the branch</param>
        /// <param name="users">List of users with push access to add</param>
        public Task <IReadOnlyList <User> > AddProtectedBranchUserRestrictions(string owner, string name, string branch, BranchProtectionUserCollection users)
        {
            Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
            Ensure.ArgumentNotNullOrEmptyString(name, "name");
            Ensure.ArgumentNotNullOrEmptyString(branch, "branch");
            Ensure.ArgumentNotNull(users, "users");

            return(ApiConnection.Post <IReadOnlyList <User> >(ApiUrls.RepoRestrictionsUsers(owner, name, branch), users, AcceptHeaders.ProtectedBranchesApiPreview));
        }