From d493e21dbe73baeddeac7055abb12786dc1af25f Mon Sep 17 00:00:00 2001 From: Hasol Im Date: Thu, 7 Dec 2023 11:05:46 -0500 Subject: [PATCH 1/3] 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 --- atlassian/jira.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/atlassian/jira.py b/atlassian/jira.py index f85eac3b6..e00a3b73b 100644 --- a/atlassian/jira.py +++ b/atlassian/jira.py @@ -1160,11 +1160,13 @@ def issue_fields(self, key): issue = self.get("{base_url}/{key}".format(base_url=base_url, key=key)) return issue["fields"] - def update_issue_field(self, key, fields="*all"): + def update_issue_field(self, key, fields="*all", notify_users=True): base_url = self.resource_url("issue") + params = {"notifyUsers": "true" if notify_users else "false"} return self.put( "{base_url}/{key}".format(base_url=base_url, key=key), data={"fields": fields}, + params=params, ) def bulk_update_issue_field(self, key_list, fields="*all"): @@ -1465,13 +1467,14 @@ def issue_add_comment(self, issue_key, comment, visibility=None): data["visibility"] = visibility return self.post(url, data=data) - def issue_edit_comment(self, issue_key, comment_id, comment, visibility=None): + def issue_edit_comment(self, issue_key, comment_id, comment, visibility=None, notify_users=True): """ Updates an existing comment :param issue_key: str :param comment_id: int :param comment: str :param visibility: OPTIONAL + :param notify_users: bool OPTIONAL :return: """ base_url = self.resource_url("issue") @@ -1481,7 +1484,8 @@ def issue_edit_comment(self, issue_key, comment_id, comment, visibility=None): data = {"body": comment} if visibility: data["visibility"] = visibility - return self.put(url, data=data) + params = {"notifyUsers": "true" if notify_users else "false"} + return self.put(url, data=data, params=params) def get_issue_remotelinks(self, issue_key, global_id=None, internal_id=None): """ From 91d872674d6941b58e30ecc19c813184bddcc531 Mon Sep 17 00:00:00 2001 From: Hasol Im Date: Thu, 7 Dec 2023 11:24:58 -0500 Subject: [PATCH 2/3] Update JIRA docs --- docs/jira.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/jira.rst b/docs/jira.rst index 79d1e3f13..914e6b7bd 100644 --- a/docs/jira.rst +++ b/docs/jira.rst @@ -219,7 +219,7 @@ Manage issues # Update issue field fields = {'summary': 'New summary'} - jira.update_issue_field(key, fields) + jira.update_issue_field(key, fields, notify_users=True) # Get existing custom fields or find by filter jira.get_custom_fields(self, search=None, start=1, limit=50): @@ -316,6 +316,9 @@ Manage issues # Add Comments jira.issue_add_comment(issue_id_or_key, "This is a sample comment string.") + # Edit Comments + jira.issue_edit_comment(issue_key, comment_id, comment, visibility=None, notify_users=True) + # Issue Comments jira.issue_get_comments(issue_id_or_key) From 98b3a6aa682fd8964ba994ab09583314f7b7e001 Mon Sep 17 00:00:00 2001 From: Hasol Im Date: Thu, 7 Dec 2023 11:50:21 -0500 Subject: [PATCH 3/3] Add docstring for `update_issue_field` --- atlassian/jira.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/atlassian/jira.py b/atlassian/jira.py index e00a3b73b..3e49d722e 100644 --- a/atlassian/jira.py +++ b/atlassian/jira.py @@ -1161,6 +1161,15 @@ def issue_fields(self, key): return issue["fields"] def update_issue_field(self, key, fields="*all", notify_users=True): + """ + Update an issue's fields. + :param key: str Issue id or issye key + :param fields: dict with target fields as keys and new contents as values + :param notify_users: bool OPTIONAL if True, use project's default notification scheme to notify users via email. + if False, do not send any email notifications. (only works with admin privilege) + + Reference: https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issues/#api-rest-api-2-issue-issueidorkey-put + """ base_url = self.resource_url("issue") params = {"notifyUsers": "true" if notify_users else "false"} return self.put(