From 97918475fbb4b791d8580c94696796aaecea9956 Mon Sep 17 00:00:00 2001 From: sdk-team Date: Wed, 1 Jul 2020 15:12:17 +0800 Subject: [PATCH] Support Saf For ExecuteExtendService. --- CHANGELOG | 3 + VERSION | 2 +- saf/CMakeLists.txt | 4 + saf/include/alibabacloud/saf/SafClient.h | 8 ++ .../saf/model/ExecuteExtendServiceRequest.h | 54 +++++++++++++ .../saf/model/ExecuteExtendServiceResult.h | 63 +++++++++++++++ saf/src/SafClient.cc | 42 +++++++++- saf/src/model/ExecuteExtendServiceRequest.cc | 62 ++++++++++++++ saf/src/model/ExecuteExtendServiceResult.cc | 80 +++++++++++++++++++ 9 files changed, 314 insertions(+), 4 deletions(-) create mode 100644 saf/include/alibabacloud/saf/model/ExecuteExtendServiceRequest.h create mode 100644 saf/include/alibabacloud/saf/model/ExecuteExtendServiceResult.h create mode 100644 saf/src/model/ExecuteExtendServiceRequest.cc create mode 100644 saf/src/model/ExecuteExtendServiceResult.cc diff --git a/CHANGELOG b/CHANGELOG index 0a35122a8..59c22075b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +2020-07-01 Version: 1.36.488 +- Support Saf For ExecuteExtendService. + 2020-06-30 Version: 1.36.487 - Add ListMetrics API. diff --git a/VERSION b/VERSION index a06b817f7..066181532 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.36.487 \ No newline at end of file +1.36.488 \ No newline at end of file diff --git a/saf/CMakeLists.txt b/saf/CMakeLists.txt index bcfedfe13..3952fff52 100755 --- a/saf/CMakeLists.txt +++ b/saf/CMakeLists.txt @@ -21,6 +21,8 @@ set(saf_public_header include/alibabacloud/saf/SafExport.h ) set(saf_public_header_model + include/alibabacloud/saf/model/ExecuteExtendServiceRequest.h + include/alibabacloud/saf/model/ExecuteExtendServiceResult.h include/alibabacloud/saf/model/ExecuteRequestRequest.h include/alibabacloud/saf/model/ExecuteRequestResult.h include/alibabacloud/saf/model/ExecuteRequestSGRequest.h @@ -28,6 +30,8 @@ set(saf_public_header_model set(saf_src src/SafClient.cc + src/model/ExecuteExtendServiceRequest.cc + src/model/ExecuteExtendServiceResult.cc src/model/ExecuteRequestRequest.cc src/model/ExecuteRequestResult.cc src/model/ExecuteRequestSGRequest.cc diff --git a/saf/include/alibabacloud/saf/SafClient.h b/saf/include/alibabacloud/saf/SafClient.h index 1bee15f4c..657c6fe3f 100755 --- a/saf/include/alibabacloud/saf/SafClient.h +++ b/saf/include/alibabacloud/saf/SafClient.h @@ -22,6 +22,8 @@ #include #include #include "SafExport.h" +#include "model/ExecuteExtendServiceRequest.h" +#include "model/ExecuteExtendServiceResult.h" #include "model/ExecuteRequestRequest.h" #include "model/ExecuteRequestResult.h" #include "model/ExecuteRequestSGRequest.h" @@ -35,6 +37,9 @@ namespace AlibabaCloud class ALIBABACLOUD_SAF_EXPORT SafClient : public RpcServiceClient { public: + typedef Outcome ExecuteExtendServiceOutcome; + typedef std::future ExecuteExtendServiceOutcomeCallable; + typedef std::function&)> ExecuteExtendServiceAsyncHandler; typedef Outcome ExecuteRequestOutcome; typedef std::future ExecuteRequestOutcomeCallable; typedef std::function&)> ExecuteRequestAsyncHandler; @@ -46,6 +51,9 @@ namespace AlibabaCloud SafClient(const std::shared_ptr &credentialsProvider, const ClientConfiguration &configuration); SafClient(const std::string &accessKeyId, const std::string &accessKeySecret, const ClientConfiguration &configuration); ~SafClient(); + ExecuteExtendServiceOutcome executeExtendService(const Model::ExecuteExtendServiceRequest &request)const; + void executeExtendServiceAsync(const Model::ExecuteExtendServiceRequest& request, const ExecuteExtendServiceAsyncHandler& handler, const std::shared_ptr& context = nullptr) const; + ExecuteExtendServiceOutcomeCallable executeExtendServiceCallable(const Model::ExecuteExtendServiceRequest& request) const; ExecuteRequestOutcome executeRequest(const Model::ExecuteRequestRequest &request)const; void executeRequestAsync(const Model::ExecuteRequestRequest& request, const ExecuteRequestAsyncHandler& handler, const std::shared_ptr& context = nullptr) const; ExecuteRequestOutcomeCallable executeRequestCallable(const Model::ExecuteRequestRequest& request) const; diff --git a/saf/include/alibabacloud/saf/model/ExecuteExtendServiceRequest.h b/saf/include/alibabacloud/saf/model/ExecuteExtendServiceRequest.h new file mode 100644 index 000000000..eb286e5f0 --- /dev/null +++ b/saf/include/alibabacloud/saf/model/ExecuteExtendServiceRequest.h @@ -0,0 +1,54 @@ +/* + * 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_SAF_MODEL_EXECUTEEXTENDSERVICEREQUEST_H_ +#define ALIBABACLOUD_SAF_MODEL_EXECUTEEXTENDSERVICEREQUEST_H_ + +#include +#include +#include +#include + +namespace AlibabaCloud +{ + namespace Saf + { + namespace Model + { + class ALIBABACLOUD_SAF_EXPORT ExecuteExtendServiceRequest : public RpcServiceRequest + { + + public: + ExecuteExtendServiceRequest(); + ~ExecuteExtendServiceRequest(); + + std::string getServiceParameters()const; + void setServiceParameters(const std::string& serviceParameters); + std::string getService()const; + void setService(const std::string& service); + std::string getRegion()const; + void setRegion(const std::string& region); + + private: + std::string serviceParameters_; + std::string service_; + std::string region_; + + }; + } + } +} +#endif // !ALIBABACLOUD_SAF_MODEL_EXECUTEEXTENDSERVICEREQUEST_H_ \ No newline at end of file diff --git a/saf/include/alibabacloud/saf/model/ExecuteExtendServiceResult.h b/saf/include/alibabacloud/saf/model/ExecuteExtendServiceResult.h new file mode 100644 index 000000000..b0ed6d487 --- /dev/null +++ b/saf/include/alibabacloud/saf/model/ExecuteExtendServiceResult.h @@ -0,0 +1,63 @@ +/* + * 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_SAF_MODEL_EXECUTEEXTENDSERVICERESULT_H_ +#define ALIBABACLOUD_SAF_MODEL_EXECUTEEXTENDSERVICERESULT_H_ + +#include +#include +#include +#include +#include + +namespace AlibabaCloud +{ + namespace Saf + { + namespace Model + { + class ALIBABACLOUD_SAF_EXPORT ExecuteExtendServiceResult : public ServiceResult + { + public: + struct Data + { + std::string invokeResult; + }; + + + ExecuteExtendServiceResult(); + explicit ExecuteExtendServiceResult(const std::string &payload); + ~ExecuteExtendServiceResult(); + std::string getMessage()const; + std::string getHttpStatusCode()const; + Data getData()const; + std::string getCode()const; + bool getSuccess()const; + + protected: + void parse(const std::string &payload); + private: + std::string message_; + std::string httpStatusCode_; + Data data_; + std::string code_; + bool success_; + + }; + } + } +} +#endif // !ALIBABACLOUD_SAF_MODEL_EXECUTEEXTENDSERVICERESULT_H_ \ No newline at end of file diff --git a/saf/src/SafClient.cc b/saf/src/SafClient.cc index 6fbc3e560..8a55002ee 100755 --- a/saf/src/SafClient.cc +++ b/saf/src/SafClient.cc @@ -31,26 +31,62 @@ SafClient::SafClient(const Credentials &credentials, const ClientConfiguration & RpcServiceClient(SERVICE_NAME, std::make_shared(credentials), configuration) { auto locationClient = std::make_shared(credentials, configuration); - endpointProvider_ = std::make_shared(locationClient, configuration.regionId(), SERVICE_NAME, "saf"); + endpointProvider_ = std::make_shared(locationClient, configuration.regionId(), SERVICE_NAME, "SAF"); } SafClient::SafClient(const std::shared_ptr& credentialsProvider, const ClientConfiguration & configuration) : RpcServiceClient(SERVICE_NAME, credentialsProvider, configuration) { auto locationClient = std::make_shared(credentialsProvider, configuration); - endpointProvider_ = std::make_shared(locationClient, configuration.regionId(), SERVICE_NAME, "saf"); + endpointProvider_ = std::make_shared(locationClient, configuration.regionId(), SERVICE_NAME, "SAF"); } SafClient::SafClient(const std::string & accessKeyId, const std::string & accessKeySecret, const ClientConfiguration & configuration) : RpcServiceClient(SERVICE_NAME, std::make_shared(accessKeyId, accessKeySecret), configuration) { auto locationClient = std::make_shared(accessKeyId, accessKeySecret, configuration); - endpointProvider_ = std::make_shared(locationClient, configuration.regionId(), SERVICE_NAME, "saf"); + endpointProvider_ = std::make_shared(locationClient, configuration.regionId(), SERVICE_NAME, "SAF"); } SafClient::~SafClient() {} +SafClient::ExecuteExtendServiceOutcome SafClient::executeExtendService(const ExecuteExtendServiceRequest &request) const +{ + auto endpointOutcome = endpointProvider_->getEndpoint(); + if (!endpointOutcome.isSuccess()) + return ExecuteExtendServiceOutcome(endpointOutcome.error()); + + auto outcome = makeRequest(endpointOutcome.result(), request); + + if (outcome.isSuccess()) + return ExecuteExtendServiceOutcome(ExecuteExtendServiceResult(outcome.result())); + else + return ExecuteExtendServiceOutcome(outcome.error()); +} + +void SafClient::executeExtendServiceAsync(const ExecuteExtendServiceRequest& request, const ExecuteExtendServiceAsyncHandler& handler, const std::shared_ptr& context) const +{ + auto fn = [this, request, handler, context]() + { + handler(this, request, executeExtendService(request), context); + }; + + asyncExecute(new Runnable(fn)); +} + +SafClient::ExecuteExtendServiceOutcomeCallable SafClient::executeExtendServiceCallable(const ExecuteExtendServiceRequest &request) const +{ + auto task = std::make_shared>( + [this, request]() + { + return this->executeExtendService(request); + }); + + asyncExecute(new Runnable([task]() { (*task)(); })); + return task->get_future(); +} + SafClient::ExecuteRequestOutcome SafClient::executeRequest(const ExecuteRequestRequest &request) const { auto endpointOutcome = endpointProvider_->getEndpoint(); diff --git a/saf/src/model/ExecuteExtendServiceRequest.cc b/saf/src/model/ExecuteExtendServiceRequest.cc new file mode 100644 index 000000000..fd918d34e --- /dev/null +++ b/saf/src/model/ExecuteExtendServiceRequest.cc @@ -0,0 +1,62 @@ +/* + * 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::Saf::Model::ExecuteExtendServiceRequest; + +ExecuteExtendServiceRequest::ExecuteExtendServiceRequest() : + RpcServiceRequest("saf", "2019-05-21", "ExecuteExtendService") +{ + setMethod(HttpRequest::Method::Post); +} + +ExecuteExtendServiceRequest::~ExecuteExtendServiceRequest() +{} + +std::string ExecuteExtendServiceRequest::getServiceParameters()const +{ + return serviceParameters_; +} + +void ExecuteExtendServiceRequest::setServiceParameters(const std::string& serviceParameters) +{ + serviceParameters_ = serviceParameters; + setParameter("ServiceParameters", serviceParameters); +} + +std::string ExecuteExtendServiceRequest::getService()const +{ + return service_; +} + +void ExecuteExtendServiceRequest::setService(const std::string& service) +{ + service_ = service; + setParameter("Service", service); +} + +std::string ExecuteExtendServiceRequest::getRegion()const +{ + return region_; +} + +void ExecuteExtendServiceRequest::setRegion(const std::string& region) +{ + region_ = region; + setParameter("Region", region); +} + diff --git a/saf/src/model/ExecuteExtendServiceResult.cc b/saf/src/model/ExecuteExtendServiceResult.cc new file mode 100644 index 000000000..94c46b4c9 --- /dev/null +++ b/saf/src/model/ExecuteExtendServiceResult.cc @@ -0,0 +1,80 @@ +/* + * 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::Saf; +using namespace AlibabaCloud::Saf::Model; + +ExecuteExtendServiceResult::ExecuteExtendServiceResult() : + ServiceResult() +{} + +ExecuteExtendServiceResult::ExecuteExtendServiceResult(const std::string &payload) : + ServiceResult() +{ + parse(payload); +} + +ExecuteExtendServiceResult::~ExecuteExtendServiceResult() +{} + +void ExecuteExtendServiceResult::parse(const std::string &payload) +{ + Json::Reader reader; + Json::Value value; + reader.parse(payload, value); + setRequestId(value["RequestId"].asString()); + auto dataNode = value["Data"]; + if(!dataNode["InvokeResult"].isNull()) + data_.invokeResult = dataNode["InvokeResult"].asString(); + if(!value["Code"].isNull()) + code_ = value["Code"].asString(); + if(!value["Success"].isNull()) + success_ = value["Success"].asString() == "true"; + if(!value["Message"].isNull()) + message_ = value["Message"].asString(); + if(!value["HttpStatusCode"].isNull()) + httpStatusCode_ = value["HttpStatusCode"].asString(); + +} + +std::string ExecuteExtendServiceResult::getMessage()const +{ + return message_; +} + +std::string ExecuteExtendServiceResult::getHttpStatusCode()const +{ + return httpStatusCode_; +} + +ExecuteExtendServiceResult::Data ExecuteExtendServiceResult::getData()const +{ + return data_; +} + +std::string ExecuteExtendServiceResult::getCode()const +{ + return code_; +} + +bool ExecuteExtendServiceResult::getSuccess()const +{ + return success_; +} +