本文介绍如何按条件查询DNAT规则。
/** * Example Code generated by Beijing Volcanoengine Technology. */ package com.volcengine.natgateway.examples; import com.volcengine.ApiClient; import com.volcengine.ApiException; import com.volcengine.sign.Credentials; import com.volcengine.natgateway.NatgatewayApi; import com.volcengine.natgateway.model.*; import java.util.*; public class TestDescribeDnatEntries { public static void main(String[] args) throws Exception { // 设置您的ak String ak = "Your AK"; // 设置您的sk String sk = "Your SK"; // 设置您要访问的地域 String region = "Your Region"; // 初始化apiclient ApiClient apiClient = new ApiClient() .setCredentials(Credentials.getCredentials(ak, sk)) .setRegion(region); NatgatewayApi api = new NatgatewayApi(apiClient); // 按条件查询DNAT规则 DescribeDnatEntriesRequest describeDnatEntriesRequest = new DescribeDnatEntriesRequest(); describeDnatEntriesRequest.setDnatEntryIds(Arrays.asList("dnat-342abc3bc3****")); // DNAT规则的ID describeDnatEntriesRequest.setNatGatewayId("ngw-2feq5xhimd88w59gp686****"); // NAT网关的ID // 发起请求并处理返回或异常 try { DescribeDnatEntriesResponse response = api.describeDnatEntries(describeDnatEntriesRequest); System.out.println(response); } catch (ApiException e) { System.out.println(e.getResponseBody()); } } }