diff --git a/CHANGELOG b/CHANGELOG index 1156de849..e625200ec 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +2021-12-01 Version: 1.36.959 +- Supported RequestDecision For YN. + 2021-11-30 Version: 1.36.958 - Support health check paging. diff --git a/VERSION b/VERSION index 59ade0134..bbd7aa6c2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.36.958 \ No newline at end of file +1.36.959 \ No newline at end of file diff --git a/saf/CMakeLists.txt b/saf/CMakeLists.txt index e2d3a06cb..ae615a442 100755 --- a/saf/CMakeLists.txt +++ b/saf/CMakeLists.txt @@ -28,7 +28,9 @@ set(saf_public_header_model include/alibabacloud/saf/model/ExecuteRequestMLRequest.h include/alibabacloud/saf/model/ExecuteRequestMLResult.h include/alibabacloud/saf/model/ExecuteRequestSGRequest.h - include/alibabacloud/saf/model/ExecuteRequestSGResult.h ) + include/alibabacloud/saf/model/ExecuteRequestSGResult.h + include/alibabacloud/saf/model/RequestDecisionRequest.h + include/alibabacloud/saf/model/RequestDecisionResult.h ) set(saf_src src/SafClient.cc @@ -39,7 +41,9 @@ set(saf_src src/model/ExecuteRequestMLRequest.cc src/model/ExecuteRequestMLResult.cc src/model/ExecuteRequestSGRequest.cc - src/model/ExecuteRequestSGResult.cc ) + src/model/ExecuteRequestSGResult.cc + src/model/RequestDecisionRequest.cc + src/model/RequestDecisionResult.cc ) add_library(saf ${LIB_TYPE} ${saf_public_header} diff --git a/saf/include/alibabacloud/saf/SafClient.h b/saf/include/alibabacloud/saf/SafClient.h index 552c9cc27..de208c07c 100755 --- a/saf/include/alibabacloud/saf/SafClient.h +++ b/saf/include/alibabacloud/saf/SafClient.h @@ -30,6 +30,8 @@ #include "model/ExecuteRequestMLResult.h" #include "model/ExecuteRequestSGRequest.h" #include "model/ExecuteRequestSGResult.h" +#include "model/RequestDecisionRequest.h" +#include "model/RequestDecisionResult.h" namespace AlibabaCloud @@ -51,6 +53,9 @@ namespace AlibabaCloud typedef Outcome ExecuteRequestSGOutcome; typedef std::future ExecuteRequestSGOutcomeCallable; typedef std::function&)> ExecuteRequestSGAsyncHandler; + typedef Outcome RequestDecisionOutcome; + typedef std::future RequestDecisionOutcomeCallable; + typedef std::function&)> RequestDecisionAsyncHandler; SafClient(const Credentials &credentials, const ClientConfiguration &configuration); SafClient(const std::shared_ptr &credentialsProvider, const ClientConfiguration &configuration); @@ -68,6 +73,9 @@ namespace AlibabaCloud ExecuteRequestSGOutcome executeRequestSG(const Model::ExecuteRequestSGRequest &request)const; void executeRequestSGAsync(const Model::ExecuteRequestSGRequest& request, const ExecuteRequestSGAsyncHandler& handler, const std::shared_ptr& context = nullptr) const; ExecuteRequestSGOutcomeCallable executeRequestSGCallable(const Model::ExecuteRequestSGRequest& request) const; + RequestDecisionOutcome requestDecision(const Model::RequestDecisionRequest &request)const; + void requestDecisionAsync(const Model::RequestDecisionRequest& request, const RequestDecisionAsyncHandler& handler, const std::shared_ptr& context = nullptr) const; + RequestDecisionOutcomeCallable requestDecisionCallable(const Model::RequestDecisionRequest& request) const; private: std::shared_ptr endpointProvider_; diff --git a/saf/include/alibabacloud/saf/model/ExecuteRequestMLRequest.h b/saf/include/alibabacloud/saf/model/ExecuteRequestMLRequest.h index da4e061c4..0e5b1af8d 100644 --- a/saf/include/alibabacloud/saf/model/ExecuteRequestMLRequest.h +++ b/saf/include/alibabacloud/saf/model/ExecuteRequestMLRequest.h @@ -39,10 +39,13 @@ namespace AlibabaCloud void setServiceParameters(const std::string& serviceParameters); std::string getService()const; void setService(const std::string& service); + std::string getLang()const; + void setLang(const std::string& lang); private: std::string serviceParameters_; std::string service_; + std::string lang_; }; } diff --git a/saf/include/alibabacloud/saf/model/ExecuteRequestSGRequest.h b/saf/include/alibabacloud/saf/model/ExecuteRequestSGRequest.h index 38dfcfb49..dc41a39e2 100644 --- a/saf/include/alibabacloud/saf/model/ExecuteRequestSGRequest.h +++ b/saf/include/alibabacloud/saf/model/ExecuteRequestSGRequest.h @@ -39,10 +39,13 @@ namespace AlibabaCloud void setServiceParameters(const std::string& serviceParameters); std::string getService()const; void setService(const std::string& service); + std::string getLang()const; + void setLang(const std::string& lang); private: std::string serviceParameters_; std::string service_; + std::string lang_; }; } diff --git a/saf/include/alibabacloud/saf/model/RequestDecisionRequest.h b/saf/include/alibabacloud/saf/model/RequestDecisionRequest.h new file mode 100644 index 000000000..6c1f51afd --- /dev/null +++ b/saf/include/alibabacloud/saf/model/RequestDecisionRequest.h @@ -0,0 +1,51 @@ +/* + * 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_REQUESTDECISIONREQUEST_H_ +#define ALIBABACLOUD_SAF_MODEL_REQUESTDECISIONREQUEST_H_ + +#include +#include +#include +#include + +namespace AlibabaCloud +{ + namespace Saf + { + namespace Model + { + class ALIBABACLOUD_SAF_EXPORT RequestDecisionRequest : public RpcServiceRequest + { + + public: + RequestDecisionRequest(); + ~RequestDecisionRequest(); + + std::string getServiceParameters()const; + void setServiceParameters(const std::string& serviceParameters); + std::string getEventCode()const; + void setEventCode(const std::string& eventCode); + + private: + std::string serviceParameters_; + std::string eventCode_; + + }; + } + } +} +#endif // !ALIBABACLOUD_SAF_MODEL_REQUESTDECISIONREQUEST_H_ \ No newline at end of file diff --git a/saf/include/alibabacloud/saf/model/RequestDecisionResult.h b/saf/include/alibabacloud/saf/model/RequestDecisionResult.h new file mode 100644 index 000000000..d4d4f0bc5 --- /dev/null +++ b/saf/include/alibabacloud/saf/model/RequestDecisionResult.h @@ -0,0 +1,55 @@ +/* + * 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_REQUESTDECISIONRESULT_H_ +#define ALIBABACLOUD_SAF_MODEL_REQUESTDECISIONRESULT_H_ + +#include +#include +#include +#include +#include + +namespace AlibabaCloud +{ + namespace Saf + { + namespace Model + { + class ALIBABACLOUD_SAF_EXPORT RequestDecisionResult : public ServiceResult + { + public: + + + RequestDecisionResult(); + explicit RequestDecisionResult(const std::string &payload); + ~RequestDecisionResult(); + std::string getMessage()const; + std::string getData()const; + long getCode()const; + + protected: + void parse(const std::string &payload); + private: + std::string message_; + std::string data_; + long code_; + + }; + } + } +} +#endif // !ALIBABACLOUD_SAF_MODEL_REQUESTDECISIONRESULT_H_ \ No newline at end of file diff --git a/saf/src/SafClient.cc b/saf/src/SafClient.cc index d089d8093..6309149fb 100755 --- a/saf/src/SafClient.cc +++ b/saf/src/SafClient.cc @@ -31,21 +31,21 @@ 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, ""); } 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, ""); } 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, ""); } SafClient::~SafClient() @@ -195,3 +195,39 @@ SafClient::ExecuteRequestSGOutcomeCallable SafClient::executeRequestSGCallable(c return task->get_future(); } +SafClient::RequestDecisionOutcome SafClient::requestDecision(const RequestDecisionRequest &request) const +{ + auto endpointOutcome = endpointProvider_->getEndpoint(); + if (!endpointOutcome.isSuccess()) + return RequestDecisionOutcome(endpointOutcome.error()); + + auto outcome = makeRequest(endpointOutcome.result(), request); + + if (outcome.isSuccess()) + return RequestDecisionOutcome(RequestDecisionResult(outcome.result())); + else + return RequestDecisionOutcome(outcome.error()); +} + +void SafClient::requestDecisionAsync(const RequestDecisionRequest& request, const RequestDecisionAsyncHandler& handler, const std::shared_ptr& context) const +{ + auto fn = [this, request, handler, context]() + { + handler(this, request, requestDecision(request), context); + }; + + asyncExecute(new Runnable(fn)); +} + +SafClient::RequestDecisionOutcomeCallable SafClient::requestDecisionCallable(const RequestDecisionRequest &request) const +{ + auto task = std::make_shared>( + [this, request]() + { + return this->requestDecision(request); + }); + + asyncExecute(new Runnable([task]() { (*task)(); })); + return task->get_future(); +} + diff --git a/saf/src/model/ExecuteExtendServiceResult.cc b/saf/src/model/ExecuteExtendServiceResult.cc index 94c46b4c9..f62905406 100644 --- a/saf/src/model/ExecuteExtendServiceResult.cc +++ b/saf/src/model/ExecuteExtendServiceResult.cc @@ -42,14 +42,14 @@ void ExecuteExtendServiceResult::parse(const std::string &payload) 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(); + if(!value["Code"].isNull()) + code_ = value["Code"].asString(); + if(!value["Message"].isNull()) + message_ = value["Message"].asString(); + if(!value["Success"].isNull()) + success_ = value["Success"].asString() == "true"; } diff --git a/saf/src/model/ExecuteRequestMLRequest.cc b/saf/src/model/ExecuteRequestMLRequest.cc index b97f11ace..f17206d12 100644 --- a/saf/src/model/ExecuteRequestMLRequest.cc +++ b/saf/src/model/ExecuteRequestMLRequest.cc @@ -49,3 +49,14 @@ void ExecuteRequestMLRequest::setService(const std::string& service) setParameter("Service", service); } +std::string ExecuteRequestMLRequest::getLang()const +{ + return lang_; +} + +void ExecuteRequestMLRequest::setLang(const std::string& lang) +{ + lang_ = lang; + setParameter("Lang", lang); +} + diff --git a/saf/src/model/ExecuteRequestSGRequest.cc b/saf/src/model/ExecuteRequestSGRequest.cc index 60e5c06cd..a4d2363fa 100644 --- a/saf/src/model/ExecuteRequestSGRequest.cc +++ b/saf/src/model/ExecuteRequestSGRequest.cc @@ -49,3 +49,14 @@ void ExecuteRequestSGRequest::setService(const std::string& service) setParameter("Service", service); } +std::string ExecuteRequestSGRequest::getLang()const +{ + return lang_; +} + +void ExecuteRequestSGRequest::setLang(const std::string& lang) +{ + lang_ = lang; + setParameter("Lang", lang); +} + diff --git a/saf/src/model/RequestDecisionRequest.cc b/saf/src/model/RequestDecisionRequest.cc new file mode 100644 index 000000000..4b79d69bc --- /dev/null +++ b/saf/src/model/RequestDecisionRequest.cc @@ -0,0 +1,51 @@ +/* + * 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::RequestDecisionRequest; + +RequestDecisionRequest::RequestDecisionRequest() : + RpcServiceRequest("saf", "2019-05-21", "RequestDecision") +{ + setMethod(HttpRequest::Method::Post); +} + +RequestDecisionRequest::~RequestDecisionRequest() +{} + +std::string RequestDecisionRequest::getServiceParameters()const +{ + return serviceParameters_; +} + +void RequestDecisionRequest::setServiceParameters(const std::string& serviceParameters) +{ + serviceParameters_ = serviceParameters; + setParameter("ServiceParameters", serviceParameters); +} + +std::string RequestDecisionRequest::getEventCode()const +{ + return eventCode_; +} + +void RequestDecisionRequest::setEventCode(const std::string& eventCode) +{ + eventCode_ = eventCode; + setParameter("EventCode", eventCode); +} + diff --git a/saf/src/model/RequestDecisionResult.cc b/saf/src/model/RequestDecisionResult.cc new file mode 100644 index 000000000..165e6e415 --- /dev/null +++ b/saf/src/model/RequestDecisionResult.cc @@ -0,0 +1,65 @@ +/* + * 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; + +RequestDecisionResult::RequestDecisionResult() : + ServiceResult() +{} + +RequestDecisionResult::RequestDecisionResult(const std::string &payload) : + ServiceResult() +{ + parse(payload); +} + +RequestDecisionResult::~RequestDecisionResult() +{} + +void RequestDecisionResult::parse(const std::string &payload) +{ + Json::Reader reader; + Json::Value value; + reader.parse(payload, value); + setRequestId(value["RequestId"].asString()); + if(!value["Code"].isNull()) + code_ = std::stol(value["Code"].asString()); + if(!value["Message"].isNull()) + message_ = value["Message"].asString(); + if(!value["Data"].isNull()) + data_ = value["Data"].asString(); + +} + +std::string RequestDecisionResult::getMessage()const +{ + return message_; +} + +std::string RequestDecisionResult::getData()const +{ + return data_; +} + +long RequestDecisionResult::getCode()const +{ + return code_; +} +