Просмотр исходного кода

SAF SDK Auto Released By xinfa.duanxf,Version:1.27.6

Signed-off-by: yixiong.jxy <yixiong.jxy@alibaba-inc.com>
yixiong.jxy 8 лет назад
Родитель
Сommit
6182017316

+ 5 - 0
CHANGELOG

@@ -1,3 +1,8 @@
+2018-10-09 Version: 1.27.6
+1, v1.0.0-->v1.0.1
+2, provider new region:beijing/shenzhen/zhangjiakou
+3, provider service for VPC user;
+
 2018-09-30 Version: 1.27.5
 1, This is an example of release-log.
 2, Please strictly follow this format to edit in English.

+ 2 - 1
CMakeLists.txt

@@ -88,4 +88,5 @@ add_subdirectory(linkface)
 add_subdirectory(ots)
 add_subdirectory(smartag)
 add_subdirectory(vod)
-add_subdirectory(ccs)
+add_subdirectory(ccs)
+add_subdirectory(saf)

+ 1 - 1
VERSION

@@ -1 +1 @@
-1.27.5
+1.27.6

+ 86 - 0
saf/CMakeLists.txt

@@ -0,0 +1,86 @@
+#
+# 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.
+#
+
+set(public_header_dir ${CMAKE_CURRENT_SOURCE_DIR}/../include)
+
+set(saf_public_header 
+	include/alibabacloud/saf/SafClient.h
+	include/alibabacloud/saf/SafExport.h )
+
+set(saf_public_header_model 
+	include/alibabacloud/saf/model/ExecuteRequestRequest.h
+	include/alibabacloud/saf/model/ExecuteRequestResult.h )
+
+set(saf_src 
+	src/SafClient.cc
+	src/model/ExecuteRequestRequest.cc
+	src/model/ExecuteRequestResult.cc )
+
+add_library(saf ${LIB_TYPE}
+	${saf_public_header}
+	${saf_public_header_model}
+	${saf_src})
+
+set_target_properties(saf
+	PROPERTIES
+	LINKER_LANGUAGE CXX
+	ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
+	LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
+	RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
+	OUTPUT_NAME ${TARGET_OUTPUT_NAME_PREFIX}saf
+	)
+
+if(${LIB_TYPE} STREQUAL "SHARED")
+	set_target_properties(saf
+		PROPERTIES
+		DEFINE_SYMBOL ALIBABACLOUD_SAF_LIBRARY)
+endif()
+
+target_include_directories(saf
+	PRIVATE include
+		${CMAKE_SOURCE_DIR}/core/include
+	)
+target_link_libraries(saf
+	core)
+
+if(CMAKE_HOST_WIN32)
+	ExternalProject_Get_Property(jsoncpp INSTALL_DIR)
+	set(jsoncpp_install_dir ${INSTALL_DIR})
+	add_dependencies(saf
+		jsoncpp)
+	target_include_directories(saf
+		PRIVATE	${jsoncpp_install_dir}/include)
+	target_link_libraries(saf
+		${jsoncpp_install_dir}/lib/jsoncpp.lib)
+	set_target_properties(saf
+    	PROPERTIES
+    		COMPILE_OPTIONS "/bigobj")
+else()
+	target_include_directories(saf
+		PRIVATE /usr/include/jsoncpp)
+	target_link_libraries(saf
+		jsoncpp)
+endif()
+
+install(FILES ${saf_public_header}
+	DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/alibabacloud/saf)
+install(FILES ${saf_public_header_model}
+	DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/alibabacloud/saf/model)
+install(TARGETS saf
+	ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+	LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+	RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+	)

