Package com.collibra.dgc.core.api.component.user

# Interface UserApi

public interface UserApi
Contains all api operations for handling users.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `User`
  `addUser(AddUserRequest addUserRequest)`
  Adds a new user.
  `List<User>`
  `addUsers(List<AddUserRequest> addUserRequests)`
  Adds new users.
  `List<UserGroup>`
  `addUserToUserGroups(AddUserToUserGroupsRequest addUserToUserGroupsRequest)`
  Adds user to given user groups.
  `User`
  `changeUser(ChangeUserRequest changeUserRequest)`
  Change the user with the information present in the input.
  `User`
  `changeUserAvatar(ChangeUserAvatarRequest changeUserAvatarRequest)`
  Change the avatar for the given user.
  `boolean`
  `exists(UUID userId)`
  Returns true if a user with given `userId` exists.
  `PagedResponse<User>`
  `findUsers(FindUsersRequest findUsersRequest)`
  Returns users matching the given input.
  `Optional<User>`
  `getCurrentUser()`
  Returns the currently logged in user.
  `User`
  `getUser(UUID userId)`
  Returns the user with the given id.
  `User`
  `getUserByEmailAddress(String emailAddress)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  this method will be removed.
  `User`
  `getUserByUsername(String username)`
  Returns user with given username.
  `String`
  `getUserEffectiveLicenseType(UUID userId)`
  The license type in effect for the user, regardless of the license pricebook version.
  `LicenseType`
  `getUserRequiredLicenseType(UUID userId)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  This returns the pricebook version 3 required license type.
  `void`
  `removeAvatar(UUID userId)`
  Remove the avatar of the given user.
  `void`
  `removeUser(UUID userId)`
  Remove the user with the given ID.
  `void`
  `removeUserFromUserGroups(RemoveUserFromUserGroupsRequest removeUserFromUserGroupsRequest)`
  Remove user from given user groups.
  `User`
  `setGroupsForUser(SetUserGroupsForUserRequest setUserGroupsForUserRequest)`
  Sets the list of user groups this user should belong to.

