|
1 |
| -test |
| 1 | +English | [简体中文](./README-CN.md) |
| 2 | + |
| 3 | +<p align="center"> |
| 4 | +<a href=" https://www.alibabacloud.com"><img src="https://aliyunsdk-pages.alicdn.com/icons/AlibabaCloud.svg"></a> |
| 5 | +</p> |
| 6 | + |
| 7 | +<h1 align="center">Alibaba Cloud SDK for Java</h1> |
| 8 | + |
| 9 | +<p align="center"> |
| 10 | +<a href="https://search.maven.org/search?q=g:%22com.aliyun%22%20AND%20a:%22aliyun-java-sdk-core%22"><img src="https://img.shields.io/maven-central/v/com.aliyun/aliyun-java-sdk-core.svg?label=Maven%20Central" alt="Latest Stable Version"/></a> |
| 11 | +<a href="https://travis-ci.org/aliyun/aliyun-openapi-java-sdk"><img src="https://travis-ci.org/aliyun/aliyun-openapi-java-sdk.svg?branch=master"/></a> |
| 12 | +<a href="https://codecov.io/gh/aliyun/aliyun-openapi-java-sdk"><img src="https://codecov.io/gh/aliyun/aliyun-openapi-java-sdk/branch/master/graph/badge.svg"/></a> |
| 13 | +<a href="https://www.codacy.com/app/aliyun/aliyun-openapi-java-sdk?utm_source=github.com&utm_medium=referral&utm_content=aliyun/aliyun-openapi-java-sdk&utm_campaign=Badge_Grade"><img src="https://api.codacy.com/project/badge/Grade/aef3826e57ca444fb217bab8edaed195"/></a> |
| 14 | +<a href="https://ci.appveyor.com/project/aliyun/aliyun-openapi-java-sdk"><img src="https://ci.appveyor.com/api/projects/status/bymi868y6443gwdp?svg=true"/></a> |
| 15 | +</p> |
| 16 | + |
| 17 | +The Alibaba Cloud SDK for Java allows you to access Alibaba Cloud services such as Elastic Compute Service (ECS), Server Load Balancer (SLB), and CloudMonitor. You can access Alibaba Cloud services without the need to handle API related tasks, such as signing and constructing your requests. |
| 18 | + |
| 19 | +This document introduces how to obtain and call Alibaba Cloud SDK for Java. |
| 20 | + |
| 21 | +If you have any problem while using Alibaba Cloud SDK for Java, please [submit an issue](https://github.com/aliyun/aliyun-openapi-java-sdk/issues/new). |
| 22 | + |
| 23 | +## Requirements |
| 24 | + |
| 25 | +- To use Alibaba Cloud SDK for Java, you must have an Alibaba Cloud account as well as an `AccessKey ID` and an `AccessKey Secret`. Create and view your AccessKey on the [RAM console](https://ram.console.aliyun.com "RAM console") or contact your system administrator. |
| 26 | + |
| 27 | +- To use the Alibaba Cloud SDK for Java to access the APIs of a product, you must first activate the product on the [Alibaba Cloud console](https://home.console.aliyun.com/?spm=5176.doc52740.2.4.QKZk8w) if required. |
| 28 | + |
| 29 | +- The Alibaba Cloud Java SDK requires JDK 1.6 or later. |
| 30 | + |
| 31 | +## Installation |
| 32 | + |
| 33 | +If you use Apache Maven to manage Java projects, you only need to add corresponding dependencies to the pom.xml files of the projects. You can download the Maven dependencies of different cloud products in [Alibaba Cloud developer resources](https://help.aliyun.com/learn/developer.html). |
| 34 | + |
| 35 | +You must install `aliyun-java-sdk-core` library no matter which product development kit you want to use. For example, to call the ECS SDK, you need to install `aliyun-java-sdk-core` library and `aliyun-java-sdk-ecs` library . |
| 36 | + |
| 37 | +To use the Ecs SDK as an example, you only need to declare the following two dependencies in the `pom.xml` file. |
| 38 | + |
| 39 | +```xml |
| 40 | +<dependency> |
| 41 | + <groupId>com.aliyun</groupId> |
| 42 | + <artifactId>aliyun-java-sdk-core</artifactId> |
| 43 | + <version>[4.3.2,5.0.0)</version> |
| 44 | +</dependency> |
| 45 | +<dependency> |
| 46 | + <groupId>com.aliyun</groupId> |
| 47 | + <artifactId>aliyun-java-sdk-ecs</artifactId> |
| 48 | + <version>[4.16.0,5.0.0)</version> |
| 49 | +</dependency> |
| 50 | +``` |
| 51 | + |
| 52 | +If maven is not downloading jar packages from a central repository, you need to add this dependency in the pom.xml file, or a NoClassDefFoundError exception will be reported |
| 53 | +```xml |
| 54 | +<dependency> |
| 55 | + <groupId>com.google.code.gson</groupId> |
| 56 | + <artifactId>gson</artifactId> |
| 57 | + <version>2.8.5</version> |
| 58 | +</dependency> |
| 59 | +``` |
| 60 | + |
| 61 | +## Quick Examples |
| 62 | + |
| 63 | +The following code example shows the three main steps to use Alibaba Cloud SDK for Java : |
| 64 | + |
| 65 | +1. Create and initialize a `DefaultAcsClient` instance. |
| 66 | + |
| 67 | +2. Create an API request and set parameters. |
| 68 | + |
| 69 | +3. Initiate the request and handle the response or exceptions. |
| 70 | + |
| 71 | +```java |
| 72 | +package com.testprogram; |
| 73 | +import com.aliyuncs.profile.DefaultProfile; |
| 74 | +import com.aliyuncs.DefaultAcsClient; |
| 75 | +import com.aliyuncs.IAcsClient; |
| 76 | +import com.aliyuncs.exceptions.ClientException; |
| 77 | +import com.aliyuncs.exceptions.ServerException; |
| 78 | +import com.aliyuncs.ecs.model.v20140526.*; |
| 79 | +public class Main { |
| 80 | + public static void main(String[] args) { |
| 81 | + // Create and initialize a DefaultAcsClient instance |
| 82 | + DefaultProfile profile = DefaultProfile.getProfile( |
| 83 | + "<your-region-id>", // The region ID |
| 84 | + "<your-access-key-id>", // The AccessKey ID of the RAM account |
| 85 | + "<your-access-key-secret>"); // The AccessKey Secret of the RAM account |
| 86 | + IAcsClient client = new DefaultAcsClient(profile); |
| 87 | + // Create an API request and set parameters |
| 88 | + DescribeInstancesRequest request = new DescribeInstancesRequest(); |
| 89 | + request.setPageSize(10); |
| 90 | + // Initiate the request and handle the response or exceptions |
| 91 | + DescribeInstancesResponse response; |
| 92 | + try { |
| 93 | + response = client.getAcsResponse(request); |
| 94 | + for (DescribeInstancesResponse.Instance instance:response.getInstances()) { |
| 95 | + System.out.println(instance.getPublicIpAddress()); |
| 96 | + } |
| 97 | + } catch (ServerException e) { |
| 98 | + e.printStackTrace(); |
| 99 | + } catch (ClientException e) { |
| 100 | + e.printStackTrace(); |
| 101 | + } |
| 102 | + } |
| 103 | +} |
| 104 | +``` |
| 105 | + |
| 106 | + |
| 107 | +## Documentation |
| 108 | +* [Requirements](./docs/0-Requirements-EN.md) |
| 109 | +* [Installation](./docs/1-Installation-EN.md) |
| 110 | +* [Client](./docs/2-Client-EN.md) |
| 111 | +* [Connection Pool](./docs/3-Pool-EN.md) |
| 112 | +* [Timeout](./docs/4-Timeout-EN.md) |
| 113 | +* [HTTPS Configurations](./docs/5-HTTPS-EN.md) |
| 114 | +* [Proxy Configurations](./docs/6-Proxy-EN.md) |
| 115 | +* [Debug](./docs/7-Debug-EN.md) |
| 116 | +* [Log](./docs/8-Log-EN.md) |
| 117 | + |
| 118 | + |
| 119 | +## Issues |
| 120 | +[Opening an Issue](https://github.com/aliyun/aliyun-openapi-java-sdk/issues/new), Issues not conforming to the guidelines may be closed immediately. |
| 121 | + |
| 122 | +## Changelog |
| 123 | +Detailed changes for each release are documented in the [release notes](./aliyun-java-sdk-core/ChangeLog.txt). |
| 124 | + |
| 125 | +## Contribution |
| 126 | +Please make sure to read the [Contributing Guide](CONTRIBUTING.md) before making a pull request. |
| 127 | + |
| 128 | +## References |
| 129 | +* [Alibaba Cloud Regions & Endpoints](https://developer.aliyun.com/endpoints) |
| 130 | +* [OpenAPI Explorer](https://api.aliyun.com/) |
| 131 | +* [Latest Release](https://github.com/aliyun/aliyun-openapi-java-sdk) |
| 132 | + |
| 133 | +## License |
| 134 | +[Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0) |
| 135 | + |
| 136 | +Copyright 1999-2019 Alibaba Group Holding Ltd. |
0 commit comments