我想列出golang中GCP工件注册表中的所有存储库。
当前代码:(https://pkg.go.dev/cloud.google.com/go/artifactregistry/apiv1beta2)
c, err := artifactregistry.NewClient(ctx, option.WithCredentialsFile("<service account json>"))
if err != nil {
// no error here
}
defer c.Close()
req := &artifactregistrypb.ListRepositoriesRequest{
Parent: "<project-id>",
}
it := c.ListRepositories(ctx, req)
for {
resp, err := it.Next()
if err == nil {
fmt.Println("resp", resp)
} else {
fmt.Println("err ==>", err)
}
}
错误打印:Invalid field value in the request.
或者有时我得到Request contains an invalid argument
我在这里做错了什么?以及";父";意思是(在ListRepositoryRequest中(
在进一步挖掘中,我发现Parent中传递的值为:;x-goog-request-params";,正确的格式应该是什么?
有时库/api文档很好,有时却不是。。。
这里是可以在API资源管理器(右侧栏(中测试的REST API。经过一些测试后,父级必须具有该格式的
projects/<PROJECT_ID>/locations/<REGION>
试着用它来解决你的问题