All Products
Search
Document Center

SDK

Last Updated: Jan 25, 2021

Alibaba Cloud provides SDK for Java, SDK for Python, and SDK for PHP. You can click one of the following links to download the SDK in a specific language:

For more information about SDKs in other languages, see Alibaba Cloud SDK.

References: Create an AccessKey pair.

Install an SDK

You can install an SDK by adding a Maven library or a JAR package dependency. SDK for Java is used in the example.

  • Add a Maven library

<repositories>
        <repository>
            <id>sonatype-nexus-staging</id>
            <name>Sonatype Nexus Staging</name>
            <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
</repositories> 
  • Add a JAR package dependency

<dependency>
      <groupId>com.aliyun</groupId>
      <artifactId>aliyun-java-sdk-alidns</artifactId>
      <version>2.6.20</version>
</dependency>
<dependency>
      <groupId>com.aliyun</groupId>
      <artifactId>aliyun-java-sdk-core</artifactId>
      <version>4.3.2</version>
</dependency>   

Sample code

import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.profile.DefaultProfile;
import com.google.gson.Gson;
import java.util.*;
import com.aliyuncs.alidns.model.v20150109.*;

public class DescribeGtmInstance {

    public static void main(String[] args) {
        DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", "<accessKeyId>", "<accessSecret>");
        IAcsClient client = new DefaultAcsClient(profile);

        DescribeDnsGtmInstanceRequest request = new DescribeDnsGtmInstanceRequest();
        request.setInstanceId("gtm-cn-xxxxxxxml05");

        try {
            DescribeDnsGtmInstanceResponse response = client.getAcsResponse(request);
            System.out.println(new Gson().toJson(response));
        } catch (ServerException e) {
            e.printStackTrace();
        } catch (ClientException e) {
            System.out.println("ErrCode:" + e.getErrCode());
            System.out.println("ErrMsg:" + e.getErrMsg());
            System.out.println("RequestId:" + e.getRequestId());
        }

    }
}