Search code examples
google-cloud-platformgoogle-compute-enginegoogle-cloud-networkinggoogle-vpc

How to list the GCE subnetworks using the googleapiclient


I'm running gcloud compute networks subnets list-usable to get the list of Google Compute Engine subnetworks permitted for use, but I would like to do the same in googleapiclient, is it possible?


Solution

  • The Compute Engine REST API method subnetworks.listUsable returns pretty much the same as the gcloud compute networks subnets list-usable command (which I reckon could be just the equivalent). There is an example in Node.JS there too and you can filter the results to your liking. All you need to provide is the project ID when doing the request.