Skip to content

Commit 6b5a592

Browse files
darrylleeDarryl Lee
andauthored
Confluence add_space_permission method (#531)
* Add method for add_space_permission (https://developer.atlassian.com/cloud/confluence/rest/api-group-experimental/#api-api-space-spacekey-permission-post). Needs some exception catching to deal with 400 errors, but it works! * Cleanup JSON * Removing id Co-authored-by: Darryl Lee <[email protected]>
1 parent fce9787 commit 6b5a592

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

atlassian/confluence.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1952,6 +1952,26 @@ def add_user_to_group(self, username, group_name):
19521952
data = {'name': username}
19531953
return self.post(url, params=params, data=data)
19541954

1955+
def add_space_permissions(self, space_key, subject_type, subject_id, operation_key, operation_target):
1956+
"""
1957+
Add permissions to a space
1958+
1959+
:param space_key: str
1960+
:param subject_type: str
1961+
:param subject_id: str
1962+
:param operation_key: str
1963+
:param operation_target: str
1964+
:return: Current permissions of space
1965+
"""
1966+
url = 'rest/api/space/{}/permission'.format(space_key)
1967+
data = {
1968+
'subject': {'type': subject_type, 'identifier': subject_id},
1969+
'operation': {'key': operation_key, 'target': operation_target},
1970+
'_links': {}
1971+
}
1972+
1973+
return self.post(url, data=data, headers=self.experimental_headers)
1974+
19551975
def get_space_permissions(self, space_key):
19561976
"""
19571977
The JSON-RPC APIs for Confluence are provided here to help you browse and discover APIs you have access to.

0 commit comments

Comments
 (0)