在使用Go客户端库创建实例组时无法定义网络吗?

huangapple go评论72阅读模式
英文:

Can't define Network when creating Instance Group with Go client library?

问题

通过GCP控制台创建非托管实例组时,可以看到REST请求如下:

POST https://www.googleapis.com/compute/v1/projects/my-project/zones/us-east1-d/instanceGroups
{
  "name": "ig-web",
  "network": "https://www.googleapis.com/compute/v1/projects/my-project/global/networks/nomad-network",
  "namedPorts": [
    {
      "name": "http",
      "port": 11080
    }
  ]
}

然而,根据API文档客户端库生成的代码,没有办法设置network URL。

有人可以解释一下吗?

英文:

When creating an unmanaged instance group through GCP Console, I can see the REST request as:

POST https://www.googleapis.com/compute/v1/projects/my-project/zones/us-east1-d/instanceGroups
{
  "name": "ig-web",
  "network": "https://www.googleapis.com/compute/v1/projects/my-project/global/networks/nomad-network",
  "namedPorts": [
    {
      "name": "http",
      "port": 11080
    }
  ]
}

However, according to the API docs and client library generated code, one has no way to set the network URL.

Anyone care to clarify?

答案1

得分: 0

这实际上是一个文档错误。以下代码将起作用:

op, err := gce.service.InstanceGroups.Insert(projectID, zone, &compute.InstanceGroup{
    Name:       name,
    NamedPorts: namedPorts,
    Network:    networkURL}).Do()
英文:

It's actually a documentation bug. The following will work:

op, err := gce.service.InstanceGroups.Insert(projectID, zone, &compute.InstanceGroup{
		Name:       name,
		NamedPorts: namedPorts,
		Network:    networkURL}).Do()

huangapple
  • 本文由 发表于 2015年12月17日 02:02:50
  • 转载请务必保留本文链接:https://go.coder-hub.com/34319039.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定