IsDemistoRestAPIInstanceAvailable

Checks if the provided Core/Demisto REST API instance is available for the XSOAR Simple Dev to Prod workflow.

python · XSOAR - Simple Dev to Prod

Details

IDIsDemistoRestAPIInstanceAvailable
Languagepython
From Version6.0.0
Docker Imagedemisto/python3:3.12.8.3296088
TagsCondition infra

README

Checks if the provided Cortex XSOAR REST API instance is available for the XSOAR Simple Dev to Prod workflow.

Script Data


Name Description
Script Type python3
Tags Condition, infra

Inputs


Argument Name Description
instanceName The name of the Core/Demisto REST API instance to check.

Outputs


Path Description Type
yes The instance is available. Unknown
no The instance is not available. Unknown
import demistomock as demisto  # noqa: F401
from CommonServerPython import *  # noqa: F401

brandNames = ["demisto rest api", "core rest api"]
instanceName = demisto.args().get("instanceName")
allInstances = demisto.getModules()
brandInstances = [
    instanceName
    for instanceName in allInstances
    if allInstances[instanceName]["brand"].lower() in brandNames
    and demisto.get(allInstances[instanceName], "state")
    and allInstances[instanceName]["state"] == "active"
]
if brandInstances and instanceName in brandInstances:
    instance = allInstances.get(instanceName)
    instance["name"] = instanceName
    demisto.setContext("DemsistoAPIInstances", instance)
    demisto.results("yes")
else:
    demisto.results("no")