-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EN-4286: Jira add comment lego (#377)
- Loading branch information
1 parent
2bff5f4
commit 2b5f959
Showing
4 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
[<img align="left" src="https://unskript.com/assets/favicon.png" width="100" height="100" style="padding-right: 5px">](https://unskript.com/assets/favicon.png) | ||
<h2>Get Jira Add Comment</h2> | ||
|
||
<br> | ||
|
||
## Description | ||
This Lego adds a comment to a Jira Issue. | ||
|
||
|
||
## Lego Details | ||
|
||
jira_add_comment(handle: JIRA, issue_id: str, comment: str, visibility: Dict[str, str] = None) | ||
|
||
handle: Object of type unSkript jira Connector | ||
issue_id: Issue ID. | ||
comment: Comment to add in Jira Issue. | ||
visibility: a dict containing two entries: "type" and "value". | ||
"type" is 'role' (or 'group' if the Jira server has configured comment visibility for groups) | ||
"value" is the name of the role (or group) to which viewing of this comment will be restricted. | ||
is_internal: True marks the comment as 'Internal' in Jira Service Desk (Default: ``False``) | ||
|
||
## Lego Input | ||
This Lego take 4 input handle, issue_id, comment, visibility. | ||
|
||
## Lego Output | ||
Here is a sample output. | ||
<img src="./1.png"> | ||
|
||
## See it in Action | ||
|
||
You can see this Lego in action following this link [unSkript Live](https://us.app.unskript.io) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"action_title": "Jira Add Comment", | ||
"action_description": "Add a Jira Comment", | ||
"action_type": "LEGO_TYPE_JIRA", | ||
"action_entry_function": "jira_add_comment", | ||
"action_needs_credential": true, | ||
"action_output_type": "ACTION_OUTPUT_TYPE_INT", | ||
"action_supports_poll": true, | ||
"action_supports_iteration": true | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
## | ||
# Copyright (c) 2021 unSkript, Inc | ||
# All rights reserved. | ||
## | ||
|
||
from jira.client import JIRA | ||
from pydantic import BaseModel, Field | ||
from typing import Dict, Optional | ||
import pprint | ||
|
||
|
||
class InputSchema(BaseModel): | ||
issue_id: str = Field( | ||
title='JIRA Issue ID', | ||
description='Issue ID. Eg EN-1234' | ||
) | ||
comment: str = Field( | ||
title='Comment', | ||
description='Comment to add in Jira Issue' | ||
) | ||
visibility: Optional[Dict[str, str]] = Field( | ||
None, | ||
title='Visibility', | ||
description='''a dict containing two entries: "type" and "value". | ||
"type" is 'role' (or 'group' if the Jira server has configured comment visibility for groups) | ||
"value" is the name of the role (or group) to which viewing of this comment will be restricted.''' | ||
) | ||
is_internal: Optional[bool] = Field( | ||
False, | ||
title='Internal', | ||
description='True marks the comment as \'Internal\' in Jira Service Desk (Default: ``False``)' | ||
) | ||
|
||
|
||
def jira_add_comment_printer(output): | ||
if output is None: | ||
return | ||
pprint.pprint(output) | ||
|
||
|
||
def jira_add_comment(hdl: JIRA, | ||
issue_id: str, | ||
comment: str, | ||
visibility: Dict[str, str] = None, | ||
is_internal: bool = False) -> int: | ||
"""jira_get_issue Get Jira Issue Info | ||
:type hdl: JIRA | ||
:param hdl: Jira handle. | ||
:type issue_id: str | ||
:param issue_id: Issue ID. | ||
:type comment: str | ||
:param comment: Comment to add in Jira Issue. | ||
:type visibility: Dict[str, str] | ||
:param visibility: a dict containing two entries: "type" and "value". | ||
"type" is 'role' (or 'group' if the Jira server has configured comment visibility for groups) | ||
"value" is the name of the role (or group) to which viewing of this comment will be restricted. | ||
:type is_internal: bool | ||
:param is_internal: True marks the comment as \'Internal\' in Jira Service Desk (Default: ``False``) | ||
:rtype: Jira comment id (int) | ||
""" | ||
try: | ||
issue = hdl.issue(issue_id) | ||
comment = hdl.add_comment(issue, comment, visibility=visibility, is_internal=is_internal) | ||
except Exception as e: | ||
raise e | ||
return int(comment.id) |