Commit 8be77e82 authored by Greg Messner's avatar Greg Messner
Browse files

Added getProjectUsers() with search.

parent 97884fc7
...@@ -23,6 +23,14 @@ ...@@ -23,6 +23,14 @@
package org.gitlab4j.api; package org.gitlab4j.api;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.List;
import javax.ws.rs.core.Form;
import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.Response;
import org.gitlab4j.api.GitLabApi.ApiVersion; import org.gitlab4j.api.GitLabApi.ApiVersion;
import org.gitlab4j.api.models.Event; import org.gitlab4j.api.models.Event;
import org.gitlab4j.api.models.Issue; import org.gitlab4j.api.models.Issue;
...@@ -33,13 +41,6 @@ import org.gitlab4j.api.models.ProjectUser; ...@@ -33,13 +41,6 @@ import org.gitlab4j.api.models.ProjectUser;
import org.gitlab4j.api.models.Snippet; import org.gitlab4j.api.models.Snippet;
import org.gitlab4j.api.models.Visibility; import org.gitlab4j.api.models.Visibility;
import javax.ws.rs.core.Form;
import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.Response;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.List;
/** /**
* This class provides an entry point to all the GitLab API project calls. * This class provides an entry point to all the GitLab API project calls.
*/ */
...@@ -923,12 +924,33 @@ public class ProjectApi extends AbstractApi implements Constants { ...@@ -923,12 +924,33 @@ public class ProjectApi extends AbstractApi implements Constants {
/** /**
* Get a list of project users. This list includes all project members and all users assigned to project parent groups. * Get a list of project users. This list includes all project members and all users assigned to project parent groups.
*
* GET /projects/:id/users
*
* @param projectId the project ID to get users for * @param projectId the project ID to get users for
* @return the users belonging to the specified project and its parent groups * @return the users belonging to the specified project and its parent groups
* @throws GitLabApiException * @throws GitLabApiException if any exception occurs
*/ */
public List<ProjectUser> getProjectUsers(Integer projectId) throws GitLabApiException { public List<ProjectUser> getProjectUsers(Integer projectId) throws GitLabApiException {
Response response = get(Response.Status.OK, this.getDefaultPerPageParam(), "projects", projectId, "users"); Response response = get(Response.Status.OK, getDefaultPerPageParam(), "projects", projectId, "users");
return (response.readEntity(new GenericType<List<ProjectUser>>() {}));
}
/**
* 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.
*
* GET /projects/:id/users
*
* @param projectId the project ID to get users for
* @param search the string to match specific users
* @return the users matching the search string and belonging to the specified project and its parent groups
* @throws GitLabApiException if any exception occurs
*/
public List<ProjectUser> getProjectUsers(Integer projectId, String search) throws GitLabApiException {
GitLabApiForm formData = new GitLabApiForm()
.withParam("search", search)
.withParam(PER_PAGE_PARAM, getDefaultPerPage());
Response response = get(Response.Status.OK, formData.asMap(), "projects", projectId, "users");
return (response.readEntity(new GenericType<List<ProjectUser>>() {})); return (response.readEntity(new GenericType<List<ProjectUser>>() {}));
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment