暫無描述

haowei.yao 1befab93b1 IMM SDK Auto Released By zhengrui.lj,Version:1.35.0 7 年之前
.github ecd09578e8 fix typo in issue template 7 年之前
3rdparty ad045aa702 fix build failed 7 年之前
aegis 7be1f34dae Fix build failed on windows 8 年之前
afs 38e88e6678 AFS SDK Auto Released By shenshi,Version:1.34.36 7 年之前
alidns 7c93bd13dc ALIDNS SDK Auto Released By shenshi,Version:1.34.52 7 年之前
alimt 012634c7ea ALIMT SDK Auto Released By xulei.xl,Version:1.33.4 7 年之前
arms bc8404e573 ARMS SDK Auto Released By qikai.yangqikai,Version:1.28.1 8 年之前
arms4finance da8c6b2c70 ARMS4FINANCE SDK Auto Released By shenshi,Version:1.34.39 7 年之前
bssopenapi fd2e75bb77 BSSOPENAPI SDK Auto Released By simon.lb,Version:1.34.48 7 年之前
cas e7c17519db CAS SDK Auto Released By lihai.zhang,Version:1.34.42 7 年之前
cbn cac98a349f CBN SDK Auto Released By shenshi,Version:1.34.16 7 年之前
ccc 5aaae25e49 CCC SDK Auto Released By yonghong.lyh,Version:1.22.1 8 年之前
ccs 6d54401df2 CCS SDK Auto Released By shenshi,Version:1.34.37 7 年之前
cdn 9b1ab3027a CDN SDK Auto Released By wb-czb515173,Version:1.34.51 7 年之前
chatbot 0880c7f722 CHATBOT SDK Auto Released By yanke.yk,Version:1.19.0 8 年之前
cloudauth b3d7dcffc4 CLOUDAUTH SDK Auto Released By gongpei.gp,Version:1.29.1 8 年之前
cloudphoto f3507a5be6 CLOUDPHOTO SDK Auto Released By shenshi,Version:1.34.29 7 年之前
cloudwf 4165dc1e2c CLOUDWF SDK Auto Released By zhangzifa,Version:1.34.53 7 年之前
cms 5d1aad0c37 CMS SDK Auto Released By zhangzifa,Version:1.34.61 7 年之前
core 97716c02e9 adapt product parameter with name parameter 7 年之前
cr 1da6c4aa18 CR SDK Auto Released By shenshi,Version:1.34.24 7 年之前
crm 50463a22aa CRM SDK Auto Released By shenshi,Version:1.34.56 7 年之前
cs 3e476f2647 CS SDK Auto Released By shenshi,Version:1.34.47 7 年之前
csb 002d5fb06f CSB SDK Auto Released By yaolan.lt,Version:1.24.1 8 年之前
dcdn 9664fb1b00 DCDN SDK Auto Released By xiaoyao,Version:1.34.8 7 年之前
domain 6072a0309b DOMAIN SDK Auto Released By lukang.zlh,Version:1.31.0 7 年之前
drds 6d41511442 由燧木发起的DRDS SDK自动发布, 版本号:1.12.0 8 年之前
dysmsapi 25bddc9e7a DYSMSAPI SDK Auto Released By zhangzifa,Version:1.34.62 7 年之前
dyvmsapi 02c620b5a5 由峰远发起的DYVMSAPI SDK自动发布, 版本号:1.10.3 8 年之前
ecs 797aedc7fe ECS SDK Auto Released By zhangzifa,Version:1.34.43 7 年之前
ehpc e93d1a7c5c EHPC SDK Auto Released By qianzheng.llc,Version:1.32.0 7 年之前
emr aa06915a34 EMR SDK Auto Released By xiaoyan.yan,Version:1.34.17 7 年之前
ess aa71e41fab ESS SDK Auto Released By deyan.jdy,Version:1.34.2 7 年之前
examples f877a9ef39 update readme 7 年之前
finmall e0174350ec FINMALL SDK Auto Released By shenshi,Version:1.34.30 7 年之前
gpdb 996c9b497a GPDB SDK Auto Released By shenshi,Version:1.34.20 7 年之前
green eadff9b0ef GREEN SDK Auto Released By fengdong.xfd,Version:1.26.3 8 年之前
hsm 339cf28edd 由鸿逸发起的HSM SDK自动发布, 版本号:1.7.1 8 年之前
httpdns 2561eb446f HTTPDNS SDK Auto Released By shenshi,Version:1.34.54 7 年之前
imagesearch 549e90ee7c IMAGESEARCH SDK Auto Released By shenshi,Version:1.34.41 7 年之前
imm 1befab93b1 IMM SDK Auto Released By zhengrui.lj,Version:1.35.0 7 年之前
iot 893339c43d IOT SDK Auto Released By cheyun.lxf,Version:1.33.5 7 年之前
ivision f1948842ea IVISION SDK Auto Released By wb-czb515173,Version:1.34.65 7 年之前
jarvis bfe051d983 JARVIS SDK Auto Released By shenshi,Version:1.34.15 7 年之前
jarvis-public b4c6fc0aeb JARVIS-PUBLIC SDK Auto Released By zhangzifa,Version:1.34.59 7 年之前
kms c98efebbad KMS SDK Auto Released By shenshi,Version:1.34.57 7 年之前
linkface f189a9dbb2 LINKFACE SDK Auto Released By jiayao.wjy,Version:1.30.1 7 年之前
live 9b7dbef9c8 LIVE SDK Auto Released By renrang.yl,Version:1.34.6 7 年之前
lubancloud f87f6a1649 LUBANCLOUD SDK Auto Released By benxiang.hhq,Version:1.30.0 7 年之前
mopen 6da61cc993 MOPEN SDK Auto Released By shenshi,Version:1.34.23 7 年之前
mts 28c7a67d80 MTS SDK Auto Released By zhangzifa,Version:1.34.60 7 年之前
ons 21d175fb29 ONS SDK Auto Released By wenting.ywt,Version:1.34.63 7 年之前
openanalytics 7f97b2de78 OPENANALYTICS SDK Auto Released By shenshi,Version:1.34.31 7 年之前
ots feae502d3a OTS SDK Auto Released By shenshi,Version:1.34.38 7 年之前
push c3ff60fd73 由释一发起的PUSH SDK自动发布, BUILD_ID=490, 版本号:1.3.0 8 年之前
pvtz e9b2a0c830 PVTZ SDK Auto Released By shenshi,Version:1.34.28 7 年之前
ram 26d4cdb3b5 RAM SDK Auto Released By shenshi,Version:1.34.18 7 年之前
rds c63bc0bcc9 RDS SDK Auto Released By zhangzifa,Version:1.34.44 7 年之前
rtc 4a0a5164c7 RTC SDK Auto Released By shenshi,Version:1.34.32 7 年之前
saf 6182017316 SAF SDK Auto Released By xinfa.duanxf,Version:1.27.6 8 年之前
sas-api ea81585f2e SAS-API SDK Auto Released By zhangzifa,Version:1.34.58 7 年之前
scdn e5522c68c8 SCDN SDK Auto Released By xiaoyao,Version:1.34.5 7 年之前
slb 84adbb2cb8 SLB SDK Auto Released By laysong.sl,Version:1.23.4 8 年之前
smartag 127c992829 SMARTAG SDK Auto Released By jijun.jj,Version:1.21.6 8 年之前
snsuapi 191f3c859f SNSUAPI SDK Auto Released By shenshi,Version:1.34.33 7 年之前
sts a59527266e STS SDK Auto Released By shenshi,Version:1.34.19 7 年之前
tesladam 7be1f34dae Fix build failed on windows 8 年之前
teslamaxcompute 43169f9d50 TESLAMAXCOMPUTE SDK Auto Released By shenshi,Version:1.34.10 7 年之前
teslastream 7f3826c2f9 TESLASTREAM SDK Auto Released By shenshi,Version:1.34.12 7 年之前
test 97716c02e9 adapt product parameter with name parameter 7 年之前
tools c17dc7c79a refactor endpoints implementation 7 年之前
ubsms 8c9353a007 UBSMS SDK Auto Released By shenshi,Version:1.34.34 7 年之前
vod 2fb169a7d4 VOD SDK Auto Released By xiao.xwp,Version:1.34.1 7 年之前
vpc 88ef8f3618 VPC SDK Auto Released By shenshi,Version:1.34.13 7 年之前
xspace 947fa7238f XSPACE SDK Auto Released By yanjiang.yy,Version:1.34.49 7 年之前
yundun eea054f3c4 YUNDUN SDK Auto Released By shenshi,Version:1.34.35 7 年之前
.gitignore 619a7827de timeout support when create client or make request 7 年之前
.travis.yml c99809b8e4 support http put and delete 7 年之前
CHANGELOG 1befab93b1 IMM SDK Auto Released By zhengrui.lj,Version:1.35.0 7 年之前
CMakeLists.txt 1befab93b1 IMM SDK Auto Released By zhengrui.lj,Version:1.35.0 7 年之前
Doxyfile f6db1a27e4 Init commit 8 年之前
LICENSE 1ee62b8677 update license year 7 年之前
README.md 619a7827de timeout support when create client or make request 7 年之前
README_zh.md 619a7827de timeout support when create client or make request 7 年之前
VERSION 1befab93b1 IMM SDK Auto Released By zhengrui.lj,Version:1.35.0 7 年之前
easyinstall.sh f877a9ef39 update readme 7 年之前
function_test.sh 619a7827de timeout support when create client or make request 7 年之前
generate_code_cov.sh 21edc7f283 fix unit test build failed 7 年之前
unit_test.sh c99809b8e4 support http put and delete 7 年之前

