@BoxResourceType(value="user") public class BoxUser extends BoxCollaborator
Unless otherwise noted, the methods in this class can throw an unchecked BoxAPIException
(unchecked
meaning that the compiler won't force you to handle it) if an error occurs. If you wish to implement custom error
handling for errors related to the Box REST API, you should capture this exception explicitly.
Modifier and Type | Class and Description |
---|---|
class |
BoxUser.Info
Contains information about a BoxUser.
|
static class |
BoxUser.Role
Enumerates the possible roles that a user can have within an enterprise.
|
static class |
BoxUser.Status
Enumerates the possible statuses that a user's account can have.
|
BoxCollaborator.CollaboratorType, BoxCollaborator.GroupType
Modifier and Type | Field and Description |
---|---|
static String[] |
ALL_FIELDS
An array of all possible file fields that can be requested when calling
getInfo(String...) . |
static URLTemplate |
EMAIL_ALIAS_URL_TEMPLATE
E-Mail Alias URL Template.
|
static URLTemplate |
EMAIL_ALIASES_URL_TEMPLATE
E-Mail Aliases URL Template.
|
static URLTemplate |
GET_ME_URL
Get Me URL Template.
|
static URLTemplate |
MOVE_FOLDER_TO_USER_TEMPLATE
Move Folder To User Template.
|
static URLTemplate |
USER_AVATAR_TEMPLATE
User Avatar Template.
|
static URLTemplate |
USER_MEMBERSHIPS_URL_TEMPLATE
User Memberships URL Template.
|
static URLTemplate |
USER_URL_TEMPLATE
User URL Template.
|
static URLTemplate |
USERS_URL_TEMPLATE
Users URL Template.
|
Constructor and Description |
---|
BoxUser(BoxAPIConnection api,
String id)
Constructs a BoxUser for a user with a given ID.
|
Modifier and Type | Method and Description |
---|---|
EmailAlias |
addEmailAlias(String email)
Adds a new email alias to this user's account.
|
EmailAlias |
addEmailAlias(String email,
boolean isConfirmed)
Adds a new email alias to this user's account and confirms it without user interaction.
|
static BoxUser.Info |
createAppUser(BoxAPIConnection api,
String name)
Provisions a new app user in an enterprise using Box Developer Edition.
|
static BoxUser.Info |
createAppUser(BoxAPIConnection api,
String name,
CreateUserParams params)
Provisions a new app user in an enterprise with additional user information using Box Developer Edition.
|
static BoxUser.Info |
createEnterpriseUser(BoxAPIConnection api,
String login,
String name)
Provisions a new user in an enterprise.
|
static BoxUser.Info |
createEnterpriseUser(BoxAPIConnection api,
String login,
String name,
CreateUserParams params)
Provisions a new user in an enterprise with additional user information.
|
void |
delete(boolean notifyUser,
boolean force)
Deletes a user from an enterprise account.
|
void |
deleteEmailAlias(String emailAliasID)
Deletes an email alias from this user's account.
|
static Iterable<BoxUser.Info> |
getAllEnterpriseOrExternalUsers(BoxAPIConnection api,
String filterTerm,
boolean usemarker,
String marker,
String... fields)
Gets any managed users that match the filter term as well as any external users that
match the filter term.
|
static Iterable<BoxUser.Info> |
getAllEnterpriseOrExternalUsers(BoxAPIConnection api,
String filterTerm,
String... fields)
Gets any managed users that match the filter term as well as any external users that
match the filter term.
|
static Iterable<BoxUser.Info> |
getAllEnterpriseUsers(BoxAPIConnection api)
Returns an iterable containing all the enterprise users.
|
static Iterable<BoxUser.Info> |
getAllEnterpriseUsers(BoxAPIConnection api,
boolean usemarker,
String marker)
Returns an iterable containing all the enterprise users.
|
static Iterable<BoxUser.Info> |
getAllEnterpriseUsers(BoxAPIConnection api,
String filterTerm,
boolean usemarker,
String marker,
String... fields)
Returns an iterable containing all the enterprise users that matches the filter and specifies which child fields
to retrieve from the API.
|
static Iterable<BoxUser.Info> |
getAllEnterpriseUsers(BoxAPIConnection api,
String filterTerm,
String... fields)
Returns an iterable containing all the enterprise users that matches the filter and specifies which child fields
to retrieve from the API.
|
Iterable<BoxGroupMembership.Info> |
getAllMemberships(String... fields)
Gets information about all of the group memberships for this user as iterable with paging support.
|
static Iterable<BoxUser.Info> |
getAppUsersByExternalAppUserID(BoxAPIConnection api,
String externalAppUserId,
boolean usemarker,
String marker,
String... fields)
Gets any app users that has an exact match with the externalAppUserId term using marker based pagination.
|
static Iterable<BoxUser.Info> |
getAppUsersByExternalAppUserID(BoxAPIConnection api,
String externalAppUserId,
String... fields)
Gets any app users that has an exact match with the externalAppUserId term.
|
InputStream |
getAvatar()
Retrieves the avatar of a user as an InputStream.
|
static BoxUser |
getCurrentUser(BoxAPIConnection api)
Gets the current user.
|
Collection<EmailAlias> |
getEmailAliases()
Gets a collection of all the email aliases for this user.
|
static Iterable<BoxUser.Info> |
getExternalUsers(BoxAPIConnection api,
String filterTerm,
boolean usemarker,
String marker,
String... fields)
Gets a limited set of information about an external user.
|
static Iterable<BoxUser.Info> |
getExternalUsers(BoxAPIConnection api,
String filterTerm,
String... fields)
Gets a limited set of information about an external user.
|
BoxUser.Info |
getInfo(String... fields)
Gets information about this user.
|
Collection<BoxGroupMembership.Info> |
getMemberships()
Gets information about all of the group memberships for this user.
|
BoxFolder.Info |
moveFolderToUser(String sourceUserID)
Deprecated.
As of release 2.22.0, replaced by
transferContent(String) ()}
Moves all of the owned content from within one user’s folder into a new folder in another user's account. You can move folders across users as long as the you have administrative permissions and the 'source' user owns the folders. Per the documentation at the link below, this will move everything from the root folder, as this is currently the only mode of operation supported. See also https://developer.box.com/en/reference/put-users-id-folders-id/ |
BoxFolder.Info |
transferContent(String destinationUserID)
Moves all of the owned content from within one user’s folder into a new folder in another user's account.
|
void |
updateInfo(BoxUser.Info info)
Updates the information about this user with any info fields that have been modified locally.
|
equals, getAPI, getID, getResourceType, hashCode
public static final String[] ALL_FIELDS
getInfo(String...)
.public static final URLTemplate USER_URL_TEMPLATE
public static final URLTemplate GET_ME_URL
public static final URLTemplate USERS_URL_TEMPLATE
public static final URLTemplate USER_MEMBERSHIPS_URL_TEMPLATE
public static final URLTemplate EMAIL_ALIAS_URL_TEMPLATE
public static final URLTemplate EMAIL_ALIASES_URL_TEMPLATE
public static final URLTemplate MOVE_FOLDER_TO_USER_TEMPLATE
public static final URLTemplate USER_AVATAR_TEMPLATE
public BoxUser(BoxAPIConnection api, String id)
api
- the API connection to be used by the user.id
- the ID of the user.public static BoxUser.Info createAppUser(BoxAPIConnection api, String name)
api
- the API connection to be used by the created user.name
- the name of the user.public static BoxUser.Info createAppUser(BoxAPIConnection api, String name, CreateUserParams params)
api
- the API connection to be used by the created user.name
- the name of the user.params
- additional user information.public static BoxUser.Info createEnterpriseUser(BoxAPIConnection api, String login, String name)
api
- the API connection to be used by the created user.login
- the email address the user will use to login.name
- the name of the user.public static BoxUser.Info createEnterpriseUser(BoxAPIConnection api, String login, String name, CreateUserParams params)
api
- the API connection to be used by the created user.login
- the email address the user will use to login.name
- the name of the user.params
- additional user information.public static BoxUser getCurrentUser(BoxAPIConnection api)
api
- the API connection of the current user.public static Iterable<BoxUser.Info> getAllEnterpriseUsers(BoxAPIConnection api)
api
- the API connection to be used when retrieving the users.public static Iterable<BoxUser.Info> getAllEnterpriseUsers(BoxAPIConnection api, boolean usemarker, String marker)
api
- the API connection to be used when retrieving the users.usemarker
- Boolean that determines whether to use marker based pagination.marker
- The marker at which the iterator will begin.public static Iterable<BoxUser.Info> getAllEnterpriseUsers(BoxAPIConnection api, String filterTerm, String... fields)
api
- the API connection to be used when retrieving the users.filterTerm
- used to filter the results to only users starting with this string in either the name or the
login. Can be null to not filter the results.fields
- the fields to retrieve. Leave this out for the standard fields.public static Iterable<BoxUser.Info> getAllEnterpriseUsers(BoxAPIConnection api, String filterTerm, boolean usemarker, String marker, String... fields)
api
- the API connection to be used when retrieving the users.filterTerm
- used to filter the results to only users starting with this string in either the name or the
login. Can be null to not filter the results.usemarker
- Boolean that determines whether to use marker based pagination.marker
- The marker at which the iterator will begin.fields
- the fields to retrieve. Leave this out for the standard fields.public static Iterable<BoxUser.Info> getExternalUsers(BoxAPIConnection api, String filterTerm, String... fields)
api
- the API connection to be used when retrieving the users.filterTerm
- used to filter the results to only users matching the given login.
This does exact match only, so if no filter term is passed in, nothing
will be returned.fields
- the fields to retrieve. Leave this out for the standard fields.public static Iterable<BoxUser.Info> getExternalUsers(BoxAPIConnection api, String filterTerm, boolean usemarker, String marker, String... fields)
api
- the API connection to be used when retrieving the users.filterTerm
- used to filter the results to only users matching the given login.
This does exact match only, so if no filter term is passed in, nothing
will be returned.usemarker
- Boolean that determines whether to use marker based pagination.marker
- The marker at which the iterator will begin.fields
- the fields to retrieve. Leave this out for the standard fields.public static Iterable<BoxUser.Info> getAllEnterpriseOrExternalUsers(BoxAPIConnection api, String filterTerm, String... fields)
api
- the API connection to be used when retrieving the users.filterTerm
- The filter term to lookup users by (login for external, login or name for managed)fields
- the fields to retrieve. Leave this out for the standard fields.public static Iterable<BoxUser.Info> getAllEnterpriseOrExternalUsers(BoxAPIConnection api, String filterTerm, boolean usemarker, String marker, String... fields)
api
- the API connection to be used when retrieving the users.filterTerm
- The filter term to lookup users by (login for external, login or name for managed)usemarker
- Boolean that determines whether to use marker based pagination.marker
- The marker at which the iterator will begin.fields
- the fields to retrieve. Leave this out for the standard fields.public static Iterable<BoxUser.Info> getAppUsersByExternalAppUserID(BoxAPIConnection api, String externalAppUserId, String... fields)
api
- the API connection to be used when retrieving the users.externalAppUserId
- the external app user id that has been set for app userfields
- the fields to retrieve. Leave this out for the standard fields.public static Iterable<BoxUser.Info> getAppUsersByExternalAppUserID(BoxAPIConnection api, String externalAppUserId, boolean usemarker, String marker, String... fields)
api
- the API connection to be used when retrieving the users.externalAppUserId
- the external app user id that has been set for app userusemarker
- Boolean that determines whether to use marker based pagination.marker
- The marker at which the iterator will begin.fields
- the fields to retrieve. Leave this out for the standard fields.public BoxUser.Info getInfo(String... fields)
fields
- the optional fields to retrieve.public Collection<BoxGroupMembership.Info> getMemberships()
Note: This method is only available to enterprise admins.
public Iterable<BoxGroupMembership.Info> getAllMemberships(String... fields)
fields
- the fields to retrieve.public EmailAlias addEmailAlias(String email)
email
- the email address to add as an alias.public EmailAlias addEmailAlias(String email, boolean isConfirmed)
email
- the email address to add as an alias.isConfirmed
- whether or not the email alias should be automatically confirmed.public void deleteEmailAlias(String emailAliasID)
The IDs of the user's email aliases can be found by calling getEmailAliases()
.
emailAliasID
- the ID of the email alias to delete.public Collection<EmailAlias> getEmailAliases()
Note that the user's primary login email is not included in the collection of email aliases.
public void delete(boolean notifyUser, boolean force)
notifyUser
- whether or not to send an email notification to the user that their account has been deleted.force
- whether or not this user should be deleted even if they still own files.public void updateInfo(BoxUser.Info info)
Note: This method is only available to enterprise admins.
info
- info the updated info.@Deprecated public BoxFolder.Info moveFolderToUser(String sourceUserID)
transferContent(String)
()}
Moves all of the owned content from within one user’s folder into a new folder in another user's account. You can move folders across users as long as the you have administrative permissions and the 'source' user owns the folders. Per the documentation at the link below, this will move everything from the root folder, as this is currently the only mode of operation supported.
See also https://developer.box.com/en/reference/put-users-id-folders-id/
sourceUserID
- the user id of the user whose files will be the source for this operationpublic BoxFolder.Info transferContent(String destinationUserID)
See also https://developer.box.com/en/reference/put-users-id-folders-id/
destinationUserID
- the user id of the user that you wish to transfer content to.public InputStream getAvatar()