Sen descrición

zhangzifa c99809b8e4 support http put and delete %!s(int64=7) %!d(string=hai) anos
.github ecd09578e8 fix typo in issue template %!s(int64=7) %!d(string=hai) anos
3rdparty ad045aa702 fix build failed %!s(int64=7) %!d(string=hai) anos
aegis 7be1f34dae Fix build failed on windows %!s(int64=8) %!d(string=hai) anos
afs 7be1f34dae Fix build failed on windows %!s(int64=8) %!d(string=hai) anos
alimt 012634c7ea ALIMT SDK Auto Released By xulei.xl,Version:1.33.4 %!s(int64=7) %!d(string=hai) anos
arms bc8404e573 ARMS SDK Auto Released By qikai.yangqikai,Version:1.28.1 %!s(int64=8) %!d(string=hai) anos
ccc 5aaae25e49 CCC SDK Auto Released By yonghong.lyh,Version:1.22.1 %!s(int64=8) %!d(string=hai) anos
ccs 6e9b1bebe0 CCS SDK Auto Released By wilson.liuw,Version:1.26.2 %!s(int64=8) %!d(string=hai) anos
cdn 44ac453806 CDN SDK Auto Released By xiaoyao,Version:1.34.3 %!s(int64=7) %!d(string=hai) anos
chatbot 0880c7f722 CHATBOT SDK Auto Released By yanke.yk,Version:1.19.0 %!s(int64=8) %!d(string=hai) anos
cloudauth b3d7dcffc4 CLOUDAUTH SDK Auto Released By gongpei.gp,Version:1.29.1 %!s(int64=8) %!d(string=hai) anos
cloudphoto 1c441b53f5 由廷诚发起的CLOUDPHOTO SDK自动发布, 版本号:1.6.5 %!s(int64=8) %!d(string=hai) anos
cms 7be1f34dae Fix build failed on windows %!s(int64=8) %!d(string=hai) anos
core c99809b8e4 support http put and delete %!s(int64=7) %!d(string=hai) anos
cs 7be1f34dae Fix build failed on windows %!s(int64=8) %!d(string=hai) anos
csb 002d5fb06f CSB SDK Auto Released By yaolan.lt,Version:1.24.1 %!s(int64=8) %!d(string=hai) anos
dcdn 9664fb1b00 DCDN SDK Auto Released By xiaoyao,Version:1.34.8 %!s(int64=7) %!d(string=hai) anos
domain 6072a0309b DOMAIN SDK Auto Released By lukang.zlh,Version:1.31.0 %!s(int64=7) %!d(string=hai) anos
drds 6d41511442 由燧木发起的DRDS SDK自动发布, 版本号:1.12.0 %!s(int64=8) %!d(string=hai) anos
dyvmsapi 02c620b5a5 由峰远发起的DYVMSAPI SDK自动发布, 版本号:1.10.3 %!s(int64=8) %!d(string=hai) anos
ecs 563e907601 fix ecs deleteInstance invalid Force parameter %!s(int64=7) %!d(string=hai) anos
ehpc e93d1a7c5c EHPC SDK Auto Released By qianzheng.llc,Version:1.32.0 %!s(int64=7) %!d(string=hai) anos
ess aa71e41fab ESS SDK Auto Released By deyan.jdy,Version:1.34.2 %!s(int64=7) %!d(string=hai) anos
examples f877a9ef39 update readme %!s(int64=7) %!d(string=hai) anos
green eadff9b0ef GREEN SDK Auto Released By fengdong.xfd,Version:1.26.3 %!s(int64=8) %!d(string=hai) anos
hsm 339cf28edd 由鸿逸发起的HSM SDK自动发布, 版本号:1.7.1 %!s(int64=8) %!d(string=hai) anos
iot 893339c43d IOT SDK Auto Released By cheyun.lxf,Version:1.33.5 %!s(int64=7) %!d(string=hai) anos
jarvis 8eb39b6f8f JARVIS SDK Auto Released By mainri.mxy,Version:1.17.6 %!s(int64=8) %!d(string=hai) anos
linkface f189a9dbb2 LINKFACE SDK Auto Released By jiayao.wjy,Version:1.30.1 %!s(int64=7) %!d(string=hai) anos
live 9b7dbef9c8 LIVE SDK Auto Released By renrang.yl,Version:1.34.6 %!s(int64=7) %!d(string=hai) anos
lubancloud f87f6a1649 LUBANCLOUD SDK Auto Released By benxiang.hhq,Version:1.30.0 %!s(int64=7) %!d(string=hai) anos
mopen f6d7b208a9 MOPEN SDK Auto Released By everettli.ll,Version:1.20.4 %!s(int64=8) %!d(string=hai) anos
mts 13ea4f0698 MTS SDK Auto Released By lingkong.mxs,Version:1.21.1 %!s(int64=8) %!d(string=hai) anos
ots e16ab91844 OTS SDK Auto Released By wanhong.chenwh,Version:1.21.5 %!s(int64=8) %!d(string=hai) anos
push c3ff60fd73 由释一发起的PUSH SDK自动发布, BUILD_ID=490, 版本号:1.3.0 %!s(int64=8) %!d(string=hai) anos
pvtz 62e3b9762a 由空木发起的PVTZ SDK自动发布, 版本号:1.10.0 %!s(int64=8) %!d(string=hai) anos
rds 459c875c7d 由秒本发起的RDS SDK自动发布, 版本号:1.10.2 %!s(int64=8) %!d(string=hai) anos
rtc 374b56dd63 RTC SDK Auto Released By renrang.yl,Version:1.30.2 %!s(int64=7) %!d(string=hai) anos
saf 6182017316 SAF SDK Auto Released By xinfa.duanxf,Version:1.27.6 %!s(int64=8) %!d(string=hai) anos
scdn e5522c68c8 SCDN SDK Auto Released By xiaoyao,Version:1.34.5 %!s(int64=7) %!d(string=hai) anos
slb 84adbb2cb8 SLB SDK Auto Released By laysong.sl,Version:1.23.4 %!s(int64=8) %!d(string=hai) anos
smartag 127c992829 SMARTAG SDK Auto Released By jijun.jj,Version:1.21.6 %!s(int64=8) %!d(string=hai) anos
tesladam 7be1f34dae Fix build failed on windows %!s(int64=8) %!d(string=hai) anos
teslamaxcompute d63881daa0 由荣旸发起的TESLAMAXCOMPUTE SDK自动发布, 版本号:1.8.2 %!s(int64=8) %!d(string=hai) anos
teslastream 20195cdd92 TESLASTREAM SDK Auto Released By tony.ly,Version:1.20.2 %!s(int64=8) %!d(string=hai) anos
test c99809b8e4 support http put and delete %!s(int64=7) %!d(string=hai) anos
tools c17dc7c79a refactor endpoints implementation %!s(int64=7) %!d(string=hai) anos
vod 2fb169a7d4 VOD SDK Auto Released By xiao.xwp,Version:1.34.1 %!s(int64=7) %!d(string=hai) anos
vpc 85da4ff587 由温仰发起的VPC SDK自动发布, BUILD_ID=466, 版本号:1.2.13 %!s(int64=8) %!d(string=hai) anos
xspace 85e2f3ebe4 XSPACE SDK Auto Released By xiaoyan.yan,Version:1.34.9 %!s(int64=7) %!d(string=hai) anos
.gitignore c99809b8e4 support http put and delete %!s(int64=7) %!d(string=hai) anos
.travis.yml c99809b8e4 support http put and delete %!s(int64=7) %!d(string=hai) anos
CHANGELOG 85e2f3ebe4 XSPACE SDK Auto Released By xiaoyan.yan,Version:1.34.9 %!s(int64=7) %!d(string=hai) anos
CMakeLists.txt c99809b8e4 support http put and delete %!s(int64=7) %!d(string=hai) anos
Doxyfile f6db1a27e4 Init commit %!s(int64=8) %!d(string=hai) anos
LICENSE 1ee62b8677 update license year %!s(int64=7) %!d(string=hai) anos
README.md f877a9ef39 update readme %!s(int64=7) %!d(string=hai) anos
README_zh.md f877a9ef39 update readme %!s(int64=7) %!d(string=hai) anos
VERSION 85e2f3ebe4 XSPACE SDK Auto Released By xiaoyan.yan,Version:1.34.9 %!s(int64=7) %!d(string=hai) anos
easyinstall.sh f877a9ef39 update readme %!s(int64=7) %!d(string=hai) anos
function_test.sh 5f3caa1943 add examples and build with as many cpus as possible %!s(int64=7) %!d(string=hai) anos
generate_code_cov.sh 21edc7f283 fix unit test build failed %!s(int64=7) %!d(string=hai) anos
unit_test.sh c99809b8e4 support http put and delete %!s(int64=7) %!d(string=hai) anos

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.
~$

More examples

LICENSE

Please refer to LICENSE (Apache 2.0 LICENSE).