VMware Cloud Community
jason_davis
Enthusiast
Enthusiast
Jump to solution

REST API to get list of VM Templates

I'm designing a kiosk app which can let users build blueprints.  I cannot find the API which can retrieve a list of VM templates in the repository.  Specifically, is there a REST API to replicate this feature in vRA?  Or do I need to use vSphere API to retrieve that level of information?

Select Template.png

Tags (1)
Reply
0 Kudos
1 Solution

Accepted Solutions
jason_davis
Enthusiast
Enthusiast
Jump to solution

So I found the answer to this question.  It was posted in another forum at the link below:

Is there api for getting source-machines from VRA.

Using the below syntax, I could get what I was looking for.

https://{{vra-fqdn}}/iaas-proxy-provider/api/source-machines?actionId=FullClone&platformTypeId=Infrastructure.CatalogItem.Machine.Virtual.vSphere&loadTemplates=true

Totally not intuitive, but it works!

View solution in original post

Reply
0 Kudos
5 Replies
eoinbyrne
Expert
Expert
Jump to solution

The templates are part of the IaaS API which is different to the CAFE API

The IaaS Proxy provider API is still there but its is entirely DEPRECATED and rife with warnings about "Use at your own risk". That being said it's been in that state since 7.0 IIRC so you might get away with using it if you can stomach the possibility of your kiosk being broken against future releases?

There is a vm-templates branch on that API which might do what you want (for now.....)

Swagger doc - vRealize Automation IaaS Proxy Provider Service API - VMware API Explorer - VMware {code}

I guess YMMV Smiley Happy

HTH

Reply
0 Kudos
jason_davis
Enthusiast
Enthusiast
Jump to solution

Hi eoinbyrne,

Yes this is exactly what I am looking for.  Now if I can just figure out how to determine the platformTypeId and actionId for the API, I may be in business.  I'll let you know if i get it working.

Thanks!

Jason Davis

Reply
0 Kudos
eoinbyrne
Expert
Expert
Jump to solution

Those parameters should be optional as they're just for filtering.

If you try the simplest GET on /vm-templates you should get the full list

You may be able to map the provider and action types via other branches of the API there or even on other service APIs

-Eoin

Reply
0 Kudos
jason_davis
Enthusiast
Enthusiast
Jump to solution

Eoin,

Thanks again for your prompt suggestion.

I think those parameters are not optional.  The documentation says they are required. 

API source machines.png

If I try to call this API without any parameters, I get this response:

The remote server returned an error: (400) Bad Request.

{

  "errors": [

    {

      "code": 50505,

      "source": null,

      "message": "System exception.",

      "systemMessage": "Required String parameter 'platformTypeId' is not present",

      "moreInfoUrl": null

    }

  ]

}

I found if I set the platformTypeId parameter = 'vSphere', then I get the following error:

The remote server returned an error: (400) Bad Request.

{

  "errors": [

    {

      "code": 50505,

      "source": null,

      "message": "System exception.",

      "systemMessage": "Required String parameter 'actionId' is not present",

      "moreInfoUrl": null

    }

  ]

}

I haven't yet been able to figure out a correct syntax to configure the actionID parameter correctly.

After thinking about this a little more, I'm starting to doubt if this is the right strategy for my app anyway.  As the API name suggests this is just working as a proxy into vSphere.  Longer term I will need more functionality in my app such as creating/modifying VM templates, which I guess will not be possible via vRA.  So I'm thinking to modify my app to connect directly to vSphere when need this type of lower level functionality.

Reply
0 Kudos
jason_davis
Enthusiast
Enthusiast
Jump to solution

So I found the answer to this question.  It was posted in another forum at the link below:

Is there api for getting source-machines from VRA.

Using the below syntax, I could get what I was looking for.

https://{{vra-fqdn}}/iaas-proxy-provider/api/source-machines?actionId=FullClone&platformTypeId=Infrastructure.CatalogItem.Machine.Virtual.vSphere&loadTemplates=true

Totally not intuitive, but it works!

Reply
0 Kudos