فهرست منبع

由荣旸发起的TESLADAM SDK自动发布, BUILD_ID=310, 版本号:1.2.1

Signed-off-by: haowei.yao <haowei.yao@alibaba-inc.com>
haowei.yao 8 سال پیش
والد
کامیت
9cc69b8d44

+ 3 - 0
CHANGELOG

@@ -1,3 +1,6 @@
+2018-02-27 Version: 1.2.1
+1, Add Action API.
+
 2018-02-27 Version: 1.2.0
 1, add new api DescribeClusters,DescribeClusterLogs,DescribeClusterNodes,UpgradeClusterComponents
 

+ 1 - 1
VERSION

@@ -1 +1 @@
-1.2.0
+1.2.1

+ 4 - 0
tesladam/CMakeLists.txt

@@ -21,6 +21,8 @@ set(tesladam_public_header
 	include/alibabacloud/tesladam/TeslaDamExport.h )
 
 set(tesladam_public_header_model 
+	include/alibabacloud/tesladam/model/ActionRequest.h
+	include/alibabacloud/tesladam/model/ActionResult.h
 	include/alibabacloud/tesladam/model/ActionDiskRmaRequest.h
 	include/alibabacloud/tesladam/model/ActionDiskRmaResult.h
 	include/alibabacloud/tesladam/model/ActionDiskMaskRequest.h
@@ -32,6 +34,8 @@ set(tesladam_public_header_model
 
 set(tesladam_src 
 	src/TeslaDamClient.cc
+	src/model/ActionRequest.cc
+	src/model/ActionResult.cc
 	src/model/ActionDiskRmaRequest.cc
 	src/model/ActionDiskRmaResult.cc
 	src/model/ActionDiskMaskRequest.cc

+ 8 - 0
tesladam/include/alibabacloud/tesladam/TeslaDamClient.h

@@ -22,6 +22,8 @@
 #include <alibabacloud/core/EndpointProvider.h>
 #include <alibabacloud/core/RpcServiceClient.h>
 #include "TeslaDamExport.h"
+#include "model/ActionRequest.h"
+#include "model/ActionResult.h"
 #include "model/ActionDiskRmaRequest.h"
 #include "model/ActionDiskRmaResult.h"
 #include "model/ActionDiskMaskRequest.h"
@@ -39,6 +41,9 @@ namespace AlibabaCloud
 		class ALIBABACLOUD_TESLADAM_EXPORT TeslaDamClient : public RpcServiceClient
 		{
 		public:
+			typedef Outcome<Error, Model::ActionResult> ActionOutcome;			
+			typedef std::future<ActionOutcome> ActionOutcomeCallable;			
+			typedef std::function<void(const TeslaDamClient*, const Model::ActionRequest&, const ActionOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> ActionAsyncHandler;
 			typedef Outcome<Error, Model::ActionDiskRmaResult> ActionDiskRmaOutcome;			
 			typedef std::future<ActionDiskRmaOutcome> ActionDiskRmaOutcomeCallable;			
 			typedef std::function<void(const TeslaDamClient*, const Model::ActionDiskRmaRequest&, const ActionDiskRmaOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> ActionDiskRmaAsyncHandler;
@@ -56,6 +61,9 @@ namespace AlibabaCloud
 			TeslaDamClient(const std::shared_ptr<CredentialsProvider> &credentialsProvider, const ClientConfiguration &configuration);
 			TeslaDamClient(const std::string &accessKeyId, const std::string &accessKeySecret, const ClientConfiguration &configuration);
 			~TeslaDamClient();
+            ActionOutcome action(const Model::ActionRequest &request)const;
+            void actionAsync(const Model::ActionRequest& request, const ActionAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
+            ActionOutcomeCallable actionCallable(const Model::ActionRequest& request) const;
             ActionDiskRmaOutcome actionDiskRma(const Model::ActionDiskRmaRequest &request)const;
             void actionDiskRmaAsync(const Model::ActionDiskRmaRequest& request, const ActionDiskRmaAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
             ActionDiskRmaOutcomeCallable actionDiskRmaCallable(const Model::ActionDiskRmaRequest& request) const;

+ 51 - 0
tesladam/include/alibabacloud/tesladam/model/ActionRequest.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_TESLADAM_MODEL_ACTIONREQUEST_H_
+#define ALIBABACLOUD_TESLADAM_MODEL_ACTIONREQUEST_H_
+
+#include <string>
+#include <vector>
+#include <alibabacloud/core/RpcServiceRequest.h>
+#include <alibabacloud/tesladam/TeslaDamExport.h>
+
+namespace AlibabaCloud
+{
+	namespace TeslaDam
+	{
+		namespace Model
+		{
+			class ALIBABACLOUD_TESLADAM_EXPORT ActionRequest : public RpcServiceRequest
+			{
+
+			public:
+				ActionRequest();
+				~ActionRequest();
+
+				int getOrderId()const;
+				void setOrderId(int orderId);
+				std::string getStepCode()const;
+				void setStepCode(const std::string& stepCode);
+
+            private:
+				int orderId_;
+				std::string stepCode_;
+
+			};
+		}
+	}
+}
+#endif // !ALIBABACLOUD_TESLADAM_MODEL_ACTIONREQUEST_H_

+ 55 - 0
tesladam/include/alibabacloud/tesladam/model/ActionResult.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_TESLADAM_MODEL_ACTIONRESULT_H_
+#define ALIBABACLOUD_TESLADAM_MODEL_ACTIONRESULT_H_
+
+#include <string>
+#include <vector>
+#include <utility>
+#include <alibabacloud/core/ServiceResult.h>
+#include <alibabacloud/tesladam/TeslaDamExport.h>
+
+namespace AlibabaCloud
+{
+	namespace TeslaDam
+	{
+		namespace Model
+		{
+			class ALIBABACLOUD_TESLADAM_EXPORT ActionResult : public ServiceResult
+			{
+			public:
+
+
+				ActionResult();
+				explicit ActionResult(const std::string &payload);
+				~ActionResult();
+				bool getStatus()const;
+				std::string getMessage()const;
+				std::string getResult()const;
+
+			protected:
+				void parse(const std::string &payload);
+			private:
+				bool status_;
+				std::string message_;
+				std::string result_;
+
+			};
+		}
+	}
+}
+#endif // !ALIBABACLOUD_TESLADAM_MODEL_ACTIONRESULT_H_

+ 39 - 3
tesladam/src/TeslaDamClient.cc

@@ -26,21 +26,21 @@ TeslaDamClient::TeslaDamClient(const Credentials &credentials, const ClientConfi
 	RpcServiceClient(std::make_shared<SimpleCredentialsProvider>(credentials), configuration)
 {
 	auto locationClient = std::make_shared<LocationClient>(credentials, configuration);
-	endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), "tesladam");
+	endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), "");
 }
 
 TeslaDamClient::TeslaDamClient(const std::shared_ptr<CredentialsProvider>& credentialsProvider, const ClientConfiguration & configuration) :
 	RpcServiceClient(credentialsProvider, configuration)
 {
 	auto locationClient = std::make_shared<LocationClient>(credentialsProvider, configuration);
-	endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), "tesladam");
+	endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), "");
 }
 
 TeslaDamClient::TeslaDamClient(const std::string & accessKeyId, const std::string & accessKeySecret, const ClientConfiguration & configuration) :
 	RpcServiceClient(std::make_shared<SimpleCredentialsProvider>(accessKeyId, accessKeySecret), configuration)
 {
 	auto locationClient = std::make_shared<LocationClient>(accessKeyId, accessKeySecret, configuration);
-	endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), "tesladam");
+	endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), "");
 }
 
 TeslaDamClient::~TeslaDamClient()
