No Description

sdk-team 3f0e3c3e9a Update Endpoint. 1 year ago
.github be6c27326e test: add github action workflow 3 years ago
3rdparty ad045aa702 fix build failed 7 years ago
accountlabel bb1c3193e8 Generated 2020-03-15 for AccountLabel. 2 years ago
acm 30fd9f48a0 Support namespaces. 6 years ago
acms-open 54883f36c2 ACM POP SDK. 6 years ago
actiontrail 015109df88 Support AK Audit API. 4 years ago
adb 8fc9b8125b Public Api. 2 years ago
adcp cd34c91d00 UpdateHubClusterFeature support ArgoCDHAEnabled. 3 years ago
address-purification 8617b6ffe5 Aaaaa. 5 years ago
aegis f0c2600a26 regenerate code 6 years ago
afs f0c2600a26 regenerate code 6 years ago
aicontent b91b263fdd add openapi for Personalized Text to Image ablity init version. 2 years ago
aigen 43b055ce70 Release GenerateCosplayImage. 2 years ago
aimiaobi 26ec339ba4 Generated 2023-08-01 for AiMiaoBi. 2 years ago
airec 8ded49c937 Generated 2020-11-26 for Airec. 5 years ago
alb d54cb68653 Support Latest APIs. 3 years ago
alidns 1b1720464f Supported sorting for DescribeDnsProduceInstances. 3 years ago
alikafka 179726e2c2 Supported use group by freedom 2 years ago
alimt 297be84e79 Add image batch translate API. 3 years ago
alinlp aab920ef80 Supported more api for user. 3 years ago
aliyuncvc 648aacf470 Public beta version. 5 years ago
amqp-open b618f90905 Support CreateInstance API. 2 years ago
antiddos-public 98aeacc7c2 Init amp. 4 years ago
apds a54f4e6f8d CreateMigrationJob SDK. 4 years ago
appmallsservice f0c2600a26 regenerate code 6 years ago
appstream-center dbaa86de9e Add ListAppInstances Open API. 3 years ago
aps 92ffb966bd Generated 2024-03-25 for aps. 2 years ago
arms 87f3f72876 Support effective time for CreateOrUpdateSilencePolicy interface. 2 years ago
arms4finance f0c2600a26 regenerate code 6 years ago
avatar 1380c5890f support start params 2 years ago
beian db6a17b08c Domain Self Diagnosis. 2 years ago
bssopenapi 5d8069b2ae DescribeInstanceAmortizedCostByAmortizationPeriodDate 3 years ago
btripopen f9cb2e2167 Test. 4 years ago
cams cfd6b2d640 QueryChatappBindWaba接口增加businessId, businessName参数返回 2 years ago
captcha 8c76154f4f Generated 2023-03-05 for captcha. 2 years ago
cas 377504fe8a Fix some bugs. 2 years ago
cassandra 97c5e2c422 Generated 2019-01-01 for Cassandra. 5 years ago
cbn 046fa0c8a7 Supported ECR Attachment. 2 years ago
cc5g a6ee7a24dc Cc5g. 3 years ago
ccc 00eafdf174 Supported BreakCodeDetails,FirstCheckInTime, LastCheckoutTime . 3 years ago
ccs f0c2600a26 regenerate code 6 years ago
cdn 6f27a24f42 Support STS. 4 years ago
cdrs 0553d7374d Update Monitor Api. 5 years ago
chatbot f0c2600a26 regenerate code 6 years ago
cloud-siem fe741d3fe9 Standardizing api. 2 years ago
cloudapi 879e8b9359 Generated 2016-07-14 for CloudAPI. 2 years ago
cloudauth 0683d0188a Generated 2019-03-07 for Cloudauth. 2 years ago
cloudauth-console fa0fe1ae07 SDK. 4 years ago
cloudesl 6f86a0ac33 Add Mutimedia Screen API Support. 4 years ago
cloudgame 6088526cd8 Supported CloudGame. 6 years ago
cloudphoto f0c2600a26 regenerate code 6 years ago
cloudwf f0c2600a26 regenerate code 6 years ago
cms 63135520bc CreateContact API Add ContactGroupName. 4 years ago
codeup ac11b7e23d Add CreateSshKey OpenAPI. 5 years ago
companyreg 351e7765f5 Public version. 5 years ago
computenest 8c606d0357 Add status operation api. 2 years ago
computenestsupplier ebee82abfa Add UpdateService GetService DeleteService. 3 years ago
config 677e71ae09 发布资源清单下载、高级搜索、合规趋势统计等API. 3 years ago
core 9b6827d238 fix EcsMetadataFetcher.h not found bug 3 years ago
cr f0c2600a26 regenerate code 6 years ago
crm f0c2600a26 regenerate code 6 years ago
cs 9290117d12 Some new parameters are supported. 6 years ago
csas befcff9add Generated 2023-01-20 for csas. 2 years ago
csb b257cba9c3 Add FindServiceList and GetService qps. 6 years ago
cusanalytic_sc_online f0c2600a26 regenerate code 6 years ago
datalake 76afd2bcdc Init Cpp sdk. 3 years ago
dataworks-public f0133be6a9 Generated 2020-05-18 for dataworks-public. 2 years ago
dbfs a22a0c32f6 Increase flow control value for ListDbfs. 3 years ago
dbs c2475a651e Generated 2019-03-06 for Dbs. 2 years ago
dcdn b7792b239d Generated 2018-01-15 for dcdn. 2 years ago
ddosbgp e7391bcf60 Update sdk. 3 years ago
ddoscoo 192ded93b1 Support body 2 years ago
ddosdiversion 144aaf2401 Sdk version release. 2 years ago
dds ac4e846136 Generated 2015-12-01 for Dds. 2 years ago
democenter 56c516a238 Add demo edition auth. 6 years ago
devops 46f59d340b Add min_access_level and organization_alis fields. 2 years ago
devops-rdc 0dc704dbaa Fix ListPIpelineTemplates. 5 years ago
dg 31aec3f28f Generated 2019-03-27 for dg. 5 years ago
dms-dg a375fa9d99 Support dms dg. 2 years ago
dms-enterprise b8b197b741 Support CreateProcCorrectOrder request param of ExecMode. 2 years ago
documentautoml 8eda6c1cc6 DocumentInit. 3 years ago
domain 183190fd14 基于转移码的转出接口 1 year ago
drds 4ff900857e New API- GetDrdsDbRdsRelationInfo, which can get private RDS list under certain DB out of DRDS instance ID and DB name. 5 years ago
dt-oc-info f10a2a333b Supported GetQccSearchCertification and GetQccCertificationDetailById Api For Zhimaxinyong. 3 years ago
dts 1dddf4ace0 Update SDK version. 3 years ago
dybaseapi 1b9c5d6a42 Supported C#. 2 years ago
dyplsapi 8bc204572b Add new API. 3 years ago
dypnsapi ee2f3a43cf Publish sdk. 2 years ago
dypnsapi-intl bdeb75c7ee Deploy for Dypnsapi-intl. 3 years ago
dysmsapi c2bfeb1216 Upgrade Service for SMS. 4 years ago
dytnsapi 34607b9120 Support better trace logging for error locating. 3 years ago
dyvmsapi e6902accf9 Update Dyvmsapi SDK. 4 years ago
eais ef4cdc8756 Add openapi StartEaiJupyter. 1 year ago
eas 9db0b784a4 Add service label api. 3 years ago
ecd 93f7addccc Support desktop group auto scale. 3 years ago
ecs 9c795d127b Add ResourcePoolOptions.Strategy for CreateAutoProvisioningGroup. 1 year ago
ecs-workbench bb7cab374e Support command audit for ecs. 2 years ago
edas ac628879ee Modify CreateK8sSecret. 5 years ago
eflo ca3378ac03 Supported modification of securityGroupId for UpdateElasticNetworkInterface API. 2 years ago
eflo-controller cbcd585696 Lingjun Controller Initial Version Released. 3 years ago
ehpc 212db1e32d Support ExecutorId for CreateJob and ListJobExecutors. 2 years ago
ehpcinstant 7a6b431ace E-HPC Instant Computing Service Release, supporting mirroring and job management. 2 years ago
eipanycast 5fb8057a45 Add UpdateAnycastEipAddressAssociations Interface. 4 years ago
elasticsearch 7f6b7dbfba Support kibana Pvl private link operation. 2 years ago
emap d7a89ac3dc Add isv interface. 6 years ago
emr 73610fe6e9 ReleaseClusterHostGroup add support for ReleaseNumber. 4 years ago
ens 776d68f0aa Generated 2017-11-10 for Ens. 2 years ago
es-serverless 3300b8de84 Added ElasticSearch Serverless SDK. 3 years ago
ess cc8cf316cd Update ScalingConfig parameters. 5 years ago
et-industry-openapi 9315d79274 delete invalid api code 6 years ago
eventbridge c5710477dc Fixed bugs for PauseEventStreaming and DeleteEventStreaming 2 years ago
examples 2e42d8fa7f update readme 7 years ago
facebody 09d6015e09 Update DetectFace. 2 years ago
fnf fc0ca83c5e DeleteFlow、DeleteSchedule Parameters move to body. 2 years ago
foas 5f1578fdbe Support multi language. 4 years ago
ft edb09dc947 Generated 2021-01-01 for Ft. 3 years ago
ga 33322a0330 Add something for ga. 3 years ago
geoip 90a140992d fix: clear pop meta files 5 years ago
goodstech b5e667c1d7 Update goodstech. 5 years ago
governance b88765a938 治理检测新增第一版OpenAPI 2 years ago
gpdb a3f04022fb Add Cloud Disk Encryption. 3 years ago
grace bce94a0fa4 Initialize SDK. 3 years ago
green f9eb4e30b8 Delete MultiMedia Post Scan API. 5 years ago
gwlb 3f0e3c3e9a Update Endpoint. 1 year ago
hbase 213faf8f4f Add event tasks. 4 years ago
hiknoengine f0c2600a26 regenerate code 6 years ago
hitsdb 4b4f526887 support UpdateSecurityGroup 2 years ago
hsm f0c2600a26 regenerate code 6 years ago
httpdns c2e912302d Supported multiple Language. 5 years ago
ice cc4191005a Add api called SubmitAvatarVideoJob, which render virtual human videos. 3 years ago
idaas-doraemon 458e22b006 ListOrderConsumeStatisticRecords add applicationExternalId serviceCode. 2 years ago
idrsservice d28ae22685 Supported OpenAPI for SDK. 5 years ago
imageaudit 675df848ba Update imageaudit. 3 years ago
imageenhan ecf1fc42a2 Release GenerateSuperResolutionImage. 3 years ago
imageprocess 38f1feda73 Release ScreenGC. 3 years ago
imagerecog 45ae211126 Update sdk. 3 years ago
imagesearch f0c2600a26 regenerate code 6 years ago
imageseg 4b9242545b Update SegmentCloth. 2 years ago
imgsearch e9b7f9a589 Update imgsearch. 3 years ago
imm ba9b236957 Support new api about model training. 3 years ago
ims c13c576175 ListUsers,ListUserBasicInfos api新增支持status字段 1 year ago
industry-brain f82391b140 Add Content. 6 years ago
iot 1ff4eb0f4c Add UnsubscribeTopic. 2 years ago
iqa f0c2600a26 regenerate code 6 years ago
ivision f0c2600a26 regenerate code 6 years ago
ivpd 4332019dac Supported UpdateUserBucketConfig. 6 years ago
jarvis f0c2600a26 regenerate code 6 years ago
jarvis-public f0c2600a26 regenerate code 6 years ago
kms 4b90751575 Generated 2016-01-20 for Kms. 2 years ago
ledgerdb d005611f56 Publish apis for ledger instances. 6 years ago
linkface f0c2600a26 regenerate code 6 years ago
linkvisual 2d2d1e86d9 Generated 2018-01-20 for Linkvisual. 2 years ago
linkwan 98b1ef2aea Generated 2019-03-01 for LinkWAN. 5 years ago
live 66cb681daa Update to support new apis. 2 years ago
ltl 8871ba8a2c Generated 2019-05-10 for ltl. 3 years ago
lto 4838a80585 Release. 3 years ago
lubancloud f0c2600a26 regenerate code 6 years ago
market 7d74c183f6 Update DescribeApiMetering API. 2 years ago
metering 9fd70bc2bf Metering 1019. 6 years ago
mns-open b2feb38de2 Remove some useless response parameters. 3 years ago
moguan-sdk 34d72f2b3b Support APP auth. 5 years ago
mopen f0c2600a26 regenerate code 6 years ago
mse 61af8db794 Public API ListAppBySwimmingLaneGroupTags. 3 years ago
mseap 2e0f1478c6 Added param for ActivateLicenseResponse . 2 years ago
mts 4985a32853 Update water-mark params 2 years ago
multimediaai 934e283efb Video Content analytics template introduced to this SDK. 5 years ago
nas e4a6e73946 Support Elastic Desktop Service. 4 years ago
nis fd5e85ebf9 Publish Api:GetNisNetworkRanking 2 years ago
nlb d75a986e9f Generated 2022-04-30 for Nlb. 2 years ago
nlp-automl 5e93a9b21f 新增模型预测高性能版本 3 years ago
objectdet 2a254b88e0 Update DetectVehicleICongestion DetectVehicleIllegalParking. 3 years ago
oceanbasepro ba5ab1093f Generated 2019-09-01 for OceanBasePro. 2 years ago
ocr ecae0a8927 Update RecognizeBankCard. 2 years ago
oms d0b781c4c5 GetDomainFields add request field 2 years ago
ons 84f0671771 Add OnsMessageDetail for query message body. 3 years ago
onsmqtt 3303c6120d Support device credential for mqtt. 5 years ago
oos e660f66f68 PatchBaseline Support Tags. 3 years ago
openanalytics f0c2600a26 regenerate code 6 years ago
openanalytics-open f063a7bdba fix: clear pop meta files 5 years ago
opensearch 623a29292c update. 3 years ago
osssddp e2d298dba8 Generated 2024-02-22 for OssSddp. 2 years ago
ots f0c2600a26 regenerate code 6 years ago
outboundbot a8f72c5f44 Supported new features for outbound. 3 years ago
paifeaturestore fbc3817ea1 Add ListFeatureViewOnlineFeatures API. 2 years ago
polardb 6f8776cbe1 Support new feature. 2 years ago
polardbx d37523f568 CreateDBInstance add DNStorageSpace 2 years ago
privatelink f699392896 Add latest update. 3 years ago
pts 077d8093c7 Add new API for querying the sample logs of PTS debug plan. 3 years ago
push 4393e6e44f Support Android badge. 1 year ago
pvtz 6217773578 Update new version. 5 years ago
qualitycheck 422f236430 Add Api. 4 years ago
quickbi-public d00f8d0fb2 Add ManualRunMailTask, GetMailTaskStatus and GetWorksEmbedList apis. 1 year ago
quotas 1c37d47f07 Add UsageMetric. 2 years ago
r-kvstore 18b7bafcd0 Account management add SourceBiz parameters. 2 years ago
ram f0c2600a26 regenerate code 6 years ago
rds 44c9ab5768 Support RDS Custom. 2 years ago
rds-data c994b2d439 Automatically generate sdk tasks. 3 years ago
reid b5c0b83b02 ListActionData add parameters. 6 years ago
reid_cloud 211ad2244b Supported cro algorithm. 5 years ago
resourcecenter e676e2e38f Generated 2022-12-01 for ResourceCenter. 1 year ago
resourcemanager 0dc755cf75 Generated 2020-03-31 for ResourceManager. 3 years ago
resourcesharing 1333c0ead7 Support share resource to service for RS. 2 years ago
retailcloud f73358f7e8 Supported ScaleApp totalPartitions. 4 years ago
ros f0c2600a26 regenerate code 6 years ago
rsimganalys 40d1ce44af Public V430. 5 years ago
rtc db5500f960 Add DescribeAppKey interface. 4 years ago
sae 39478f1c33 Generated 2019-05-06 for sae. 2 years ago
saf e2a8813a1b Supported RequestDecision For YN. 4 years ago
safconsole fb12252d2d Supported console. 5 years ago
sas 0efc4956ec Support rd sdk. 3 years ago
sas-api f0c2600a26 regenerate code 6 years ago
sasti 00e697671e Add GetGraphQueryTemplates. 3 years ago
scdn 665991c212 Update PreloadScdnObjectCaches. 3 years ago
schedulerx2 b2cade322d Create AppGroup Support Set AppVersion. 2 years ago
scsp cfd8b7cb85 Publish multi language sdk. 5 years ago
sddp b3b1f59165 Generated 2019-01-03 for Sddp. 2 years ago
servicemesh 82cfdabb16 Generated 2020-01-11 for servicemesh. 5 years ago
sgw 15e8858e41 Supported CheckBlockVolumeName api for Checking the volume name has been already used by the OSS bucket folder. 4 years ago
slb 051077c805 Generated 2014-05-15 for Slb. 2 years ago
smartag c40875737f Support sts. 5 years ago
smarthosting 9693807164 Generated 2020-08-01 for SmartHosting. 6 years ago
smartsales 852d78709b SmartSales-OpenAPI. 4 years ago
smc 90a140992d fix: clear pop meta files 5 years ago
snsuapi f0c2600a26 regenerate code 6 years ago
sts 5c4cdd976d Publish AssumeRoleWithOIDC API by adding more detail in response. 2 years ago
swas-open 63bf0ee442 Generated 2020-06-01 for SWAS-OPEN. 2 years ago
tag 429d57cff4 Generated 2018-08-28 for Tag. 1 year ago
tdsr 565bfada36 Supported backend interface for ICBU. 6 years ago
teambition-aliyun 78ca57fe3d Fix create project task. 6 years ago
tesladam f0c2600a26 regenerate code 6 years ago
teslamaxcompute f0c2600a26 regenerate code 6 years ago
teslastream f0c2600a26 regenerate code 6 years ago
test 1f6051b3b3 fix roarequest query parameters 4 years ago
threedvision dce3c27547 Release EstimateMonocularVideoDepth. 3 years ago
tingwu 0755e147eb Generated 2023-09-30 for tingwu. 2 years ago
tools c17dc7c79a refactor endpoints implementation 7 years ago
trademark f0c2600a26 regenerate code 6 years ago
ubsms f0c2600a26 regenerate code 6 years ago
vcs 1908e64fa6 Change Configuration. 5 years ago
ververica 385caac18e Public release. 3 years ago
viapi 53da02f63b Support for deploy. 3 years ago
viapi-regen 8de0b02bda Release CustomizeClassifyImage. 3 years ago
videoenhan 22313c7d61 Update QueryFaceVideoTemplate. 2 years ago
videorecog a657203073 Update SplitVideoParts. 3 years ago
videosearch 5b5f0128c9 API GetTaskStatus return task detail. 6 years ago
videoseg 2f4689f88a Update videoseg. 3 years ago
visionai-poc d7e14e0c1b Vision-poc response modified. 6 years ago
vod 52c309ecd7 GetPlayInfo Add EncryptMode. 1 year ago
voicenavigator 8ec9faabe1 Supported new features etc. 4 years ago
vpc 262fc718c8 Support create default VPC and create default vSwitch . 3 years ago
vs 4edd799a79 Support odcap device. 5 years ago
waf-openapi d733a6db40 Upgrade SDK. 2 years ago
wfts 6f08307187 Automatically generate sdk tasks. 4 years ago
workorder c99e90b98e Encrypt Dialog Content. 5 years ago
wss 179314c9fe Generated 2021-12-21 for wss. 1 year ago
xspace f0c2600a26 regenerate code 6 years ago
xtrace 4f16d1bd02 Add result value spanId for GetTrace api. 5 years ago
yundun f0c2600a26 regenerate code 6 years ago
yundun-ds f0c2600a26 regenerate code 6 years ago
.clang-format a57f6ec422 fix code style 6 years ago
.gitignore be6c27326e test: add github action workflow 3 years ago
.travis.yml 4262cf11c8 fix travis ci config 7 years ago
CHANGELOG 99c7c0b611 Fix ListManagedRules bugs. 4 years ago
CHANGELOG.md 3e81be19ef AMP version. 4 years ago
CMakeLists.txt 8bed6eecc7 improve CmakeLists file 6 years ago
CONTRIBUTING.md fe958d3794 refactor readme 7 years ago
Doxyfile f6db1a27e4 Init commit 8 years ago
LICENSE 1ee62b8677 update license year 7 years ago
README-CN.md 9c47520d45 update README-CN.md 3 years ago
README.md 5550c66a4c Update README.md 3 years ago
VERSION 3f0e3c3e9a Update Endpoint. 1 year ago
easyinstall.sh 31f2c5d410 improve cmake compile 6 years ago
function_test.sh 619a7827de timeout support when create client or make request 7 years ago
generate_code_cov.sh 21edc7f283 fix unit test build failed 7 years ago
unit_test.sh c99809b8e4 support http put and delete 7 years ago

