Example 3: Configuring many settings at once

In this example, we are going to configure many settings at once using the multiple set option of the plugin store command, in order to quickly dispatch a large configuration for a Plugin.

For more information about the plugin store command and options, see plugin store and Introduction.

The syntax for this type of command is the following:
plugin store “<plugin name>” multiple set “<percent encoded json>” on “<now>”
Suppose that we already collected a great number of settings for a Plugin in a JSON file formatted as follows:
{
    “settingKey1”: “settingValue1”,
    “settingKey2”: “settingValue2”,
    “settingKey3”: “settingValue3”,
    …
    “settingKeyN”: “settingValueN”,
}

As described in Example 1: Configuring the AWS Plugin, we can just create a new action and fill the action script with the commands we desire. In this case, we will issue a multiple set after having copied and pasted the percent encoded JSON in the appropriate section.

<?xml version="1.0" encoding="utf-8"?>
<BES xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" SkipUI="true">
    <SingleAction>
        <Title>AWS Plugin Config Template</Title>
        <Relevance>true</Relevance>
        <ActionScript MIMEType="application/x-Fixlet-Windows-Shell">
            plugin store "AWSAssetDiscoveryPlugin" multiple set "<percent encoded json>" on "{parameter "action issue date" of action}"
        </ActionScript>
        <SuccessCriteria />
        <Settings />
        <SettingsLocks />
        <Target>
            <ComputerID>1078556546</ComputerID>
        </Target>
    </SingleAction>
</BES>

Issuing this action through the REST APIs, will result in the addition of all the key-values of the configuration JSON in the database.

As displayed in the image below, hundreds of settings can be quickly added in one single operation.



Note that the added settings are in clear text as we have not added the “encrypted” keyword.

This type of approach was meant to be executed from code and, as such, the easier path is creating a dedicated script for encoding the JSON file, creating the action script and then issuing the new action through REST APIs.