Kaynağa Gözat

Supported RequestDecision For YN.

sdk-team 4 yıl önce
ebeveyn
işleme
e2a8813a1b

+ 3 - 0
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.
 

+ 1 - 1
VERSION

@@ -1 +1 @@
-1.36.958
+1.36.959

+ 6 - 2
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}

+ 8 - 0
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<Error, Model::ExecuteRequestSGResult> ExecuteRequestSGOutcome;
 			typedef std::future<ExecuteRequestSGOutcome> ExecuteRequestSGOutcomeCallable;
 			typedef std::function<void(const SafClient*, const Model::ExecuteRequestSGRequest&, const ExecuteRequestSGOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> ExecuteRequestSGAsyncHandler;
+			typedef Outcome<Error, Model::RequestDecisionResult> RequestDecisionOutcome;
+			typedef std::future<RequestDecisionOutcome> RequestDecisionOutcomeCallable;
+			typedef std::function<void(const SafClient*, const Model::RequestDecisionRequest&, const RequestDecisionOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> RequestDecisionAsyncHandler;
 
 			SafClient(const Credentials &credentials, const ClientConfiguration &configuration);
 			SafClient(const std::shared_ptr<CredentialsProvider> &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<const AsyncCallerContext>& 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<const AsyncCallerContext>& context = nullptr) const;
+			RequestDecisionOutcomeCallable requestDecisionCallable(const Model::RequestDecisionRequest& request) const;
 	
 		private:
 			std::shared_ptr<EndpointProvider> endpointProvider_;

+ 3 - 0
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_;
 
 			};
 		}

+ 3 - 0
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_;
 
 			};
 		}

+ 51 - 0
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 <string>
+#include <vector>
+#include <alibabacloud/core/RpcServiceRequest.h>
+#include <alibabacloud/saf/SafExport.h>
+
+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_

+ 55 - 0
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 <string>
+#include <vector>
+#include <utility>
+#include <alibabacloud/core/ServiceResult.h>
+#include <alibabacloud/saf/SafExport.h>
+
+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_

+ 39 - 3
saf/src/SafClient.cc

@@ -31,21 +31,21 @@ SafClient::SafClient(const Credentials &credentials, const ClientConfiguration &
 	RpcServiceClient(SERVICE_NAME, std::make_shared<SimpleCredentialsProvider>(credentials), configuration)
 {
 	auto locationClient = std::make_shared<LocationClient>(credentials, configuration);
-	endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "saf");
+	endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "");
 }
 
 SafClient::SafClient(const std::shared_ptr<CredentialsProvider>& credentialsProvider, const ClientConfiguration & configuration) :
 	RpcServiceClient(SERVICE_NAME, credentialsProvider, configuration)
 {
 	auto locationClient = std::make_shared<LocationClient>(credentialsProvider, configuration);
-	endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "saf");
+	endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "");
 }
 
 SafClient::SafClient(const std::string & accessKeyId, const std::string & accessKeySecret, const ClientConfiguration & configuration) :
 	RpcServiceClient(SERVICE_NAME, std::make_shared<SimpleCredentialsProvider>(accessKeyId, accessKeySecret), configuration)
 {
 	auto locationClient = std::make_shared<LocationClient>(accessKeyId, accessKeySecret, configuration);
-	endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "saf");
+	endpointProvider_ = std::make_shared<EndpointProvider>(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<const AsyncCallerContext>& 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<std::packaged_task<RequestDecisionOutcome()>>(
+			[this, request]()
+			{
+			return this->requestDecision(request);
+			});
+
+	asyncExecute(new Runnable([task]() { (*task)(); }));
+	return task->get_future();
+}
+

+ 4 - 4
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["HttpStatusCode"].isNull())
+		httpStatusCode_ = value["HttpStatusCode"].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["Success"].isNull())
+		success_ = value["Success"].asString() == "true";
 
 }
 

+ 11 - 0
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);
+}
+

+ 11 - 0
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);
+}
+

+ 51 - 0
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 <alibabacloud/saf/model/RequestDecisionRequest.h>
+
+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);
+}
+

+ 65 - 0
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 <alibabacloud/saf/model/RequestDecisionResult.h>
+#include <json/json.h>
+
+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_;
+}
+