Skip to content

Commit 9181fe1

Browse files
committed
Confluence: remove user from group method
1 parent 0e7b9bf commit 9181fe1

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

atlassian/confluence.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -3368,9 +3368,21 @@ def add_user_to_group(self, username, group_name):
33683368
:param group_name: str - name of group to add user to
33693369
:return: Current state of the group
33703370
"""
3371-
url = "rest/api/user/%s/group/%s" % (username, group_name)
3371+
url = f"rest/api/user/{username}/group/{group_name}"
33723372
return self.put(url)
33733373

3374+
def remove_user_from_group(self, username, group_name):
3375+
"""
3376+
Remove the given {@link User} identified by username from the given {@link Group} identified by groupName.
3377+
This method is idempotent i.e. if the membership is not present then no action will be taken.
3378+
3379+
:param username: str - username of user to add to group
3380+
:param group_name: str - name of group to add user to
3381+
:return: Current state of the group
3382+
"""
3383+
url = f"rest/api/user/{username}/group/{group_name}"
3384+
return self.delete(url)
3385+
33743386
# Space Permissions
33753387
def get_all_space_permissions(self, space_key):
33763388
"""

docs/confluence.rst

+6
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,12 @@ Users and Groups
349349
# Change calling user's password
350350
confluence.change_my_password(oldpass, newpass)
351351
352+
# Add given user to a group
353+
confluence.add_user_to_group(username, group_name)
354+
355+
# Remove given user from a group
356+
confluence.remove_user_from_group(username, group_name)
357+
352358
CQL
353359
---
354360

0 commit comments

Comments
 (0)