You need to enable JavaScript to run this app.
导航

获取网络ACL信息

最近更新时间2023.06.09 11:20:33

首次发布时间2023.06.09 11:20:33

本文介绍如何获取指定网络ACL的信息。

示例代码

/**
* Example Code generated by Beijing Volcanoengine Technology.
*/
package com.volcengine.vpc.examples;

import com.volcengine.ApiClient;
import com.volcengine.ApiException;
import com.volcengine.sign.Credentials;

import com.volcengine.vpc.VpcApi;
import com.volcengine.vpc.model.*;


public class TestDescribeNetworkAclAttributes {
    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);

        VpcApi api = new VpcApi(apiClient);

        // 获取指定网络ACL的信息
        DescribeNetworkAclAttributesRequest describeNetworkAclAttributesRequest = new DescribeNetworkAclAttributesRequest();
        describeNetworkAclAttributesRequest.setNetworkAclId("nacl-bp1fg655nh68xyz9****"); //网络ACL的ID

        // 发起请求并处理返回或异常
        try {
            DescribeNetworkAclAttributesResponse response = api.describeNetworkAclAttributes(describeNetworkAclAttributesRequest);
            System.out.println(response);
        } catch (ApiException e) {
            System.out.println(e.getResponseBody());
        }
    }
}

相关文档