|
23 | 23 |
|
24 | 24 | package org.gitlab4j.api; |
25 | 25 |
|
| 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 | + |
26 | 34 | import org.gitlab4j.api.GitLabApi.ApiVersion; |
27 | 35 | import org.gitlab4j.api.models.Event; |
28 | 36 | import org.gitlab4j.api.models.Issue; |
|
33 | 41 | import org.gitlab4j.api.models.Snippet; |
34 | 42 | import org.gitlab4j.api.models.Visibility; |
35 | 43 |
|
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 | | - |
43 | 44 | /** |
44 | 45 | * This class provides an entry point to all the GitLab API project calls. |
45 | 46 | */ |
@@ -923,12 +924,33 @@ public void removeMember(Integer projectId, Integer userId) throws GitLabApiExce |
923 | 924 |
|
924 | 925 | /** |
925 | 926 | * 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 | + * |
926 | 930 | * @param projectId the project ID to get users for |
927 | 931 | * @return the users belonging to the specified project and its parent groups |
928 | | - * @throws GitLabApiException |
| 932 | + * @throws GitLabApiException if any exception occurs |
929 | 933 | */ |
930 | 934 | 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"); |
932 | 954 | return (response.readEntity(new GenericType<List<ProjectUser>>() {})); |
933 | 955 | } |
934 | 956 |
|
|
0 commit comments