SetMultipleValues
Set multiple keys/values to the context.
- Type
- python
- Pack
- CommonScripts
Source
import demistomock as demisto # noqa: F401
from CommonServerPython import * # noqa: F401
def main():
delimiter = demisto.args().get("delimiter", ",")
keys = [k.strip() for k in demisto.args()["keys"].split(delimiter)]
values_str = demisto.args()["values"]
if "[" in values_str and "]" in values_str:
values_str = f"[{values_str}]"
values = argToList(values_str, separator=delimiter)
ec = {demisto.args()["parent"] + "(true)": dict(zip(keys, values))}
demisto.results(
{
"Type": entryTypes["note"],
"Contents": ec,
"ContentsFormat": formats["json"],
"HumanReadable": "Keys " + ",".join(keys) + " set",
"EntryContext": ec,
}
)
if __name__ in ("__main__", "__builtin__", "builtins"): # pragma: no cover
main()
README
Sets multiple key/value pairs to the context under a common parent key.
Script Data
| Name | Description |
|---|---|
| Script Type | python |
| Tags | Utility |
Inputs
| Argument Name | Description | Required | |||
|---|---|---|---|---|---|
| parent | The parent key to which we append all the other keys. | Required | |||
| keys | Separated list of keys separated by the specified delimiter (Comma is the default delimiter). | Required | |||
| values | Separated list of values separated by the specified delimiter (Comma is the default delimiter). | Required | |||
| delimiter | Delimiter by which the content of the values and keys lists are separated. Eg: “,” , “:”, “ |
”. Default is “,”. | Optional |
Outputs
There are no outputs for this script.
Example
Command
!SetMultipleValues parent=test_parent keys=key1,key2,key3 values=val1,valu2,val3
Context Result
