开发者社区 > 域名解析DNS > 云解析DNS > 正文

云解析 PrivateZone的SDK有哪些?

云解析 PrivateZone的SDK有哪些?

展开
收起
保持可爱mmm 2020-03-29 00:34:50 721 0
1 条回答
写回答
取消 提交回答
  • SDK安装 通过maven进行安装添加maven库

        <dependency>
            <groupId>com.aliyun</groupId>
            <artifactId>aliyun-java-sdk-core</artifactId>
            <version>3.6.0</version>
        </dependency>
        <dependency>
            <groupId>com.aliyun</groupId>
            <artifactId>aliyun-java-sdk-pvtz</artifactId>
            <version>1.0.0</version>
        </dependency>
        <!-- format output -->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.48</version>
        </dependency>
    

    示例代码

    package com.aliyun.pvtz.demo;

    import com.alibaba.fastjson.JSON; import com.aliyuncs.DefaultAcsClient; import com.aliyuncs.IAcsClient; import com.aliyuncs.exceptions.ClientException; import com.aliyuncs.profile.DefaultProfile; import com.aliyuncs.pvtz.model.v20180101.*;

    public class PopApiDemo {

    public static void main(String[] args) throws ClientException {
        // Create and initialize a DefaultAcsClient instance
        DefaultProfile profile = DefaultProfile.getProfile(
            "cn-hangzhou",     // RegionId, use "cn-hangzhou"
            "***********",     // The AccessKey ID of the RAM account
            "**********");     // The AccessKey Secret of the RAM account
        IAcsClient client = new DefaultAcsClient(profile);
    
        // list private zone list
        DescribeZonesRequest pvtzZoneListRequest = new DescribeZonesRequest();
        pvtzZoneListRequest.setPageSize(10);
        DescribeZonesResponse pvtzZoneListResponse = client.getAcsResponse(pvtzZoneListRequest);
        System.out.println(JSON.toJSONString(pvtzZoneListResponse));
    
        // add record to zone. (zoneid: 31c43e48a9864bc6f7ed8e72100a22f1)
        AddZoneRecordRequest pvtzRecordAddRequest = new AddZoneRecordRequest();
        pvtzRecordAddRequest.setZoneId("31c43e48a9864bc6f7ed8e72100a22f1");
        pvtzRecordAddRequest.setRr("www");
        pvtzRecordAddRequest.setTtl(60);
        pvtzRecordAddRequest.setType("A");
        pvtzRecordAddRequest.setValue("10.1.1.1");
        AddZoneRecordResponse pvtzRecordAddResponse = client.getAcsResponse(pvtzRecordAddRequest);
        System.out.println(JSON.toJSONString(pvtzRecordAddResponse));
    
        // list record
        DescribeZoneRecordsRequest pvtzRecordListRequest = new DescribeZoneRecordsRequest();
        pvtzRecordListRequest.setZoneId("31c43e48a9864bc6f7ed8e72100a22f1");
        DescribeZoneRecordsResponse pvtzRecordListResponse = client.getAcsResponse(pvtzRecordListRequest);
        System.out.println(JSON.toJSONString(pvtzRecordListResponse));
    
        // pause record
        SetZoneRecordStatusRequest pvtzRecordPauseRequest = new SetZoneRecordStatusRequest();
        pvtzRecordPauseRequest.setRecordId(15035L);
        pvtzRecordPauseRequest.setStatus("DISABLE");
        SetZoneRecordStatusResponse pvtzRecordPauseResponse = client.getAcsResponse(pvtzRecordPauseRequest);
        System.out.println(JSON.toJSONString(pvtzRecordPauseResponse));
    
        // delete record
        DeleteZoneRecordRequest pvtzRecordDeleteRequest = new DeleteZoneRecordRequest();
        pvtzRecordDeleteRequest.setRecordId(15035L);
        DeleteZoneRecordResponse pvtzRecordDeleteResponse = client.getAcsResponse(pvtzRecordDeleteRequest);
        System.out.println(JSON.toJSONString(pvtzRecordDeleteResponse));
    }
    

    }

    2020-03-29 00:39:46
    赞同 展开评论 打赏

阿里云云解析DNS产品相关资讯

相关产品

  • 云解析DNS
  • 相关电子书

    更多
    从 SDK 到编解码:视频直播架构解析 立即下载
    跨平台的云服务SDK需要什么 立即下载
    一个跨平台的云服务SDK需要什么 立即下载

    相关镜像