Skip to content

Commit

Permalink
Update crowd.py
Browse files Browse the repository at this point in the history
- Using black to format code, replace pylint.
  • Loading branch information
zhouruixi committed Dec 10, 2023
1 parent 122b516 commit d67c889
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions atlassian/crowd.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,43 +131,40 @@ def user_delete(self, username):

return self.delete(self._crowd_api_url("usermanagement", "user"), params=params)

def user_groups(self, username, kind='direct'):
def user_groups(self, username, kind="direct"):
"""
Get user's all group info
:param username: str - username
:param kind: str - group type
:return: The specify user's group info
"""
path = self._crowd_api_url("usermanagement",
"user/group/{kind}".format(kind=kind))
response = self.get(path, params={'username': username})
return search('groups[*].name', response)
path = self._crowd_api_url("usermanagement", "user/group/{kind}".format(kind=kind))
response = self.get(path, params={"username": username})
return search("groups[*].name", response)

def group_members(self, group, kind='direct', max_results=99999):
def group_members(self, group, kind="direct", max_results=99999):
"""
Get group's all direct members
:param group: str - group name
:param kind: str - group type
:param max_results: int - maximum number of results
:return: The specify group's direct members info
"""
path = self._crowd_api_url("usermanagement",
"group/user/{kind}".format(kind=kind))
params = {'groupname': group, 'max-results': max_results}
path = self._crowd_api_url("usermanagement", "group/user/{kind}".format(kind=kind))
params = {"groupname": group, "max-results": max_results}
response = self.get(path, params=params)
return search('users[*].name', response)
return search("users[*].name", response)

def is_user_in_group(self, username, group, kind='direct'):
def is_user_in_group(self, username, group, kind="direct"):
"""
Check if the user is a member of the group
:param username: str - username
:param group: str - group name
:param kind: str - group type
:return: bool - Return `True` or `False`
"""
path = self._crowd_api_url("usermanagement",
"group/user/{kind}".format(kind=kind))
params = {'username': username, 'groupname': group}
path = self._crowd_api_url("usermanagement", "group/user/{kind}".format(kind=kind))
params = {"username": username, "groupname": group}
response = self.get(path, params=params, advanced_mode=True)
return response.status_code == 200

Expand Down

0 comments on commit d67c889

Please sign in to comment.