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 Deep Security Manager. Once it’s 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 Deep Security Manager.
  6. Use a ComputerApi object or a PolicyApi object to assign the shared ruleset to your computer(s).

For more information about shared rulesets, see the Deep Security Help Center.

Example: Create a Shared Ruleset from a software inventory

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

def create_shared_ruleset(computer_id, ruleset_name, api, configuration, api_version, api_exception):
    """ Creates a shared ruleset from a computer's software inventory.
    :param computer_id: The ID of the computer.
    :param ruleset_name: The name of the ruleset.
    :param api: The Deep Security API modules.
    :param configuration: Configuration object to pass to the api client.
    :param api_version: The version of the API to use.
    :param api_exception: The Deep Security API exception module.
    :return: A list of SoftwareChangeReviewResult objects.
    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
            new_inventory = software_inventories_api.describe_software_inventory(, api_version)

        # Create ruleset
        ruleset = api.Ruleset() = ruleset_name
        rulesets_api = api.RulesetsApi(api.ApiClient(configuration))
        return rulesets_api.create_ruleset(ruleset,, api_version)

    except api_exception as e:
        return "Exception: " + str(e)
 * Creates a shared ruleset from a computer's software inventory
 * @param {Number} computerID The ID of the computer whose inventory the ruleset should be created from.
 * @param {String} rulesetName The name of the ruleset.
 * @param {ApiClient} api The Deep Security API exports.
 * @param {String} apiVersion The api version to use.
 * @returns {Promise} A promise object that resolves to a Ruleset object.
exports.createSharedRuleset = function(computerID, rulesetName, api, apiVersion) {
  return new Promise((resolve, reject) => {= new api.SoftwareInventory();
    softwareInventory.computerID = computerID;
    const softwareInventoryApi = new api.SoftwareInventoriesApi();
    softwareInventoryApi.createSoftwareInventory(softwareInventory, apiVersion)
      .then(softwareInventory => {waitForInventoryBuild() {
          softwareInventoryApi.describeSoftwareInventory(softwareInventory.ID, apiVersion)
            .then(softwareInventory => {
              if (softwareInventory.state === api.SoftwareInventory.StateEnum.complete) {= new api.Ruleset();
       = rulesetName;

                const rulesetApi = new api.RulesetsApi();
                rulesetApi.createRuleset(ruleset, softwareInventory.ID, apiVersion)
                  .then(ruleset => {
                    return resolve(ruleset);
                  .catch(error => {
                    return reject(error);
              } else {30 seconds
                setTimeout(waitForInventoryBuild, 30000);
            .catch(error => {
              return reject(error);
      .catch(error => {
 * Create a shared ruleset from a computer's software inventory.
 * @param computerId The ID of the computer whose software inventory the ruleset will be created from.
 * @param rulesetName The name of the ruleset.
 * @param apiVersion The api version.
 * @return The newly created ruleset.
public static Ruleset createSharedRuleset(Integer computerId, String rulesetName, String apiVersion) {= new SoftwareInventory();
	SoftwareInventoriesApi softwareInventoriesApi = new SoftwareInventoriesApi();
	try {
		SoftwareInventory newInventory = softwareInventoriesApi.createSoftwareInventory(softwareInventory, apiVersion);
		Long inventoryId = newInventory.getID();while(!newInventory.getState().equals(StateEnum.COMPLETE)) {30 seconds
			try {
				//System.out.println("Waiting 30 seconds...");
			} catch (InterruptedException e) {
			newInventory = softwareInventoriesApi.describeSoftwareInventory(inventoryId, apiVersion);
		}= new Ruleset();
		RulesetsApi rulesetApi = new RulesetsApi();
		return rulesetApi.createRuleset(ruleset, inventoryId, apiVersion);
	} catch (ApiException e) {
	return null;

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