To create a lease policy for your deployment, you make a POST request with a project ID that has a cloud template version released to the project.
- If specified with soft enforcement, the policy can be overridden and will have lower priority than policies with hard enforcement.
- If specified with hard enforcement, the policy must be enforced. If strict enforcement is not possible, for example in cases of conflicting policies, the policy can be overridden but Automation Service Broker will report an error.
Prerequisites
- Verify that all general prerequisites and prerequisites for the Automation Service Broker Policies service have been satisfied. See Prerequisites for API Use Case Examples.
- Verify that you have the ID for a project that has the cloud template versioned and released to it. See the prerequisites section of Create and Update a Cloud Template.
Procedure
Example: Create a lease policy with soft enforcement
Assign variables.
Note: If your organization uses an API service that is hosted outside of the United States, your URL variable must include a country abbreviation. See
Regional Endpoints for VMware Aria Automation APIs.
$ url='https://api.mgmt.cloud.vmware.com'
$ api_version='2020-08-25'
$ project_id='394a4ccb-22c6-4ef0-8c75-8b77efbefb51'
Create the soft lease policy named Sample Lease.
$ curl -X POST \ $url/policy/api/policies?apiVersion=$api_version \ -H "Authorization: Bearer $access_token" \ -H 'Content-Type: application/json' \ -d '{ "name":"Sample Lease", "projectId":"'$project_id'", "definition":{ "leaseGrace":1, "leaseTermMax":10, "leaseTotalTermMax":100 }, "enforcementType":"SOFT", "typeId":"com.vmware.policy.deployment.lease" }' | jq "."
The response shows the lease policy.
{ "id": "49893797-208c-4322-8ed5-061467674d54", "name": "Sample Lease", "typeId": "com.mycompany.policy.deployment.lease", "enforcementType": "SOFT", "orgId": "c9258a19-fef0-4431-a999-d711e1741c60", "projectId": "394a4ccb-22c6-4ef0-8c75-8b77efbefb51", "definition": { "leaseGrace": 1, "leaseTermMax": 10, "leaseTotalTermMax": 100 }, "createdAt": "2021-11-08T02:29:07.936Z", "createdBy": "[email protected]", "lastUpdatedAt": "2021-11-08T02:29:07.936Z", "lastUpdatedBy": "[email protected]" }