Get vmwarefolderId List

Hello team,
How can i create an option list that will gather all the forlderIds of a specific vmware cloud ?

image

can’t find any api into the swagger :frowning:
regards,
Matthieu

The API endpoint for that is documented here: Retrieves all resource folders for Specified Cloud

Hello, thank you for your answer.

I’ve managed to get it work on a specified cloud :
image

with this translation script :

console.log('DEBUG REST OL : '+data['folders'].length)
for (var x = 0; x < data['folders'].length; x++) {
console.log('DEBUG REST OL : value no '+x+' = '+data['folders'][x].name)
  results.push({name:data['folders'][x].name,value:data['folders'][x].id});
  }

do you have an idea to do it with having cloud as an input in a catalog item ?
The final goal is to choose a cloud tighted to a vmware cluster in a catalog item, an then be able to choose the folder in which the VM will be created
regards,

Matthieu

Hi Matthieu,

For this use case you can use the option source url: /api/options/vmware/vmwareFolders?zoneId=354
To use this in a catalog item, set the option list Source URL to https://morpheus-dev/devops.groupe-bel.net/api/options/vmware/vmwareFolders
Then on the folder input you can specify the zoneId query parameter as the value from your cloud input in the request script, for this example I’ve assumed the cloud input name is morpheusCloud so the request script is:

results.push({name: 'zoneId', value : data.morpheusCloud});

Finally, you also need to change your translation script to match the json response structure from the new url, so the translation script is:

console.log('DEBUG REST OL : '+data['data'].length)
for (var x = 0; x < data['data'].length; x++) {
console.log('DEBUG REST OL : value no '+x+' = '+data['data'][x].name)
  results.push({name:data['data'][x].name,value:data['data'][x].value});
  }

That should do it, just let us know.

Thanks,
James

1 Like

Hello James,
It works perfectly fine.
Thank you