Skip to content

Commit 6a3839b

Browse files
authored
Add "approve" and "reject" user methods (#1007)
Fixes #1006
1 parent a3ab79b commit 6a3839b

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/main/java/org/gitlab4j/api/UserApi.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,36 @@ public Stream<User> getActiveUsersStream() throws GitLabApiException {
169169
return (getActiveUsers(getDefaultPerPage()).stream());
170170
}
171171

172+
/**
173+
* Approves the specified user. Available only for admin.
174+
*
175+
* <pre><code>GitLab Endpoint: POST /users/:id/approve</code></pre>
176+
*
177+
* @param userId the ID of the user to approve
178+
* @throws GitLabApiException if any exception occurs
179+
*/
180+
public void approveUser(Long userId) throws GitLabApiException {
181+
if (userId == null) {
182+
throw new RuntimeException("userId cannot be null");
183+
}
184+
post(Response.Status.CREATED, (Form) null, "users", userId, "approve");
185+
}
186+
187+
/**
188+
* Rejects specified user that is pending approval. Available only for administrators.
189+
*
190+
* <pre><code>GitLab Endpoint: POST /users/:id/reject</code></pre>
191+
*
192+
* @param userId the ID of the user to reject
193+
* @throws GitLabApiException if any exception occurs
194+
*/
195+
public void rejectUser(Long userId) throws GitLabApiException {
196+
if (userId == null) {
197+
throw new RuntimeException("userId cannot be null");
198+
}
199+
post(Response.Status.OK, (Form) null, "users", userId, "reject");
200+
}
201+
172202
/**
173203
* Blocks the specified user. Available only for admin.
174204
*

0 commit comments

Comments
 (0)