API Explorer
API Explorer
Introduction
What's New
Appliance Management
Application Data Management
Asset Management
Asset Metadata
Authentication and Authorization
Cloud Disaster Recovery
Compliance
Copy Management
Credentials Management
Discovery
File Level Restore
Installation
Inventory Source Management
Kubernetes Data Management
Licenses Management
Location Management
Log Management
Monitoring
Protection Policies
Recovery and Reuse Management
Remote Service
Search Clusters
Secrets Manager
Server Disaster Recovery
Storage Management
Telemetry Setting
Upgrade
User Security Management
Virtual Machine Data Management
Whitelist Management

Create and update multi-condition protection rules

This tutorial describes how to create and update multi-condition protection rules. Protection rules enable you to automatically determine which assets are assigned to protection policies when the assets are discovered.

Basic Flow (Login → Create a protection policy → Create a multi-condition protection rule → Update a multi-condition protection rule )

1. Login

Use the login API call to retrieve the access token. See the authentication and authorization tutorial for more information.

2. Create a protection policy

A protection policy must exist prior to creating the protection rule. Create a protection policy as described in How to create protection policy.

Once the protection policy is created, the following API enables you to get the protection policy details.

Get the protection policy by filtering the name field:

GET /api/v2/protection-policies?filter=name eq "plc"

Get the protection policy by its ID:

GET /api/v2/protection-policies/4a5ea3d9-0d99-426a-b7bd-5b811c8caed4

The response is similiar to this:

OK (200)

{
    "id": "4a5ea3d9-0d99-426a-b7bd-5b811c8caed4",
    "name": "plc",
    "description": "",
    "assetType": "VMWARE_VIRTUAL_MACHINE",
    "type": "ACTIVE",
    "targetStorageProvisionStrategy": "AUTO_PROVISION",
    ...
}

3. Create a multi-condition protection rule

The following API enables you to create a multi-condition protection rule:

POST /api/v2/protection-rules

The following POST body example protects assets under condition 1 or condition 2:

Condition 1 Condition 2
VM display name matches the regular expression as “fake.*M[0-9][0-9]” in which the resource pool name contains “fake”. VM user tag is in list (“QA||CBS-Apple”,“DEV||CBS-Moon”).

In this POST example, the actionResult is the protection policy ID that you obtained from the create protection policy call.

{
    "name": "rule",
    "category": "COMPOUND",
    "rules": [
        {
            "category": "PRIMITIVE",
            "conditions": [
                {
                    "assetAttributeName": "name",
                    "operator": "MATCH_REGEX",
                    "assetAttributeValues": [
                        "fake.*M[0-9][0-9]"
                    ]
                },
                {
                    "assetAttributeName": "attributes.vm.resourcePool.resourcePoolName",
                    "operator": "CONTAINS",
                    "assetAttributeValues": [
                        "fake"
                    ]
                }
            ],
            "logicalOperator": "AND"
        },
        {
            "category": "PRIMITIVE",
            "conditions": [
                {
                    "assetAttributeName": "userTags",
                    "operator": "IN",
                    "assetAttributeValues": [
                        "QA||CBS-Apple",
                        "DEV||CBS-Moon"
                    ]
                }
            ],
            "logicalOperator": "AND"
        }
    ],
    "action": "MOVE_TO_GROUP",
    "actionResult": "4a5ea3d9-0d99-426a-b7bd-5b811c8caed4",
    "logicalOperator": "OR",
    "inventorySourceType": "VMWARE_VIRTUAL_MACHINE",
        "tenant": {
        "id": "00000000-0000-4000-a000-000000000000"
    }
}

The response code is 201 (Created).

4. Update a multi-condition protection rule

Once the protection rule is created, the following API enables you to get the protection rule details.

Get the protection rule by filtering the name field:

GET /api/v2/protection-rules?filter=name eq "rule"

Get the protection rule by its ID:

GET /api/v2/protection-rules/f44d10ec-ac0c-44d2-abc1-886b324fc3f1

The response is similiar to this:

OK (200)

