Skip to content

Commit 837a451

Browse files
author
wb-hx510875
committed
doc: add installation&example doc
1 parent 1eca62d commit 837a451

File tree

6 files changed

+288
-0
lines changed

6 files changed

+288
-0
lines changed

README-CN.md

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
[English](README.md) | 简体中文
2+
![](https://aliyunsdk-pages.alicdn.com/icons/AlibabaCloud.svg)
3+
4+
# Alibaba Cloud SDK
5+
6+
## 使用说明
7+
8+
- [安装教程](./docs/cn/0-INSTALLATION.md)
9+
- [使用案例](./docs/cn/1-EXAMPLE.md)
10+
11+
## 问题
12+
13+
[Opening an Issue](https://github.com/aliyun/alibabacloud-cpp-sdk/issues/new),不符合指南的问题可能会立即关闭。
14+
15+
## 相关
16+
17+
* [OpenAPI Developer Portal][open-api]
18+
* [Latest Release][latest-release]
19+
* [Alibabacloud Console System][console]
20+
* [Alibaba Cloud Home Page][aliyun]
21+
22+
## 许可证
23+
24+
[Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0)
25+
26+
版权所有 1999-present, 阿里巴巴集团.
27+
28+
[open-api]: https://next.api.aliyun.com
29+
[latest-release]: https://github.com/aliyun/alibabacloud-cpp-sdk/releases
30+
[console]: https://home.console.aliyun.com
31+
[aliyun]: https://www.aliyun.com

README.md

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
English | [简体中文](README-CN.md)
2+
3+
![](https://aliyunsdk-pages.alicdn.com/icons/AlibabaCloud.svg)
4+
5+
# Alibaba Cloud SDK
6+
7+
## Usage
8+
9+
- [Installation](./docs/en/0-INSTALLATION.md)
10+
- [Example](./docs/en/1-EXAMPLE.md)
11+
12+
## Issues
13+
14+
[Opening an Issue](https://github.com/aliyun/alibabacloud-cpp-sdk/issues/new), Issues not conforming to the guidelines may be closed immediately.
15+
16+
## References
17+
18+
* [OpenAPI Developer Portal][open-api]
19+
* [Latest Release][latest-release]
20+
* [Alibabacloud Console System][console]
21+
* [Alibaba Cloud Home Page][aliyun]
22+
23+
## License
24+
25+
[Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0)
26+
27+
Copyright 1999-present, Alibaba Cloud All rights reserved.
28+
29+
[open-api]: https://next.api.aliyun.com
30+
[latest-release]: https://github.com/aliyun/alibabacloud-cpp-sdk/releases
31+
[console]: https://home.console.aliyun.com
32+
[aliyun]: https://www.aliyun.com

docs/cn/0-INSTALLATION.md

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
2+
# 安装教程
3+
4+
## 必备的依赖库
5+
6+
- [Boost](https://www.boost.org/users/download/)
7+
- [CPPRestSDK](https://github.com/microsoft/cpprestsdk/releases)
8+
- [OpenSSL](https://www.openssl.org/source/)
9+
- [Git](https://git-scm.com/)
10+
11+
在使用这个 SDK 访问 API 之前,请先安装必备的依赖库。
12+
13+
- 使用 Homebrew 安装
14+
15+
```bash
16+
brew install boost cpprestsdk openssl
17+
```
18+
19+
- 使用 yum 安装
20+
21+
```bash
22+
yum install boost-devel openssl-devel
23+
24+
# 暂不支持通过 yum 安装 cpprestsdk
25+
```
26+
27+
- 使用 apt-get 安装
28+
29+
```bash
30+
# install boost
31+
sudo add-apt-repository ppa:mhier/libboost-latest -y
32+
sudo apt-get update
33+
sudo apt-get install libboost-all-dev
34+
35+
sudo apt-get install libcpprest-dev libcurl4-openssl-dev libssl-dev
36+
```
37+
38+
- 使用 vcpkg 安装
39+
40+
```bash
41+
vcpkg install boost openssl-windows cpprestsdk
42+
```
43+
44+
## 编译安装
45+
46+
### Linux
47+
48+
```bash
49+
git clone https://github.com/aliyun/alibabacloud-cpp-sdk.git
50+
cd ecs-20140526/
51+
sh scripts/install.sh
52+
```
53+
54+
### Windows
55+
56+
1. 使用 [git-bash](https://git-scm.com/downloads) 执行以下命令,从 Github 克隆源码
57+
58+
```bash
59+
git clone https://github.com/aliyun/alibabacloud-cpp-sdk.git
60+
cd alibabacloud-cpp-sdk/ecs-20140526
61+
```
62+
2. 使用 Visual Studio 进行编译:
63+
* 安装 [CMake](https://cmake.org/download/)[Visual Studio](https://visualstudio.microsoft.com/zh-hans/)
64+
* 在 ecs-20140526 项目的根目录下创建 `cmake_build` 文件夹
65+
* 打开 [CMake](https://cmake.org/download/) 软件, 然后进行以下操作
66+
* 选择 `Browse Source``源代码目录(ecs-20140526)`
67+
* 选择 `Browse build``构建目录(ecs-20140526/cmake_build)`
68+
* 点击 `configure`
69+
* 点击 `generate`, 构建 VS 解决方案。
70+
71+
3. 编译安装 C++ SDK
72+
* 进入 cmake_build 目录,使用 Visual Studio 打开 darabonba_core.sln 解决方案
73+
* 选择构建 `Release` 输出
74+
* 并打开配置管理器勾选 `INSTALL`
75+
* 构建 -> 生成解决方案

docs/cn/1-EXAMPLE.md

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# 使用案例
2+
3+
> 以使用 [ecs-20140526](../../ecs-20140526/) C++ SDK 为例
4+
5+
- 初始化 Config
6+
7+
```c++
8+
#include <alibabacloud/open_api.hpp>
9+
10+
Alibabacloud_OpenApi::Config config;
11+
config.accessKeyId = make_shared<string>(getenv("ACCESS_KEY_ID"));
12+
config.accessKeySecret = make_shared<string>(getenv("ACCESS_KEY_SECRET"));
13+
config.regionId = make_shared<string>("cn-hangzhou");
14+
```
15+
16+
- 初始化 Client
17+
18+
```c++
19+
#include <alibabacloud/ecs_20140526.hpp>
20+
21+
Alibabacloud_Ecs20140526::Client client(make_shared<Alibabacloud_RPC::Config>(config));
22+
```
23+
24+
- 初始化 Request 并且设置属性
25+
26+
```c++
27+
Alibabacloud_Ecs20140526::DescribeZonesRequest request;
28+
request.regionId = make_shared<string>("cn-hangzhou");
29+
```
30+
31+
- 请求 API 并获取回调结果
32+
33+
```c++
34+
Alibabacloud_Ecs20140526::DescribeZonesResponse response = client.describeZones(
35+
make_shared<Alibabacloud_Ecs20140526::DescribeZonesRequest>(request)
36+
);
37+
```

docs/en/0-INSTALLATION.md

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
2+
# Installation
3+
4+
## Required Dependency Libraries
5+
6+
- [Boost](https://www.boost.org/users/download/)
7+
- [CPPRestSDK](https://github.com/microsoft/cpprestsdk/releases)
8+
- [OpenSSL](https://www.openssl.org/source/)
9+
- [Git](https://git-scm.com/)
10+
11+
To use this SDK to access the API, you must first install the required dependency libraries.
12+
13+
- Install with Homebrew
14+
15+
```bash
16+
brew install boost cpprestsdk openssl
17+
```
18+
19+
- Install with yum
20+
21+
```bash
22+
yum install boost-devel openssl-devel
23+
24+
# The cpprestsdk does not support installation with yum.
25+
```
26+
27+
- Install with api-get
28+
29+
```bash
30+
# install boost
31+
sudo add-apt-repository ppa:mhier/libboost-latest -y
32+
sudo apt-get update
33+
sudo apt-get install libboost-all-dev
34+
35+
sudo apt-get install libcpprest-dev libcurl4-openssl-dev libssl-dev
36+
```
37+
38+
- Install with vcpkg
39+
40+
```bash
41+
vcpkg install boost cpprestsdk openssl-windows
42+
```
43+
44+
## Install
45+
46+
### Linux
47+
48+
```bash
49+
git clone https://github.com/aliyun/alibabacloud-cpp-sdk.git
50+
cd ecs-20140526/
51+
sh scripts/install.sh
52+
```
53+
54+
### Windows
55+
56+
1. Run the following command to clone code from Github via [git-bash](https://git-scm.com/downloads):
57+
58+
```bash
59+
git clone https://github.com/aliyun/alibabacloud-cpp-sdk.git
60+
cd alibabacloud-cpp-sdk/ecs-20140526
61+
```
62+
63+
2. Build Visual Studio solution
64+
* Install [CMake](https://cmake.org/download/) && [Visual Studio](https://visualstudio.microsoft.com/zh-hans/)
65+
* Change directory to source code and make the `cmake_build` folder in the ecs-20140526 project root directory.
66+
* Open [CMake](https://cmake.org/download/) software and
67+
* `Browse Source` to open source code directory.
68+
* `Browse build` to open the created `cmake_build` directory
69+
* click `configure`
70+
* click `generate`, Generate VS solution
71+
72+
3. Build and Install C++ SDK
73+
* Go to the cmake_build directory and open ${project_name}.sln with Visual Studio Solutions
74+
* Select `Release`
75+
* Check INSTALL option from Build -> Configuration Manager
76+
* Build->Build Solutions to build.

docs/en/1-EXAMPLE.md

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Example
2+
3+
> Use [ecs-20140526](../../ecs-20140526/) C++ SDK for Example
4+
5+
- Initialize Config
6+
7+
```c++
8+
#include <alibabacloud/open_api.hpp>
9+
10+
Alibabacloud_OpenApi::Config config;
11+
config.accessKeyId = make_shared<string>(getenv("ACCESS_KEY_ID"));
12+
config.accessKeySecret = make_shared<string>(getenv("ACCESS_KEY_SECRET"));
13+
config.regionId = make_shared<string>("cn-hangzhou");
14+
```
15+
16+
- Initialize Client
17+
18+
```c++
19+
#include <alibabacloud/ecs_20140526.hpp>
20+
21+
Alibabacloud_Ecs20140526::Client client(make_shared<Alibabacloud_RPC::Config>(config));
22+
```
23+
24+
- Initialize Request and set properties
25+
26+
```c++
27+
Alibabacloud_Ecs20140526::DescribeZonesRequest request;
28+
request.regionId = make_shared<string>("cn-hangzhou");
29+
```
30+
31+
- Request API and get response
32+
33+
```c++
34+
Alibabacloud_Ecs20140526::DescribeZonesResponse response = client.describeZones(
35+
make_shared<Alibabacloud_Ecs20140526::DescribeZonesRequest>(request)
36+
);
37+
```

0 commit comments

Comments
 (0)