From f8010943762d3c3abf7f9f9e54d05d101248dfe1 Mon Sep 17 00:00:00 2001 From: sdk-team Date: Wed, 13 Jan 2021 12:34:19 +0000 Subject: [PATCH] Add SwitchInstanceHA API. --- CHANGELOG | 4 + r-kvstore/CMakeLists.txt | 4 + .../alibabacloud/r-kvstore/R_kvstoreClient.h | 8 + .../model/ModifyInstanceSpecRequest.h | 3 + .../r-kvstore/model/SwitchInstanceHARequest.h | 81 +++++++++ .../r-kvstore/model/SwitchInstanceHAResult.h | 49 ++++++ r-kvstore/src/R-kvstoreClient.cc | 36 ++++ .../src/model/ModifyInstanceSpecRequest.cc | 11 ++ .../src/model/SwitchInstanceHARequest.cc | 161 ++++++++++++++++++ r-kvstore/src/model/SwitchInstanceHAResult.cc | 44 +++++ 10 files changed, 401 insertions(+) create mode 100644 r-kvstore/include/alibabacloud/r-kvstore/model/SwitchInstanceHARequest.h create mode 100644 r-kvstore/include/alibabacloud/r-kvstore/model/SwitchInstanceHAResult.h create mode 100644 r-kvstore/src/model/SwitchInstanceHARequest.cc create mode 100644 r-kvstore/src/model/SwitchInstanceHAResult.cc diff --git a/CHANGELOG b/CHANGELOG index 1775549ea..f1e5cb3ee 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +2021-01-13 Version: patch +- Add SwitchInstanceHA API. +- ModifyInstanceSpec add SourceBiz param. + 2021-01-13 Version: patch - Add support for IoT jobs, including job management and query APIs like CreateJob, UpdateJob, QueryJob, CancelJob, ListTask, QueryTask, QueryJobStatistics etc. diff --git a/r-kvstore/CMakeLists.txt b/r-kvstore/CMakeLists.txt index 0d6a189b1..b41e401dc 100644 --- a/r-kvstore/CMakeLists.txt +++ b/r-kvstore/CMakeLists.txt @@ -187,6 +187,8 @@ set(r-kvstore_public_header_model include/alibabacloud/r-kvstore/model/RestartInstanceResult.h include/alibabacloud/r-kvstore/model/RestoreInstanceRequest.h include/alibabacloud/r-kvstore/model/RestoreInstanceResult.h + include/alibabacloud/r-kvstore/model/SwitchInstanceHARequest.h + include/alibabacloud/r-kvstore/model/SwitchInstanceHAResult.h include/alibabacloud/r-kvstore/model/SwitchNetworkRequest.h include/alibabacloud/r-kvstore/model/SwitchNetworkResult.h include/alibabacloud/r-kvstore/model/SyncDtsStatusRequest.h @@ -366,6 +368,8 @@ set(r-kvstore_src src/model/RestartInstanceResult.cc src/model/RestoreInstanceRequest.cc src/model/RestoreInstanceResult.cc + src/model/SwitchInstanceHARequest.cc + src/model/SwitchInstanceHAResult.cc src/model/SwitchNetworkRequest.cc src/model/SwitchNetworkResult.cc src/model/SyncDtsStatusRequest.cc diff --git a/r-kvstore/include/alibabacloud/r-kvstore/R_kvstoreClient.h b/r-kvstore/include/alibabacloud/r-kvstore/R_kvstoreClient.h index de564505b..a44af74c7 100644 --- a/r-kvstore/include/alibabacloud/r-kvstore/R_kvstoreClient.h +++ b/r-kvstore/include/alibabacloud/r-kvstore/R_kvstoreClient.h @@ -188,6 +188,8 @@ #include "model/RestartInstanceResult.h" #include "model/RestoreInstanceRequest.h" #include "model/RestoreInstanceResult.h" +#include "model/SwitchInstanceHARequest.h" +#include "model/SwitchInstanceHAResult.h" #include "model/SwitchNetworkRequest.h" #include "model/SwitchNetworkResult.h" #include "model/SyncDtsStatusRequest.h" @@ -456,6 +458,9 @@ namespace AlibabaCloud typedef Outcome RestoreInstanceOutcome; typedef std::future RestoreInstanceOutcomeCallable; typedef std::function&)> RestoreInstanceAsyncHandler; + typedef Outcome SwitchInstanceHAOutcome; + typedef std::future SwitchInstanceHAOutcomeCallable; + typedef std::function&)> SwitchInstanceHAAsyncHandler; typedef Outcome SwitchNetworkOutcome; typedef std::future SwitchNetworkOutcomeCallable; typedef std::function&)> SwitchNetworkAsyncHandler; @@ -725,6 +730,9 @@ namespace AlibabaCloud RestoreInstanceOutcome restoreInstance(const Model::RestoreInstanceRequest &request)const; void restoreInstanceAsync(const Model::RestoreInstanceRequest& request, const RestoreInstanceAsyncHandler& handler, const std::shared_ptr& context = nullptr) const; RestoreInstanceOutcomeCallable restoreInstanceCallable(const Model::RestoreInstanceRequest& request) const; + SwitchInstanceHAOutcome switchInstanceHA(const Model::SwitchInstanceHARequest &request)const; + void switchInstanceHAAsync(const Model::SwitchInstanceHARequest& request, const SwitchInstanceHAAsyncHandler& handler, const std::shared_ptr& context = nullptr) const; + SwitchInstanceHAOutcomeCallable switchInstanceHACallable(const Model::SwitchInstanceHARequest& request) const; SwitchNetworkOutcome switchNetwork(const Model::SwitchNetworkRequest &request)const; void switchNetworkAsync(const Model::SwitchNetworkRequest& request, const SwitchNetworkAsyncHandler& handler, const std::shared_ptr& context = nullptr) const; SwitchNetworkOutcomeCallable switchNetworkCallable(const Model::SwitchNetworkRequest& request) const; diff --git a/r-kvstore/include/alibabacloud/r-kvstore/model/ModifyInstanceSpecRequest.h b/r-kvstore/include/alibabacloud/r-kvstore/model/ModifyInstanceSpecRequest.h index 265d00322..7003d9dde 100644 --- a/r-kvstore/include/alibabacloud/r-kvstore/model/ModifyInstanceSpecRequest.h +++ b/r-kvstore/include/alibabacloud/r-kvstore/model/ModifyInstanceSpecRequest.h @@ -49,6 +49,8 @@ namespace AlibabaCloud void setSecurityToken(const std::string& securityToken); std::string getEffectiveTime()const; void setEffectiveTime(const std::string& effectiveTime); + std::string getSourceBiz()const; + void setSourceBiz(const std::string& sourceBiz); std::string getBusinessInfo()const; void setBusinessInfo(const std::string& businessInfo); bool getAutoPay()const; @@ -78,6 +80,7 @@ namespace AlibabaCloud std::string accessKeyId_; std::string securityToken_; std::string effectiveTime_; + std::string sourceBiz_; std::string businessInfo_; bool autoPay_; std::string fromApp_; diff --git a/r-kvstore/include/alibabacloud/r-kvstore/model/SwitchInstanceHARequest.h b/r-kvstore/include/alibabacloud/r-kvstore/model/SwitchInstanceHARequest.h new file mode 100644 index 000000000..19825ddea --- /dev/null +++ b/r-kvstore/include/alibabacloud/r-kvstore/model/SwitchInstanceHARequest.h @@ -0,0 +1,81 @@ +/* + * Copyright 2009-2017 Alibaba Cloud All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ALIBABACLOUD_R_KVSTORE_MODEL_SWITCHINSTANCEHAREQUEST_H_ +#define ALIBABACLOUD_R_KVSTORE_MODEL_SWITCHINSTANCEHAREQUEST_H_ + +#include +#include +#include +#include + +namespace AlibabaCloud +{ + namespace R_kvstore + { + namespace Model + { + class ALIBABACLOUD_R_KVSTORE_EXPORT SwitchInstanceHARequest : public RpcServiceRequest + { + + public: + SwitchInstanceHARequest(); + ~SwitchInstanceHARequest(); + + long getResourceOwnerId()const; + void setResourceOwnerId(long resourceOwnerId); + std::string getAccessKeyId()const; + void setAccessKeyId(const std::string& accessKeyId); + int getSwitchMode()const; + void setSwitchMode(int switchMode); + std::string getSecurityToken()const; + void setSecurityToken(const std::string& securityToken); + std::string getNodeId()const; + void setNodeId(const std::string& nodeId); + std::string getProduct()const; + void setProduct(const std::string& product); + std::string getResourceOwnerAccount()const; + void setResourceOwnerAccount(const std::string& resourceOwnerAccount); + std::string getOwnerAccount()const; + void setOwnerAccount(const std::string& ownerAccount); + long getOwnerId()const; + void setOwnerId(long ownerId); + std::string getInstanceId()const; + void setInstanceId(const std::string& instanceId); + std::string getSwitchType()const; + void setSwitchType(const std::string& switchType); + std::string getCategory()const; + void setCategory(const std::string& category); + + private: + long resourceOwnerId_; + std::string accessKeyId_; + int switchMode_; + std::string securityToken_; + std::string nodeId_; + std::string product_; + std::string resourceOwnerAccount_; + std::string ownerAccount_; + long ownerId_; + std::string instanceId_; + std::string switchType_; + std::string category_; + + }; + } + } +} +#endif // !ALIBABACLOUD_R_KVSTORE_MODEL_SWITCHINSTANCEHAREQUEST_H_ \ No newline at end of file diff --git a/r-kvstore/include/alibabacloud/r-kvstore/model/SwitchInstanceHAResult.h b/r-kvstore/include/alibabacloud/r-kvstore/model/SwitchInstanceHAResult.h new file mode 100644 index 000000000..5bdee2035 --- /dev/null +++ b/r-kvstore/include/alibabacloud/r-kvstore/model/SwitchInstanceHAResult.h @@ -0,0 +1,49 @@ +/* + * Copyright 2009-2017 Alibaba Cloud All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ALIBABACLOUD_R_KVSTORE_MODEL_SWITCHINSTANCEHARESULT_H_ +#define ALIBABACLOUD_R_KVSTORE_MODEL_SWITCHINSTANCEHARESULT_H_ + +#include +#include +#include +#include +#include + +namespace AlibabaCloud +{ + namespace R_kvstore + { + namespace Model + { + class ALIBABACLOUD_R_KVSTORE_EXPORT SwitchInstanceHAResult : public ServiceResult + { + public: + + + SwitchInstanceHAResult(); + explicit SwitchInstanceHAResult(const std::string &payload); + ~SwitchInstanceHAResult(); + + protected: + void parse(const std::string &payload); + private: + + }; + } + } +} +#endif // !ALIBABACLOUD_R_KVSTORE_MODEL_SWITCHINSTANCEHARESULT_H_ \ No newline at end of file diff --git a/r-kvstore/src/R-kvstoreClient.cc b/r-kvstore/src/R-kvstoreClient.cc index 181e3ce0c..7b9a0110d 100644 --- a/r-kvstore/src/R-kvstoreClient.cc +++ b/r-kvstore/src/R-kvstoreClient.cc @@ -3039,6 +3039,42 @@ R_kvstoreClient::RestoreInstanceOutcomeCallable R_kvstoreClient::restoreInstance return task->get_future(); } +R_kvstoreClient::SwitchInstanceHAOutcome R_kvstoreClient::switchInstanceHA(const SwitchInstanceHARequest &request) const +{ + auto endpointOutcome = endpointProvider_->getEndpoint(); + if (!endpointOutcome.isSuccess()) + return SwitchInstanceHAOutcome(endpointOutcome.error()); + + auto outcome = makeRequest(endpointOutcome.result(), request); + + if (outcome.isSuccess()) + return SwitchInstanceHAOutcome(SwitchInstanceHAResult(outcome.result())); + else + return SwitchInstanceHAOutcome(outcome.error()); +} + +void R_kvstoreClient::switchInstanceHAAsync(const SwitchInstanceHARequest& request, const SwitchInstanceHAAsyncHandler& handler, const std::shared_ptr& context) const +{ + auto fn = [this, request, handler, context]() + { + handler(this, request, switchInstanceHA(request), context); + }; + + asyncExecute(new Runnable(fn)); +} + +R_kvstoreClient::SwitchInstanceHAOutcomeCallable R_kvstoreClient::switchInstanceHACallable(const SwitchInstanceHARequest &request) const +{ + auto task = std::make_shared>( + [this, request]() + { + return this->switchInstanceHA(request); + }); + + asyncExecute(new Runnable([task]() { (*task)(); })); + return task->get_future(); +} + R_kvstoreClient::SwitchNetworkOutcome R_kvstoreClient::switchNetwork(const SwitchNetworkRequest &request) const { auto endpointOutcome = endpointProvider_->getEndpoint(); diff --git a/r-kvstore/src/model/ModifyInstanceSpecRequest.cc b/r-kvstore/src/model/ModifyInstanceSpecRequest.cc index 558c25d12..505ed06da 100644 --- a/r-kvstore/src/model/ModifyInstanceSpecRequest.cc +++ b/r-kvstore/src/model/ModifyInstanceSpecRequest.cc @@ -104,6 +104,17 @@ void ModifyInstanceSpecRequest::setEffectiveTime(const std::string& effectiveTim setParameter("EffectiveTime", effectiveTime); } +std::string ModifyInstanceSpecRequest::getSourceBiz()const +{ + return sourceBiz_; +} + +void ModifyInstanceSpecRequest::setSourceBiz(const std::string& sourceBiz) +{ + sourceBiz_ = sourceBiz; + setParameter("SourceBiz", sourceBiz); +} + std::string ModifyInstanceSpecRequest::getBusinessInfo()const { return businessInfo_; diff --git a/r-kvstore/src/model/SwitchInstanceHARequest.cc b/r-kvstore/src/model/SwitchInstanceHARequest.cc new file mode 100644 index 000000000..df698de97 --- /dev/null +++ b/r-kvstore/src/model/SwitchInstanceHARequest.cc @@ -0,0 +1,161 @@ +/* + * Copyright 2009-2017 Alibaba Cloud All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +using AlibabaCloud::R_kvstore::Model::SwitchInstanceHARequest; + +SwitchInstanceHARequest::SwitchInstanceHARequest() : + RpcServiceRequest("r-kvstore", "2015-01-01", "SwitchInstanceHA") +{ + setMethod(HttpRequest::Method::Post); +} + +SwitchInstanceHARequest::~SwitchInstanceHARequest() +{} + +long SwitchInstanceHARequest::getResourceOwnerId()const +{ + return resourceOwnerId_; +} + +void SwitchInstanceHARequest::setResourceOwnerId(long resourceOwnerId) +{ + resourceOwnerId_ = resourceOwnerId; + setParameter("ResourceOwnerId", std::to_string(resourceOwnerId)); +} + +std::string SwitchInstanceHARequest::getAccessKeyId()const +{ + return accessKeyId_; +} + +void SwitchInstanceHARequest::setAccessKeyId(const std::string& accessKeyId) +{ + accessKeyId_ = accessKeyId; + setParameter("AccessKeyId", accessKeyId); +} + +int SwitchInstanceHARequest::getSwitchMode()const +{ + return switchMode_; +} + +void SwitchInstanceHARequest::setSwitchMode(int switchMode) +{ + switchMode_ = switchMode; + setParameter("SwitchMode", std::to_string(switchMode)); +} + +std::string SwitchInstanceHARequest::getSecurityToken()const +{ + return securityToken_; +} + +void SwitchInstanceHARequest::setSecurityToken(const std::string& securityToken) +{ + securityToken_ = securityToken; + setParameter("SecurityToken", securityToken); +} + +std::string SwitchInstanceHARequest::getNodeId()const +{ + return nodeId_; +} + +void SwitchInstanceHARequest::setNodeId(const std::string& nodeId) +{ + nodeId_ = nodeId; + setParameter("NodeId", nodeId); +} + +std::string SwitchInstanceHARequest::getProduct()const +{ + return product_; +} + +void SwitchInstanceHARequest::setProduct(const std::string& product) +{ + product_ = product; + setParameter("Product", product); +} + +std::string SwitchInstanceHARequest::getResourceOwnerAccount()const +{ + return resourceOwnerAccount_; +} + +void SwitchInstanceHARequest::setResourceOwnerAccount(const std::string& resourceOwnerAccount) +{ + resourceOwnerAccount_ = resourceOwnerAccount; + setParameter("ResourceOwnerAccount", resourceOwnerAccount); +} + +std::string SwitchInstanceHARequest::getOwnerAccount()const +{ + return ownerAccount_; +} + +void SwitchInstanceHARequest::setOwnerAccount(const std::string& ownerAccount) +{ + ownerAccount_ = ownerAccount; + setParameter("OwnerAccount", ownerAccount); +} + +long SwitchInstanceHARequest::getOwnerId()const +{ + return ownerId_; +} + +void SwitchInstanceHARequest::setOwnerId(long ownerId) +{ + ownerId_ = ownerId; + setParameter("OwnerId", std::to_string(ownerId)); +} + +std::string SwitchInstanceHARequest::getInstanceId()const +{ + return instanceId_; +} + +void SwitchInstanceHARequest::setInstanceId(const std::string& instanceId) +{ + instanceId_ = instanceId; + setParameter("InstanceId", instanceId); +} + +std::string SwitchInstanceHARequest::getSwitchType()const +{ + return switchType_; +} + +void SwitchInstanceHARequest::setSwitchType(const std::string& switchType) +{ + switchType_ = switchType; + setParameter("SwitchType", switchType); +} + +std::string SwitchInstanceHARequest::getCategory()const +{ + return category_; +} + +void SwitchInstanceHARequest::setCategory(const std::string& category) +{ + category_ = category; + setParameter("Category", category); +} + diff --git a/r-kvstore/src/model/SwitchInstanceHAResult.cc b/r-kvstore/src/model/SwitchInstanceHAResult.cc new file mode 100644 index 000000000..aec16fd57 --- /dev/null +++ b/r-kvstore/src/model/SwitchInstanceHAResult.cc @@ -0,0 +1,44 @@ +/* + * Copyright 2009-2017 Alibaba Cloud All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +using namespace AlibabaCloud::R_kvstore; +using namespace AlibabaCloud::R_kvstore::Model; + +SwitchInstanceHAResult::SwitchInstanceHAResult() : + ServiceResult() +{} + +SwitchInstanceHAResult::SwitchInstanceHAResult(const std::string &payload) : + ServiceResult() +{ + parse(payload); +} + +SwitchInstanceHAResult::~SwitchInstanceHAResult() +{} + +void SwitchInstanceHAResult::parse(const std::string &payload) +{ + Json::Reader reader; + Json::Value value; + reader.parse(payload, value); + setRequestId(value["RequestId"].asString()); + +} +