From fd8193e0bd217a5c14d370172ad9088b6312c9ea Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Thu, 20 May 2021 23:18:41 +0200 Subject: [PATCH] Add comment_visibility parameter for comment operation for jira module (#2556) (#2566) * Add comment_visibility parameter for comment operation for jira module Co-authored-by: felixfontein * Update plugins/modules/web_infrastructure/jira.py Co-authored-by: Felix Fontein * Update plugins/modules/web_infrastructure/jira.py Co-authored-by: Felix Fontein * addressed pep8 E711 * Added missing parameter. * params is not in use anymore. * It appears other modules are using options, where in documentation they use suboptions. Inconsistancy? * adjusted indentation * tweaked suboptions, fixed documentation * Added fragment * Update changelogs/fragments/2556-add-comment_visibility-parameter-for-comment-operation-of-jira-module.yml Co-authored-by: Felix Fontein * Update plugins/modules/web_infrastructure/jira.py Co-authored-by: Felix Fontein Co-authored-by: felixfontein (cherry picked from commit 7a169af0534d21142e2ddd5b89a882aedd2b6256) Co-authored-by: momcilo78 --- ...r-for-comment-operation-of-jira-module.yml | 2 + plugins/modules/web_infrastructure/jira.py | 39 +++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 changelogs/fragments/2556-add-comment_visibility-parameter-for-comment-operation-of-jira-module.yml diff --git a/changelogs/fragments/2556-add-comment_visibility-parameter-for-comment-operation-of-jira-module.yml b/changelogs/fragments/2556-add-comment_visibility-parameter-for-comment-operation-of-jira-module.yml new file mode 100644 index 0000000000..e31fad744a --- /dev/null +++ b/changelogs/fragments/2556-add-comment_visibility-parameter-for-comment-operation-of-jira-module.yml @@ -0,0 +1,2 @@ +minor_changes: + - jira - add comment visibility parameter for comment operation (https://github.com/ansible-collections/community.general/pull/2556). diff --git a/plugins/modules/web_infrastructure/jira.py b/plugins/modules/web_infrastructure/jira.py index 6acf0c7f51..4c10974126 100644 --- a/plugins/modules/web_infrastructure/jira.py +++ b/plugins/modules/web_infrastructure/jira.py @@ -86,6 +86,25 @@ options: - The comment text to add. - Note that JIRA may not allow changing field values on specific transitions or states. + comment_visibility: + type: dict + description: + - Used to specify comment comment visibility. + - See U(https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issue-comments/#api-rest-api-2-issue-issueidorkey-comment-post) for details. + suboptions: + type: + description: + - Use type to specify which of the JIRA visibility restriction types will be used. + type: str + required: true + choices: [group, role] + value: + description: + - Use value to specify value corresponding to the type of visibility restriction. For example name of the group or role. + type: str + required: true + version_added: '3.2.0' + status: type: str required: false @@ -223,6 +242,18 @@ EXAMPLES = r""" operation: comment comment: A comment added by Ansible +- name: Comment on issue with restricted visibility + community.general.jira: + uri: '{{ server }}' + username: '{{ user }}' + password: '{{ pass }}' + issue: '{{ issue.meta.key }}' + operation: comment + comment: A comment added by Ansible + comment_visibility: + type: role + value: Developers + # Assign an existing issue using edit - name: Assign an issue using free-form fields community.general.jira: @@ -385,6 +416,10 @@ class JIRA(StateModuleHelper): issuetype=dict(type='str', ), issue=dict(type='str', aliases=['ticket']), comment=dict(type='str', ), + comment_visibility=dict(type='dict', options=dict( + type=dict(type='str', choices=['group', 'role'], required=True), + value=dict(type='str', required=True) + )), status=dict(type='str', ), assignee=dict(type='str', ), fields=dict(default={}, type='dict'), @@ -445,6 +480,10 @@ class JIRA(StateModuleHelper): data = { 'body': self.vars.comment } + # if comment_visibility is specified restrict visibility + if self.vars.comment_visibility is not None: + data['visibility'] = self.vars.comment_visibility + url = self.vars.restbase + '/issue/' + self.vars.issue + '/comment' self.vars.meta = self.post(url, data)