It looks like you're new here. If you want to get involved, click one of these buttons!
I am trying to find a way of getting the API to search for a instance based on its label and than output only its instance-id.
Anyone know how to do this?
A label is not meant as an identifier and shall never be used as such. ID is in "instance-id" for a reason ;-)
You could always just fetch all your instances through https://api.vultr.com/v2/instances and iterate through its output until you find a match.
Maybe it is an idea to do the above once so you can map label-instance-id and then migrate to storing / referencing instance-ids internally instead?
@RickBakkr said: A label is not meant as an identifier and shall never be used as such. ID is in "instance-id" for a reason ;-) You could always just fetch all your instances through https://api.vultr.com/v2/instances and iterate through its output until you find a match. Maybe it is an idea to do the above once so you can map label-instance-id and then migrate to storing / referencing instance-ids internally instead?
@RickBakkr said: A label is not meant as an identifier and shall never be used as such. ID is in "instance-id" for a reason ;-)
I am looking to do it extarnally as I want to be able to automaticly create and remove VMs.
@MatthewM said: @RickBakkr said: A label is not meant as an identifier and shall never be used as such. ID is in "instance-id" for a reason ;-) You could always just fetch all your instances through https://api.vultr.com/v2/instances and iterate through its output until you find a match. Maybe it is an idea to do the above once so you can map label-instance-id and then migrate to storing / referencing instance-ids internally instead? I am looking to do it extarnally as I want to be able to automaticly create and remove VMs.
@MatthewM said:
https://www.vultr.com/api/v2/#operation/create-instance
Do note: "Developer Preview Only - Not Intended For Production Use"
Here you go [gist]
Comments
A label is not meant as an identifier and shall never be used as such. ID is in "instance-id" for a reason ;-)
You could always just fetch all your instances through https://api.vultr.com/v2/instances and iterate through its output until you find a match.
Maybe it is an idea to do the above once so you can map label-instance-id and then migrate to storing / referencing instance-ids internally instead?
I am looking to do it extarnally as I want to be able to automaticly create and remove VMs.
https://www.vultr.com/api/v2/#operation/create-instance
Do note: "Developer Preview Only - Not Intended For Production Use"
Here you go [gist]