Users represent an individual's account on Box.
- Get the Current User's Information
- Create An Enterprise User
- Update User
- Delete User
- Get Email Aliases
- Add Email Alias
- Delete Email Alias
- Get Enterprise Users
- Move User's Folder
To get the current user, call the static [getCurrentUser(BoxAPIConnection)
]
get-current-user method. Then use getInfo()
to get information
about the user.
BoxUser user = BoxUser.getCurrentUser(api);
BoxUser.Info info = user.getInfo();
To create an enterprise user call the createEnterpriseUser(BoxAPIConnection, String, String)
or createEnterpriseUser(BoxAPIConnection, String, String, CreateUserParams)
method.
BoxUser.Info createdUserInfo = BoxUser.createEnterpriseUser(api, "user@email.com", "A User");
To update a user call the updateInfo(BoxUser.Info)
method.
BoxUser user = new BoxUser(api, "0");
BoxUser.Info info = user.new Info();
info.setName(name);
user.updateInfo(info);
To delete a user call the delete(boolean, boolean)
method.
BoxUser user = new BoxUser(api, "0");
user.delete(false, false);
To get a users email aliases call the getEmailAliases()
method.
BoxUser user = new BoxUser(api, "0");
Collection<EmailAlias> emailAliases = user.getEmailAliases();
To add an email alias for a user call the addEmailAlias(String)
method.
BoxUser user = new BoxUser(api, "0");
user.addEmailAlias("user@email.com");
To delete a users email alias call the deleteEmailAlias(String)
method.
BoxUser user = new BoxUser(api, "0");
user.deleteEmailAlias("123");
To get an enterprises users call the getAllEnterpriseUsers(BoxAPIConnection)
, getAllEnterpriseUsers(BoxAPIConnection, String, String...)
, or getAllEnterpriseOrExternalUsers(BoxAPIConnection, String, String...)
method.
Iterable<BoxUser.Info> users = BoxUser.getAllEnterpriseUsers(api);
To move a users folder call the moveFolderToUser(String)
method. Currently, only moving the root folder (0) is supported.
BoxUser user = new BoxUser(api, "0");
BoxFolder.Info folderInfo = user.moveFolderToUser("1");