You can write codes based on Alibaba Cloud SDK to call an Alibaba Cloud API so as to flexibly deploy and quickly operate Alibaba Cloud products and services.

Note
AccessKey is needed in the using process. You can create and manage the AccessKey on the AccessKey Management page.

Environment preparations

You can query and download the latest SDK at https://oss.sonatype.org/#nexus-search;gav~com.aliyun~aliyun-java-sdk-*~~~.

You can download the source codes from GitHub: https://github.com/aliyun/aliyun-openapi-java-sdk/

Maven

<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>
    <dependencies>
        <dependency>
            <groupId>com.aliyun</groupId>
            <artifactId>aliyun-java-sdk-core</artifactId>
            <version>2.3.3</version>
        </dependency>
        <dependency>
            <groupId>com.aliyun</groupId>
            <artifactId>aliyun-java-sdk-cs</artifactId>
            <version>2.0.2</version>
        </dependency>
    </dependencies>

Sample

public static void main(String[] argc) throws Exception {
        String accessKeyID = "xx";
        String accessKeySecret = "xx";
        String region="cn-shenzhen"; // or other
        DescribeApiVersionRequest describeApiVersionRequest = new DescribeApiVersionRequest();
        IClientProfile profile = DefaultProfile.getProfile(region, accessKeyID, accessKeySecret);
        IAcsClient client = new DefaultAcsClient(profile);
        try {
            HttpResponse httpResponse
                    = client.doAction(describeApiVersionRequest);
            System.out.println(httpResponse.getUrl());
            System.out.println(new String(httpResponse.getContent()));
        } catch (ClientException e) {
            e.printStackTrace();