- ## Method Details

  - ### addUser

    User addUser(AddUserRequest addUserRequest)
    Adds a new user. The username can contain only unicode printable characters and cannot contain leading and trailing spaces.
    Parameters:
      `addUserRequest` - the properties of the user to be added
    Returns:
      the newly added user

  - ### addUsers

    @SecurityAuditMethod(resultFormatter=com.collibra.audit.formatter.CollectionCountFormatter.class) List<User> addUsers(List<AddUserRequest> addUserRequests)
    Adds new users. The username can contain only unicode printable characters and cannot contain leading and trailing spaces.
    Parameters:
      `addUserRequests` - the properties of users to be added
    Returns:
      the newly added users

  - ### getUser

    @SecurityAuditMethod(resultFormatter=com.collibra.dgc.core.api.internal.security.audit.formatter.ApiUserFormatter.class) User getUser(UUID userId)
    Returns the user with the given id.
    Parameters:
      `userId` - the id of the user
    Returns:
      the found user

  - ### getUserByEmailAddress

    @SecurityAuditMethod(resultFormatter=com.collibra.dgc.core.api.internal.security.audit.formatter.ApiUserFormatter.class) @Deprecated(forRemoval=true) User getUserByEmailAddress(String emailAddress)
    Deprecated, for removal: This API element is subject to removal in a future version.
    this method will be removed. Use `findUsers(FindUsersRequest)` (com.collibra.dgc.core.api.component.user.UserApi instead.)}
    Returns user with given email address. This method should not be used when multiple users have the same email.
    Parameters:
      `emailAddress` - email address of the user
    Returns:
      user with given email address

  - ### getUserByUsername

    @SecurityAuditMethod(resultFormatter=com.collibra.dgc.core.api.internal.security.audit.formatter.ApiUserFormatter.class) User getUserByUsername(String username)
    Returns user with given username.
    Parameters:
      `username` - Username of the user
    Returns:
      user with given username

  - ### getCurrentUser

    @SecurityAuditMethod(includeInAudit=false) Optional<User> getCurrentUser()
    Returns the currently logged in user.
    Returns:
      The currently logged in user or empty Optional object if not logged in.

  - ### findUsers

    @SecurityAuditMethod(resultFormatter=com.collibra.dgc.core.api.internal.security.audit.formatter.PagedResponseCountFormatter.class) PagedResponse<User> findUsers(FindUsersRequest findUsersRequest)
    Returns users matching the given input.
    Parameters:
      `findUsersRequest` - specified inputs in order to search for users
    Returns:
      the list with found users

  - ### exists

    boolean exists(UUID userId)
    Returns true if a user with given `userId` exists.
    Parameters:
      `userId` - the ID of the user being tested
    Returns:
      true if a user with given `userId` exists

  - ### changeUser

    @SecurityAuditMethod(resultFormatter=com.collibra.dgc.core.api.internal.security.audit.formatter.ApiUserFormatter.class) User changeUser(ChangeUserRequest changeUserRequest)
    Change the user with the information present in the input. The username can contain only unicode printable characters and cannot contain leading and trailing spaces.
    Parameters:
      `changeUserRequest` - changes that need to be performed on the user
    Returns:
      the changed user

  - ### changeUserAvatar

    @SecurityAuditMethod(resultFormatter=com.collibra.dgc.core.api.internal.security.audit.formatter.ApiUserFormatter.class) User changeUserAvatar(ChangeUserAvatarRequest changeUserAvatarRequest)
    Change the avatar for the given user.
    Parameters:
      `changeUserAvatarRequest` - the request containing all the necessary information for the change.
    Returns:
      the changed user.

  - ### removeAvatar

    void removeAvatar(UUID userId)
    Remove the avatar of the given user.
    Parameters:
      `userId` - the user ID for whom the avatar will be removed

  - ### removeUser

    void removeUser(UUID userId)
    Remove the user with the given ID.
    Parameters:
      `userId` - The ID of the user that will be removed.

  - ### setGroupsForUser

    @SecurityAuditMethod(resultFormatter=com.collibra.dgc.core.api.internal.security.audit.formatter.ApiUserFormatter.class) User setGroupsForUser(SetUserGroupsForUserRequest setUserGroupsForUserRequest)
    Sets the list of user groups this user should belong to.

    If user belongs to any user groups that are not specified in this request then it will be removed from those groups after request is executed.

    Parameters:
      `setUserGroupsForUserRequest` - the list of user groups that this user should belong to
    Returns:
      the user

  - ### removeUserFromUserGroups

    void removeUserFromUserGroups(RemoveUserFromUserGroupsRequest removeUserFromUserGroupsRequest)
    Remove user from given user groups.
    Parameters:
      `removeUserFromUserGroupsRequest` - the properties needed to remove the user from given user groups

  - ### addUserToUserGroups

    @SecurityAuditMethod(resultFormatter=com.collibra.audit.formatter.CollectionCountFormatter.class) List<UserGroup> addUserToUserGroups(AddUserToUserGroupsRequest addUserToUserGroupsRequest)
    Adds user to given user groups.
    Parameters:
      `addUserToUserGroupsRequest` - the properties needed to add the user to given user groups
    Returns:
      the list of user groups the user has been assigned to

  - ### getUserRequiredLicenseType

    @Deprecated(since="2024.02", forRemoval=true) LicenseType getUserRequiredLicenseType(UUID userId)
    Deprecated, for removal: This API element is subject to removal in a future version.
    This returns the pricebook version 3 required license type. A public API is not available for later pricebook versions.
    Get the pricebook version 3 required license type for the user.

    The required LicenseType is the maximum license type of any permission included in a global role or resource role of that user (or group of that user). Returns a value if on pricebook v3, otherwise returns null.

    Parameters:
      `userId` - the id of the user
    Returns:
      the required LicenseType, or `null`

  - ### getUserEffectiveLicenseType

    String getUserEffectiveLicenseType(UUID userId)
    The license type in effect for the user, regardless of the license pricebook version. The user's effective license type may not match the required license type based on permissions, especially in Pricebook Version 3, which imposes additional restrictions tied to workflow consumption. However, in the upcoming Pricebook Version 4 starting in May 2024, the effective license will, at least initially, align with the required license.
    Parameters:
      `userId` -
    Returns:
      The effective license type or an empty string. Never null.