README-CN.md

English | 简体中文

Alibaba Cloud SDK for C++

Travis Build Status codecov

Alibaba Cloud SDK for C++ 让您不用复杂编程即可访问云服务器、负载均衡、云监控等阿里云服务。这里向您介绍如何获取 Alibaba Cloud SDK for C++ 并开始调用。

如果您在使用的过程中遇到任何问题,欢迎前往阿里云SDK问答社区提问,提问前请阅读提问引导。亦可在当前 GitHub 提交 Issues

使用诊断

Troubleshoot 提供 OpenAPI 使用诊断服务,通过 RequestID报错信息 ,帮助开发者快速定位,为开发者提供解决方案。

环境要求

在使用 Alibaba Cloud SDK for C++ 前,确保您已经:

  • 注册了阿里云账号并获取了访问密钥(AccessKey)。

说明: 为了保证您的账号安全,建议您使用RAM账号来访问阿里云服务。阿里云账号对拥有的资源有全部权限。RAM账号由阿里云账号授权创建,仅有对特定资源限定的操作权限。详情参见RAM

  • 开通了云产品服务。有些云产品如对象存储(OSS)需要先在阿里云控制台开通服务。

  • 安装支持 C++ 11 或更高版本的编译器:

    • Windows: Visual Studio 2015 或以上版本
    • Linux: GCC 4.9 或以上版本
  • 安装 CMake 3.0 或以上版本

  • 建议 4G 或以上内存