README.md

Alibaba Cloud C++ Software Development Kit

中文文档

Build Status codecov

The Alibaba Cloud C++ Software Development Kit (SDK) 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.

This document introduces how to obtain and call Alibaba Cloud C++ SDK.

If you have any problem while using C++ SDK, please submit an issue.

Prerequisites

  • To use Alibaba Cloud C++ SDK, you must have an Alibaba Cloud account and an AccessKey.

    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.

    Note: To increase the security of your account, we recommend that you use the AccessKey of the RAM user to access Alibaba Cloud services.

  • To use Alibaba Cloud C++ SDK to access the APIs of a product, you must first activate the product on the Alibaba Cloud console if required.

  • C++11 supported compiler installed

    • Windows: Visual Studio 2015 or newer
    • Linux: GCC 4.9 or newer
  • CMake 3.0 or newer

  • 4G memory or more

Install C++ SDK from source code

Linux

  1. Install third-party libraries on the Linux platform, including libcurl, libopenssl, libuuid, and libjsoncpp.

    • Run the following commands on the Redhat/Fedora system

      sudo dnf install libcurl-devel openssl-devel libuuid-devel libjsoncpp-devel
      
    • Run the following commands on the Debian/Ubuntu system

      sudo apt-get install libcurl4-openssl-dev libssl-dev uuid-dev libjsoncpp-dev
      
  2. Run the following commands to clone source codes from GitHub.

    git clone https://github.com/aliyun/aliyun-openapi-cpp-sdk.git
    
  3. Build and install SDK

    • Manually build and install

      cd aliyun-openapi-cpp-sdk
      mkdir sdk_build
      cd sdk_build
      cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr ..
      make
      sudo make install
      
    • Or you may do this with easyinstall.sh in the source directory

      cd aliyun-openapi-cpp-sdk
      sudo sh easyinstall.sh
      