+ 54 - 0
saf/include/alibabacloud/saf/SafClient.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_SAFCLIENT_H_
+#define ALIBABACLOUD_SAF_SAFCLIENT_H_
+
+#include <future>
+#include <alibabacloud/core/AsyncCallerContext.h>
+#include <alibabacloud/core/EndpointProvider.h>
+#include <alibabacloud/core/RpcServiceClient.h>
+#include "SafExport.h"
+#include "model/ExecuteRequestRequest.h"
+#include "model/ExecuteRequestResult.h"
+
+
+namespace AlibabaCloud
+{
+	namespace Saf
+	{
+		class ALIBABACLOUD_SAF_EXPORT SafClient : public RpcServiceClient
+		{
+		public:
+			typedef Outcome<Error, Model::ExecuteRequestResult> ExecuteRequestOutcome;
+			typedef std::future<ExecuteRequestOutcome> ExecuteRequestOutcomeCallable;
+			typedef std::function<void(const SafClient*, const Model::ExecuteRequestRequest&, const ExecuteRequestOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> ExecuteRequestAsyncHandler;
+
+			SafClient(const Credentials &credentials, const ClientConfiguration &configuration);
+			SafClient(const std::shared_ptr<CredentialsProvider> &credentialsProvider, const ClientConfiguration &configuration);
+			SafClient(const std::string &accessKeyId, const std::string &accessKeySecret, const ClientConfiguration &configuration);
+			~SafClient();
+			ExecuteRequestOutcome executeRequest(const Model::ExecuteRequestRequest &request)const;
+			void executeRequestAsync(const Model::ExecuteRequestRequest& request, const ExecuteRequestAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
+			ExecuteRequestOutcomeCallable executeRequestCallable(const Model::ExecuteRequestRequest& request) const;
+	
+		private:
+			std::shared_ptr<EndpointProvider> endpointProvider_;
+		};
+	}
+}
+
+#endif // !ALIBABACLOUD_SAF_SAFCLIENT_H_

+ 32 - 0
saf/include/alibabacloud/saf/SafExport.h

@@ -0,0 +1,32 @@
+/*
+ * 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_SAFEXPORT_H_
+#define ALIBABACLOUD_SAF_SAFEXPORT_H_
+
+#include <alibabacloud/core/Global.h>
+
+#if defined(ALIBABACLOUD_SHARED)
+#	if defined(ALIBABACLOUD_SAF_LIBRARY)
+#		define ALIBABACLOUD_SAF_EXPORT ALIBABACLOUD_DECL_EXPORT
+#	else
+#		define ALIBABACLOUD_SAF_EXPORT ALIBABACLOUD_DECL_IMPORT
+#	endif
+#else
+#	define ALIBABACLOUD_SAF_EXPORT
+#endif
+
+#endif // !ALIBABACLOUD_SAF_SAFEXPORT_H_

+ 51 - 0
saf/include/alibabacloud/saf/model/ExecuteRequestRequest.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_EXECUTEREQUESTREQUEST_H_
+#define ALIBABACLOUD_SAF_MODEL_EXECUTEREQUESTREQUEST_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 ExecuteRequestRequest : public RpcServiceRequest
+			{
+
+			public:
+				ExecuteRequestRequest();
+				~ExecuteRequestRequest();
+
+				std::string getServiceParameters()const;
+				void setServiceParameters(const std::string& serviceParameters);
+				std::string getService()const;
+				void setService(const std::string& service);
+
+            private:
+				std::string serviceParameters_;
+				std::string service_;
+
+			};
+		}
+	}
+}
+#endif // !ALIBABACLOUD_SAF_MODEL_EXECUTEREQUESTREQUEST_H_

+ 61 - 0
saf/include/alibabacloud/saf/model/ExecuteRequestResult.h

@@ -0,0 +1,61 @@
+/*
+ * 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_EXECUTEREQUESTRESULT_H_
+#define ALIBABACLOUD_SAF_MODEL_EXECUTEREQUESTRESULT_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 ExecuteRequestResult : public ServiceResult
+			{
+			public:
+				struct Data
+				{
+					std::string score;
+					std::string extend;
+					std::string tags;
+				};
+
+
+				ExecuteRequestResult();
+				explicit ExecuteRequestResult(const std::string &payload);
+				~ExecuteRequestResult();
+				std::string getMessage()const;
+				Data getData()const;
+				int getCode()const;
+
+			protected:
+				void parse(const std::string &payload);
+			private:
+				std::string message_;
+				Data data_;
+				int code_;
+
+			};
+		}
+	}
+}
+#endif // !ALIBABACLOUD_SAF_MODEL_EXECUTEREQUESTRESULT_H_

+ 89 - 0
saf/src/SafClient.cc

@@ -0,0 +1,89 @@
+/*
+ * 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/SafClient.h>
+#include <alibabacloud/core/SimpleCredentialsProvider.h>
+
+using namespace AlibabaCloud;
+using namespace AlibabaCloud::Location;
+using namespace AlibabaCloud::Saf;
+using namespace AlibabaCloud::Saf::Model;
+
+namespace
+{
+	const std::string SERVICE_NAME = "saf";
+}
+
+SafClient::SafClient(const Credentials &credentials, const ClientConfiguration &configuration) :
+	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");
+}
+
+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");
+}
+
+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");
+}
+
+SafClient::~SafClient()
+{}
+
+SafClient::ExecuteRequestOutcome SafClient::executeRequest(const ExecuteRequestRequest &request) const
+{
+	auto endpointOutcome = endpointProvider_->getEndpoint();
+	if (!endpointOutcome.isSuccess())
+		return ExecuteRequestOutcome(endpointOutcome.error());
+
+	auto outcome = makeRequest(endpointOutcome.result(), request);
+
+	if (outcome.isSuccess())
+		return ExecuteRequestOutcome(ExecuteRequestResult(outcome.result()));
+	else
+		return ExecuteRequestOutcome(outcome.error());
+}
+
+void SafClient::executeRequestAsync(const ExecuteRequestRequest& request, const ExecuteRequestAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
+{
+	auto fn = [this, request, handler, context]()
+	{
+		handler(this, request, executeRequest(request), context);
+	};
+
+	asyncExecute(new Runnable(fn));
+}
+
+SafClient::ExecuteRequestOutcomeCallable SafClient::executeRequestCallable(const ExecuteRequestRequest &request) const
+{
+	auto task = std::make_shared<std::packaged_task<ExecuteRequestOutcome()>>(
+			[this, request]()
+			{
+			return this->executeRequest(request);
+			});
+
+	asyncExecute(new Runnable([task]() { (*task)(); }));
+	return task->get_future();
+}
+

+ 49 - 0
saf/src/model/ExecuteRequestRequest.cc

@@ -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.
+ */
+
+#include <alibabacloud/saf/model/ExecuteRequestRequest.h>
+
+using AlibabaCloud::Saf::Model::ExecuteRequestRequest;
+
+ExecuteRequestRequest::ExecuteRequestRequest() :
+	RpcServiceRequest("saf", "2018-09-19", "ExecuteRequest")
+{}
+
+ExecuteRequestRequest::~ExecuteRequestRequest()
+{}
+
+std::string ExecuteRequestRequest::getServiceParameters()const
+{
+	return serviceParameters_;
+}
+
+void ExecuteRequestRequest::setServiceParameters(const std::string& serviceParameters)
+{
+	serviceParameters_ = serviceParameters;
+	setParameter("ServiceParameters", serviceParameters);
+}
+
+std::string ExecuteRequestRequest::getService()const
+{
+	return service_;
+}
+
+void ExecuteRequestRequest::setService(const std::string& service)
+{
+	service_ = service;
+	setParameter("Service", service);
+}
+

+ 71 - 0
saf/src/model/ExecuteRequestResult.cc

@@ -0,0 +1,71 @@
+/*
+ * 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/ExecuteRequestResult.h>
+#include <json/json.h>
+
+using namespace AlibabaCloud::Saf;
+using namespace AlibabaCloud::Saf::Model;
+
+ExecuteRequestResult::ExecuteRequestResult() :
+	ServiceResult()
+{}
+
+ExecuteRequestResult::ExecuteRequestResult(const std::string &payload) :
+	ServiceResult()
+{
+	parse(payload);
+}
+
+ExecuteRequestResult::~ExecuteRequestResult()
+{}
+
+void ExecuteRequestResult::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["Tags"].isNull())
+		data_.tags = dataNode["Tags"].asString();
+	if(!dataNode["Score"].isNull())
+		data_.score = dataNode["Score"].asString();
+	if(!dataNode["Extend"].isNull())
+		data_.extend = dataNode["Extend"].asString();
+	if(!value["Code"].isNull())
+		code_ = std::stoi(value["Code"].asString());
+	if(!value["Message"].isNull())
+		message_ = value["Message"].asString();
+
+}
+
+std::string ExecuteRequestResult::getMessage()const
+{
+	return message_;
+}
+
+ExecuteRequestResult::Data ExecuteRequestResult::getData()const
+{
+	return data_;
+}
+
+int ExecuteRequestResult::getCode()const
+{
+	return code_;
+}
+