Skip to content

Commit 82293a2

Browse files
[Jira] Get Permissions parameter addition for permissions (#1016)
1 parent a48fb82 commit 82293a2

File tree

1 file changed

+27
-29
lines changed

1 file changed

+27
-29
lines changed

atlassian/jira.py

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -22,35 +22,33 @@ def __init__(self, url, *args, **kwargs):
2222

2323
super(Jira, self).__init__(url, *args, **kwargs)
2424

25-
def get_permissions(self, project_id=None, project_key=None, issue_id=None, issue_key=None):
26-
"""
27-
Returns all permissions in the system and whether the currently logged in user has them.
28-
You can optionally provide a specific context
29-
to get permissions for (projectKey OR projectId OR issueKey OR issueId)
30-
When no context supplied the project related permissions will return true
31-
if the user has that permission in ANY project
32-
If a project context is provided, project related permissions will return true
33-
if the user has the permissions in the specified project.
34-
For permissions that are determined using issue data (e.g Current Assignee), true will be returned
35-
if the user meets the permission criteria in ANY issue in that project If an issue context is provided,
36-
it will return whether or not the user has each permission in that specific issue
37-
NB: The above means that for issue-level permissions (EDIT_ISSUE for example),
38-
hasPermission may be true when no context is provided, or when a project context is provided,
39-
but may be false for any given (or all) issues. This would occur (for example)
40-
if Reporters were given the EDIT_ISSUE permission.
41-
This is because any user could be a reporter,
42-
except in the context of a concrete issue, where the reporter is known.
43-
44-
Global permissions will still be returned for all scopes.
45-
46-
Prior to version 6.4 this service returned project permissions with keys corresponding to
47-
com.atlassian.jira.security.Permissions.Permission constants.
48-
Since 6.4 those keys are considered deprecated and this service returns system project permission keys
49-
corresponding to constants defined in com.atlassian.jira.permission.ProjectPermissions.
50-
Permissions with legacy keys are still also returned for backwards compatibility,
51-
they are marked with an attribute deprecatedKey=true.
52-
The attribute is missing for project permissions with the current keys.
25+
def get_permissions(self, permissions, project_id=None, project_key=None, issue_id=None, issue_key=None):
26+
"""
27+
Returns a list of permissions indicating which permissions the user has. Details of the user's permissions can
28+
be obtained in a global, project, issue or comment context.
29+
30+
The user is reported as having a project permission:
31+
- in the global context, if the user has the project permission in any project.
32+
- for a project, where the project permission is determined using issue data, if the user meets the
33+
permission's criteria for any issue in the project. Otherwise, if the user has the project permission in
34+
the project.
35+
- for an issue, where a project permission is determined using issue data, if the user has the permission in the
36+
issue. Otherwise, if the user has the project permission in the project containing the issue.
37+
- for a comment, where the user has both the permission to browse the comment and the project permission for the
38+
comment's parent issue. Only the BROWSE_PROJECTS permission is supported. If a commentId is provided whose
39+
permissions does not equal BROWSE_PROJECTS, a 400 error will be returned.
40+
41+
This means that users may be shown as having an issue permission (such as EDIT_ISSUES) in the global context or
42+
a project context but may not have the permission for any or all issues. For example, if Reporters have the
43+
EDIT_ISSUES permission a user would be shown as having this permission in the global context or the context of
44+
a project, because any user can be a reporter. However, if they are not the user who reported the issue queried
45+
they would not have EDIT_ISSUES permission for that issue.
5346
47+
Global permissions are unaffected by context.
48+
49+
This operation can be accessed anonymously.
50+
51+
:param permissions: (str) A list of permission keys. This parameter accepts a comma-separated list. (Required)
5452
:param project_id: (str) id of project to scope returned permissions for.
5553
:param project_key: (str) key of project to scope returned permissions for.
5654
:param issue_id: (str) key of the issue to scope returned permissions for.
@@ -59,7 +57,7 @@ def get_permissions(self, project_id=None, project_key=None, issue_id=None, issu
5957
"""
6058

6159
url = self.resource_url("mypermissions")
62-
params = {}
60+
params = {"permissions": permissions}
6361

6462
if project_id:
6563
params["projectId"] = project_id

0 commit comments

Comments
 (0)