KeylightCreateIssue

Use this script to simplify the process of creating or updating a record in Keylight (v2). You specify custom arguments for which to populate the components. The arguments in this documentation are meant as examples only.

python · Lockpath Keylight

Details

IDKeylightCreateIssue
Languagepython
From Version5.0.0
Docker Imagedemisto/python3:3.12.13.10116658

README

Use this script to simplify the process of creating or updating a record in Keylight (v2). You specify custom arguments for which to populate the components. The arguments in this documentation are meant as examples only.

Script Data


Name Description
Script Type python3
Cortex XSOAR Version 5.0.0

Dependencies


This script uses the following commands and scripts.

  • kl-get-component
  • kl-get-records

Inputs


Argument Name Description
task_id The task ID (task name) of the task to create. This is not a lookup field.
project The project name to create. This is a lookup field.

Outputs


Path Description Type
Keylight.JSON The format needed to create or update a record in Keylight(v2). Unknown
import json

import CommonServerPython as csp
import demistomock as demisto
from pytest import raises  # noqa: PT013


def test_script(mocker):
    return_data = [
        [{"Contents": [{"Name": "Audit Projects", "ID": 123, "ShortName": "bla bla", "SystemName": "bla bla"}]}],
        [{"Contents": [{"DisplayName": "cool project", "ID": "1"}]}],
    ]
    mocker.patch.object(demisto, "args", return_value={"task_id": "This is task", "project": "cool project"})
    mocker.patch.object(demisto, "executeCommand", side_effect=return_data)
    spy = mocker.spy(csp, "return_outputs")
    from KeylightCreateIssue import main

    main()
    assert json.loads(spy.mock_calls[0][1][0]) == [
        {"fieldName": "Task ID", "value": "This is task", "isLookup": False},
        {"fieldName": "Audit Project", "value": "1", "isLookup": True},
    ]

    # Can't find the wanted project
    mocker.patch.object(demisto, "executeCommand", side_effect=return_data)
    mocker.patch.object(demisto, "args", return_value={"task_id": "This is task", "project": "uncool project"})
    with raises(ValueError):
        main()