安装 (从源代码构建)

Linux

  1. 要在 Linux 平台进行编译, 您必须安装依赖的外部库文件 libcurl、libopenssl、libuuid、libjsoncpp, 通常情况下,系统的包管理器中的会有提供。
  • 例如:在基于 Redhat / Fedora 的系统上安装这些软件包

    # use yum
    yum install jsoncpp-devel openssl-devel libuuid-devel libcurl-devel
    
    # use dnf
    sudo dnf install libcurl-devel openssl-devel libuuid-devel libjsoncpp-devel
    
  • 在基于 Debian/Ubuntu 的系统

    sudo apt-get install libcurl4-openssl-dev libssl-dev uuid-dev libjsoncpp-dev
    
  1. 执行以下命令,从 Github 克隆源码

    git clone https://github.com/aliyun/aliyun-openapi-cpp-sdk.git
    
  2. 编译安装

  • 手动编译安装

    cd aliyun-openapi-cpp-sdk
    mkdir sdk_build
    cd sdk_build
    cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr ..
    make
    sudo make install
    
  • 或者通过 easyinstall.sh一键式安装

    cd aliyun-openapi-cpp-sdk
    sudo sh easyinstall.sh <lower name of product (like 'ecs')>
    
    # example
    sudo sh easyinstall.sh core
    sudo sh easyinstall.sh ecs
    

