Skip to content

Commit 8583e25

Browse files
author
Sky Moore
committed
feat: label and unlabel issues
1 parent 4e10bec commit 8583e25

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

atlassian/jira.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,6 +1191,33 @@ def get_issue_labels(self, issue_key):
11911191
return self.get(url)
11921192
return (self.get(url) or {}).get("fields").get("labels")
11931193

1194+
def update_issue(self, issue_key, update):
1195+
"""
1196+
:param issue: the issue to update
1197+
:param update: the update to make
1198+
:return: True if successful, False if not
1199+
"""
1200+
endpoint = "/rest/api/2/issue/{issue_key}".format(issue_key=issue_key)
1201+
return self.put(endpoint, data=update)
1202+
1203+
def label_issue(self, issue_key, labels):
1204+
"""
1205+
:param issue: the issue to update
1206+
:param labels: the labels to add
1207+
:return: True if successful, False if not
1208+
"""
1209+
labels = [{"add": label} for label in labels]
1210+
return self.update_issue(issue_key, {"update": {"labels": labels}})
1211+
1212+
def unlabel_issue(self, issue_key, labels):
1213+
"""
1214+
:param issue: the issue to update
1215+
:param labels: the labels to remove
1216+
:return: True if successful, False if not
1217+
"""
1218+
labels = [{"remove": label} for label in labels]
1219+
return self.update_issue(issue_key, {"update": {"labels": labels}})
1220+
11941221
def add_attachment(self, issue_key, filename):
11951222
"""
11961223
Add attachment to Issue

0 commit comments

Comments
 (0)