RunPollingCommand

Runs a specified polling command one time. This is useful for initiating a local playbook context before running a polling scheduled task. This automation runs using the default Limited User role, unless you explicitly change the permissions. For more information, see the section about permissions here: - For Cortex XSOAR 6 see https://docs-cortex.paloaltonetworks.com/r/Cortex-XSOAR/6.x/Cortex-XSOAR-Playbook-Design-Guide/Automations - For Cortex XSOAR 8 Cloud see https://docs-cortex.paloaltonetworks.com/r/Cortex-XSOAR/8/Cortex-XSOAR-Cloud-Documentation/Create-a-script - For Cortex XSOAR 8.7 On-prem see https://docs-cortex.paloaltonetworks.com/r/Cortex-XSOAR/8.7/Cortex-XSOAR-On-prem-Documentation/Create-a-script

python · Common Scripts

Details

IDRunPollingCommand
Languagepython
From Version5.0.0
Docker Imagedemisto/python3:3.12.13.10404775

README

Runs a one time specified polling command. This is useful for initiating a local playbook context before running a polling scheduled task.

Script Data


Name Description
Script Type python
Tags -
Cortex XSOAR Version 4.0.0+

Inputs


Argument Name Description
ids The list of IDs to poll.
pollingCommand The name of the polling command to run.
pollingCommandArgName The name of the argument of the polling command.
additionalPollingCommandArgNames The comma-separated arguments of the polling command.
additionalPollingCommandArgValues The comma-separated arguments values of the polling command.

Outputs


There are no outputs for this script.

import pytest
from RunPollingCommand import prepare_arg_dict

IDS_ARGS = [
    # sanity
    (
        ("ids", ["a", "b", "c"], None, None, "SomeIntegration"),
        {"ids": "a,b,c", "using": "SomeIntegration"},
    ),
    # single ID
    (
        ("ids", "a", None, None),
        {"ids": "a"},
    ),
    # numeric IDs
    (
        ("ids", [1, 2, 3], None, None),
        {"ids": "1,2,3"},
    ),
    # extra args
    (
        ("ids", ["a", "b", "c"], "arg1", "value1"),
        {"ids": "a,b,c", "arg1": "value1"},
    ),
    # extra args as unicode lists
    (
        ("ids", ["a", "b", "c"], ["arg1", "arg2"], ["value1", "value2"]),
        {"ids": "a,b,c", "arg1": "value1", "arg2": "value2"},
    ),
    # extra args as chane of unicode
    (
        ("ids", ["a", "b", "c"], "arg1, arg2,arg3", ["value1", "value2", "value3"]),
        {"ids": "a,b,c", "arg1": "value1", "arg2": "value2", "arg3": "value3"},
    ),
    # extra args as string
    (
        ("ids", ["שלום"], "היי, arg2,arg3", ["ביי", "value2", "value3"]),
        {"ids": "שלום", "היי": "ביי", "arg2": "value2", "arg3": "value3"},
    ),
    # extra args as string with int values
    (
        ("ids", ["a", "b", "c"], "arg1,arg2", [1, 2]),
        {"ids": "a,b,c", "arg1": "1", "arg2": "2"},
    ),
]


@pytest.mark.parametrize("inputs, expected_args", IDS_ARGS)
def test_prepare_arg_dict(inputs, expected_args):
    args = prepare_arg_dict(*inputs)
    assert args == expected_args


def test_prepare_arg_dict__error():
    with pytest.raises(ValueError):
        prepare_arg_dict("ids", "a", "arg1", None)