我想在 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
我在這里做錯了什么?“父母”是什么意思?(在 ListRepositoriesRequest 中)
在進一步挖掘中,我發現在 Parent 中傳遞的值轉到:“x-goog-request-params”,正確的格式應該是什么?
uj5u.com熱心網友回復:
有時圖書館/ api有據可查,有時沒有......
這里是您可以在 API 資源管理器中測驗的 REST API(右側欄)。經過一些測驗,父級必須具有該格式
projects/<PROJECT_ID>/locations/<REGION>
嘗試解決您的問題
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/414526.html
標籤:
上一篇:使用嵌入式結構的建構式實體化結構
