Skip to content

Commit

Permalink
[Jira] Fix the parameter of remove_user_from_group from username to a…
Browse files Browse the repository at this point in the history
…ccount id (#1018)

* Fix the parameter from username to account id

* fix remove_user_from_group for both DC and Cloud

* fix optional parameter syntax

* add docs

* fix optional parameter syntax

add docs

* fix format by black
  • Loading branch information
YugoHino authored Aug 11, 2022
1 parent bb360be commit c0b7627
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
15 changes: 12 additions & 3 deletions atlassian/jira.py
Original file line number Diff line number Diff line change
Expand Up @@ -772,18 +772,27 @@ def add_user_to_group(self, username, group_name):
data = {"name": username}
return self.post(url, params=params, data=data)

def remove_user_from_group(self, username, group_name):
def remove_user_from_group(self, username=None, group_name=None, account_id=None):
"""
Remove given user from a group
For Jira DC/Server platform
:param username: str
:param group_name: str
:return:
For Jira Cloud platform
:param account_id: str (username is no longer available for Jira Cloud platform)
:param group_name: str
:return:
"""
log.warning("Removing user from a group...")
url = self.resource_url("group/user")
params = {"groupname": group_name, "username": username}

url_domain = self.url
if "atlassian.net" in url_domain:
params = {"groupname": group_name, "accountId": account_id}
else:
params = {"groupname": group_name, "username": username}
return self.delete(url, params=params)

def get_users_with_browse_permission_to_a_project(
Expand Down
2 changes: 1 addition & 1 deletion docs/jira.rst
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Manage groups
jira.add_user_to_group(username, group_name)
# Remove given user from a group
jira.remove_user_from_group(username, group_name)
jira.remove_user_from_group(username=None, group_name=None, account_id=None)
Manage projects
---------------
Expand Down

0 comments on commit c0b7627

Please sign in to comment.