/// <summary>
            /// List all users that the current user can see
            /// </summary>
            /// <param name="_Config">A GitLab.NET Configuration object</param>
            /// <returns></returns>
            public static List <User> List(Config _Config, GitLab _Parent = null)
            {
                List <User> RetVal = new List <User>();

                try
                {
                    int         page  = 1;
                    List <User> users = new List <User>();

                    do
                    {
                        users.Clear();

                        string URI = _Config.APIUrl + "users?per_page=100" + "&page=" + page.ToString();

                        HttpResponse <string> R = Unirest.get(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);
                        }
                        else
                        {
                            dynamic Result = JsonConvert.DeserializeObject(R.Body);
                            if (Result is JArray)
                            {
                                JArray ResultArray = (JArray)Result;
                                foreach (JToken Token in ResultArray)
                                {
                                    User U = JsonConvert.DeserializeObject <User>(Token.ToString());
                                    U.SetParent(_Parent);
                                    users.Add(U);
                                }
                            }
                        }
                        page++;
                        RetVal.AddRange(users);
                    }while (users.Count > 0 & page < 100);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                return(RetVal);
            }
Exemple #2
0
 /// <summary>
 /// Sets the parent GitLab object of this Project.
 /// </summary>
 /// <param name="_parent"></param>
 internal void SetParent(GitLab _parent)
 {
     _Parent = _parent;
 }