BaseScript

[Enter a description of the script, including what function it performs and any important information users need to know, for example required permissions.].

python · Starter Pack

Source

import demistomock as demisto  # noqa: F401
from CommonServerPython import *  # noqa: F401

"""Base Script for Cortex XSOAR (aka Demisto)

This is an empty script with some basic structure according
to the code conventions.

MAKE SURE YOU REVIEW/REPLACE ALL THE COMMENTS MARKED AS "TODO"

Developer Documentation: https://xsoar.pan.dev/docs/welcome
Code Conventions: https://xsoar.pan.dev/docs/integrations/code-conventions
Linting: https://xsoar.pan.dev/docs/integrations/linting

"""

from CommonServerUserPython import *

from typing import Any


""" STANDALONE FUNCTION """


# TODO: REMOVE the following dummy function:
def basescript_dummy(dummy: str) -> dict[str, str]:
    """Returns a simple python dict with the information provided
    in the input (dummy).

    :type dummy: ``str``
    :param dummy: string to add in the dummy dict that is returned

    :return: dict as {"dummy": dummy}
    :rtype: ``str``
    """

    return {"dummy": dummy}


# TODO: ADD HERE THE FUNCTIONS TO INTERACT WITH YOUR PRODUCT API


""" COMMAND FUNCTION """


# TODO: REMOVE the following dummy command function
def basescript_dummy_command(args: dict[str, Any]) -> CommandResults:
    dummy = args.get("dummy", None)
    if not dummy:
        raise ValueError("dummy not specified")

    # Call the standalone function and get the raw response
    result = basescript_dummy(dummy)

    return CommandResults(
        outputs_prefix="BaseScript",
        outputs_key_field="",
        outputs=result,
    )


# TODO: ADD additional command functions that translate XSOAR inputs/outputs


""" MAIN FUNCTION """


def main():
    try:
        # TODO: replace the invoked command function with yours
        return_results(basescript_dummy_command(demisto.args()))
    except Exception as ex:
        return_error(f"Failed to execute BaseScript. Error: {str(ex)}")


""" ENTRY POINT """


if __name__ in ("__main__", "__builtin__", "builtins"):
    main()

README

Script description.

Script Data


Name Description
Script Type python3
Tags basescript
Cortex XSOAR Version 5.0.0

Inputs


Argument Name Description
dummy [Enter a description of the argument, including any important information users need to know, for example, default values.]

Outputs


Path Description Type
BaseScript.Output [Enter a description of the data returned in this output.] String