Integration Cache
#
OverviewOccasionally, you might need to store data between integration commands runs.
A common use-case would be storing API tokens which have expiration time (i.e. JWT).
Very often JWTs (a.k.a. JSON Web Tokens) are generated through an API call and have a validity of several minutes or hours: in order to avoid re-generating tokens every time a command is executed in Cortex XSOAR, you can cache them using integrationContext
and retrieve them until they expire.
For that, Cortex XSOAR introduces the cached object integrationContext
.
The object is stored in the database per integration instance.
Note: the integrationContext
object cannot be retrieved or set in the test-module
command.
#
ImplementationThe integrationContext
supports two methods: getter and setter.
Both methods are provided by the demisto
class.
If no object is stored, the method will return an empty dictionary.
getIntegrationContext()
Method#
The This is the getter the cached object, which returns a key-value dictionary.
setIntegrationContext()
Method#
The This is the setter the cached object.
This method takes only one argument - the object to store, which its keys and values must be strings.
Note that this method overrides the existing object which is stored, so in order to update a stored object, one should first get it, make the requested changes and then set it.