Class UserApi
- java.lang.Object
-
- org.gitlab4j.api.AbstractApi
-
- org.gitlab4j.api.UserApi
-
- All Implemented Interfaces:
Constants
public class UserApi extends AbstractApi
This class provides an entry point to all the GitLab API users calls.- See Also:
- Users API at GitLab
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.gitlab4j.api.Constants
Constants.ActionType, Constants.ApplicationScope, Constants.ArchiveFormat, Constants.CommitBuildState, Constants.Encoding, 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
-
-
Field Summary
-
Fields inherited from interface org.gitlab4j.api.Constants
NEXT_PAGE_HEADER, PAGE_HEADER, PAGE_PARAM, PER_PAGE, PER_PAGE_PARAM, PREV_PAGE_HEADER, TOTAL_HEADER, TOTAL_PAGES_HEADER
-
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Email
addEmail(Object userIdOrUsername, String email, Boolean skipConfirmation)
Add an email to the user's emails.Email
addEmail(String email)
Add an email to the current user's emails.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(Object userIdOrUsername, String key, String value)
Changes custom attribute for the given userCustomAttribute
changeCustomAttribute(Object userIdOrUsername, CustomAttribute customAttribute)
Change custom attribute for the given userCustomAttribute
createCustomAttribute(Object userIdOrUsername, String key, String value)
Creates custom attribute for the given userCustomAttribute
createCustomAttribute(Object userIdOrUsername, CustomAttribute customAttribute)
Creates custom attribute for the given userImpersonationToken
createImpersonationToken(Object userIdOrUsername, 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 bycreateUser(User, CharSequence, boolean)
void
deleteCustomAttribute(Object userIdOrUsername, String key)
Delete a custom attribute for the given uservoid
deleteCustomAttribute(Object userIdOrUsername, CustomAttribute customAttribute)
Delete a custom attribute for the given uservoid
deleteEmail(Long emailId)
Deletes an email belonging to the current user.void
deleteEmail(Object userIdOrUsername, Long emailId)
Deletes a user's emailvoid
deleteSshKey(Integer keyId)
Deletes key owned by currently authenticated user.void
deleteSshKey(Object userIdOrUsername, Integer keyId)
Deletes key owned by a specified user.void
deleteUser(Object userIdOrUsername)
Deletes a user.void
deleteUser(Object userIdOrUsername, 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 usernamePager<User>
findUsers(String emailOrUsername, int itemsPerPage)
Search users by Email or username and return a PagerList<User>
findUsers(String emailOrUsername, int page, int perPage)
Search users by Email or username in the specified page range.Stream<User>
findUsersStream(String emailOrUsername)
Search users by Email or username.List<User>
getActiveUsers()
Get a list of active usersPager<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.Stream<User>
getActiveUsersStream()
Get a Stream of active usersList<User>
getblockedUsers(int page, int perPage)
Get a list of blocked 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.Stream<User>
getBlockedUsersStream()
Get a Stream of blocked users.User
getCurrentUser()
Get currently authenticated user.Email
getEmail(Long emailId)
Get a single Email instance specified by he email IDList<Email>
getEmails()
Get a list of emails for the current user.List<Email>
getEmails(Object userIdOrUsername)
Get a list of a specified user’s emails.ImpersonationToken
getImpersonationToken(Object userIdOrUsername, Integer tokenId)
Get an impersonation token of a user.List<ImpersonationToken>
getImpersonationTokens(Object userIdOrUsername)
Get a list of a specified user's impersonation tokens.List<ImpersonationToken>
getImpersonationTokens(Object userIdOrUsername, Constants.ImpersonationState state)
Get a list of a specified user's impersonation tokens.Optional<ImpersonationToken>
getOptionalImpersonationToken(Object userIdOrUsername, 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(Integer 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(Integer 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.Stream<User>
getUsersStream()
Get a Stream of users.User
modifyUser(User user, CharSequence password, Integer projectsLimit)
Deprecated.Will be removed in version 5.0, replaced byupdateUser(User, CharSequence)
void
revokeImpersonationToken(Object userIdOrUsername, Integer tokenId)
Revokes an impersonation token.User
setUserAvatar(Object userIdOrUsername, File avatarFile)
Uploads and sets the user's avatar for the specified user.void
unblockUser(Integer userId)
Unblocks the specified user.User
updateUser(User user, CharSequence password)
Modifies an existing user.-
Methods inherited from class org.gitlab4j.api.AbstractApi
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, putUpload, putUpload, putWithFormData, upload, upload, upload, urlEncode, validate
-
-
-
-
Method Detail
-
enableCustomAttributes
public void enableCustomAttributes()
Enables custom attributes to be returned when fetching User instances.
-
disableCustomAttributes
public void disableCustomAttributes()
Disables custom attributes to be returned when fetching User instances.
-
getUsers
public List<User> getUsers() throws GitLabApiException
Get a list of users.GitLab Endpoint: GET /users
- Returns:
- a list of Users
- Throws:
GitLabApiException
- if any exception occurs
-
getUsers
public List<User> getUsers(int page, int perPage) throws GitLabApiException
Get a list of users using the specified page and per page settings.GitLab Endpoint: GET /users
- Parameters:
page
- the page to getperPage
- the number of users per page- Returns:
- the list of Users in the specified range
- Throws:
GitLabApiException
- if any exception occurs
-
getUsers
public Pager<User> getUsers(int itemsPerPage) throws GitLabApiException
Get a Pager of users.GitLab Endpoint: GET /users
- Parameters:
itemsPerPage
- the number of User instances that will be fetched per page- Returns:
- a Pager of User
- Throws:
GitLabApiException
- if any exception occurs
-
getUsersStream
public Stream<User> getUsersStream() throws GitLabApiException
Get a Stream of users.GitLab Endpoint: GET /users
- Returns:
- a Stream of Users.
- Throws:
GitLabApiException
- if any exception occurs
-
getActiveUsers
public List<User> getActiveUsers() throws GitLabApiException
Get a list of active usersGitLab Endpoint: GET /users?active=true
- Returns:
- a list of active Users
- Throws:
GitLabApiException
- if any exception occurs
-
getActiveUsers
public List<User> getActiveUsers(int page, int perPage) throws GitLabApiException
Get a list of active users using the specified page and per page settings.GitLab Endpoint: GET /users?active=true
- Parameters:
page
- the page to getperPage
- the number of users per page- Returns:
- the list of active Users in the specified range
- Throws:
GitLabApiException
- if any exception occurs
-
getActiveUsers
public Pager<User> getActiveUsers(int itemsPerPage) throws GitLabApiException
Get a Pager of active users.GitLab Endpoint: GET /users?active=true
- Parameters:
itemsPerPage
- the number of active User instances that will be fetched per page- Returns:
- a Pager of active User
- Throws:
GitLabApiException
- if any exception occurs
-
getActiveUsersStream
public Stream<User> getActiveUsersStream() throws GitLabApiException
Get a Stream of active usersGitLab Endpoint: GET /users?active=true
- Returns:
- a Stream of active Users
- Throws:
GitLabApiException
- if any exception occurs
-
blockUser
public void blockUser(Integer userId) throws GitLabApiException
Blocks the specified user. Available only for admin.GitLab Endpoint: POST /users/:id/block
- Parameters:
userId
- the ID of the user to block- Throws:
GitLabApiException
- if any exception occurs
-
unblockUser
public void unblockUser(Integer userId) throws GitLabApiException
Unblocks the specified user. Available only for admin.GitLab Endpoint: POST /users/:id/unblock
- Parameters:
userId
- the ID of the user to unblock- Throws:
GitLabApiException
- if any exception occurs
-
getBlockedUsers
public List<User> getBlockedUsers() throws GitLabApiException
Get a list of blocked users.GitLab Endpoint: GET /users?blocked=true
- Returns:
- a list of blocked Users
- Throws:
GitLabApiException
- if any exception occurs
-
getblockedUsers
public List<User> getblockedUsers(int page, int perPage) throws GitLabApiException
Get a list of blocked users using the specified page and per page settings.GitLab Endpoint: GET /users?blocked=true
- Parameters:
page
- the page to getperPage
- the number of users per page- Returns:
- the list of blocked Users in the specified range
- Throws:
GitLabApiException
- if any exception occurs
-
getBlockedUsers
public Pager<User> getBlockedUsers(int itemsPerPage) throws GitLabApiException
Get a Pager of blocked users.GitLab Endpoint: GET /users?blocked=true
- Parameters:
itemsPerPage
- the number of blocked User instances that will be fetched per page- Returns:
- a Pager of blocked User
- Throws:
GitLabApiException
- if any exception occurs
-
getBlockedUsersStream
public Stream<User> getBlockedUsersStream() throws GitLabApiException
Get a Stream of blocked users.GitLab Endpoint: GET /users?blocked=true
- Returns:
- a Stream of blocked Users
- Throws:
GitLabApiException
- if any exception occurs
-
getUser
public User getUser(Integer userId) throws GitLabApiException
Get a single user.GitLab Endpoint: GET /users/:id
- Parameters:
userId
- the ID of the user to get- Returns:
- the User instance for the specified user ID
- Throws:
GitLabApiException
- if any exception occurs
-
getOptionalUser
public Optional<User> getOptionalUser(Integer userId)
Get a single user as an Optional instance.GitLab Endpoint: GET /users/:id
- Parameters:
userId
- the ID of the user to get- Returns:
- the User for the specified user ID as an Optional instance
-
getUser
public User getUser(String username) throws GitLabApiException
Lookup a user by username. Returns null if not found.NOTE: This is for admin users only.
GitLab Endpoint: GET /users?username=:username
- Parameters:
username
- the username of the user to get- Returns:
- the User instance for the specified username, or null if not found
- Throws:
GitLabApiException
- if any exception occurs
-
getOptionalUser
public Optional<User> getOptionalUser(String username)
Lookup a user by username and return an Optional instance.NOTE: This is for admin users only.
GitLab Endpoint: GET /users?username=:username
- Parameters:
username
- the username of the user to get- Returns:
- the User for the specified username as an Optional instance
-
findUsers
public List<User> findUsers(String emailOrUsername) throws GitLabApiException
Search users by Email or usernameGitLab Endpoint: GET /users?search=:email_or_username
- Parameters:
emailOrUsername
- the email or username to search for- Returns:
- the User List with the email or username like emailOrUsername
- Throws:
GitLabApiException
- if any exception occurs
-
findUsers
public List<User> findUsers(String emailOrUsername, int page, int perPage) throws GitLabApiException
Search users by Email or username in the specified page range.GitLab Endpoint: GET /users?search=:email_or_username
- Parameters:
emailOrUsername
- the email or username to search forpage
- the page to getperPage
- the number of users per page- Returns:
- the User List with the email or username like emailOrUsername in the specified page range
- Throws:
GitLabApiException
- if any exception occurs
-
findUsers
public Pager<User> findUsers(String emailOrUsername, int itemsPerPage) throws GitLabApiException
Search users by Email or username and return a PagerGitLab Endpoint: GET /users?search=:email_or_username
- Parameters:
emailOrUsername
- the email or username to search foritemsPerPage
- the number of Project instances that will be fetched per page- Returns:
- the User Pager with the email or username like emailOrUsername
- Throws:
GitLabApiException
- if any exception occurs
-
findUsersStream
public Stream<User> findUsersStream(String emailOrUsername) throws GitLabApiException
Search users by Email or username.GitLab Endpoint: GET /users?search=:email_or_username
- Parameters:
emailOrUsername
- the email or username to search for- Returns:
- a Stream of User instances with the email or username like emailOrUsername
- Throws:
GitLabApiException
- if any exception occurs
-
createUser
public User createUser(User user, CharSequence password, Integer projectsLimit) throws GitLabApiException
Deprecated.Will be removed in version 5.0, replaced bycreateUser(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.
GitLab Endpoint: 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
- Parameters:
user
- the User instance with the user info to createpassword
- the password for the new userprojectsLimit
- the maximum number of project- Returns:
- created User instance
- Throws:
GitLabApiException
- if any exception occurs
-
createUser
public 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).
GitLab Endpoint: 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
- Parameters:
user
- the User instance with the user info to createpassword
- the password for the new userresetPassword
- whether to send a password reset link- Returns:
- created User instance
- Throws:
GitLabApiException
- if any exception occurs
-
updateUser
public User updateUser(User user, CharSequence password) throws GitLabApiException
Modifies an existing user. Only administrators can change attributes of a user.
GitLab Endpoint: 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
- Parameters:
user
- the User instance with the user info to modifypassword
- the new password for the user- Returns:
- the modified User instance
- Throws:
GitLabApiException
- if any exception occurs
-
modifyUser
@Deprecated public User modifyUser(User user, CharSequence password, Integer projectsLimit) throws GitLabApiException
Deprecated.Will be removed in version 5.0, replaced byupdateUser(User, CharSequence)
Modifies an existing user. Only administrators can change attributes of a user.GitLab Endpoint: 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
- Parameters:
user
- the User instance with the user info to modifypassword
- the new password for the userprojectsLimit
- the maximum number of project- Returns:
- the modified User instance
- Throws:
GitLabApiException
- if any exception occurs
-
deleteUser
public void deleteUser(Object userIdOrUsername) throws GitLabApiException
Deletes a user. Available only for administrators.GitLab Endpoint: DELETE /users/:id
- Parameters:
userIdOrUsername
- the user in the form of an Integer(ID), String(username), or User instance- Throws:
GitLabApiException
- if any exception occurs
-
deleteUser
public void deleteUser(Object userIdOrUsername, Boolean hardDelete) throws GitLabApiException
Deletes a user. Available only for administrators.GitLab Endpoint: DELETE /users/:id
- Parameters:
userIdOrUsername
- the user in the form of an Integer(ID), String(username), or User instancehardDelete
- If true, contributions that would usually be moved to the ghost user will be deleted instead, as well as groups owned solely by this user- Throws:
GitLabApiException
- if any exception occurs
-
getCurrentUser
public User getCurrentUser() throws GitLabApiException
Get currently authenticated user.GitLab Endpoint: GET /user
- Returns:
- the User instance for the currently authenticated user
- Throws:
GitLabApiException
- if any exception occurs
-
getSshKeys
public List<SshKey> getSshKeys() throws GitLabApiException
Get a list of currently authenticated user's SSH keys.GitLab Endpoint: GET /user/keys
- Returns:
- a list of currently authenticated user's SSH keys
- Throws:
GitLabApiException
- if any exception occurs
-
getSshKeys
public List<SshKey> getSshKeys(Integer userId) throws GitLabApiException
Get a list of a specified user's SSH keys. Available only for admin users.GitLab Endpoint: GET /users/:id/keys
- Parameters:
userId
- the user ID to get the SSH keys for- Returns:
- a list of a specified user's SSH keys
- Throws:
GitLabApiException
- if any exception occurs
-
getSshKey
public SshKey getSshKey(Integer keyId) throws GitLabApiException
Get a single SSH Key.GitLab Endpoint: GET /user/keys/:key_id
- Parameters:
keyId
- the ID of the SSH key.- Returns:
- an SshKey instance holding the info on the SSH key specified by keyId
- Throws:
GitLabApiException
- if any exception occurs
-
getOptionalSshKey
public Optional<SshKey> getOptionalSshKey(Integer keyId)
Get a single SSH Key as an Optional instance.GitLab Endpoint: GET /user/keys/:key_id
- Parameters:
keyId
- the ID of the SSH key- Returns:
- an SshKey as an Optional instance holding the info on the SSH key specified by keyId
-
addSshKey
public SshKey addSshKey(String title, String key) throws GitLabApiException
Creates a new key owned by the currently authenticated user.GitLab Endpoint: POST /user/keys
- Parameters:
title
- the new SSH Key's titlekey
- the new SSH key- Returns:
- an SshKey instance with info on the added SSH key
- Throws:
GitLabApiException
- if any exception occurs
-
addSshKey
public SshKey addSshKey(Integer userId, String title, String key) throws GitLabApiException
Create new key owned by specified user. Available only for admin users.GitLab Endpoint: POST /users/:id/keys
- Parameters:
userId
- the ID of the user to add the SSH key fortitle
- the new SSH Key's titlekey
- the new SSH key- Returns:
- an SshKey instance with info on the added SSH key
- Throws:
GitLabApiException
- if any exception occurs
-
deleteSshKey
public void deleteSshKey(Integer keyId) throws GitLabApiException
Deletes key owned by currently authenticated user. This is an idempotent function and calling it on a key that is already deleted or not available results in success.GitLab Endpoint: DELETE /user/keys/:key_id
- Parameters:
keyId
- the key ID to delete- Throws:
GitLabApiException
- if any exception occurs
-
deleteSshKey
public void deleteSshKey(Object userIdOrUsername, Integer keyId) throws GitLabApiException
Deletes key owned by a specified user. Available only for admin users.GitLab Endpoint: DELETE /users/:id/keys/:key_id
- Parameters:
userIdOrUsername
- the user in the form of an Integer(ID), String(username), or User instancekeyId
- the key ID to delete- Throws:
GitLabApiException
- if any exception occurs
-
getImpersonationTokens
public List<ImpersonationToken> getImpersonationTokens(Object userIdOrUsername) throws GitLabApiException
Get a list of a specified user's impersonation tokens. Available only for admin users.GitLab Endpoint: GET /users/:id/impersonation_tokens
- Parameters:
userIdOrUsername
- the user in the form of an Integer(ID), String(username), or User instance- Returns:
- a list of a specified user's impersonation tokens
- Throws:
GitLabApiException
- if any exception occurs
-
getImpersonationTokens
public List<ImpersonationToken> getImpersonationTokens(Object userIdOrUsername, Constants.ImpersonationState state) throws GitLabApiException
Get a list of a specified user's impersonation tokens. Available only for admin users.GitLab Endpoint: GET /users/:id/impersonation_tokens
- Parameters:
userIdOrUsername
- the user in the form of an Integer(ID), String(username), or User instancestate
- the state of impersonation tokens to list (ALL, ACTIVE, INACTIVE)- Returns:
- a list of a specified user's impersonation tokens
- Throws:
GitLabApiException
- if any exception occurs
-
getImpersonationToken
public ImpersonationToken getImpersonationToken(Object userIdOrUsername, Integer tokenId) throws GitLabApiException
Get an impersonation token of a user. Available only for admin users.GitLab Endpoint: GET /users/:user_id/impersonation_tokens/:impersonation_token_id
- Parameters:
userIdOrUsername
- the user in the form of an Integer(ID), String(username), or User instancetokenId
- the impersonation token ID to get- Returns:
- the specified impersonation token
- Throws:
GitLabApiException
- if any exception occurs
-
getOptionalImpersonationToken
public Optional<ImpersonationToken> getOptionalImpersonationToken(Object userIdOrUsername, Integer tokenId)
Get an impersonation token of a user as an Optional instance. Available only for admin users.GitLab Endpoint: GET /users/:user_id/impersonation_tokens/:impersonation_token_id
- Parameters:
userIdOrUsername
- the user in the form of an Integer(ID), String(username), or User instancetokenId
- the impersonation token ID to get- Returns:
- the specified impersonation token as an Optional instance
-
createImpersonationToken
public ImpersonationToken createImpersonationToken(Object userIdOrUsername, String name, Date expiresAt, ImpersonationToken.Scope[] scopes) throws GitLabApiException
Create an impersonation token. Available only for admin users.GitLab Endpoint: POST /users/:user_id/impersonation_tokens
- Parameters:
userIdOrUsername
- the user in the form of an Integer(ID), String(username), or User instancename
- the name of the impersonation token, requiredexpiresAt
- the expiration date of the impersonation token, optionalscopes
- an array of scopes of the impersonation token- Returns:
- the created ImpersonationToken instance
- Throws:
GitLabApiException
- if any exception occurs
-
revokeImpersonationToken
public void revokeImpersonationToken(Object userIdOrUsername, Integer tokenId) throws GitLabApiException
Revokes an impersonation token. Available only for admin users.GitLab Endpoint: DELETE /users/:user_id/impersonation_tokens/:impersonation_token_id
- Parameters:
userIdOrUsername
- the user in the form of an Integer(ID), String(username), or User instancetokenId
- the impersonation token ID to revoke- Throws:
GitLabApiException
- if any exception occurs
-
createCustomAttribute
public CustomAttribute createCustomAttribute(Object userIdOrUsername, CustomAttribute customAttribute) throws GitLabApiException
Creates custom attribute for the given user- Parameters:
userIdOrUsername
- the user in the form of an Integer(ID), String(username), or User instancecustomAttribute
- the custom attribute to set- Returns:
- the created CustomAttribute
- Throws:
GitLabApiException
- on failure while setting customAttributes
-
createCustomAttribute
public CustomAttribute createCustomAttribute(Object userIdOrUsername, String key, String value) throws GitLabApiException
Creates custom attribute for the given user- Parameters:
userIdOrUsername
- the user in the form of an Integer(ID), String(username), or User instancekey
- for the customAttributevalue
- or the customAttribute- Returns:
- the created CustomAttribute
- Throws:
GitLabApiException
- on failure while setting customAttributes
-
changeCustomAttribute
public CustomAttribute changeCustomAttribute(Object userIdOrUsername, CustomAttribute customAttribute) throws GitLabApiException
Change custom attribute for the given user- Parameters:
userIdOrUsername
- the user in the form of an Integer(ID), String(username), or User instancecustomAttribute
- the custome attribute to change- Returns:
- the changed CustomAttribute
- Throws:
GitLabApiException
- on failure while changing customAttributes
-
changeCustomAttribute
public CustomAttribute changeCustomAttribute(Object userIdOrUsername, String key, String value) throws GitLabApiException
Changes custom attribute for the given user- Parameters:
userIdOrUsername
- the user in the form of an Integer(ID), String(username), or User instancekey
- for the customAttributevalue
- for the customAttribute- Returns:
- changedCustomAttribute
- Throws:
GitLabApiException
- on failure while changing customAttributes
-
deleteCustomAttribute
public void deleteCustomAttribute(Object userIdOrUsername, CustomAttribute customAttribute) throws GitLabApiException
Delete a custom attribute for the given user- Parameters:
userIdOrUsername
- the user in the form of an Integer(ID), String(username), or User instancecustomAttribute
- to remove- Throws:
GitLabApiException
- on failure while deleting customAttributes
-
deleteCustomAttribute
public void deleteCustomAttribute(Object userIdOrUsername, String key) throws GitLabApiException
Delete a custom attribute for the given user- Parameters:
userIdOrUsername
- the user in the form of an Integer(ID), String(username), or User instancekey
- of the customAttribute to remove- Throws:
GitLabApiException
- on failure while deleting customAttributes
-
setUserAvatar
public User setUserAvatar(Object userIdOrUsername, File avatarFile) throws GitLabApiException
Uploads and sets the user's avatar for the specified user.PUT /users/:id
- Parameters:
userIdOrUsername
- the user in the form of an Integer(ID), String(username), or User instanceavatarFile
- the File instance of the avatar file to upload- Returns:
- the updated User instance
- Throws:
GitLabApiException
- if any exception occurs
-
getEmails
public List<Email> getEmails() throws GitLabApiException
Get a list of emails for the current user.GitLab Endpoint: GET /users/emails
- Returns:
- a List of Email instances for the current user
- Throws:
GitLabApiException
- if any exception occurs
-
getEmails
public List<Email> getEmails(Object userIdOrUsername) throws GitLabApiException
Get a list of a specified user’s emails. Available only for admin users.GitLab Endpoint: GET /user/:id/emails
- Parameters:
userIdOrUsername
- the user in the form of an Integer(ID), String(username), or User instance- Returns:
- a List of Email instances for the specified user
- Throws:
GitLabApiException
- if any exception occurs
-
addEmail
public Email addEmail(String email) throws GitLabApiException
Add an email to the current user's emails.GitLab Endpoint: POST /user/:id/emails
- Parameters:
email
- the email address to add- Returns:
- the Email instance for the added email
- Throws:
GitLabApiException
- if any exception occurs
-
getEmail
public Email getEmail(Long emailId) throws GitLabApiException
Get a single Email instance specified by he email IDGitLab Endpoint: GET /user/emails/:emailId
- Parameters:
emailId
- the email ID to get- Returns:
- the Email instance for the provided email ID
- Throws:
GitLabApiException
- if any exception occurs
-
addEmail
public Email addEmail(Object userIdOrUsername, String email, Boolean skipConfirmation) throws GitLabApiException
Add an email to the user's emails.GitLab Endpoint: POST /user/:id/emails
- Parameters:
userIdOrUsername
- the user in the form of an Integer(ID), String(username), or User instanceemail
- the email address to addskipConfirmation
- skip confirmation and assume e-mail is verified - true or false (default)- Returns:
- the Email instance for the added email
- Throws:
GitLabApiException
- if any exception occurs
-
deleteEmail
public void deleteEmail(Long emailId) throws GitLabApiException
Deletes an email belonging to the current user.GitLab Endpoint: DELETE /user/emails/:emailId
- Parameters:
emailId
- the email ID to delete- Throws:
GitLabApiException
- if any exception occurs
-
deleteEmail
public void deleteEmail(Object userIdOrUsername, Long emailId) throws GitLabApiException
Deletes a user's emailGitLab Endpoint: DELETE /user/:id/emails/:emailId
- Parameters:
userIdOrUsername
- the user in the form of an Integer(ID), String(username), or User instanceemailId
- the email ID to delete- Throws:
GitLabApiException
- if any exception occurs
-
-