如何根据用户标签列出云功能



我在ListFunctions调用中看到,它返回了项目和指定区域中的所有函数。我想按标签过滤,但我看不到ListFunctionsRequest接受过滤器,按标签过滤。有什么建议吗?类似于gcloud CLI所支持的内容:https://cloud.google.com/sdk/gcloud/reference/functions/list

文件:https://pkg.go.dev/cloud.google.com/go/functions/apiv1#CloudFunctionsClient.ListFunctions

来自文档的代码

ctx := context.Background()
c, err := functions.NewCloudFunctionsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &functionspb.ListFunctionsRequest{
// TODO: Fill request struct fields.
}
it := c.ListFunctions(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}```

云函数API不支持过滤查询参数

gcloud过滤由CLI执行,而不是由API执行。因此,如果您直接使用API,则需要重新实现此过滤器功能。

最新更新