Kovi
Kovi

Reputation: 13

How to get information about all available images to create vm instance through API

I am creating a sort of Demand entry App in which I want to populate metadata(regions, zones, images etc) through google API. I am calling this API, for example, https://compute.googleapis.com/compute/v1/projects/{project}/global/images with my project id. But I got 200 responses and don't see any data.

Thanks
Kovi

https://compute.googleapis.com/compute/v1/projects/{project}/global/images

{
  "id": "projects/sap-iidc-cde/global/images",
  "selfLink": "https://www.googleapis.com/compute/v1/projects/sap-iidc-cde/global/images",
  "kind": "compute#imageList"
}

Upvotes: 1

Views: 789

Answers (2)

Pradeep Bhadani
Pradeep Bhadani

Reputation: 4721

Currently getting public image list is not available in image.list method. There is a ticket asking to support public image but don't have recent updates. https://issuetracker.google.com/issues/64718267

A workaround could be to curl https://console.cloud.google.com/compute/images?project= and then parse the response to get image ids

Otherwise, the gcloud command is the best bet at the moment. you can run this command within your program and parse the output to get list of images.

Upvotes: 0

John Hanley
John Hanley

Reputation: 81336

This API only returns custom images available to the specified project. A custom image is one that the Project created.

If you want to list images in other projects such as Debian or Windows, you need to use their project ID.

Well known images projects:

centos-cloud, coreos-cloud, debian-cloud, cos-cloud, rhel-cloud, rhel-sap-cloud, suse-cloud, suse-sap-cloud, ubuntu-os-cloud, windows-cloud, windows-sql-cloud

To list images use the SDK CLI. This will show you the various Project IDs associated with each image.

gcloud compute images list

Upvotes: 1

Related Questions