JiraV3ConvertAttachmentsToTable
This script is used to convert Jira attachments to a table.
- Type
- python
- Pack
- Jira
Source
from itertools import chain
import demistomock as demisto
from CommonServerPython import *
def convert_to_table(context_results: List[Dict[str, Any]]) -> CommandResults:
"""
Args:
context_results (str): A list of dictionaries representing the attachments of the Jira issue.
Returns:
CommandResults: CommandResults object containing only readable_output
"""
attachments_names = [{"Name": context_result.get("name", "")} for context_result in context_results]
md = tableToMarkdown(
"",
attachments_names,
headers=[*dict.fromkeys(chain.from_iterable(attachments_names))],
removeNull=True,
sort_headers=False,
headerTransform=pascalToSpace,
)
return CommandResults(readable_output=md)
def main(): # pragma: no cover
try:
if context := dict_safe_get(
demisto.callingContext,
["context", "Incidents", 0, "CustomFields", "jiraattachments"],
{},
):
return_results(convert_to_table(context))
else:
return CommandResults(readable_output="No data to present")
except Exception as exc:
return_error(f"Failed to execute JiraV3ConvertAttachmentsToTable. Error: {exc}")
if __name__ in ("__main__", "__builtin__", "builtins"):
main()
README
This script is used to convert Jira attachments to a table.
Script Data
| Name | Description |
|---|---|
| Script Type | python3 |
| Tags | dynamic-section |
| Cortex XSOAR Version | 6.8.0 |
Inputs
There are no inputs for this script.
Outputs
There are no outputs for this script.