use of org.gitlab4j.api.models.User in project choerodon-starters by open-hand.
the class UserApi method getActiveUsers.
/**
* Get a list of active users. Only returns the first page
* <p>
* GET /users?active=true
*
* @return a list of active Users, this list will only contain the first 100 users in the system.
* @throws GitLabApiException if any exception occurs
*/
public List<User> getActiveUsers() throws GitLabApiException {
GitLabApiForm formData = new GitLabApiForm().withParam("active", true).withParam(PER_PAGE_PARAM, getDefaultPerPage());
Response response = get(Response.Status.OK, formData.asMap(), "users");
return (response.readEntity(new GenericType<List<User>>() {
}));
}
use of org.gitlab4j.api.models.User in project choerodon-starters by open-hand.
the class UserApi method findUsers.
/**
* Search users by Email or username in the specified page range.
* <p>
* GET /users?search=:email_or_username
*
* @param emailOrUsername the email or username to search for
* @param page the page to get
* @param perPage the number of users per page
* @return the User List with the email or username like emailOrUsername in the specified page range
* @throws GitLabApiException if any exception occurs
*/
public List<User> findUsers(String emailOrUsername, int page, int perPage) throws GitLabApiException {
GitLabApiForm formData = new GitLabApiForm().withParam("search", emailOrUsername, true).withParam(PAGE_PARAM, page).withParam(PER_PAGE_PARAM, perPage);
Response response = get(Response.Status.OK, formData.asMap(), "users");
return (response.readEntity(new GenericType<List<User>>() {
}));
}
use of org.gitlab4j.api.models.User in project choerodon-starters by open-hand.
the class UserApi method getBlockedUsers.
/**
* Get a list of blocked users. Only returns the first page
* <p>
* GET /users?blocked=true
*
* @return a list of blocked Users, this list will only contain the first 100 users in the system.
* @throws GitLabApiException if any exception occurs
*/
public List<User> getBlockedUsers() throws GitLabApiException {
GitLabApiForm formData = new GitLabApiForm().withParam("blocked", true).withParam(PER_PAGE_PARAM, getDefaultPerPage());
Response response = get(Response.Status.OK, formData.asMap(), "users");
return (response.readEntity(new GenericType<List<User>>() {
}));
}
use of org.gitlab4j.api.models.User in project choerodon-starters by open-hand.
the class GitLabApi method setSudoAsId.
/**
* Sets up all future calls to the GitLab API to be done as another user specified by provided user ID.
* To revert back to normal non-sudo operation you must call unsudo(), or pass null as the sudoAsId.
*
* @param sudoAsId the ID of the user to sudo as, null will turn off sudo
* @throws GitLabApiException if any exception occurs
*/
public void setSudoAsId(Integer sudoAsId) throws GitLabApiException {
if (sudoAsId == null) {
apiClient.setSudoAsId(null);
return;
}
// Get the User specified by the sudoAsId, if you are not an admin or the username is not found, this will fail
User user = getUserApi().getUser(sudoAsId);
if (user == null || !user.getId().equals(sudoAsId)) {
throw new GitLabApiException("the specified user ID was not found");
}
apiClient.setSudoAsId(sudoAsId);
}
Aggregations