【问题标题】:How to add filter in computeService.Zones.List(project) Google Cloud Platform API如何在 computeService.Zones.List(project) Google Cloud Platform API 中添加过滤器
【发布时间】:2019-04-05 21:44:19
【问题描述】:

我正在尝试在 Google Cloud Platform API 中过滤区域列表

但我无法在 Google 中找到任何说明将过滤器放入 API 的文档:

req := computeService.Zones.List(project)

以上代码行将列出 Google Cloud Compute 中的区域

在命令行中我们也可以这样做

gcloud compute zones list --filter="name:us-"

谢谢, 席德

【问题讨论】:

  • 我找不到任何文档,因为我不知道 coputeService 后面的确切包。您的进口产品看起来如何?你试过 godoc.org 吗?
  • 嗨,这是我正在使用的导入“google.golang.org/api/compute/v1”供您参考:cloud.google.com/compute/docs/reference/rest/v1/zones/list

标签: go google-cloud-platform


【解决方案1】:

它会帮助某人以防万一:

req := computeService.Zones.List("ProjectName")
if err := req.Filter("name=us*").Pages(ctx, func(page *compute.ZoneList) error {
//Your code
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-08
    • 2016-12-19
    • 2019-02-26
    • 1970-01-01
    • 2015-09-17
    • 2017-09-04
    相关资源
    最近更新 更多