ProvidesCommand

Finds which integrations implement a specific Demisto command. The results will be returned as comma-separated values (CSV). The "Core REST API" integration must first be enabled.

python · Common Scripts

Details

IDProvidesCommand
Languagepython
From Version5.0.0
Docker Imagedemisto/python3:3.12.13.10404775
Tagsgeneral

README

Finds which integrations implement a specific Demisto command. The results will be returned as comma-separated values (CSV). The “Core REST API” integration must first be enabled.

Script Data


Name Description
Script Type python3
Tags general
Cortex XSOAR Version 5.0.0

Dependencies


This script uses the following commands and scripts.

  • core-api-post
  • core-api-get

Inputs


Argument Name Description
command The integration command to find
enabled Filters results to integrations that are enabled or disabled. ‘true’ or ‘false’. Will return both types by default. False means that an integration instance is either not defined or not enabled. True means that an integration instance is both defined and enabled.

Outputs


There are no outputs for this script.

Troubleshooting

Multi-tenant environments should be configured with the Cortex Rest API instance when using this
automation. Make sure the Use tenant parameter (in the Cortex Rest API integration) is checked
to ensure that API calls are made to the current tenant instead of the master tenant.

import json

import demistomock as demisto


def executeCommand(name, args=None):
    if name == "core-api-get" and args and "uri" in args and args["uri"] == "/settings/integration-commands":
        file_name = "TestData/integration_commands.json"
    elif name == "core-api-post" and args and "uri" in args and args["uri"] == "/settings/integration/search":
        file_name = "TestData/integration_search.json"
    else:
        raise ValueError(f"Unimplemented command called: {name}")

    with open(file_name) as f:
        raw_data = f.read()
        data = json.loads(raw_data)
        return data


def test_main(mocker):
    from ProvidesCommand import main

    mocker.patch.object(demisto, "executeCommand", side_effect=executeCommand)

    mocker.patch.object(demisto, "args", return_value={"command": "send-mail"})
    mocker.patch.object(demisto, "results")
    main()
    assert demisto.results.call_count == 1
    results = demisto.results.call_args
    assert results[0][0] == "EWS Mail Sender,Gmail,mail-sender,Mail Sender (New)"

    mocker.patch.object(demisto, "args", return_value={"command": "send-mail", "enabled": "true"})
    mocker.patch.object(demisto, "results")
    main()
    assert demisto.results.call_count == 1
    results = demisto.results.call_args
    assert results[0][0] == "Mail Sender (New)"

    mocker.patch.object(demisto, "args", return_value={"command": "send-mail", "enabled": "false"})
    mocker.patch.object(demisto, "results")
    main()
    assert demisto.results.call_count == 1
    results = demisto.results.call_args
    assert results[0][0] == "EWS Mail Sender,Gmail,mail-sender"