The C++ SDK will be installed to /usr.

windows

  1. Install perl.

  2. Run the following command to clone code from Github via git-bash:

    git clone https://github.com/aliyun/aliyun-openapi-cpp-sdk.git
    
  3. Build Visual Studio solution

  • Change directory to source code and make directory sdk_build

  • Open CMake UI and

    • Browse Source to open source code directory.

    • Browse build to open the created sdk_build directory

    • Configure

    • Generate

  1. Build and Install C++ SDK
  • Open aliyun-openapi-cpp-sdk\\sdk_build\\alibabacloud-sdk.sln with Visual Studio

  • Select Release

  • Check INSTALL option from Build -> Configuration Manager

  • Build->Build Solutions to build.

SDK will be installed to C:\Program File (x86)\alibabacloud-sdk

Use the C++ SDK

Before using C++ SDK, you must first configure the preprocessor to define ALIBABACLOUD_SHARED to achieve dynamic linking with Alibaba Cloud C++ SDK shared libraries. Then you must create a client instance, specify the region of cloud services and provide authentication parameters before sending API requests.

The following code shows how to call the DescribeInstances API of ECS to query detailed information of all ECS instances in a specific region.

#include <iostream>
#include <alibabacloud/core/AlibabaCloud.h>
#include <alibabacloud/ecs/EcsClient.h>

