VMware Cloud Community
ManishKumarSing
Contributor
Contributor

How to delete a virtual machine using VRA rest api

Hi,

We created virtial machine using VRA rest api, once the task is done we want to remove the machine.

Is there rest api to delete the VM.

2 Replies
jacksonecac
Enthusiast
Enthusiast

Yes, by default in the Library folder there is a native workflow under the vCenter folder that will delete a vm.

Reply
0 Kudos
Craig_G2
Hot Shot
Hot Shot

Hi, in vRA 7 you would do something like this...

Get the Id of the resource you want to destroy:

GET: https://vra.corp.local/catalog-service/api/consumer/resources

Then get the Id of the destroy action (assuming it has been entitled):

GET: https://vra.corp.local/catalog-service/api/consumer/resources/{resourceId}/actions

Then you can grab the template for the resource action:

GET: https://vra.corp.local/catalog-service/api/consumer/resources/{resourceId}/actions/{resourceActionId}/requests/template

{

    "type":  "com.vmware.vcac.catalog.domain.request.CatalogResourceRequest",

    "resourceId":  "a3577bc9-17e4-461d-ac7e-345a0563e855",

    "actionId":  "1253cc68-5292-452f-b27e-f896dc82e8cd",

    "description":  null,

    "data":  {

                 "description":  null,

                 "reasons":  null

             }

}


And finally you would request the day two action to destroy the resource. The body of the POST will be the template you got from above

POST: https://vra.corp.local/catalog-service/api/consumer/resources/{resourceId}/actions/{resourceActionId}/requests

Further resources can be found here:

https://vra.corp.local/catalog-service/api/docs/resource_Resource.html#path__api_consumer_resources....