The API provides access to many of the Workload Security system settings. It is useful
to automate configurations immediately after deployment.
You use the following SDK classes to interact with system settings:
SystemSettings: Defines properties for all of the available system settings. The properties are named after the system setting with which they correspond. For a list of system settings, see System Settings in the Settings Reference.SettingValue: Stores a single string value. UseSettingValueobjects to store the values ofSystemSettingsproperties, which are of type SettingValue.SystemSettingsApi: Enables you to list and modify system settings on Workload Security (using aSystemSettingsobject), and to get, modify, and reset the value of a specific system setting.
Retrieve, modify, or reset a single system setting
When you are working with one or a small number of system settings, use the methods
or functions of the
SystemSettingsApi class that provide access to a single system setting:- To retrieve a setting or to reset it to the default value, create a
SystemSettingsApiclass and use thedescribeSystemSettingorresetSystemSettingmethod or function. Include the setting name as an argument. See System Settings for a list of settings. - To modify a setting, create a
SystemSettingsApiclass and use themodifySystemSettingmethod or function, and include the setting name and setting value as arguments. The value is aSettingValueobject.
To modify a system setting, you need the name of the setting, and a
SettingValue object that contains the desired value. Note the value of a SettingValue object is a String:# value for platform_setting_agent_initiated_activation_enabled allow_value = api.SettingValue() allow_value.value = str(allow)
Then, use a
SystemSettingsApi object to modify the setting:system_settings_api = api.SystemSettingsApi(api.ApiClient(configuration)) return system_settings_api.modify_system_setting(api.SystemSettings.platform_setting_agent_initiated_activation_enabled, allow_value, api_version)
Example: Modify a single system setting
The following example sets the value of the system setting that controls whether agent-initiated
activation is allowed:
# Create the setting value allow_value = api.SettingValue() allow_value.value = str(allow) # Modify system setting on Workload Security system_settings_api = api.SystemSettingsApi(api.ApiClient(configuration)) return system_settings_api.modify_system_setting(api.SystemSettings.platform_setting_agent_initiated_activation_enabled, allow_value, api_version)
Also see the Modify a System Setting operation in the API Reference.
List or modify multiple system settings
When you are working with many system settings, use the methods or functions of the
SystemSettingsApi class that provide access to all system settings in a single call:listSystemSettings:Returns aSystemSettingsobject that contains the values that are set for all system settings on Workload Security.modifySystemSettings:Modifies all system settings according to theSystemSettingsobject that is provided as an argument.
Use the following general steps to use an SDK to modify a system setting:
-
Create a
SettingValueobject for every system setting that you are configuring. Set the value of each object to the value that you want for the corresponding system setting. -
Create a
SystemSettingsobject and set the properties to theSettingValueobjects. - Create a
SystemSettingsApiobject and use it to modify the system settings on Workload Security according to theSystemSettingsobject.
SettingValue values are of type String. The following example creates a SettingValue for a setting that you want to set to 100:max_sessions = api.SettingValue() max_sessions.value = "100"
Use the
SettingValue as the value of a setting:system_settings = api.SystemSettings() system_settings.platform_setting_active_sessions_max_num = max_sessions
Finally, modify the setting on Workload Security:
settings_api = api.SystemSettingsApi(api.ApiClient(configuration)) return settings_api.modify_system_settings(system_settings, api_version)
Example: Modify multiple system settings
The following example sets two system settings: the system setting that controls the
maximum number of sessions that a user can create, and the action that the manager
takes when the maximum is exceeded:
# Create the SettingValue object and set the max sessions value max_sessions = api.SettingValue() max_sessions.value = str(max_allowed) # Add the SettingValue object to a SystemSettings object system_settings = api.SystemSettings() system_settings.platform_setting_active_sessions_max_num = max_sessions # Repeat for the platform_setting_active_sessions_max_exceeded_action exceed_action = api.SettingValue() exceed_action.value = action system_settings.platform_setting_active_sessions_max_exceeded_action = exceed_action # Modify system settings on Workload Security settings_api = api.SystemSettingsApi(api.ApiClient(configuration)) return settings_api.modify_system_settings(system_settings, api_version)
Also see the Modify System Settings operation in the API Reference. For information about authenticating API calls, see
Authenticate with Workload Security.
