本文介绍如何创建专线网关。
package com.volcengine.directconnect.examples; import com.volcengine.ApiClient; import com.volcengine.ApiException; import com.volcengine.sign.Credentials; import com.volcengine.directconnect.DirectconnectApi; import com.volcengine.directconnect.model.*; public class TestCreateDirectConnectGateway { 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); DirectconnectApi api = new DirectconnectApi(apiClient); // 配置待创建专线网关的参数。 CreateDirectConnectGatewayRequest createDirectConnectGatewayRequest = new CreateDirectConnectGatewayRequest(); createDirectConnectGatewayRequest.setDescription("test"); // 设置专线网关的描述。 createDirectConnectGatewayRequest.setDirectConnectGatewayName("test"); // 设置专线网关的名称。 // 发起请求并处理返回或异常。 try { CreateDirectConnectGatewayResponse response = api.createDirectConnectGateway(createDirectConnectGatewayRequest); System.out.println(response); } catch (ApiException e) { System.out.println(e.getResponseBody()); } } }