Create a Lease Policy
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.
- Verify that all general prerequisites and prerequisites for theAutomation Service BrokerPolicies 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.
Creating a lease policy is
optional. For example, you can create a lease policy to specify when you want a
deployment to expire. You specify the policy with either a soft or hard lease
enforcement type.
- 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 butAutomation Service Brokerwill report an error.
- Assign the project ID variable.project_id='<your_project_id>'
- Assign a lease policy with soft enforcement to your project.curl -X POST \ $url/policy/api/policies?apiVersion=$api_version \ -H "Authorization: Bearer $access_token" \ -H 'Content-Type: application/json' \ -d '{ "name":"<your_lease_policy_name>", "projectId":"'$project_id'", "definition":{ "leaseGrace":1, "leaseTermMax":10, "leaseTotalTermMax":100 }, "enforcementType":"SOFT", "typeId":"com.mycompany.policy.deployment.lease" }' | jq "."
Create a lease policy with soft
enforcement
Assign variables.
$ url='https://appliance.domain.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": "admin@mycompany.com", "lastUpdatedAt": "2021-11-08T02:29:07.936Z", "lastUpdatedBy": "admin@mycompany.com" }