Alibaba Cloud SDK for C++ 将被安装在 /usr .

Windows

  1. 安装 perl

  2. 使用 git-bash 执行以下命令,从 Github 克隆源码

    git clone https://github.com/aliyun/aliyun-openapi-cpp-sdk.git
    
  3. 使用 Visual Studio 进行编译:

  • 在 aliyun-openapi-cpp-sdk 下创建 sdk_build 目录
  • 打开 cmake-gui , 然后进行以下操作
    • 选择 Browse Source源代码目录(aliyun-openapi-cpp-sdk)
    • 选择 Browse build构建目录(sdk_build)
    • 点击 configure
    • 使用小写的产品名称,设置 BUILD_PRODUCT 参数的值
    • 点击 generate, 构建 VS 解决方案。
  1. 编译安装 C++ SDK
  • 进入 sdk_build 目录,使用 Visual Studio 打开 alibabacloud-sdk.sln 解决方案
  • 选择构建 Release 输出
  • 并打开配置管理器勾选 INSTALL
  • 构建 -> 生成解决方案

Alibaba Cloud SDK for C++ 将安装在 C:\Program File (x86)\alibabacloud-sdk 目录

注意:请以管理员身份运行 Visual Studio 和 cmake-gui,否则无法安装 SDK


快速使用

