Defining Your App’s Asset Configuration¶
Much of the functionality of a Splunk SOAR app depends on its ability to connect to external systems. This is done using an asset configuration, which provides the necessary connection details and credentials.
Like much of the definitions for objects in a Splunk SOAR app, the asset configuration is defined using Pydantic models. The power of Pydantic models allows you to define complex data structures with validation and serialization capabilities, in a way where your code editor will be able to provide autocompletions and type checking.
Note
Users familiar with the BaseConnector style of Splunk SOAR apps may remember defining asset configuration with JSON. The Splunk SOAR SDK prefers to define all configuration in Python, and generate the JSON schema automatically. This ensures that the code and configuration are always in sync, and provides developers with significantly more useful editor support.
In the case of assets, these models must be subclasses of Asset. An example Asset definition looks something like this:
41class Asset(BaseAsset):
42 base_url: str = AssetField(default="https://example")
43 api_key: str = AssetField(sensitive=True, description="API key for authentication")
44 key_header: str = AssetField(
45 default="Authorization",
46 value_list=["Authorization", "X-API-Key"],
47 description="Header for API key authentication",
48 )
49 timezone: ZoneInfo
50 timezone_with_default: ZoneInfo = AssetField(default=ZoneInfo("America/Denver"))
See also
For more information on how to define an asset configuration, see the App Structure documentation.
Finally, in order to register the asset configuration with the app, it must be provided to the App instance as the asset_cls parameter. For example:
app = App(
name="My App",
description="An example app",
version="1.0.0",
asset_cls=Asset, # <--- Asset class provided here
)