EditServerConfig
Edit the server configuration (under *settings/troubleshooting*). You can either add a new configuration or update and remove an existing one.
python · Common Scripts
Source
import traceback from typing import Any from CommonServerPython import * SERVER_SYSTEM_CONFIG_PATH = "/system/config" """ STANDALONE FUNCTION """ def get_current_server_config() -> dict: res = execute_command("core-api-get", {"uri": SERVER_SYSTEM_CONFIG_PATH}) config_json = res["response"] return config_json.get("sysConf", {}) def set_system_config(server_config: dict): execute_command( "core-api-post", { "uri": SERVER_SYSTEM_CONFIG_PATH, "body": {"data": server_config, "version": -1}, }, ) def remove_key_from_server_config(key: str, server_config: dict): if key in server_config: server_config.pop(key) set_system_config(server_config) def update_server_config(key: str, value: str, server_config: dict): if not value: raise DemistoException("EditServerConfig Error: You must give a value when you want to update a server configuration.") server_config[key] = value set_system_config(server_config) def edit_server_config(args: dict[str, Any]) -> CommandResults: action = args.get("action", "") key = args.get("key", "") value = args.get("value", "") sys_conf = get_current_server_config() if action == "update": update_server_config(key, value, sys_conf) elif action == "remove": remove_key_from_server_config(key, sys_conf) else: raise DemistoException("EditServerConfig Error: action must be update or remove.") return CommandResults(readable_output=f"Server configuration with {key} was {action}d successfully.") def main(): try: return_results(edit_server_config(demisto.args())) except Exception as ex: demisto.error(traceback.format_exc()) return_error(f"Failed to execute EditServerConfig. Error: {ex!s}") """ ENTRY POINT """ if __name__ in ("__main__", "__builtin__", "builtins"): main()
README
Edit the server configuration (under settings/troubleshooting). You can either add a new configuration or update and remove an existing one.
Script Data
| Name | Description |
|---|---|
| Script Type | python3 |
| Tags | |
| Cortex XSOAR Version | 6.0.0 |
Inputs
| Argument Name | Description |
|---|---|
| action | The action to make. If update is chosen and the key does not exist, a new key will be added. |
| key | The key to set. |
| value | The value to set. |
Outputs
There are no outputs for this script.
Script Example
!EditServerConfig action=update key=content.unlock.integrations value=HelloWorld
Human Readable Output
Server configuration with content.unlock.integrations was updated successfully.
Troubleshooting
Multi-tenant environments should be configured with the Cortex Rest API instance when using this
automation. Make sure the Use tenant parameter (in the Cortex Rest API integration) is checked
to ensure that API calls are made to the current tenant instead of the master tenant.