Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions atlassian/jira.py
Original file line number Diff line number Diff line change
Expand Up @@ -1191,6 +1191,33 @@ def get_issue_labels(self, issue_key):
return self.get(url)
return (self.get(url) or {}).get("fields").get("labels")

def update_issue(self, issue_key, update):
"""
:param issue: the issue to update
:param update: the update to make
:return: True if successful, False if not
"""
endpoint = "/rest/api/2/issue/{issue_key}".format(issue_key=issue_key)
return self.put(endpoint, data=update)

def label_issue(self, issue_key, labels):
"""
:param issue: the issue to update
:param labels: the labels to add
:return: True if successful, False if not
"""
labels = [{"add": label} for label in labels]
return self.update_issue(issue_key, {"update": {"labels": labels}})

def unlabel_issue(self, issue_key, labels):
"""
:param issue: the issue to update
:param labels: the labels to remove
:return: True if successful, False if not
"""
labels = [{"remove": label} for label in labels]
return self.update_issue(issue_key, {"update": {"labels": labels}})

def add_attachment(self, issue_key, filename):
"""
Add attachment to Issue
Expand Down