Skip to content

Commit 3e1ef05

Browse files
authored
JIRA: Add notify_users option to 2 methods (#1278)
* Add notify_users option to 2 methods update_issue_field method can utilize "notifyUsers" query parameter to enable/disable email notification. https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-issueidorkey-put So does issue_edit_coment method as well. https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-comments/#api-rest-api-3-issue-issueidorkey-comment-id-put * Update JIRA docs * Add docstring for `update_issue_field`
1 parent cfde828 commit 3e1ef05

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

atlassian/jira.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,11 +1160,22 @@ def issue_fields(self, key):
11601160
issue = self.get("{base_url}/{key}".format(base_url=base_url, key=key))
11611161
return issue["fields"]
11621162

1163-
def update_issue_field(self, key, fields="*all"):
1163+
def update_issue_field(self, key, fields="*all", notify_users=True):
1164+
"""
1165+
Update an issue's fields.
1166+
:param key: str Issue id or issye key
1167+
:param fields: dict with target fields as keys and new contents as values
1168+
:param notify_users: bool OPTIONAL if True, use project's default notification scheme to notify users via email.
1169+
if False, do not send any email notifications. (only works with admin privilege)
1170+
1171+
Reference: https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issues/#api-rest-api-2-issue-issueidorkey-put
1172+
"""
11641173
base_url = self.resource_url("issue")
1174+
params = {"notifyUsers": "true" if notify_users else "false"}
11651175
return self.put(
11661176
"{base_url}/{key}".format(base_url=base_url, key=key),
11671177
data={"fields": fields},
1178+
params=params,
11681179
)
11691180

11701181
def bulk_update_issue_field(self, key_list, fields="*all"):
@@ -1465,13 +1476,14 @@ def issue_add_comment(self, issue_key, comment, visibility=None):
14651476
data["visibility"] = visibility
14661477
return self.post(url, data=data)
14671478

1468-
def issue_edit_comment(self, issue_key, comment_id, comment, visibility=None):
1479+
def issue_edit_comment(self, issue_key, comment_id, comment, visibility=None, notify_users=True):
14691480
"""
14701481
Updates an existing comment
14711482
:param issue_key: str
14721483
:param comment_id: int
14731484
:param comment: str
14741485
:param visibility: OPTIONAL
1486+
:param notify_users: bool OPTIONAL
14751487
:return:
14761488
"""
14771489
base_url = self.resource_url("issue")
@@ -1481,7 +1493,8 @@ def issue_edit_comment(self, issue_key, comment_id, comment, visibility=None):
14811493
data = {"body": comment}
14821494
if visibility:
14831495
data["visibility"] = visibility
1484-
return self.put(url, data=data)
1496+
params = {"notifyUsers": "true" if notify_users else "false"}
1497+
return self.put(url, data=data, params=params)
14851498

14861499
def get_issue_remotelinks(self, issue_key, global_id=None, internal_id=None):
14871500
"""

docs/jira.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ Manage issues
219219
220220
# Update issue field
221221
fields = {'summary': 'New summary'}
222-
jira.update_issue_field(key, fields)
222+
jira.update_issue_field(key, fields, notify_users=True)
223223
224224
# Get existing custom fields or find by filter
225225
jira.get_custom_fields(self, search=None, start=1, limit=50):
@@ -316,6 +316,9 @@ Manage issues
316316
# Add Comments
317317
jira.issue_add_comment(issue_id_or_key, "This is a sample comment string.")
318318
319+
# Edit Comments
320+
jira.issue_edit_comment(issue_key, comment_id, comment, visibility=None, notify_users=True)
321+
319322
# Issue Comments
320323
jira.issue_get_comments(issue_id_or_key)
321324

0 commit comments

Comments
 (0)