Skip to content

Commit ea5a7ca

Browse files
authored
[Jira] Add update_permissionscheme method (atlassian-api#1498)
1 parent 8ac11ad commit ea5a7ca

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

atlassian/jira.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3764,6 +3764,53 @@ def set_permissionscheme_grant(self, permission_id, new_permission):
37643764
url = "{base_url}/{schemeID}/permission".format(base_url=base_url, schemeID=permission_id)
37653765
return self.post(url, data=new_permission)
37663766

3767+
def update_permissionscheme(self, permission_id, name, description=None, permissions=None, scope=None, expand=None):
3768+
"""
3769+
Updates a permission scheme. Below are some important things to note when using this resource:
3770+
- If a permissions list is present in the request, then it is set in the permission scheme, overwriting all existing grants.
3771+
- If you want to update only the name and description, then do not send a permissions list in the request.
3772+
- Sending an empty list will remove all permission grants from the permission scheme.
3773+
3774+
Cloud API docs: https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-permission-schemes/#api-rest-api-3-permissionscheme-schemeid-put
3775+
3776+
:param permission_id: int, REQUIRED: The ID of the permission scheme to update.
3777+
:param name: str, REQUIRED: The name of the permission scheme. Must be unique.
3778+
:param description: str, OPTIONAL: A description for the permission scheme. Defaults to None.
3779+
:param permissions: list[dict], OPTIONAL: A collection of permission grants. Defaults to None.
3780+
Example:
3781+
[
3782+
{
3783+
"holder": {
3784+
"parameter": "jira-core-users",
3785+
"type": "group",
3786+
"value": "ca85fac0-d974-40ca-a615-7af99c48d24f"
3787+
},
3788+
"permission": "ADMINISTER_PROJECTS"
3789+
}
3790+
]
3791+
:param scope: OPTIONAL: The scope of the permission scheme.
3792+
:param expand: str, OPTIONAL: Use expand to include additional information in the response.
3793+
This parameter accepts a comma-separated list.
3794+
Note that permissions are always included when you specify any value.
3795+
3796+
:return:
3797+
"""
3798+
base_url = self.resource_url("permissionscheme")
3799+
url = "{base_url}/{scheme_id}".format(base_url=base_url, scheme_id=permission_id)
3800+
data = {"name": name}
3801+
if description is not None:
3802+
data["description"] = description
3803+
if permissions is not None:
3804+
data["permissions"] = permissions
3805+
if scope is not None:
3806+
data["scope"] = scope
3807+
3808+
params = {}
3809+
if expand:
3810+
params["expand"] = expand
3811+
3812+
return self.put(url, data=data, params=params)
3813+
37673814
"""
37683815
REST resource that allows to view security schemes defined in the product.
37693816
Resource for managing priority schemes.

0 commit comments

Comments
 (0)