diff --git a/atlassian/jira.py b/atlassian/jira.py index b82a0a4d7..83af2c4cc 100644 --- a/atlassian/jira.py +++ b/atlassian/jira.py @@ -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