using namespace AlibabaCloud;
using namespace AlibabaCloud::Ecs;

int main(int argc, char** argv) {
  // Initialize the SDK
  AlibabaCloud::InitializeSdk();

  // Configure the ECS instance
  ClientConfiguration configuration("<your-region-id>");
  EcsClient client("<your-access-key-id>", "<your-access-key-secret>", configuration);

  // Create an API request and set parameters
  Model::DescribeInstancesRequest request;
  request.setPageSize(10);

  auto outcome = client.describeInstances(request);
  if (!outcome.isSuccess()) {
    // Handle exceptions
    std::cout << outcome.error().errorCode() << std::endl;
    AlibabaCloud::ShutdownSdk();
    return -1;
  }

  std::cout << "totalCount: " << outcome.result().getTotalCount() << std::endl;

  // Close the SDK
  AlibabaCloud::ShutdownSdk();
  return 0;
}

Copy the above to ecs_test.cc, then build with the following command.

~$ g++ -o ecstest ecs_test.cc --std=c++11 -lalibabacloud-sdk-core -l alibabacloud-sdk-ecs
~$ ./ecstest
# Result or error message will be shown here.
~$

Timeout Configuration

CPP SDK uses libcurl to do HTTP transfer.

  • The following timeout parameters are used to for libcurl.

    • connectTimeout: timeout for the connect phase. Refer.
    • readTimeout: maximum time the request is allowed to take, Refer
  • Default Value

    • connectTimeout: 5000ms
    • readTimeout: 10000ms
  • You may specify timeout parameters when create a client or make a request.

  • Request timeout has higher priority than client timeout.

  • If you want to disable timeout feature, deliver 0 or -1 to setConnectTimeout and setReadTimeout.

The following code shows hot to specify timeout parameters, and the final connectTimeout is 1000ms and readTimeout 6000ms.

#include <iostream>
#include <alibabacloud/core/AlibabaCloud.h>
#include <alibabacloud/ecs/EcsClient.h>

using namespace AlibabaCloud;
using namespace AlibabaCloud::Ecs;

int main(int argc, char** argv) {
  // Initialize the SDK
  AlibabaCloud::InitializeSdk();

  // Configure the ECS instance
  ClientConfiguration configuration("<your-region-id>");
  // specify timeout when create client.
  configuration.setConnectTimeout(1500);
  configuration.setReadTimeout(4000);

  EcsClient client("<your-access-key-id>", "<your-access-key-secret>", configuration);

  // Create an API request and set parameters
  Model::DescribeInstancesRequest request;
  request.setPageSize(10);
  // specify timeout when request
  request.setConnectTimeout(1000);
  request.setReadTimeout(6000);

  auto outcome = client.describeInstances(request);
  if (!outcome.isSuccess()) {
    // Handle exceptions
    std::cout << outcome.error().errorCode() << std::endl;
    AlibabaCloud::ShutdownSdk();
    return -1;
  }

  std::cout << "totalCount: " << outcome.result().getTotalCount() << std::endl;

  // Close the SDK
  AlibabaCloud::ShutdownSdk();
  return 0;
}

More examples

LICENSE

Please refer to LICENSE (Apache 2.0 LICENSE).