You need to enable JavaScript to run this app.
导航
查询IPsec连接
最近更新时间:2023.07.05 15:21:25首次发布时间:2023.07.05 15:21:25

本文介绍如何查询IPsec连接的信息。

示例代码

package com.volcengine.vpn.examples;

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

import com.volcengine.vpn.VpnApi;
import com.volcengine.vpn.model.*;


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

        VpnApi api = new VpnApi(apiClient);
        
        // 配置待查询IPsec连接的参数。
        DescribeVpnConnectionAttributesRequest describeVpnConnectionAttributesRequest = new DescribeVpnConnectionAttributesRequest();
        describeVpnConnectionAttributesRequest.setVpnConnectionId("vgc-2bzvqi8kerd342dx0eg2f****"); // 设置待查询IPsec连接的ID。
        
        // 发起请求并处理返回或异常。
        try {
            DescribeVpnConnectionAttributesResponse response = api.describeVpnConnectionAttributes(describeVpnConnectionAttributesRequest);
            System.out.println(response);
        } catch (ApiException e) {
            System.out.println(e.getResponseBody());
        }
    }
}

相关文档