Table of contents
Topics on this page

Create a shared ruleset

Shared rulesets allow you to apply and manage your rules across multiple different computers. Generally, use the following steps to create a shared ruleset:

  1. Create and configure a SoftwareInventory object for the computer you wish to base the ruleset on.
  2. Use a SoftwareInventoryApi object to create the software inventory on Workload Security. Once it is created, an inventory build begins on the specified computer.
  3. Use the SoftwareInventoryApi object to confirm that the inventory build has completed successfully.
  4. Create a Ruleset object.
  5. Use a RulesetApi object to create the Ruleset on Workload Security.
  6. Use a ComputerApi object or a PolicyApi object to assign the shared ruleset to your computers.

For more information about shared rulesets, see the Use the API to create shared and global rulesets.

The following example creates a software inventory and uses that software inventory to create a Shared Ruleset:

source

software_inventory = api.SoftwareInventory()
software_inventory.computer_id = computer_id

# Build software_inventory
software_inventories_api = api.SoftwareInventoriesApi(api.ApiClient(configuration))
new_inventory = software_inventories_api.create_software_inventory(software_inventory, api_version)

while new_inventory.state != "complete":
    # check status every 30 seconds
    time.sleep(30)
    new_inventory = software_inventories_api.describe_software_inventory(new_inventory.id, api_version)

# Create ruleset
ruleset = api.Ruleset()
ruleset.name = ruleset_name
rulesets_api = api.RulesetsApi(api.ApiClient(configuration))

return rulesets_api.create_ruleset(ruleset, new_inventory.id, api_version)

Also see the Create a Shared Ruleset operation in the API Reference.