1 回答

TA貢獻(xiàn)1871條經(jīng)驗(yàn) 獲得超13個贊
VPN 網(wǎng)關(guān)與 NAT 網(wǎng)關(guān)不同。
使用此代碼列出路由器。在路由器列表中,是 NAT 網(wǎng)關(guān)
import "google.golang.org/api/compute/v1"
// Replace with valid values for your project
project := "my-project"
region := "my-region"
ctx := context.Background()
c, err := google.DefaultClient(ctx, compute.CloudPlatformScope)
if err != nil {
log.Fatal(err)
}
computeService, err := compute.New(c)
if err != nil {
log.Fatal(err)
}
req := computeService.Routers.List(project, region)
if err := req.Pages(ctx, func(page *compute.RouterList) error {
for _, router := range page.Items {
// process each `router` resource:
fmt.Printf("%#v\n", router)
// NAT Gateways are found in router.nats
}
return nil
}); err != nil {
log.Fatal(err)
}
- 1 回答
- 0 關(guān)注
- 115 瀏覽
添加回答
舉報(bào)