本示例介绍如何使用Alibaba Cloud SDK for Java调用RDS的DeleteIpv6Gateway接口删除IPv6网关。

前提条件

  • 使用Alibaba Cloud SDK for Java,您需要一个阿里云账号和访问密钥(AccessKey)。 请在阿里云控制台中的AccessKey管理页面上创建和查看您的AccessKey。
  • 确保您已经安装了Alibaba Cloud SDK for Java,准确的SDK版本号,请参见 阿里云开发工具包(SDK)
    <dependencies>
        <!-- https://mvnrepository.com/artifact/com.aliyun/aliyun-java-sdk-core -->
        <dependency>
            <groupId>com.aliyun</groupId>
            <artifactId>aliyun-java-sdk-core</artifactId>
            <version>4.4.3</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.aliyun/aliyun-java-sdk-vpc -->
        <dependency>
            <groupId>com.aliyun</groupId>
            <artifactId>aliyun-java-sdk-vpc</artifactId>
            <version>3.0.5</version>
        </dependency>
    </dependencies>

示例代码

import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.profile.DefaultProfile;
import com.aliyuncs.vpc.model.v20160428.DeleteIpv6GatewayRequest;
import com.aliyuncs.vpc.model.v20160428.DeleteIpv6GatewayResponse;
import com.google.gson.Gson;

public class DeleteIpv6Gateway {
    public static void main(String[] args) {
        // 初始化请求参数
        DefaultProfile profile = DefaultProfile.getProfile(
                 "<your-region-id>",// 地域ID
                 "<your-access-key-id>",// 您的AccessKey ID
                 "<your-access-key-secret>");// 您的AccessKey Secret
        IAcsClient client = new DefaultAcsClient(profile);
        // 配置请求参数
        DeleteIpv6GatewayRequest request = new DeleteIpv6GatewayRequest();
        // 要删除的IPv6网关实例ID。
        request.setIpv6GatewayId("ipv6gw-2zeb8ba9chsox3kokl4ib");
        try {
            // 发送请求获取返回结果
            DeleteIpv6GatewayResponse response = client.getAcsResponse(request);
            // 处理返回结果
            System.out.println(new Gson().toJson(response));
        } catch (ClientException e) {
            System.out.println("ErrCode:" + e.getErrCode());
            System.out.println("ErrMsg:" + e.getErrMsg());
            System.out.println("RequestId:" + e.getRequestId());
        }
    }
}
说明 更多参数和接口信息,请参见API概览