如何使用 googleapiclient 列出 GCE 子网

How to list the GCE subnetworks using the googleapiclient

我 运行 gcloud compute networks subnets list-usable 获取允许使用的 Google Compute Engine 子网的列表,但我想在 googleapiclient 中做同样的事情,这可能吗?

Compute Engine REST API 方法 subnetworks.listUsable returns 与 gcloud compute networks subnets list-usable 命令几乎相同(我认为这可能是等效的)。 Node.JS 中也有一个示例,您可以根据自己的喜好过滤结果。您只需在请求时提供 项目 ID