• Home
  • Annotate
  • current directory
Name Date Size #Lines LOC

..29-Oct-2021-

core/29-Oct-2021-

examples/29-Oct-2021-

facebody/29-Oct-2021-

imageenhan/29-Oct-2021-

imagerecog/29-Oct-2021-

imageseg/29-Oct-2021-

objectdet/29-Oct-2021-

ocr/29-Oct-2021-

test/29-Oct-2021-

CHANGELOG A D29-Oct-2021100.5 KiB3,9212,761

CONTRIBUTING.md A D29-Oct-20211.1 KiB2116

Doxyfile A D29-Oct-202111.5 KiB337335

LICENSE A D29-Oct-2021581 1410

README-CN.md A D29-Oct-20218.3 KiB267180

README-ENG.md A D29-Oct-20218.2 KiB264176

VERSION A D29-Oct-20218 11

easyinstall.sh A D29-Oct-2021409 1912

function_test.sh A D29-Oct-2021520 2315

generate_code_cov.sh A D29-Oct-2021685 2917

unit_test.sh A D29-Oct-2021843 4836

README-CN.md

1[English](./README.md) | 简体中文
2
3<p align="center">
4<a href="https://www.alibabacloud.com"><img src="https://aliyunsdk-pages.alicdn.com/icons/Aliyun.svg"></a>
5</p>
6
7<h1 align="center">Alibaba Cloud SDK for C++</h1>
8
9<p align="center">
10<a href="https://travis-ci.org/aliyun/aliyun-openapi-cpp-sdk"><img src="https://travis-ci.org/aliyun/aliyun-openapi-cpp-sdk.svg?branch=master" alt="Travis Build Status"></a>
11<a href="https://codecov.io/gh/aliyun/aliyun-openapi-cpp-sdk"><img src="https://codecov.io/gh/aliyun/aliyun-openapi-cpp-sdk/branch/master/graph/badge.svg" alt="codecov"></a>
12</p>
13
14Alibaba Cloud SDK for C++ 让您不用复杂编程即可访问云服务器、负载均衡、云监控等阿里云服务。这里向您介绍如何获取 Alibaba Cloud SDK for C++ 并开始调用。
15
16如果您在使用的过程中遇到任何问题,欢迎前往[阿里云SDK问答社区](https://yq.aliyun.com/tags/type_ask-tagid_23350)提问,提问前请阅读[提问引导](https://help.aliyun.com/document_detail/93957.html)。亦可在当前 GitHub [提交 Issues](https://github.com/aliyun/aliyun-openapi-cpp-sdk/issues/new)17
18## 使用诊断
19[Troubleshoot](https://troubleshoot.api.aliyun.com/?source=github_sdk) 提供 OpenAPI 使用诊断服务,通过 `RequestID` 或 `报错信息` ,帮助开发者快速定位,为开发者提供解决方案。
20
21## 环境要求
22
23在使用 Alibaba Cloud SDK for C++ 前,确保您已经:
24
25* 注册了阿里云账号并获取了访问密钥(AccessKey)。
26
27> **说明:** 为了保证您的账号安全,建议您使用RAM账号来访问阿里云服务。阿里云账号对拥有的资源有全部权限。RAM账号由阿里云账号授权创建,仅有对特定资源限定的操作权限。详情[参见RAM](https://help.aliyun.com/document_detail/28647.html)28
29* 开通了云产品服务。有些云产品如对象存储(OSS)需要先在[阿里云控制台](https://home.console.aliyun.com)开通服务。
30
31* 安装支持 C++ 11 或更高版本的编译器:
32  * Windows: Visual Studio 2015 或以上版本
33  * Linux: GCC 4.9 或以上版本
34
35* 安装 CMake 3.0 或以上版本
36* 建议 4G 或以上内存
37
38## 安装 (从源代码构建)
39
40### Linux
41
421. 要在 Linux 平台进行编译, 您必须安装依赖的外部库文件 libcurl、libopenssl、libuuid、libjsoncpp, 通常情况下,系统的包管理器中的会有提供。
43
44* 例如:在基于 Redhat / Fedora 的系统上安装这些软件包
45
46```bash
47# use yum
48yum install jsoncpp-devel openssl-devel uuid-devel libcurl-devel
49
50# use dnf
51sudo dnf install libcurl-devel openssl-devel libuuid-devel libjsoncpp-devel
52```
53
54* 在基于 Debian/Ubuntu 的系统
55
56```bash
57sudo apt-get install libcurl4-openssl-dev libssl-dev uuid-dev libjsoncpp-dev
58```
59
602. 执行以下命令,从 Github 克隆源码
61
62```bash
63git clone https://github.com/aliyun/aliyun-openapi-cpp-sdk.git
64```
65
663. 编译安装
67
68* 手动编译安装
69
70```bash
71cd aliyun-openapi-cpp-sdk
72mkdir sdk_build
73cd sdk_build
74cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr ..
75make
76sudo make install
77```
78
79* 或者通过 `easyinstall.sh`一键式安装
80
81```bash
82cd aliyun-openapi-cpp-sdk
83sudo sh easyinstall.sh <lower name of product (like 'ecs')>
84
85# example
86sudo sh easyinstall.sh core
87sudo sh easyinstall.sh ecs
88```
89
90**Alibaba Cloud SDK for C++ 将被安装在 `/usr` .**
91
92### Windows
93
941. 安装 [perl](https://www.perl.org/get.html#win32)
95
962. 使用 git-bash 执行以下命令,从 Github 克隆源码
97
98  ```bash
99  git clone https://github.com/aliyun/aliyun-openapi-cpp-sdk.git
100  ```
101
1023. 使用 Visual Studio 进行编译:
103
104* 在 aliyun-openapi-cpp-sdk 下创建 `sdk_build` 目录
105* 打开 cmake-gui , 然后进行以下操作
106  * 选择 `Browse Source` 为 `源代码目录(aliyun-openapi-cpp-sdk)`
107  * 选择 `Browse build` 为 `构建目录(sdk_build)`
108  * 点击 `configure`
109  * 使用小写的产品名称,设置 `BUILD_PRODUCT` 参数的值
110  * 点击 `generate`, 构建 VS 解决方案。
111
1124. 编译安装 C++ SDK
113
114* 进入 sdk_build 目录,使用 Visual Studio 打开 alibabacloud-sdk.sln 解决方案
115* 选择构建 `Release` 输出
116* 并打开配置管理器勾选 `INSTALL`
117* 构建 -> 生成解决方案
118
119**Alibaba Cloud SDK for C++ 将安装在 `C:\Program File (x86)\alibabacloud-sdk` 目录**
120
121**注意:请以管理员身份运行 Visual Studio 和 cmake-gui,否则无法安装 SDK**
122
123---
124
125## 快速使用
126
127在调用 Alibaba Cloud SDK for C++ 时,您首先需要配置预处理器定义 ALIBABACLOUD_SHARED 以引用阿里云 C++ SDK 的共享库,然后通过创建 Client 实例提供身份验证,并指定云服务的地域,然后发送API请求。
128
129以下代码展示了如何调用 DescribeInstancesAPI 查询指定地域所有 ECS 实例的详细信息。
130
131> **说明:** 您需要替换示例中的 your-region-id、your-access-key-id 和 your-access-key-secret 的值。
132
133```cpp
134#include <iostream>
135#include <alibabacloud/core/AlibabaCloud.h>
136#include <alibabacloud/ecs/EcsClient.h>
137
138using namespace AlibabaCloud;
139using namespace AlibabaCloud::Ecs;
140
141int main(int argc, char** argv) {
142  // 初始化 SDK
143  AlibabaCloud::InitializeSdk();
144
145  // 配置 ecs 实例
146  ClientConfiguration configuration("<your-region-id>");
147  EcsClient client("<your-access-key-id>", "<your-access-key-secret>", configuration);
148
149  // 创建API请求并设置参数
150  Model::DescribeInstancesRequest request;
151  request.setPageSize(10);
152
153  auto outcome = client.describeInstances(request);
154  if (!outcome.isSuccess()) {
155    // 异常处理
156    std::cout << outcome.error().errorCode() << std::endl;
157    AlibabaCloud::ShutdownSdk();
158    return -1;
159  }
160
161  std::cout << "totalCount: " << outcome.result().getTotalCount() << std::endl;
162
163  // 关闭 SDK
164  AlibabaCloud::ShutdownSdk();
165  return 0;
166}
167```
168
169复制上述文件到 ecs_test.cc170
171Linux 下
172
173```bash
174~$ g++ -o ecstest ecs_test.cc --std=c++11 -lalibabacloud-sdk-core -l alibabacloud-sdk-ecs
175~$ ./ecstest
176# 结果或错误返回将在此展示
177~$
178```
179
180## Timeout 设置
181
182CPP SDK 使用 libcurl 作为底层 HTTP 传输库。
183
184* 下面两个参数用来传递超时参数到 libcurl。
185  * `connectTimeout`: 连接超时设置。 [参考](https://curl.haxx.se/libcurl/c/CURLOPT_CONNECTTIMEOUT_MS.html).
186  * `readTimeout`: 传输超时设置。[参考](https://curl.haxx.se/libcurl/c/CURLOPT_TIMEOUT_MS.html)
187
188* 默认值
189  * connectTimeout: 5000ms
190  * readTimeout: 10000ms
191
192* 可以在创建 Client 或者发 Requst 设置超时参数。
193
194* Requst 设置优先级高于 Client 设置。
195
196* 输入 0 或者 -1 到 `setConnectTimeout` 和 `setReadTimeout` 可以禁用此功能。
197
198下面代码是设置超时参数的例子,由于 Request 优先级高于 Client,所以最终 `ConnectTimeout` 为 `1000ms`, `readTimeout` 为 `6000ms`。
199
200```cpp
201#include <iostream>
202#include <alibabacloud/core/AlibabaCloud.h>
203#include <alibabacloud/ecs/EcsClient.h>
204
205using namespace AlibabaCloud;
206using namespace AlibabaCloud::Ecs;
207
208int main(int argc, char** argv) {
209  // Initialize the SDK
210  AlibabaCloud::InitializeSdk();
211
212  // Configure the ECS instance
213  ClientConfiguration configuration("<your-region-id>");
214  // specify timeout when create client.
215  configuration.setConnectTimeout(1500);
216  configuration.setReadTimeout(4000);
217
218  EcsClient client("<your-access-key-id>", "<your-access-key-secret>", configuration);
219
220  // Create an API request and set parameters
221  Model::DescribeInstancesRequest request;
222  request.setPageSize(10);
223  // specify timeout when request
224  request.setConnectTimeout(1000);
225  request.setReadTimeout(6000);
226
227  auto outcome = client.describeInstances(request);
228  if (!outcome.isSuccess()) {
229    // Handle exceptions
230    std::cout << outcome.error().errorCode() << std::endl;
231    AlibabaCloud::ShutdownSdk();
232    return -1;
233  }
234
235  std::cout << "totalCount: " << outcome.result().getTotalCount() << std::endl;
236
237  // Close the SDK
238  AlibabaCloud::ShutdownSdk();
239  return 0;
240}
241
242```
243
244---
245
246**更多 [例程](https://github.com/aliyun/aliyun-openapi-cpp-sdk/tree/master/examples)**
247
248**参考ucloud_ai组件调用alicloud AI API接口及example用法**
249
250## 问题
251
252[提交 Issue](https://github.com/aliyun/aliyun-openapi-cpp-sdk/issues/new/choose), 不符合指南的问题可能会立即关闭。
253
254## 发行说明
255
256每个版本的详细更改记录在[发行说明](CHANGELOG)中。
257
258## 贡献
259
260提交 Pull Request 之前请阅读[贡献指南](CONTRIBUTING.md)。
261
262## 许可证
263
264[Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0)
265
266版权所有 1999-2019 阿里巴巴集团
267

README-ENG.md

1English | [简体中文](./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 C++</h1>
8
9<p align="center">
10<a href="https://travis-ci.org/aliyun/aliyun-openapi-cpp-sdk"><img src="https://travis-ci.org/aliyun/aliyun-openapi-cpp-sdk.svg?branch=master" alt="Travis Build Status"></a>
11<a href="https://codecov.io/gh/aliyun/aliyun-openapi-cpp-sdk"><img src="https://codecov.io/gh/aliyun/aliyun-openapi-cpp-sdk/branch/master/graph/badge.svg" alt="codecov"></a>
12</p>
13
14Alibaba Cloud SDK for C++ 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.
15
16This document introduces how to obtain and call this SDK.
17
18If you have any problem while using Alibaba Cloud SDK for C++, please submit an [issue](https://github.com/aliyun/aliyun-openapi-cpp-sdk/issues/new).
19
20## Troubleshoot
21[Troubleshoot](https://troubleshoot.api.aliyun.com/?source=github_sdk) Provide OpenAPI diagnosis service to help developers locate quickly and provide solutions for developers through `RequestID` or `error message`.
22
23## Requirements
24
25- To use this SDK, you must have an Alibaba Cloud account and an AccessKey.
26
27  The AccessKey is required when initializing the client. You can create an AccessKey in the Alibaba Cloud console. For more information, see [Create an AccessKey](https://usercenter.console.aliyun.com/?spm=5176.doc52740.2.3.QKZk8w#/manage/ak).
28
29  >**Note:** To increase the security of your account, we recommend that you use the AccessKey of the RAM user to access Alibaba Cloud services.
30
31- To use this SDK 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.
32
33- C++11 supported compiler installed
34  - Windows: Visual Studio 2015 or newer
35  - Linux: GCC 4.9 or newer
36- CMake 3.0 or newer
37- 4G memory or more
38
39## Installation
40
41### Linux
42
431. Install third-party libraries on the Linux platform, including `libcurl`, `libopenssl`, `libuuid`, and `libjsoncpp`.
44
45- Run the following commands on the `Redhat/Fedora` system
46
47```bash
48# use yum
49yum install jsoncpp-devel openssl-devel uuid-devel libcurl-devel
50
51# use dnf
52sudo dnf install libcurl-devel openssl-devel libuuid-devel libjsoncpp-devel
53```
54
55- Run the following commands on the `Debian/Ubuntu` system
56
57```bash
58sudo apt-get install libcurl4-openssl-dev libssl-dev uuid-dev libjsoncpp-dev
59```
60
612. Run the following commands to clone source codes from GitHub.
62
63```bash
64git clone https://github.com/aliyun/aliyun-openapi-cpp-sdk.git
65```
66
673. Build and install SDK
68
69- Manually build and install
70
71```bash
72cd aliyun-openapi-cpp-sdk
73mkdir sdk_build
74cd sdk_build
75cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr ..
76make
77sudo make install
78```
79
80- Or you may do this with `easyinstall.sh` in the source directory
81
82```bash
83cd aliyun-openapi-cpp-sdk
84sudo sh easyinstall.sh <lower name of product (like 'ecs')>
85
86# example
87sudo sh easyinstall.sh core
88sudo sh easyinstall.sh ecs
89```
90
91**The Alibaba Cloud SDK for C++ will be installed to `/usr`.**
92
93### Windows
94
951. Install [perl](https://www.perl.org/get.html#win32).
96
972. Run the following command to clone code from Github via git-bash:
98
99```bash
100git clone https://github.com/aliyun/aliyun-openapi-cpp-sdk.git
101```
102
1033. Build Visual Studio solution
104
105- Change directory to source code and make directory sdk_build
106
107- Open CMake UI and
108
109  - `Browse Source` to open source code directory.
110
111  - `Browse build`  to open the created `sdk_build` directory
112
113  - `Configure`
114
115  - use the lower name of product to set the value of `BUILD_PRODUCT`
116
117  - `Generate`
118
1194. Build and Install C++ SDK
120
121- Open `aliyun-openapi-cpp-sdk\\sdk_build\\alibabacloud-sdk.sln` with Visual Studio
122
123- Select  `Release`
124
125- Check INSTALL option from Build -> Configuration Manager
126
127- Build->Build Solutions to build.
128
129**Alibaba Cloud SDK for C++ will be installed to `C:\Program File (x86)\alibabacloud-sdk`**
130
131---
132
133## Quick Examples
134
135Before using this SDK, you must first configure the preprocessor to define `ALIBABACLOUD_SHARED` to achieve dynamic linking with the SDK shared libraries. Then you must create a client instance, specify the region of cloud services and provide authentication parameters before sending API requests.
136
137The following code shows how to call the [DescribeInstances](~~25506~~) API of ECS to query detailed information of all ECS instances in a specific region.
138
139```cpp
140#include <iostream>
141#include <alibabacloud/core/AlibabaCloud.h>
142#include <alibabacloud/ecs/EcsClient.h>
143
144using namespace AlibabaCloud;
145using namespace AlibabaCloud::Ecs;
146
147int main(int argc, char** argv) {
148  // Initialize the SDK
149  AlibabaCloud::InitializeSdk();
150
151  // Configure the ECS instance
152  ClientConfiguration configuration("<your-region-id>");
153  EcsClient client("<your-access-key-id>", "<your-access-key-secret>", configuration);
154
155  // Create an API request and set parameters
156  Model::DescribeInstancesRequest request;
157  request.setPageSize(10);
158
159  auto outcome = client.describeInstances(request);
160  if (!outcome.isSuccess()) {
161    // Handle exceptions
162    std::cout << outcome.error().errorCode() << std::endl;
163    AlibabaCloud::ShutdownSdk();
164    return -1;
165  }
166
167  std::cout << "totalCount: " << outcome.result().getTotalCount() << std::endl;
168
169  // Close the SDK
170  AlibabaCloud::ShutdownSdk();
171  return 0;
172}
173```
174
175Copy the above to ecs_test.cc, then build with the following command.
176
177```bash
178~$ g++ -o ecstest ecs_test.cc --std=c++11 -lalibabacloud-sdk-core -l alibabacloud-sdk-ecs
179~$ ./ecstest
180# Result or error message will be shown here.
181~$
182```
183
184## Timeout Configuration
185
186CPP SDK uses libcurl to do HTTP transfer.
187
188- The following timeout parameters are used to for libcurl.
189
190 - `connectTimeout`: timeout for the connect phase. [Refer](https://curl.haxx.se/libcurl/c/CURLOPT_CONNECTTIMEOUT_MS.html).
191 - `readTimeout`: maximum time the request is allowed to take, [Refer](https://curl.haxx.se/libcurl/c/CURLOPT_TIMEOUT_MS.html)
192
193- Default Value
194 - `connectTimeout`: 5000ms
195 - `readTimeout`: 10000ms
196
197- You may specify `timeout` parameters when create a client or make a request.
198
199- Request timeout has higher priority than client timeout.
200
201- If you want to disable timeout feature, deliver `0` or `-1` to `setConnectTimeout` and `setReadTimeout`.
202
203The following code shows hot to specify `timeout` parameters, and the final connectTimeout is 1000ms and readTimeout 6000ms.
204
205```cpp
206#include <iostream>
207#include <alibabacloud/core/AlibabaCloud.h>
208#include <alibabacloud/ecs/EcsClient.h>
209
210using namespace AlibabaCloud;
211using namespace AlibabaCloud::Ecs;
212
213int main(int argc, char** argv) {
214  // Initialize the SDK
215  AlibabaCloud::InitializeSdk();
216
217  // Configure the ECS instance
218  ClientConfiguration configuration("<your-region-id>");
219  // specify timeout when create client.
220  configuration.setConnectTimeout(1500);
221  configuration.setReadTimeout(4000);
222
223  EcsClient client("<your-access-key-id>", "<your-access-key-secret>", configuration);
224
225  // Create an API request and set parameters
226  Model::DescribeInstancesRequest request;
227  request.setPageSize(10);
228  // specify timeout when request
229  request.setConnectTimeout(1000);
230  request.setReadTimeout(6000);
231
232  auto outcome = client.describeInstances(request);
233  if (!outcome.isSuccess()) {
234    // Handle exceptions
235    std::cout << outcome.error().errorCode() << std::endl;
236    AlibabaCloud::ShutdownSdk();
237    return -1;
238  }
239
240  std::cout << "totalCount: " << outcome.result().getTotalCount() << std::endl;
241
242  // Close the SDK
243  AlibabaCloud::ShutdownSdk();
244  return 0;
245}
246
247```
248
249**More [examples](https://github.com/aliyun/aliyun-openapi-cpp-sdk/tree/master/examples)**
250
251## Issues
252[Opening an Issue](https://github.com/aliyun/aliyun-openapi-cpp-sdk/issues/new/choose), Issues not conforming to the guidelines may be closed immediately.
253
254## Changelog
255Detailed changes for each release are documented in the [release notes](CHANGELOG).
256
257## Contribution
258Please make sure to read the [Contributing Guide](CONTRIBUTING.md) before making a pull request.
259
260## License
261[Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0)
262
263Copyright 1999-2019 Alibaba Group Holding Ltd.
264