public class UserApi extends AbstractApi
Constants.ActionType, Constants.ArchiveFormat, Constants.CommitBuildState, Constants.EpicOrderBy, Constants.GroupOrderBy, Constants.ImpersonationState, Constants.IssueOrderBy, Constants.IssueScope, Constants.IssueState, Constants.JobScope, Constants.LineType, Constants.MergeRequestOrderBy, Constants.MergeRequestScope, Constants.MergeRequestState, Constants.MilestoneState, Constants.PipelineOrderBy, Constants.PipelineScope, Constants.ProjectOrderBy, Constants.SortOrder, Constants.StateEvent, Constants.TargetType, Constants.TokenType
NEXT_PAGE_HEADER, PAGE_HEADER, PAGE_PARAM, PER_PAGE, PER_PAGE_PARAM, PREV_PAGE_HEADER, TOTAL_HEADER, TOTAL_PAGES_HEADER
Modifier and Type | Method and Description |
---|---|
SshKey |
addSshKey(Integer userId,
String title,
String key)
Create new key owned by specified user.
|
SshKey |
addSshKey(String title,
String key)
Creates a new key owned by the currently authenticated user.
|
void |
blockUser(Integer userId)
Blocks the specified user.
|
CustomAttribute |
changeCustomAttribute(Integer userId,
CustomAttribute customAttribute)
Change custom attribute for the given user
|
CustomAttribute |
changeCustomAttribute(Integer userId,
String key,
String value)
Changes custom attribute for the given user
|
CustomAttribute |
createCustomAttribute(Integer userId,
CustomAttribute customAttribute)
Creates custom attribute for the given user
|
CustomAttribute |
createCustomAttribute(Integer userId,
String key,
String value)
Creates custom attribute for the given user
|
ImpersonationToken |
createImpersonationToken(Integer userId,
String name,
Date expiresAt,
ImpersonationToken.Scope[] scopes)
Create an impersonation token.
|
User |
createUser(User user,
CharSequence password,
boolean resetPassword)
Creates a new user.
|
User |
createUser(User user,
CharSequence password,
Integer projectsLimit)
Deprecated.
Will be removed in version 5.0, replaced by
createUser(User, CharSequence, boolean) |
void |
deleteCustomAttribute(Integer userId,
CustomAttribute customAttribute)
Delete a custom attribute for the given user
|
void |
deleteCustomAttribute(Integer userId,
String key)
Delete a custom attribute for the given user
|
void |
deleteSshKey(Integer keyId)
Deletes key owned by currently authenticated user.
|
void |
deleteSshKey(Integer userId,
Integer keyId)
Deletes key owned by a specified user.
|
void |
deleteUser(Integer userId)
Deletes a user.
|
void |
deleteUser(Integer userId,
Boolean hardDelete)
Deletes a user.
|
void |
deleteUser(User user)
Deletes a user.
|
void |
deleteUser(User user,
Boolean hardDelete)
Deletes a user.
|
void |
disableCustomAttributes()
Disables custom attributes to be returned when fetching User instances.
|
void |
enableCustomAttributes()
Enables custom attributes to be returned when fetching User instances.
|
List<User> |
findUsers(String emailOrUsername)
Search users by Email or username
|
Pager<User> |
findUsers(String emailOrUsername,
int itemsPerPage)
Search users by Email or username and return a Pager
|
List<User> |
findUsers(String emailOrUsername,
int page,
int perPage)
Search users by Email or username in the specified page range.
|
List<User> |
getActiveUsers()
Get a list of active users.
|
Pager<User> |
getActiveUsers(int itemsPerPage)
Get a Pager of active users.
|
List<User> |
getActiveUsers(int page,
int perPage)
Get a list of active users using the specified page and per page settings.
|
List<User> |
getBlockedUsers()
Get a list of blocked users.
|
Pager<User> |
getBlockedUsers(int itemsPerPage)
Get a Pager of blocked users.
|
List<User> |
getblockedUsers(int page,
int perPage)
Get a list of blocked users using the specified page and per page settings.
|
User |
getCurrentUser()
Get currently authenticated user.
|
ImpersonationToken |
getImpersonationToken(Integer userId,
Integer tokenId)
Get an impersonation token of a user.
|
List<ImpersonationToken> |
getImpersonationTokens(Integer userId)
Get a list of a specified user's impersonation tokens.
|
List<ImpersonationToken> |
getImpersonationTokens(Integer userId,
Constants.ImpersonationState state)
Get a list of a specified user's impersonation tokens.
|
Optional<ImpersonationToken> |
getOptionalImpersonationToken(Integer userId,
Integer tokenId)
Get an impersonation token of a user as an Optional instance.
|
Optional<SshKey> |
getOptionalSshKey(Integer keyId)
Get a single SSH Key as an Optional instance.
|
Optional<User> |
getOptionalUser(int userId)
Get a single user as an Optional instance.
|
Optional<User> |
getOptionalUser(String username)
Lookup a user by username and return an Optional instance.
|
SshKey |
getSshKey(Integer keyId)
Get a single SSH Key.
|
List<SshKey> |
getSshKeys()
Get a list of currently authenticated user's SSH keys.
|
List<SshKey> |
getSshKeys(Integer userId)
Get a list of a specified user's SSH keys.
|
User |
getUser(int userId)
Get a single user.
|
User |
getUser(String username)
Lookup a user by username.
|
List<User> |
getUsers()
Get a list of users.
|
Pager<User> |
getUsers(int itemsPerPage)
Get a Pager of users.
|
List<User> |
getUsers(int page,
int perPage)
Get a list of users using the specified page and per page settings.
|
User |
modifyUser(User user,
CharSequence password,
Integer projectsLimit)
Deprecated.
Will be removed in version 5.0, replaced by
updateUser(User, CharSequence) |
void |
revokeImpersonationToken(Integer userId,
Integer tokenId)
Revokes an impersonation token.
|
void |
unblockUser(Integer userId)
Unblocks the specified user.
|
User |
updateUser(User user,
CharSequence password)
Modifies an existing user.
|
addFormParam, addFormParam, delete, delete, get, get, getApiClient, getApiVersion, getDefaultPerPage, getDefaultPerPageParam, getDefaultPerPageParam, getGroupIdOrPath, getPageQueryParams, getPageQueryParams, getPerPageQueryParam, getProjectIdOrPath, getUserIdOrUsername, getWithAccepts, handle, head, isApiVersion, post, post, post, post, post, put, put, putWithFormData, upload, upload, urlEncode, validate
public void enableCustomAttributes()
public void disableCustomAttributes()
public List<User> getUsers() throws GitLabApiException
GET /users
GitLabApiException
- if any exception occurspublic List<User> getUsers(int page, int perPage) throws GitLabApiException
GET /users
page
- the page to getperPage
- the number of users per pageGitLabApiException
- if any exception occurspublic Pager<User> getUsers(int itemsPerPage) throws GitLabApiException
GET /users
itemsPerPage
- the number of User instances that will be fetched per pageGitLabApiException
- if any exception occurspublic List<User> getActiveUsers() throws GitLabApiException
GET /users?active=true
GitLabApiException
- if any exception occurspublic List<User> getActiveUsers(int page, int perPage) throws GitLabApiException
GET /users?active=true
page
- the page to getperPage
- the number of users per pageGitLabApiException
- if any exception occurspublic Pager<User> getActiveUsers(int itemsPerPage) throws GitLabApiException
GET /users?active=true
itemsPerPage
- the number of active User instances that will be fetched per pageGitLabApiException
- if any exception occurspublic void blockUser(Integer userId) throws GitLabApiException
POST /users/:id/block
userId
- the ID of the user to blockGitLabApiException
- if any exception occurspublic void unblockUser(Integer userId) throws GitLabApiException
POST /users/:id/unblock
userId
- the ID of the user to unblockGitLabApiException
- if any exception occurspublic List<User> getBlockedUsers() throws GitLabApiException
GET /users?blocked=true
GitLabApiException
- if any exception occurspublic List<User> getblockedUsers(int page, int perPage) throws GitLabApiException
GET /users?blocked=true
page
- the page to getperPage
- the number of users per pageGitLabApiException
- if any exception occurspublic Pager<User> getBlockedUsers(int itemsPerPage) throws GitLabApiException
GET /users?blocked=true
itemsPerPage
- the number of blocked User instances that will be fetched per pageGitLabApiException
- if any exception occurspublic User getUser(int userId) throws GitLabApiException
GET /users/:id
userId
- the ID of the user to getGitLabApiException
- if any exception occurspublic Optional<User> getOptionalUser(int userId)
GET /users/:id
userId
- the ID of the user to getpublic User getUser(String username) throws GitLabApiException
NOTE: This is for admin users only.
GET /users?username=:username
username
- the username of the user to getGitLabApiException
- if any exception occurspublic Optional<User> getOptionalUser(String username)
NOTE: This is for admin users only.
GET /users?username=:username
username
- the username of the user to getpublic List<User> findUsers(String emailOrUsername) throws GitLabApiException
GET /users?search=:email_or_username
emailOrUsername
- the email or username to search forGitLabApiException
- if any exception occurspublic List<User> findUsers(String emailOrUsername, int page, int perPage) throws GitLabApiException
GET /users?search=:email_or_username
emailOrUsername
- the email or username to search forpage
- the page to getperPage
- the number of users per pageGitLabApiException
- if any exception occurspublic Pager<User> findUsers(String emailOrUsername, int itemsPerPage) throws GitLabApiException
GET /users?search=:email_or_username
emailOrUsername
- the email or username to search foritemsPerPage
- the number of Project instances that will be fetched per pageGitLabApiException
- if any exception occurspublic User createUser(User user, CharSequence password, Integer projectsLimit) throws GitLabApiException
createUser(User, CharSequence, boolean)
Creates a new user. Note only administrators can create new users. Either password or reset_password should be specified (reset_password takes priority).
If both the User object's projectsLimit and the parameter projectsLimit is specified the parameter will take precedence.
POST /users
The following properties of the provided User instance can be set during creation:
email (required) - Email
username (required) - Username
name (required) - Name
skype (optional) - Skype ID
linkedin (optional) - LinkedIn
twitter (optional) - Twitter account
websiteUrl (optional) - Website URL
organization (optional) - Organization name
projectsLimit (optional) - Number of projects user can create
externUid (optional) - External UID
provider (optional) - External provider name
bio (optional) - User's biography
location (optional) - User's location
admin (optional) - User is admin - true or false (default)
canCreateGroup (optional) - User can create groups - true or false
skipConfirmation (optional) - Skip confirmation - true or false (default)
external (optional) - Flags the user as external - true or false(default)
sharedRunnersMinutesLimit (optional) - Pipeline minutes quota for this user
user
- the User instance with the user info to createpassword
- the password for the new userprojectsLimit
- the maximum number of projectGitLabApiException
- if any exception occurspublic User createUser(User user, CharSequence password, boolean resetPassword) throws GitLabApiException
Creates a new user. Note only administrators can create new users. Either password or resetPassword should be specified (resetPassword takes priority).
POST /users
The following properties of the provided User instance can be set during creation:
email (required) - Email
username (required) - Username
name (required) - Name
skype (optional) - Skype ID
linkedin (optional) - LinkedIn
twitter (optional) - Twitter account
websiteUrl (optional) - Website URL
organization (optional) - Organization name
projectsLimit (optional) - Number of projects user can create
externUid (optional) - External UID
provider (optional) - External provider name
bio (optional) - User's biography
location (optional) - User's location
admin (optional) - User is admin - true or false (default)
canCreateGroup (optional) - User can create groups - true or false
skipConfirmation (optional) - Skip confirmation - true or false (default)
external (optional) - Flags the user as external - true or false(default)
sharedRunnersMinutesLimit (optional) - Pipeline minutes quota for this user
user
- the User instance with the user info to createpassword
- the password for the new userresetPassword
- whether to send a password reset linkGitLabApiException
- if any exception occurspublic User updateUser(User user, CharSequence password) throws GitLabApiException
Modifies an existing user. Only administrators can change attributes of a user.
PUT /users
The following properties of the provided User instance can be set during update:
email (required) - Email
username (required) - Username
name (required) - Name
skype (optional) - Skype ID
linkedin (optional) - LinkedIn
twitter (optional) - Twitter account
websiteUrl (optional) - Website URL
organization (optional) - Organization name
projectsLimit (optional) - Number of projects user can create
externUid (optional) - External UID
provider (optional) - External provider name
bio (optional) - User's biography
location (optional) - User's location
admin (optional) - User is admin - true or false (default)
canCreateGroup (optional) - User can create groups - true or false
skipConfirmation (optional) - Skip confirmation - true or false (default)
external (optional) - Flags the user as external - true or false(default)
sharedRunnersMinutesLimit (optional) - Pipeline minutes quota for this user
user
- the User instance with the user info to modifypassword
- the new password for the userGitLabApiException
- if any exception occurs@Deprecated public User modifyUser(User user, CharSequence password, Integer projectsLimit) throws GitLabApiException
updateUser(User, CharSequence)
PUT /users/:id
The following properties of the provided User instance can be set during update:
email (required) - Email
username (required) - Username
name (required) - Name
skype (optional) - Skype ID
linkedin (optional) - LinkedIn
twitter (optional) - Twitter account
websiteUrl (optional) - Website URL
organization (optional) - Organization name
projectsLimit (optional) - Number of projects user can create
externUid (optional) - External UID
provider (optional) - External provider name
bio (optional) - User's biography
location (optional) - User's location
admin (optional) - User is admin - true or false (default)
canCreateGroup (optional) - User can create groups - true or false
skipConfirmation (optional) - Skip confirmation - true or false (default)
external (optional) - Flags the user as external - true or false(default)
sharedRunnersMinutesLimit (optional) - Pipeline minutes quota for this user
user
- the User instance with the user info to modifypassword
- the new password for the userprojectsLimit
- the maximum number of projectGitLabApiException
- if any exception occurspublic void deleteUser(Integer userId) throws GitLabApiException
DELETE /users/:id
userId
- the user ID to deleteGitLabApiException
- if any exception occurspublic void deleteUser(Integer userId, Boolean hardDelete) throws GitLabApiException
DELETE /users/:id
userId
- the user ID to deletehardDelete
- If true, contributions that would usually be moved to the
ghost user will be deleted instead, as well as groups owned solely by this userGitLabApiException
- if any exception occurspublic void deleteUser(User user) throws GitLabApiException
DELETE /users/:id
user
- the User instance to deleteGitLabApiException
- if any exception occurspublic void deleteUser(User user, Boolean hardDelete) throws GitLabApiException
DELETE /users/:id
user
- the User instance to deletehardDelete
- If true, contributions that would usually be moved to the
ghost user will be deleted instead, as well as groups owned solely by this userGitLabApiException
- if any exception occurspublic User getCurrentUser() throws GitLabApiException
GET /user
GitLabApiException
- if any exception occurspublic List<SshKey> getSshKeys() throws GitLabApiException
GET /user/keys
GitLabApiException
- if any exception occurspublic List<SshKey> getSshKeys(Integer userId) throws GitLabApiException
GET /users/:id/keys
userId
- the ID of the user to get SSH keys forGitLabApiException
- if any exception occurspublic SshKey getSshKey(Integer keyId) throws GitLabApiException
GET /user/keys/:key_id
keyId
- the ID of the SSH key.GitLabApiException
- if any exception occurspublic Optional<SshKey> getOptionalSshKey(Integer keyId)
GET /user/keys/:key_id
keyId
- the ID of the SSH keypublic SshKey addSshKey(String title, String key) throws GitLabApiException
POST /user/keys
title
- the new SSH Key's titlekey
- the new SSH keyGitLabApiException
- if any exception occurspublic SshKey addSshKey(Integer userId, String title, String key) throws GitLabApiException
POST /users/:id/keys
userId
- the ID of the user to add the SSH key fortitle
- the new SSH Key's titlekey
- the new SSH keyGitLabApiException
- if any exception occurspublic void deleteSshKey(Integer keyId) throws GitLabApiException
DELETE /user/keys/:key_id
keyId
- the key ID to deleteGitLabApiException
- if any exception occurspublic void deleteSshKey(Integer userId, Integer keyId) throws GitLabApiException
DELETE /users/:id/keys/:key_id
userId
- the user ID of the user to delete the key forkeyId
- the key ID to deleteGitLabApiException
- if any exception occurspublic List<ImpersonationToken> getImpersonationTokens(Integer userId) throws GitLabApiException
GET /users/:id/impersonation_tokens
userId
- the ID of the user to get impersonation tokens forGitLabApiException
- if any exception occurspublic List<ImpersonationToken> getImpersonationTokens(Integer userId, Constants.ImpersonationState state) throws GitLabApiException
GET /users/:id/impersonation_tokens
userId
- the ID of the user to get impersonation tokens forstate
- the state of impersonation tokens to list (ALL, ACTIVE, INACTIVE)GitLabApiException
- if any exception occurspublic ImpersonationToken getImpersonationToken(Integer userId, Integer tokenId) throws GitLabApiException
GET /users/:user_id/impersonation_tokens/:impersonation_token_id
userId
- the ID of the user to get SSH keys fortokenId
- the impersonation token ID to getGitLabApiException
- if any exception occurspublic Optional<ImpersonationToken> getOptionalImpersonationToken(Integer userId, Integer tokenId)
GET /users/:user_id/impersonation_tokens/:impersonation_token_id
userId
- the ID of the user to get SSH keys fortokenId
- the impersonation token ID to getpublic ImpersonationToken createImpersonationToken(Integer userId, String name, Date expiresAt, ImpersonationToken.Scope[] scopes) throws GitLabApiException
POST /users/:user_id/impersonation_tokens
userId
- the ID of the user to get SSH keys forname
- the name of the impersonation token, requiredexpiresAt
- the expiration date of the impersonation token, optionalscopes
- an array of scopes of the impersonation tokenGitLabApiException
- if any exception occurspublic void revokeImpersonationToken(Integer userId, Integer tokenId) throws GitLabApiException
DELETE /users/:user_id/impersonation_tokens/:impersonation_token_id
userId
- the user ID of the user to revoke the impersonation token fortokenId
- the impersonation token ID to revokeGitLabApiException
- if any exception occurspublic CustomAttribute createCustomAttribute(Integer userId, CustomAttribute customAttribute) throws GitLabApiException
userId
- to set the customAttributes forcustomAttribute
- to setGitLabApiException
- on failure while setting customAttributespublic CustomAttribute createCustomAttribute(Integer userId, String key, String value) throws GitLabApiException
userId
- to set the customAttributes forkey
- for the customAttributevalue
- for the customAttributeGitLabApiException
- on failure while setting customAttributespublic CustomAttribute changeCustomAttribute(Integer userId, CustomAttribute customAttribute) throws GitLabApiException
userId
- to change the customAttributes forcustomAttribute
- to changeGitLabApiException
- on failure while changing customAttributespublic CustomAttribute changeCustomAttribute(Integer userId, String key, String value) throws GitLabApiException
userId
- to change the customAttribute forkey
- for the customAttributevalue
- for the customAttributeGitLabApiException
- on failure while changing customAttributespublic void deleteCustomAttribute(Integer userId, CustomAttribute customAttribute) throws GitLabApiException
userId
- to delete the customAttribute forcustomAttribute
- to removeGitLabApiException
- on failure while deleting customAttributespublic void deleteCustomAttribute(Integer userId, String key) throws GitLabApiException
userId
- to delete the customAttribute forkey
- of the customAttribute to removeGitLabApiException
- on failure while deleting customAttributesCopyright © 2018. All rights reserved.