本文介绍如何按条件查询DNAT规则。
// Example Code generated by Beijing Volcanoengine Technology. package natgatewayexample import ( "fmt" "github.com/volcengine/volcengine-go-sdk/service/natgateway" "github.com/volcengine/volcengine-go-sdk/volcengine" "github.com/volcengine/volcengine-go-sdk/volcengine/credentials" "github.com/volcengine/volcengine-go-sdk/volcengine/session" ) func DescribeDnatEntries() { // 设置您的ak、sk和要访问的地域 ak, sk, region := "Your AK", "Your SK", "Region" config := volcengine.NewConfig(). WithRegion(region). WithCredentials(credentials.NewStaticCredentials(ak, sk, "")) sess, err := session.NewSession(config) if err != nil { panic(err) } svc := natgateway.New(sess) // 按条件查询DNAT规则 describeDnatEntriesInput := &natgateway.DescribeDnatEntriesInput{ DnatEntryIds: volcengine.StringSlice([]string{"dnat-342abc3bc3****"}), // DNAT规则的ID NatGatewayId: volcengine.String("ngw-2feq5xhimd88w59gp686****"), // NAT网关的ID } // 发起请求并处理返回或异常 resp, err := svc.DescribeDnatEntries(describeDnatEntriesInput) if err != nil { panic(err) } fmt.Println(resp) }