{
    "id": "f44d10ec-ac0c-44d2-abc1-886b324fc3f1",
    "name": "rule",
    "category": "COMPOUND",
    "rules": [
        {
            "id": "721e2cca-30b7-4c5c-84e3-792672e43cf2",
            "category": "PRIMITIVE",
            "conditions": [
                {
                    ...
                },
                {
                    ...
                }
            ],
            "conditionConnector": "AND",
            "logicalOperator": "AND",
            ...
        },
        {
            "id": "dd1db275-18c5-4672-8863-e5994185cddc",
            "category": "PRIMITIVE",
            "conditions": [
                {
                    ...
                }
            ],
            "conditionConnector": "AND",
            "logicalOperator": "AND",
            ...
        }
    ],
    "action": "MOVE_TO_GROUP",
    "actionResult": "4a5ea3d9-0d99-426a-b7bd-5b811c8caed4",
    "conditionConnector": "OR",
    "logicalOperator": "OR",
    "inventorySourceType": "VMWARE_VIRTUAL_MACHINE",
    "priority": 4,
    "tenant": {
        "id": "00000000-0000-4000-a000-000000000000"
    },
    "...
}

The following API enables you to update a multi-condition protection rule:

PUT /api/v2/protection-rules/{id}

In this PUT example, the {id} is the protection rule ID that you obtained from the create protection rule call.

The following PUT body example updates the primitive rule condition.

{
    "id": "f44d10ec-ac0c-44d2-abc1-886b324fc3f1",
    "name": "rule",
    "category": "COMPOUND",
    "rules": [
        {
            "id": "dd1db275-18c5-4672-8863-e5994185cddc",
            "category": "PRIMITIVE",
            "conditions": [
                {
                    "assetAttributeName": "userTags",
                    "operator": "NOT_IN",
                    "assetAttributeValues": [
                        "DEV||CBS-Moon",
                        "QA||CBS-QA",
                        "DEV||CBS-Dev"
                    ]
                }
            ],
            "logicalOperator": "AND"
        }
    ],
    "action": "MOVE_TO_GROUP",
    "actionResult": "4a5ea3d9-0d99-426a-b7bd-5b811c8caed4",
    "logicalOperator": "OR",
    "inventorySourceType": "VMWARE_VIRTUAL_MACHINE",
    "priority": 5,
    "tenant": {
        "id": "00000000-0000-4000-a000-000000000000"
    }
}

The response is similiar to this:

OK (200)

{
    "id": "f44d10ec-ac0c-44d2-abc1-886b324fc3f1",
    "name": "rule",
    "category": "COMPOUND",
    "rules": [
        {
            "id": "dd1db275-18c5-4672-8863-e5994185cddc",
            "category": "PRIMITIVE",
            "conditions": [
                {
                    "assetAttributeName": "userTags",
                    "operator": "NOT_IN",
                    "assetAttributeValues": [
                        "DEV||CBS-Moon",
                        "QA||CBS-QA",
                        "DEV||CBS-Dev"
                    ]
                }
            ],
            "conditionConnector": "AND",
            "logicalOperator": "AND",
            ...
        }
    ],
    "action": "MOVE_TO_GROUP",
    "actionResult": "4a5ea3d9-0d99-426a-b7bd-5b811c8caed4",
    "conditionConnector": "OR",
    "logicalOperator": "OR",
    "inventorySourceType": "VMWARE_VIRTUAL_MACHINE",
    "priority": 4,
    "tenant": {
        "id": "00000000-0000-4000-a000-000000000000"
    },
    "assignedAssetsCount": 93,
    "lastRunAt": "2021-04-13T07:38:01.936Z",
    "_embedded": {
        "protectionlifeCycle": {
            "id": "4a5ea3d9-0d99-426a-b7bd-5b811c8caed4",
            "name": "plc",
            "type": "ACTIVE",
            "protectionEngine": null
        },
        "protectionPolicy": {
            "id": "4a5ea3d9-0d99-426a-b7bd-5b811c8caed4",
            "name": "plc",
            "type": "ACTIVE",
            "protectionEngine": null
        }
    }
}