public class UserResource extends Object
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_USERS_RETURNED |
static int |
MAX_USERS_RETURNED |
Constructor and Description |
---|
UserResource(UserService userService,
UserUtil userUtil,
PasswordPolicyManager passwordPolicyManager,
I18nHelper i18n,
EmailFormatter emailFormatter,
JiraAuthenticationContext authContext,
TimeZoneManager timeZoneManager,
AvatarPickerHelper avatarPickerHelper,
AvatarManager avatarManager,
AvatarService avatarService,
AttachmentHelper attachmentHelper,
UserPropertyManager userPropertyManager,
PermissionManager permissionManager,
ProjectService projectService,
IssueService issueService,
ProjectManager projectManager,
com.atlassian.event.api.EventPublisher eventPublisher,
AssigneeService assigneeService,
IssueManager issueManager,
UserPickerResourceHelper userPickerHelper,
JiraBaseUrls jiraBaseUrls,
ColumnService columnService,
XsrfInvocationChecker xsrfChecker,
UserManager userManager,
I18nHelper.BeanFactory beanFactory,
ApplicationRoleManager applicationRoleManager,
ApplicationRoleBeanConverter applicationRoleBeanConverter,
UpdateUserApplicationHelper updateUserApplicationHelper,
ResponseFactory responseFactory,
ApplicationProperties applicationProperties) |
Modifier and Type | Method and Description |
---|---|
javax.ws.rs.core.Response |
addUserToApplication(String username,
String applicationKey)
Add user to given application.
|
javax.ws.rs.core.Response |
changeUserPassword(String name,
String key,
PasswordBean passwordBean)
Modify user password.
|
javax.ws.rs.core.Response |
createAvatarFromTemporary(String username,
AvatarCroppingBean croppingInstructions)
Converts temporary avatar into a real avatar
|
javax.ws.rs.core.Response |
createUser(UserWriteBean userBean)
Create user.
|
javax.ws.rs.core.Response |
defaultColumns(String username)
Returns the default columns for the given user.
|
javax.ws.rs.core.Response |
deleteAvatar(String username,
Long id)
Deletes avatar
|
javax.ws.rs.core.Response |
findAssignableUsers(String name,
String projectKey,
String issueKey,
Integer startAt,
Integer maxResults,
Integer actionDescriptorId,
javax.ws.rs.core.UriInfo uriInfo)
Returns a list of users that match the search string.
|
javax.ws.rs.core.Response |
findBulkAssignableUsers(String name,
String projectKeysStr,
Integer startAt,
Integer maxResults,
javax.ws.rs.core.UriInfo uriInfo)
Returns a list of users that match the search string and can be assigned issues for all the given projects.
|
javax.ws.rs.core.Response |
findUsers(String username,
Integer startAt,
Integer maxResults,
Boolean includeActive,
Boolean includeInactive,
javax.ws.rs.core.UriInfo uriInfo)
Returns a list of users that match the search string.
|
javax.ws.rs.core.Response |
findUsersForPicker(String query,
Integer maxResults,
Boolean showAvatar,
List<String> excludeUsers)
Returns a list of users matching query with highlighting.
|
javax.ws.rs.core.Response |
findUsersWithAllPermissions(String name,
String permissions,
String issueKey,
String projectKey,
Integer startAt,
Integer maxResults)
Returns a list of active users that match the search string and have all specified permissions for the project or issue.
This resource can be accessed by users with ADMINISTER_PROJECT permission for the project or global ADMIN or SYSADMIN rights. |
javax.ws.rs.core.Response |
findUsersWithBrowsePermission(String username,
String issueKey,
String projectKey,
Integer startAt,
Integer maxResults,
javax.ws.rs.core.UriInfo uriInfo)
Returns a list of active users that match the search string.
|
protected com.opensymphony.workflow.loader.ActionDescriptor |
getActionDescriptorById(String issueKey,
Integer actionDescriptorId) |
Map<String,List<AvatarBean>> |
getAllAvatars(String name)
Returns all avatars which are visible for the currently logged in user.
|
javax.ws.rs.core.Response |
getUser(String name,
String key,
boolean includeDeleted)
Returns a user.
|
javax.ws.rs.core.Response |
removeUser(String name,
String key)
Removes user and its references (like project roles associations, watches, history).
|
javax.ws.rs.core.Response |
removeUserFromApplication(String username,
String applicationKey)
Remove user from given application.
|
javax.ws.rs.core.Response |
resetColumns(String username)
Reset the default columns for the given user to the system default.
|
javax.ws.rs.core.Response |
setColumns(String username,
List<String> fields)
Sets the default columns for the given user.
|
javax.ws.rs.core.Response |
storeTemporaryAvatar(String username,
String filename,
Long size,
javax.servlet.http.HttpServletRequest request)
Creates temporary avatar.
|
javax.ws.rs.core.Response |
storeTemporaryAvatarUsingMultiPart(String username,
com.atlassian.plugins.rest.common.multipart.FilePart filePart,
javax.servlet.http.HttpServletRequest request)
Creates temporary avatar using multipart.
|
javax.ws.rs.core.Response |
updateUser(String name,
String key,
UserWriteBean userBean)
Modify user.
|
javax.ws.rs.core.Response |
updateUserAvatar(String username,
AvatarBean avatarBean) |
public static final int DEFAULT_USERS_RETURNED
public static final int MAX_USERS_RETURNED
public UserResource(UserService userService, UserUtil userUtil, PasswordPolicyManager passwordPolicyManager, I18nHelper i18n, EmailFormatter emailFormatter, JiraAuthenticationContext authContext, TimeZoneManager timeZoneManager, AvatarPickerHelper avatarPickerHelper, AvatarManager avatarManager, AvatarService avatarService, AttachmentHelper attachmentHelper, UserPropertyManager userPropertyManager, PermissionManager permissionManager, ProjectService projectService, IssueService issueService, ProjectManager projectManager, com.atlassian.event.api.EventPublisher eventPublisher, AssigneeService assigneeService, IssueManager issueManager, UserPickerResourceHelper userPickerHelper, JiraBaseUrls jiraBaseUrls, ColumnService columnService, XsrfInvocationChecker xsrfChecker, UserManager userManager, I18nHelper.BeanFactory beanFactory, ApplicationRoleManager applicationRoleManager, ApplicationRoleBeanConverter applicationRoleBeanConverter, UpdateUserApplicationHelper updateUserApplicationHelper, ResponseFactory responseFactory, ApplicationProperties applicationProperties)
public javax.ws.rs.core.Response getUser(String name, String key, boolean includeDeleted)
name
- the usernamekey
- user keyincludeDeleted
- whether deleted users should be returned (flag available to users with global ADMIN rights)public javax.ws.rs.core.Response findUsers(String username, Integer startAt, Integer maxResults, Boolean includeActive, Boolean includeInactive, @Context javax.ws.rs.core.UriInfo uriInfo)
username
- A query string used to search username, name or e-mail addressstartAt
- the index of the first user to return (0-based)maxResults
- the maximum number of users to return (defaults to 50). The maximum allowed value is 1000.
If you specify a value that is higher than this number, your search results will be truncated.includeActive
- If true, then active users are included in the results (default true)includeInactive
- If true, then inactive users are included in the results (default false)uriInfo
- context used for creating urls in user objectspublic javax.ws.rs.core.Response findUsersForPicker(String query, Integer maxResults, Boolean showAvatar, List<String> excludeUsers)
query
- A string used to search username, Name or e-mail addressmaxResults
- the maximum number of users to return (defaults to 50). The maximum allowed value is 1000.
If you specify a value that is higher than this number, your search results will be truncated.public javax.ws.rs.core.Response findAssignableUsers(String name, String projectKey, String issueKey, Integer startAt, Integer maxResults, Integer actionDescriptorId, @Context javax.ws.rs.core.UriInfo uriInfo)
name
- the usernameprojectKey
- the key of the project we are finding assignable users forissueKey
- the issue key for the issue being edited we need to find assignable users for.startAt
- the index of the first user to return (0-based)maxResults
- the maximum number of users to return (defaults to 50). The maximum allowed value is 1000.
If you specify a value that is higher than this number, your search results will be truncated.uriInfo
- Context used for constructing user objects@ExperimentalApi public javax.ws.rs.core.Response createUser(UserWriteBean userBean)
@ExperimentalApi public javax.ws.rs.core.Response updateUser(String name, String key, UserWriteBean userBean)
name
- the usernamekey
- user key@ExperimentalApi public javax.ws.rs.core.Response changeUserPassword(String name, String key, PasswordBean passwordBean)
name
- the usernamekey
- user key@ExperimentalApi public javax.ws.rs.core.Response removeUser(String name, String key)
name
- the usernamekey
- user keyprotected com.opensymphony.workflow.loader.ActionDescriptor getActionDescriptorById(String issueKey, Integer actionDescriptorId)
public javax.ws.rs.core.Response findUsersWithBrowsePermission(String username, String issueKey, String projectKey, Integer startAt, Integer maxResults, @Context javax.ws.rs.core.UriInfo uriInfo)
username
- the username filter, no users returned if left blankissueKey
- the issue key for the issue being edited we need to find viewable users for.projectKey
- the optional project key to search for users with if no issueKey is supplied.startAt
- the index of the first user to return (0-based)maxResults
- the maximum number of users to return (defaults to 50). The maximum allowed value is 1000.
If you specify a value that is higher than this number, your search results will be truncated.uriInfo
- Context used for constructing user objectspublic javax.ws.rs.core.Response findUsersWithAllPermissions(String name, String permissions, String issueKey, String projectKey, Integer startAt, Integer maxResults)
name
- the username filter, list includes all users if unspecifiedpermissions
- comma separated list of permissions for project or issue returned users must have, see
Permissions
JavaDoc for the list of all possible permissions.issueKey
- the issue key for the issue for which returned users have specified permissions.projectKey
- the optional project key to search for users with if no issueKey is supplied.startAt
- the index of the first user to return (0-based)maxResults
- the maximum number of users to return (defaults to 50). The maximum allowed value is 1000.
If you specify a value that is higher than this number, your search results will be truncated.public javax.ws.rs.core.Response findBulkAssignableUsers(String name, String projectKeysStr, Integer startAt, Integer maxResults, @Context javax.ws.rs.core.UriInfo uriInfo)
name
- the usernamestartAt
- the index of the first user to return (0-based)maxResults
- the maximum number of users to return (defaults to 50). The maximum allowed value is 1000.
If you specify a value that is higher than this number, your search results will be truncated.projectKeysStr
- the keys of the projects we are finding assignable users for, comma-separateduriInfo
- Context used for constructing user objectspublic Map<String,List<AvatarBean>> getAllAvatars(String name)
name
- usernamepublic javax.ws.rs.core.Response createAvatarFromTemporary(String username, AvatarCroppingBean croppingInstructions)
username
- usernamecroppingInstructions
- cropping instructionspublic javax.ws.rs.core.Response updateUserAvatar(String username, AvatarBean avatarBean)
public javax.ws.rs.core.Response storeTemporaryAvatar(String username, String filename, Long size, @Context javax.servlet.http.HttpServletRequest request)
The following examples shows these three steps using curl. The cookies (session) need to be preserved between requests, hence the use of -b and -c. The id created in step 2 needs to be passed to step 3 (you can simply pass the whole response of step 2 as the request of step 3).
curl -c cookiejar.txt -X POST -u admin:admin -H "X-Atlassian-Token: no-check" \ -H "Content-Type: image/png" --data-binary @mynewavatar.png \ 'http://localhost:8090/jira/rest/api/2/user/avatar/temporary?username=admin&filename=mynewavatar.png' curl -b cookiejar.txt -X POST -u admin:admin -H "X-Atlassian-Token: no-check" \ -H "Content-Type: application/json" --data '{"cropperWidth": "65","cropperOffsetX": "10","cropperOffsetY": "16"}' \ -o tmpid.json \ http://localhost:8090/jira/rest/api/2/user/avatar?username=admin curl -b cookiejar.txt -X PUT -u admin:admin -H "X-Atlassian-Token: no-check" \ -H "Content-Type: application/json" --data-binary @tmpid.json \ http://localhost:8090/jira/rest/api/2/user/avatar?username=admin
username
- usernamefilename
- name of file being uploadedsize
- size of filerequest
- servlet requestpublic javax.ws.rs.core.Response storeTemporaryAvatarUsingMultiPart(String username, com.atlassian.plugins.rest.common.multipart.FilePart filePart, @Context javax.servlet.http.HttpServletRequest request)
Creating a temporary avatar is part of a 3-step process in uploading a new avatar for a user: upload, crop, confirm. This endpoint allows you to use a multipart upload instead of sending the image directly as the request body.
You *must* use "avatar" as the name of the upload parameter:
curl -c cookiejar.txt -X POST -u admin:admin -H "X-Atlassian-Token: no-check" \ -F "avatar=@mynewavatar.png;type=image/png" \ 'http://localhost:8090/jira/rest/api/2/user/avatar/temporary?username=admin'
username
- Usernamerequest
- servlet requestpublic javax.ws.rs.core.Response deleteAvatar(String username, Long id)
username
- usernameid
- database id for avatarpublic javax.ws.rs.core.Response defaultColumns(String username)
username
- usernamepublic javax.ws.rs.core.Response setColumns(String username, List<String> fields)
username
- usernamefields
- list of column idspublic javax.ws.rs.core.Response resetColumns(String username)
username
- username@ExperimentalApi public javax.ws.rs.core.Response addUserToApplication(String username, String applicationKey)
username
- usernameapplicationKey
- application key@ExperimentalApi public javax.ws.rs.core.Response removeUserFromApplication(String username, String applicationKey)
username
- usernameapplicationKey
- application keyCopyright © 2002-2021 Atlassian. All Rights Reserved.