コード例 #1
0
ファイル: Project.Members.cs プロジェクト: Elisavett/GitLab
 public void SetMemberAccessLevel(Member _Member, Member.AccessLevel _AccessLevel)
 {
     if (this.Parent != null)
     {
         Project.UpdateMember(this.Parent.Parent.CurrentConfig, this.Parent, _Member, _AccessLevel);
         RefreshItems();
     }
     else
     {
         throw new GitLabStaticAccessException("Unable to set Access Level without Parent GitLab object");
     }
 }
コード例 #2
0
            /// <summary>
            /// Adds a user to the list of group members.
            /// </summary>
            /// <param name="_Config"></param>
            /// <param name="_Group"></param>
            /// <param name="_User"></param>
            /// <param name="_AccessLevel"></param>
            public static void AddMember(Config _Config, Group _Group, User _User, Member.AccessLevel _AccessLevel)
            {
                string URI = _Config.APIUrl + "groups/" + _Group.id.ToString() + "/members/?user_id=" + _User.id + "&access_level=" + Convert.ToInt64(_AccessLevel);

                HttpResponse <string> R = Unirest.post(URI)
                                          .header("accept", "application/json")
                                          .header("PRIVATE-TOKEN", _Config.APIKey)
                                          .asString();

                if (R.Code < 200 || R.Code >= 300)
                {
                    throw new GitLabServerErrorException(R.Body, R.Code);
                }
            }
コード例 #3
0
            /// <summary>
            /// Updates a project team member to a specified access level.
            /// </summary>
            /// <param name="_Config"></param>
            /// <param name="_Project"></param>
            /// <param name="_User"></param>
            /// <param name="_AccessLevel"></param>
            public static void UpdateMember(Config _Config, Project _Project, User _User, Member.AccessLevel _AccessLevel)
            {
                //OWNER access level only valid for groups according to https://docs.gitlab.com/ce/api/access_requests.html
                if (_AccessLevel > Member.AccessLevel.MASTER)
                {
                    _AccessLevel = Member.AccessLevel.MASTER;
                }

                string URI = _Config.APIUrl + "projects/" + _Project.id.ToString() + "/members/" + _User.id + "&access_level=" + Convert.ToInt64(_AccessLevel);

                HttpResponse <string> R = Unirest.put(URI)
                                          .header("accept", "application/json")
                                          .header("PRIVATE-TOKEN", _Config.APIKey)
                                          .asString();

                if (R.Code < 200 || R.Code >= 300)
                {
                    throw new GitLabServerErrorException(R.Body, R.Code);
                }
            }