ManageIQ api: get vm id from service request id


With jenkins we use manageiq 's rest api to create a vm in a service, so we create a service request id, which creates a vm.
We want to get the vm id create from with service request id: how to to so?


@abellotti can you review this question from @gquentin and forward to a SME if necessary.


Not from the service_requests, but from the service itself you can fetch the vms associated with that service via subcollection as follows:

 GET /api/services/:id?expand=vms

This will fetch the service as well as the vms,

or if you just need the vms,

GET /api/services/:id/vms



The service is associated with several vms: how to know the one which has just been created?


maybe look at the created_on attribute of the vms ?

GET /api/services/:id?expand=vms

as well as:

GET /api/services/:id/vms?expand=resources

will both expand the vms and you can look at created_on.

or if you just need specific attributes:

GET /api/services/:id/vms?expand=resources&attributes=name,vendor,created_on,...