Sin descripción

sdk-team 2655b67ecf Fix API hace 2 años
.github be6c27326e test: add github action workflow hace 3 años
3rdparty ad045aa702 fix build failed hace 7 años
acm 30fd9f48a0 Support namespaces. hace 6 años
acms-open 54883f36c2 ACM POP SDK. hace 6 años
actiontrail 015109df88 Support AK Audit API. hace 4 años
adb 8fc9b8125b Public Api. hace 2 años
adcp cd34c91d00 UpdateHubClusterFeature support ArgoCDHAEnabled. hace 3 años
address-purification 8617b6ffe5 Aaaaa. hace 5 años
aegis f0c2600a26 regenerate code hace 6 años
afs f0c2600a26 regenerate code hace 6 años
aigen 43b055ce70 Release GenerateCosplayImage. hace 2 años
aimiaobi 26ec339ba4 Generated 2023-08-01 for AiMiaoBi. hace 2 años
airec 8ded49c937 Generated 2020-11-26 for Airec. hace 5 años
alb d54cb68653 Support Latest APIs. hace 3 años
alidns 1b1720464f Supported sorting for DescribeDnsProduceInstances. hace 3 años
alikafka 93a074e698 Add UpdateConsumerOffset api. hace 3 años
alimt 297be84e79 Add image batch translate API. hace 3 años
alinlp aab920ef80 Supported more api for user. hace 3 años
aliyuncvc 648aacf470 Public beta version. hace 5 años
amqp-open b618f90905 Support CreateInstance API. hace 2 años
antiddos-public 98aeacc7c2 Init amp. hace 4 años
apds a54f4e6f8d CreateMigrationJob SDK. hace 4 años
appmallsservice f0c2600a26 regenerate code hace 6 años
appstream-center dbaa86de9e Add ListAppInstances Open API. hace 3 años
arms 15ad2ff078 Update sdk. hace 4 años
arms4finance f0c2600a26 regenerate code hace 6 años
avatar 1380c5890f support start params hace 2 años
bssopenapi 5d8069b2ae DescribeInstanceAmortizedCostByAmortizationPeriodDate hace 3 años
btripopen f9cb2e2167 Test. hace 4 años
cams 70dddee991 Coupon template hace 2 años
captcha 8c76154f4f Generated 2023-03-05 for captcha. hace 2 años
cas 377504fe8a Fix some bugs. hace 2 años
cassandra 97c5e2c422 Generated 2019-01-01 for Cassandra. hace 5 años
cbn e788fcb800 DescribeChildInstanceRegions. hace 3 años
cc5g a6ee7a24dc Cc5g. hace 3 años
ccc 00eafdf174 Supported BreakCodeDetails,FirstCheckInTime, LastCheckoutTime . hace 3 años
ccs f0c2600a26 regenerate code hace 6 años
cdn 6f27a24f42 Support STS. hace 4 años
cdrs 0553d7374d Update Monitor Api. hace 5 años
chatbot f0c2600a26 regenerate code hace 6 años
cloud-siem fe741d3fe9 Standardizing api. hace 2 años
cloudapi 879e8b9359 Generated 2016-07-14 for CloudAPI. hace 2 años
cloudauth 89a2517800 Add AuthId. hace 4 años
cloudauth-console fa0fe1ae07 SDK. hace 4 años
cloudesl 6f86a0ac33 Add Mutimedia Screen API Support. hace 4 años
cloudgame 6088526cd8 Supported CloudGame. hace 6 años
cloudphoto f0c2600a26 regenerate code hace 6 años
cloudwf f0c2600a26 regenerate code hace 6 años
cms 63135520bc CreateContact API Add ContactGroupName. hace 4 años
codeup ac11b7e23d Add CreateSshKey OpenAPI. hace 5 años
companyreg 351e7765f5 Public version. hace 5 años
computenest a91b82458d Generate SDK for service instance APIs. hace 3 años
computenestsupplier ebee82abfa Add UpdateService GetService DeleteService. hace 3 años
config 677e71ae09 发布资源清单下载、高级搜索、合规趋势统计等API. hace 3 años
core 9b6827d238 fix EcsMetadataFetcher.h not found bug hace 3 años
cr f0c2600a26 regenerate code hace 6 años
crm f0c2600a26 regenerate code hace 6 años
cs 9290117d12 Some new parameters are supported. hace 6 años
csas e922990dbc Supported SortBy for ListUserDevices. hace 2 años
csb b257cba9c3 Add FindServiceList and GetService qps. hace 6 años
cusanalytic_sc_online f0c2600a26 regenerate code hace 6 años
datalake 76afd2bcdc Init Cpp sdk. hace 3 años
dataworks-public e9e64ef7f1 Generated 2020-05-18 for dataworks-public. hace 2 años
dbfs a22a0c32f6 Increase flow control value for ListDbfs. hace 3 años
dbs c2475a651e Generated 2019-03-06 for Dbs. hace 2 años
dcdn d1bab4fe11 Add ListDcdnEsTemplateInfo. hace 4 años
ddosbgp e7391bcf60 Update sdk. hace 3 años
ddoscoo 1f7b94e379 Update sdk. hace 4 años
ddosdiversion 144aaf2401 Sdk version release. hace 2 años
dds 005a84c9f4 Generated 2015-12-01 for Dds. hace 2 años
democenter 56c516a238 Add demo edition auth. hace 6 años
devops-rdc 0dc704dbaa Fix ListPIpelineTemplates. hace 5 años
dg 31aec3f28f Generated 2019-03-27 for dg. hace 5 años
dms-enterprise b8b197b741 Support CreateProcCorrectOrder request param of ExecMode. hace 2 años
documentautoml 8eda6c1cc6 DocumentInit. hace 3 años
domain 53badb17c1 Ram action config. hace 4 años
drds 4ff900857e New API- GetDrdsDbRdsRelationInfo, which can get private RDS list under certain DB out of DRDS instance ID and DB name. hace 5 años
dt-oc-info f10a2a333b Supported GetQccSearchCertification and GetQccCertificationDetailById Api For Zhimaxinyong. hace 3 años
dts 1dddf4ace0 Update SDK version. hace 3 años
dyplsapi 8bc204572b Add new API. hace 3 años
dypnsapi ee2f3a43cf Publish sdk. hace 2 años
dypnsapi-intl bdeb75c7ee Deploy for Dypnsapi-intl. hace 3 años
dysmsapi c2bfeb1216 Upgrade Service for SMS. hace 4 años
dytnsapi 34607b9120 Support better trace logging for error locating. hace 3 años
dyvmsapi e6902accf9 Update Dyvmsapi SDK. hace 4 años
eais d209714cb0 Add openapi TagResources. hace 3 años
eas 9db0b784a4 Add service label api. hace 3 años
ecd 93f7addccc Support desktop group auto scale. hace 3 años
ecs 31b4d82c33 Support DryRun for DeleteInstance. hace 2 años
edas ac628879ee Modify CreateK8sSecret. hace 5 años
eflo 1637cf567e Support ClientToken for Idemoptent. hace 2 años
eflo-controller cbcd585696 Lingjun Controller Initial Version Released. hace 3 años
ehpc 419d2ef5e8 Support UserData parameter for ApplyNodes interface. hace 2 años
eipanycast 5fb8057a45 Add UpdateAnycastEipAddressAssociations Interface. hace 4 años
elasticsearch b9383c3ee7 Complete Request Body. hace 3 años
emap d7a89ac3dc Add isv interface. hace 6 años
emr 73610fe6e9 ReleaseClusterHostGroup add support for ReleaseNumber. hace 4 años
ens d17a79e8b6 Support clouddisk API. hace 3 años
es-serverless 3300b8de84 Added ElasticSearch Serverless SDK. hace 3 años
ess cc8cf316cd Update ScalingConfig parameters. hace 5 años
et-industry-openapi 9315d79274 delete invalid api code hace 6 años
eventbridge c5710477dc Fixed bugs for PauseEventStreaming and DeleteEventStreaming hace 2 años
examples 2e42d8fa7f update readme hace 7 años
facebody ae139aef77 Update QueryFaceImageTemplate. hace 2 años
fnf 2b84cadd9d 增加StartSyncExecution hace 2 años
foas 5f1578fdbe Support multi language. hace 4 años
ft edb09dc947 Generated 2021-01-01 for Ft. hace 3 años
ga 33322a0330 Add something for ga. hace 3 años
geoip 90a140992d fix: clear pop meta files hace 5 años
goodstech b5e667c1d7 Update goodstech. hace 5 años
gpdb a3f04022fb Add Cloud Disk Encryption. hace 3 años
grace bce94a0fa4 Initialize SDK. hace 3 años
green f9eb4e30b8 Delete MultiMedia Post Scan API. hace 5 años
hbase 213faf8f4f Add event tasks. hace 4 años
hiknoengine f0c2600a26 regenerate code hace 6 años
hitsdb 4b4f526887 support UpdateSecurityGroup hace 2 años
hsm f0c2600a26 regenerate code hace 6 años
httpdns c2e912302d Supported multiple Language. hace 5 años
ice cc4191005a Add api called SubmitAvatarVideoJob, which render virtual human videos. hace 3 años
idaas-doraemon 2864623659 Support all language. hace 4 años
idrsservice d28ae22685 Supported OpenAPI for SDK. hace 5 años
imageaudit 675df848ba Update imageaudit. hace 3 años
imageenhan ecf1fc42a2 Release GenerateSuperResolutionImage. hace 3 años
imageprocess 38f1feda73 Release ScreenGC. hace 3 años
imagerecog 45ae211126 Update sdk. hace 3 años
imagesearch f0c2600a26 regenerate code hace 6 años
imageseg 2344a2c7cc Update SegmentCloth. hace 2 años
imgsearch e9b7f9a589 Update imgsearch. hace 3 años
imm ba9b236957 Support new api about model training. hace 3 años
industry-brain f82391b140 Add Content. hace 6 años
iot 1ff4eb0f4c Add UnsubscribeTopic. hace 2 años
iqa f0c2600a26 regenerate code hace 6 años
ivision f0c2600a26 regenerate code hace 6 años
ivpd 4332019dac Supported UpdateUserBucketConfig. hace 6 años
jarvis f0c2600a26 regenerate code hace 6 años
jarvis-public f0c2600a26 regenerate code hace 6 años
kms c49607aeca add Instance, NetworkRule, Policy, ApplicationAccessPoint, ClientKey OpenAPIs hace 3 años
ledgerdb d005611f56 Publish apis for ledger instances. hace 6 años
linkface f0c2600a26 regenerate code hace 6 años
linkvisual 2d2d1e86d9 Generated 2018-01-20 for Linkvisual. hace 2 años
linkwan 98b1ef2aea Generated 2019-03-01 for LinkWAN. hace 5 años
live 150f012d41 Update to support new apis. hace 2 años
ltl 8871ba8a2c Generated 2019-05-10 for ltl. hace 3 años
lto 4838a80585 Release. hace 3 años
lubancloud f0c2600a26 regenerate code hace 6 años
market ecee6ebdcf Add DistributionProducts API. hace 3 años
metering 9fd70bc2bf Metering 1019. hace 6 años
mns-open b2feb38de2 Remove some useless response parameters. hace 3 años
moguan-sdk 34d72f2b3b Support APP auth. hace 5 años
mopen f0c2600a26 regenerate code hace 6 años
mse 61af8db794 Public API ListAppBySwimmingLaneGroupTags. hace 3 años
mts fe6548a733 SubmitURLUploadJob, support S3 Storage. hace 5 años
multimediaai 934e283efb Video Content analytics template introduced to this SDK. hace 5 años
nas e4a6e73946 Support Elastic Desktop Service. hace 4 años
nlb d75a986e9f Generated 2022-04-30 for Nlb. hace 2 años
nlp-automl 5e93a9b21f 新增模型预测高性能版本 hace 3 años
objectdet 2a254b88e0 Update DetectVehicleICongestion DetectVehicleIllegalParking. hace 3 años
oceanbasepro 0d265770f7 Generated 2019-09-01 for OceanBasePro. hace 2 años
ocr ecae0a8927 Update RecognizeBankCard. hace 2 años
oms d0b781c4c5 GetDomainFields add request field hace 2 años
ons 84f0671771 Add OnsMessageDetail for query message body. hace 3 años
onsmqtt 3303c6120d Support device credential for mqtt. hace 5 años
oos e660f66f68 PatchBaseline Support Tags. hace 3 años
openanalytics f0c2600a26 regenerate code hace 6 años
openanalytics-open f063a7bdba fix: clear pop meta files hace 5 años
opensearch 623a29292c update. hace 3 años
ots f0c2600a26 regenerate code hace 6 años
outboundbot a8f72c5f44 Supported new features for outbound. hace 3 años
paifeaturestore 6eb45b0747 Add FG apis in ModelFeature. hace 2 años
polardb 6f8776cbe1 Support new feature. hace 2 años
polardbx 8f21fa7c59 Supported all language sdk. hace 5 años
privatelink f699392896 Add latest update. hace 3 años
pts 077d8093c7 Add new API for querying the sample logs of PTS debug plan. hace 3 años
push 1884db41cf Supported AndroidVivoReceiptId for Push and MassPush. hace 2 años
pvtz 6217773578 Update new version. hace 5 años
qualitycheck 422f236430 Add Api. hace 4 años
quickbi-public 1c75989037 AllotDatasetAccelerationTask API add error code. hace 2 años
quotas 900bb894d0 Support query quota. hace 5 años
r-kvstore ed952131e7 Add DescribeClusterBackupList OpenAPI. hace 2 años
ram f0c2600a26 regenerate code hace 6 años
rds 627569cd6f Fix bug ram. hace 3 años
rds-data c994b2d439 Automatically generate sdk tasks. hace 3 años
reid b5c0b83b02 ListActionData add parameters. hace 6 años
reid_cloud 211ad2244b Supported cro algorithm. hace 5 años
resourcecenter 50542d3a96 Supported GetResourceCounts for Resourcecenter. hace 3 años
resourcemanager 0dc755cf75 Generated 2020-03-31 for ResourceManager. hace 3 años
resourcesharing 1333c0ead7 Support share resource to service for RS. hace 2 años
retailcloud f73358f7e8 Supported ScaleApp totalPartitions. hace 4 años
ros f0c2600a26 regenerate code hace 6 años
rsimganalys 40d1ce44af Public V430. hace 5 años
rtc db5500f960 Add DescribeAppKey interface. hace 4 años
sae fa4f475079 Add support for secret. hace 3 años
saf e2a8813a1b Supported RequestDecision For YN. hace 4 años
safconsole fb12252d2d Supported console. hace 5 años
sas 0efc4956ec Support rd sdk. hace 3 años
sas-api f0c2600a26 regenerate code hace 6 años
sasti 00e697671e Add GetGraphQueryTemplates. hace 3 años
scdn 665991c212 Update PreloadScdnObjectCaches. hace 3 años
schedulerx2 1bf5fe98af Get Workflow Instance Add Node Field. hace 3 años
scsp cfd8b7cb85 Publish multi language sdk. hace 5 años
sddp b3b1f59165 Generated 2019-01-03 for Sddp. hace 2 años
servicemesh 82cfdabb16 Generated 2020-01-11 for servicemesh. hace 5 años
sgw 15e8858e41 Supported CheckBlockVolumeName api for Checking the volume name has been already used by the OSS bucket folder. hace 4 años
slb edbe01d364 Support HealthCheckMethod for HTTP and HTTPS listener. hace 5 años
smartag c40875737f Support sts. hace 5 años
smarthosting 9693807164 Generated 2020-08-01 for SmartHosting. hace 6 años
smartsales 852d78709b SmartSales-OpenAPI. hace 4 años
smc 90a140992d fix: clear pop meta files hace 5 años
snsuapi f0c2600a26 regenerate code hace 6 años
sts 5c4cdd976d Publish AssumeRoleWithOIDC API by adding more detail in response. hace 2 años
swas-open 4970164a9f Generated 2020-06-01 for SWAS-OPEN. hace 2 años
tag fe60cca404 Add MetaTag APIs. hace 4 años
tdsr 565bfada36 Supported backend interface for ICBU. hace 6 años
teambition-aliyun 78ca57fe3d Fix create project task. hace 6 años
tesladam f0c2600a26 regenerate code hace 6 años
teslamaxcompute f0c2600a26 regenerate code hace 6 años
teslastream f0c2600a26 regenerate code hace 6 años
test 1f6051b3b3 fix roarequest query parameters hace 4 años
threedvision dce3c27547 Release EstimateMonocularVideoDepth. hace 3 años
tingwu 0755e147eb Generated 2023-09-30 for tingwu. hace 2 años
tools c17dc7c79a refactor endpoints implementation hace 7 años
trademark f0c2600a26 regenerate code hace 6 años
ubsms f0c2600a26 regenerate code hace 6 años
vcs 1908e64fa6 Change Configuration. hace 5 años
ververica 385caac18e Public release. hace 3 años
viapi 53da02f63b Support for deploy. hace 3 años
viapi-regen 8de0b02bda Release CustomizeClassifyImage. hace 3 años
videoenhan 06af2542bd Update QueryFaceVideoTemplate. hace 2 años
videorecog a657203073 Update SplitVideoParts. hace 3 años
videosearch 5b5f0128c9 API GetTaskStatus return task detail. hace 6 años
videoseg 2f4689f88a Update videoseg. hace 3 años
visionai-poc d7e14e0c1b Vision-poc response modified. hace 6 años
vod 4ec1c844d0 open GenerateDownloadDecryptkey. hace 2 años
voicenavigator 8ec9faabe1 Supported new features etc. hace 4 años
vpc 262fc718c8 Support create default VPC and create default vSwitch . hace 3 años
vs 4edd799a79 Support odcap device. hace 5 años
waf-openapi a70be0a97a Upgrade SDK. hace 3 años
wfts 6f08307187 Automatically generate sdk tasks. hace 4 años
workorder c99e90b98e Encrypt Dialog Content. hace 5 años
xspace f0c2600a26 regenerate code hace 6 años
xtrace 4f16d1bd02 Add result value spanId for GetTrace api. hace 5 años
yundun f0c2600a26 regenerate code hace 6 años
yundun-ds f0c2600a26 regenerate code hace 6 años
.clang-format a57f6ec422 fix code style hace 6 años
.gitignore be6c27326e test: add github action workflow hace 3 años
.travis.yml 4262cf11c8 fix travis ci config hace 7 años
CHANGELOG 99c7c0b611 Fix ListManagedRules bugs. hace 4 años
CHANGELOG.md 3e81be19ef AMP version. hace 4 años
CMakeLists.txt 8bed6eecc7 improve CmakeLists file hace 6 años
CONTRIBUTING.md fe958d3794 refactor readme hace 7 años
Doxyfile f6db1a27e4 Init commit hace 8 años
LICENSE 1ee62b8677 update license year hace 7 años
README-CN.md 9c47520d45 update README-CN.md hace 3 años
README.md 5550c66a4c Update README.md hace 3 años
VERSION 2655b67ecf Fix API hace 2 años
easyinstall.sh 31f2c5d410 improve cmake compile hace 6 años
function_test.sh 619a7827de timeout support when create client or make request hace 7 años
generate_code_cov.sh 21edc7f283 fix unit test build failed hace 7 años
unit_test.sh c99809b8e4 support http put and delete hace 7 años

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 阿里巴巴集团