Skip to content

Commit

Permalink
Merge 5b3f372 into 949399a
Browse files Browse the repository at this point in the history
  • Loading branch information
hillairet committed Aug 9, 2016
2 parents 949399a + 5b3f372 commit 7251bd3
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions jira/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1667,6 +1667,51 @@ def project_role(self, project, id):

# Resolutions

def add_user_to_role(self, project, role, username):
"""
Add the user ``username`` to the ``role`` in ``project``
:param project: ID or key of the project to get the role from
:param role: ID of the role where the user will be added
:param username: The user to add to the role.
"""
data = {}
data['user'] = [username]
if isinstance(role, Number):
role = "%s" % role
url = self._get_url('project/' + project + '/role/' + role)

r = self._session.post(
url, data=json.dumps(data))
if r.status_code == 200:
return True
else:
logging.warning(
'Failed to add user %s to role. Got code: %s' % (username, r.status_code))
return r.status_code

def add_group_to_role(self, project, role, group):
"""
Add the ``group`` to the ``role`` in ``project``
:param project: ID or key of the project to get the role from
:param role: ID of the role where the user will be added
:param group: The group to add to the role.
"""
data = {}
data['group'] = [group]
if isinstance(role, Number):
role = "%s" % role
url = self._get_url('project/' + project + '/role/' + role)

r = self._session.post(url, data=json.dumps(data))
if r.status_code == 200:
return True
else:
logging.warning(
'Failed to add group %s to role. Got code: %s' % (group, r.status_code))
return r.status_code

def resolutions(self):
"""Get a list of resolution Resources from the server."""
r_json = self._get_json('resolution')
Expand Down

0 comments on commit 7251bd3

Please sign in to comment.