11package org .gitlab4j .api ;
22
3- import java .util .List ;
3+ import org .gitlab4j .api .GitLabApi .ApiVersion ;
4+ import org .gitlab4j .api .models .SshKey ;
5+ import org .gitlab4j .api .models .User ;
46
57import javax .ws .rs .core .Form ;
68import javax .ws .rs .core .GenericType ;
79import javax .ws .rs .core .Response ;
8-
9- import org .gitlab4j .api .GitLabApi .ApiVersion ;
10- import org .gitlab4j .api .models .SshKey ;
11- import org .gitlab4j .api .models .User ;
10+ import java .util .List ;
1211
1312/**
1413 * This class provides an entry point to all the GitLab API users calls.
@@ -24,7 +23,7 @@ public class UserApi extends AbstractApi {
2423 *
2524 * GET /users
2625 *
27- * @return a list of Users, this list will only contain the first 20 users in the system.
26+ * @return a list of Users, this list will only contain the first 100 users in the system.
2827 * @throws GitLabApiException if any exception occurs
2928 */
3029 public List <User > getUsers () throws GitLabApiException {
@@ -52,14 +51,112 @@ public List<User> getUsers(int page, int perPage) throws GitLabApiException {
5251 *
5352 * GET /users
5453 *
55- * @param itemsPerPage the number of Project instances that will be fetched per page
54+ * @param itemsPerPage the number of User instances that will be fetched per page
5655 * @return a Pager of User
5756 * @throws GitLabApiException if any exception occurs
5857 */
5958 public Pager <User > getUsers (int itemsPerPage ) throws GitLabApiException {
6059 return (new Pager <User >(this , User .class , itemsPerPage , null , "users" ));
6160 }
6261
62+ /**
63+ * Get a list of active users. Only returns the first page
64+ *
65+ * GET /users?active=true
66+ *
67+ * @return a list of active Users, this list will only contain the first 100 users in the system.
68+ * @throws GitLabApiException if any exception occurs
69+ */
70+ public List <User > getActiveUsers () throws GitLabApiException {
71+ GitLabApiForm formData = new GitLabApiForm ()
72+ .withParam ("active" , true )
73+ .withParam (PER_PAGE_PARAM , getDefaultPerPage ());
74+ Response response = get (Response .Status .OK , formData .asMap (), "users" );
75+ return (response .readEntity (new GenericType <List <User >>() {}));
76+ }
77+
78+ /**
79+ * Get a list of active users using the specified page and per page settings.
80+ *
81+ * GET /users?active=true
82+ *
83+ * @param page the page to get
84+ * @param perPage the number of users per page
85+ * @return the list of active Users in the specified range
86+ * @throws GitLabApiException if any exception occurs
87+ */
88+ public List <User > getActiveUsers (int page , int perPage ) throws GitLabApiException {
89+ GitLabApiForm formData = new GitLabApiForm ()
90+ .withParam ("active" , true )
91+ .withParam (PAGE_PARAM , page )
92+ .withParam (PER_PAGE_PARAM , perPage );
93+ Response response = get (Response .Status .OK , formData .asMap (), "users" );
94+ return (response .readEntity (new GenericType <List <User >>() {}));
95+ }
96+
97+ /**
98+ * Get a Pager of active users.
99+ *
100+ * GET /users?active=true
101+ *
102+ * @param itemsPerPage the number of active User instances that will be fetched per page
103+ * @return a Pager of active User
104+ * @throws GitLabApiException if any exception occurs
105+ */
106+ public Pager <User > getActiveUsers (int itemsPerPage ) throws GitLabApiException {
107+ GitLabApiForm formData = new GitLabApiForm ().withParam ("active" , true );
108+ return (new Pager <User >(this , User .class , itemsPerPage , formData .asMap (), "users" ));
109+ }
110+
111+ /**
112+ * Get a list of blocked users. Only returns the first page
113+ *
114+ * GET /users?blocked=true
115+ *
116+ * @return a list of blocked Users, this list will only contain the first 100 users in the system.
117+ * @throws GitLabApiException if any exception occurs
118+ */
119+ public List <User > getBlockedUsers () throws GitLabApiException {
120+ GitLabApiForm formData = new GitLabApiForm ()
121+ .withParam ("blocked" , true )
122+ .withParam (PER_PAGE_PARAM , getDefaultPerPage ());
123+ Response response = get (Response .Status .OK , formData .asMap (), "users" );
124+ return (response .readEntity (new GenericType <List <User >>() {}));
125+ }
126+
127+ /**
128+ * Get a list of blocked users using the specified page and per page settings.
129+ *
130+ * GET /users?blocked=true
131+ *
132+ * @param page the page to get
133+ * @param perPage the number of users per page
134+ * @return the list of blocked Users in the specified range
135+ * @throws GitLabApiException if any exception occurs
136+ */
137+ public List <User > getblockedUsers (int page , int perPage ) throws GitLabApiException {
138+ GitLabApiForm formData = new GitLabApiForm ()
139+ .withParam ("blocked" , true )
140+ .withParam (PAGE_PARAM , page )
141+ .withParam (PER_PAGE_PARAM , perPage );
142+ Response response = get (Response .Status .OK , formData .asMap (), "users" );
143+ return (response .readEntity (new GenericType <List <User >>() {}));
144+ }
145+
146+ /**
147+ * Get a Pager of blocked users.
148+ *
149+ * GET /users?blocked=true
150+ *
151+ * @param itemsPerPage the number of blocked User instances that will be fetched per page
152+ * @return a Pager of blocked User
153+ * @throws GitLabApiException if any exception occurs
154+ */
155+ public Pager <User > getBlockedUsers (int itemsPerPage ) throws GitLabApiException {
156+ GitLabApiForm formData = new GitLabApiForm ().withParam ("blocked" , true );
157+ return (new Pager <User >(this , User .class , itemsPerPage , formData .asMap (), "users" ));
158+ }
159+
63160 /**
64161 * Get a single user.
65162 *
0 commit comments