Skip to content

Commit 8be77e8

Browse files
committed
Added getProjectUsers() with search.
1 parent 97884fc commit 8be77e8

File tree

1 file changed

+31
-9
lines changed

1 file changed

+31
-9
lines changed

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

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@
2323

2424
package org.gitlab4j.api;
2525

26+
import java.io.UnsupportedEncodingException;
27+
import java.net.URLEncoder;
28+
import java.util.List;
29+
30+
import javax.ws.rs.core.Form;
31+
import javax.ws.rs.core.GenericType;
32+
import javax.ws.rs.core.Response;
33+
2634
import org.gitlab4j.api.GitLabApi.ApiVersion;
2735
import org.gitlab4j.api.models.Event;
2836
import org.gitlab4j.api.models.Issue;
@@ -33,13 +41,6 @@
3341
import org.gitlab4j.api.models.Snippet;
3442
import org.gitlab4j.api.models.Visibility;
3543

36-
import javax.ws.rs.core.Form;
37-
import javax.ws.rs.core.GenericType;
38-
import javax.ws.rs.core.Response;
39-
import java.io.UnsupportedEncodingException;
40-
import java.net.URLEncoder;
41-
import java.util.List;
42-
4344
/**
4445
* This class provides an entry point to all the GitLab API project calls.
4546
*/
@@ -923,12 +924,33 @@ public void removeMember(Integer projectId, Integer userId) throws GitLabApiExce
923924

924925
/**
925926
* Get a list of project users. This list includes all project members and all users assigned to project parent groups.
927+
*
928+
* GET /projects/:id/users
929+
*
926930
* @param projectId the project ID to get users for
927931
* @return the users belonging to the specified project and its parent groups
928-
* @throws GitLabApiException
932+
* @throws GitLabApiException if any exception occurs
929933
*/
930934
public List<ProjectUser> getProjectUsers(Integer projectId) throws GitLabApiException {
931-
Response response = get(Response.Status.OK, this.getDefaultPerPageParam(), "projects", projectId, "users");
935+
Response response = get(Response.Status.OK, getDefaultPerPageParam(), "projects", projectId, "users");
936+
return (response.readEntity(new GenericType<List<ProjectUser>>() {}));
937+
}
938+
939+
/**
940+
* Get a list of project users matching the specified search string. This list includes all project members and all users assigned to project parent groups.
941+
*
942+
* GET /projects/:id/users
943+
*
944+
* @param projectId the project ID to get users for
945+
* @param search the string to match specific users
946+
* @return the users matching the search string and belonging to the specified project and its parent groups
947+
* @throws GitLabApiException if any exception occurs
948+
*/
949+
public List<ProjectUser> getProjectUsers(Integer projectId, String search) throws GitLabApiException {
950+
GitLabApiForm formData = new GitLabApiForm()
951+
.withParam("search", search)
952+
.withParam(PER_PAGE_PARAM, getDefaultPerPage());
953+
Response response = get(Response.Status.OK, formData.asMap(), "projects", projectId, "users");
932954
return (response.readEntity(new GenericType<List<ProjectUser>>() {}));
933955
}
934956

0 commit comments

Comments
 (0)