@@ -59,6 +59,42 @@ CoreClient::EndpointOutcome TeslaDamClient::endpoint()const
 		return CoreClient::EndpointOutcome(endpoint);
 }
 
+TeslaDamClient::ActionOutcome TeslaDamClient::action(const ActionRequest &request) const
+{
+	auto endpointOutcome = endpoint();
+	if (!endpointOutcome.isSuccess())
+		return ActionOutcome(endpointOutcome.error());
+
+	auto outcome = makeRequest(endpointOutcome.result(), request);
+
+	if (outcome.isSuccess())
+		return ActionOutcome(ActionResult(outcome.result()));
+	else
+		return ActionOutcome(outcome.error());
+}
+
+void TeslaDamClient::actionAsync(const ActionRequest& request, const ActionAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
+{
+	auto fn = [this, request, handler, context]()
+	{
+		handler(this, request, action(request), context);
+	};
+
+	asyncExecute(new Runnable(fn));
+}
+
+TeslaDamClient::ActionOutcomeCallable TeslaDamClient::actionCallable(const ActionRequest &request) const
+{
+	auto task = std::make_shared<std::packaged_task<ActionOutcome()>>(
+			[this, request]()
+			{
+			return this->action(request);
+			});
+
+	asyncExecute(new Runnable([task]() { (*task)(); }));
+	return task->get_future();
+}
+
 TeslaDamClient::ActionDiskRmaOutcome TeslaDamClient::actionDiskRma(const ActionDiskRmaRequest &request) const
 {
 	auto endpointOutcome = endpoint();

+ 49 - 0
tesladam/src/model/ActionRequest.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/tesladam/model/ActionRequest.h>
+
+using AlibabaCloud::TeslaDam::Model::ActionRequest;
+
+ActionRequest::ActionRequest() :
+	RpcServiceRequest("tesladam", "2018-01-18", "Action")
+{}
+
+ActionRequest::~ActionRequest()
+{}
+
+int ActionRequest::getOrderId()const
+{
+	return orderId_;
+}
+
+void ActionRequest::setOrderId(int orderId)
+{
+	orderId_ = orderId;
+	setParameter("OrderId", std::to_string(orderId));
+}
+
+std::string ActionRequest::getStepCode()const
+{
+	return stepCode_;
+}
+
+void ActionRequest::setStepCode(const std::string& stepCode)
+{
+	stepCode_ = stepCode;
+	setParameter("StepCode", stepCode);
+}
+

+ 66 - 0
tesladam/src/model/ActionResult.cc

@@ -0,0 +1,66 @@
+/*
+ * 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/tesladam/model/ActionResult.h>
+#include <json/json.h>
+
+using namespace AlibabaCloud::TeslaDam;
+using namespace AlibabaCloud::TeslaDam::Model;
+
+ActionResult::ActionResult() :
+	ServiceResult()
+{}
+
+ActionResult::ActionResult(const std::string &payload) :
+	ServiceResult()
+{
+	parse(payload);
+}
+
+ActionResult::~ActionResult()
+{}
+
+void ActionResult::parse(const std::string &payload)
+{
+	Json::Reader reader;
+	Json::Value value;
+	reader.parse(payload, value);
+
+	setRequestId(value["RequestId"].asString());
+	if(!value["Status"].isNull())
+		status_ = value["Status"].asString() == "true";
+	if(!value["Message"].isNull())
+		message_ = value["Message"].asString();
+	if(!value["Result"].isNull())
+		result_ = value["Result"].asString();
+
+}
+
+bool ActionResult::getStatus()const
+{
+	return status_;
+}
+
+std::string ActionResult::getMessage()const
+{
+	return message_;
+}
+
+std::string ActionResult::getResult()const
+{
+	return result_;
+}
+