在调用 Alibaba Cloud SDK for C++ 时,您首先需要配置预处理器定义 ALIBABACLOUD_SHARED 以引用阿里云 C++ SDK 的共享库,然后通过创建 Client 实例提供身份验证,并指定云服务的地域,然后发送API请求。

以下代码展示了如何调用 DescribeInstancesAPI 查询指定地域所有 ECS 实例的详细信息。

说明: 您需要替换示例中的 your-region-id、your-access-key-id 和 your-access-key-secret 的值。

#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) {
  // 初始化 SDK
  AlibabaCloud::InitializeSdk();

  // 配置 ecs 实例
  ClientConfiguration configuration("<your-region-id>");
  EcsClient client("<your-access-key-id>", "<your-access-key-secret>", configuration);

  // 创建API请求并设置参数
  Model::DescribeInstancesRequest request;
  request.setPageSize(10);

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

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

  // 关闭 SDK
  AlibabaCloud::ShutdownSdk();
  return 0;
}

复制上述文件到 ecs_test.cc。

Linux 下

~$ g++ -o ecstest ecs_test.cc --std=c++11 -lalibabacloud-sdk-core -l alibabacloud-sdk-ecs
~$ ./ecstest
# 结果或错误返回将在此展示
~$

Timeout 设置

CPP SDK 使用 libcurl 作为底层 HTTP 传输库。

  • 下面两个参数用来传递超时参数到 libcurl。

    • connectTimeout: 连接超时设置。 参考.
    • readTimeout: 传输超时设置。参考
  • 默认值

    • connectTimeout: 5000ms
    • readTimeout: 10000ms
  • 可以在创建 Client 或者发 Requst 设置超时参数。

  • Requst 设置优先级高于 Client 设置。

  • 输入 0 或者 -1 到 setConnectTimeoutsetReadTimeout 可以禁用此功能。

下面代码是设置超时参数的例子,由于 Request 优先级高于 Client,所以最终 ConnectTimeout1000msreadTimeout6000ms

#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;
}


更多 例程

问题

提交 Issue, 不符合指南的问题可能会立即关闭。

发行说明

每个版本的详细更改记录在发行说明中。

贡献

提交 Pull Request 之前请阅读贡献指南

许可证

Apache-2.0

版权所有 1999-2019 阿里巴巴集团