소스 검색

Add UnsubscribeTopic.

sdk-team 2 년 전
부모
커밋
1ff4eb0f4c

+ 1 - 1
VERSION

@@ -1 +1 @@
-1.36.1860
+1.36.1861

+ 4 - 0
iot/CMakeLists.txt

@@ -809,6 +809,8 @@ set(iot_public_header_model
 	include/alibabacloud/iot/model/UnbindRoleFromEdgeInstanceResult.h
 	include/alibabacloud/iot/model/UnbindSceneRuleFromEdgeInstanceRequest.h
 	include/alibabacloud/iot/model/UnbindSceneRuleFromEdgeInstanceResult.h
+	include/alibabacloud/iot/model/UnsubscribeTopicRequest.h
+	include/alibabacloud/iot/model/UnsubscribeTopicResult.h
 	include/alibabacloud/iot/model/UpdateConsumerGroupRequest.h
 	include/alibabacloud/iot/model/UpdateConsumerGroupResult.h
 	include/alibabacloud/iot/model/UpdateDestinationRequest.h
@@ -1660,6 +1662,8 @@ set(iot_src
 	src/model/UnbindRoleFromEdgeInstanceResult.cc
 	src/model/UnbindSceneRuleFromEdgeInstanceRequest.cc
 	src/model/UnbindSceneRuleFromEdgeInstanceResult.cc
+	src/model/UnsubscribeTopicRequest.cc
+	src/model/UnsubscribeTopicResult.cc
 	src/model/UpdateConsumerGroupRequest.cc
 	src/model/UpdateConsumerGroupResult.cc
 	src/model/UpdateDestinationRequest.cc

+ 8 - 0
iot/include/alibabacloud/iot/IotClient.h

@@ -810,6 +810,8 @@
 #include "model/UnbindRoleFromEdgeInstanceResult.h"
 #include "model/UnbindSceneRuleFromEdgeInstanceRequest.h"
 #include "model/UnbindSceneRuleFromEdgeInstanceResult.h"
+#include "model/UnsubscribeTopicRequest.h"
+#include "model/UnsubscribeTopicResult.h"
 #include "model/UpdateConsumerGroupRequest.h"
 #include "model/UpdateConsumerGroupResult.h"
 #include "model/UpdateDestinationRequest.h"
@@ -2061,6 +2063,9 @@ namespace AlibabaCloud
 			typedef Outcome<Error, Model::UnbindSceneRuleFromEdgeInstanceResult> UnbindSceneRuleFromEdgeInstanceOutcome;
 			typedef std::future<UnbindSceneRuleFromEdgeInstanceOutcome> UnbindSceneRuleFromEdgeInstanceOutcomeCallable;
 			typedef std::function<void(const IotClient*, const Model::UnbindSceneRuleFromEdgeInstanceRequest&, const UnbindSceneRuleFromEdgeInstanceOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> UnbindSceneRuleFromEdgeInstanceAsyncHandler;
+			typedef Outcome<Error, Model::UnsubscribeTopicResult> UnsubscribeTopicOutcome;
+			typedef std::future<UnsubscribeTopicOutcome> UnsubscribeTopicOutcomeCallable;
+			typedef std::function<void(const IotClient*, const Model::UnsubscribeTopicRequest&, const UnsubscribeTopicOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> UnsubscribeTopicAsyncHandler;
 			typedef Outcome<Error, Model::UpdateConsumerGroupResult> UpdateConsumerGroupOutcome;
 			typedef std::future<UpdateConsumerGroupOutcome> UpdateConsumerGroupOutcomeCallable;
 			typedef std::function<void(const IotClient*, const Model::UpdateConsumerGroupRequest&, const UpdateConsumerGroupOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> UpdateConsumerGroupAsyncHandler;
@@ -3338,6 +3343,9 @@ namespace AlibabaCloud
 			UnbindSceneRuleFromEdgeInstanceOutcome unbindSceneRuleFromEdgeInstance(const Model::UnbindSceneRuleFromEdgeInstanceRequest &request)const;
 			void unbindSceneRuleFromEdgeInstanceAsync(const Model::UnbindSceneRuleFromEdgeInstanceRequest& request, const UnbindSceneRuleFromEdgeInstanceAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
 			UnbindSceneRuleFromEdgeInstanceOutcomeCallable unbindSceneRuleFromEdgeInstanceCallable(const Model::UnbindSceneRuleFromEdgeInstanceRequest& request) const;
+			UnsubscribeTopicOutcome unsubscribeTopic(const Model::UnsubscribeTopicRequest &request)const;
+			void unsubscribeTopicAsync(const Model::UnsubscribeTopicRequest& request, const UnsubscribeTopicAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
+			UnsubscribeTopicOutcomeCallable unsubscribeTopicCallable(const Model::UnsubscribeTopicRequest& request) const;
 			UpdateConsumerGroupOutcome updateConsumerGroup(const Model::UpdateConsumerGroupRequest &request)const;
 			void updateConsumerGroupAsync(const Model::UpdateConsumerGroupRequest& request, const UpdateConsumerGroupAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
 			UpdateConsumerGroupOutcomeCallable updateConsumerGroupCallable(const Model::UpdateConsumerGroupRequest& request) const;

+ 63 - 0
iot/include/alibabacloud/iot/model/UnsubscribeTopicRequest.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_IOT_MODEL_UNSUBSCRIBETOPICREQUEST_H_
+#define ALIBABACLOUD_IOT_MODEL_UNSUBSCRIBETOPICREQUEST_H_
+
+#include <string>
+#include <vector>
+#include <alibabacloud/core/RpcServiceRequest.h>
+#include <alibabacloud/iot/IotExport.h>
+
+namespace AlibabaCloud
+{
+	namespace Iot
+	{
+		namespace Model
+		{
+			class ALIBABACLOUD_IOT_EXPORT UnsubscribeTopicRequest : public RpcServiceRequest
+			{
+
+			public:
+				UnsubscribeTopicRequest();
+				~UnsubscribeTopicRequest();
+
+				std::string getIotInstanceId()const;
+				void setIotInstanceId(const std::string& iotInstanceId);
+				std::string getProductKey()const;
+				void setProductKey(const std::string& productKey);
+				std::string getApiProduct()const;
+				void setApiProduct(const std::string& apiProduct);
+				std::vector<std::string> getTopic()const;
+				void setTopic(const std::vector<std::string>& topic);
+				std::string getApiRevision()const;
+				void setApiRevision(const std::string& apiRevision);
+				std::string getDeviceName()const;
+				void setDeviceName(const std::string& deviceName);
+
+            private:
+				std::string iotInstanceId_;
+				std::string productKey_;
+				std::string apiProduct_;
+				std::vector<std::string> topic_;
+				std::string apiRevision_;
+				std::string deviceName_;
+
+			};
+		}
+	}
+}
+#endif // !ALIBABACLOUD_IOT_MODEL_UNSUBSCRIBETOPICREQUEST_H_

+ 57 - 0
iot/include/alibabacloud/iot/model/UnsubscribeTopicResult.h

@@ -0,0 +1,57 @@
+/*
+ * 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_IOT_MODEL_UNSUBSCRIBETOPICRESULT_H_
+#define ALIBABACLOUD_IOT_MODEL_UNSUBSCRIBETOPICRESULT_H_
+
+#include <string>
+#include <vector>
+#include <utility>
+#include <alibabacloud/core/ServiceResult.h>
+#include <alibabacloud/iot/IotExport.h>
+
+namespace AlibabaCloud
+{
+	namespace Iot
+	{
+		namespace Model
+		{
+			class ALIBABACLOUD_IOT_EXPORT UnsubscribeTopicResult : public ServiceResult
+			{
+			public:
+
+
+				UnsubscribeTopicResult();
+				explicit UnsubscribeTopicResult(const std::string &payload);
+				~UnsubscribeTopicResult();
+				std::vector<std::string> getFailureTopics()const;
+				std::string getErrorMessage()const;
+				std::string getCode()const;
+				bool getSuccess()const;
+
+			protected:
+				void parse(const std::string &payload);
+			private:
+				std::vector<std::string> failureTopics_;
+				std::string errorMessage_;
+				std::string code_;
+				bool success_;
+
+			};
+		}
+	}
+}
+#endif // !ALIBABACLOUD_IOT_MODEL_UNSUBSCRIBETOPICRESULT_H_

+ 36 - 0
iot/src/IotClient.cc

@@ -14235,6 +14235,42 @@ IotClient::UnbindSceneRuleFromEdgeInstanceOutcomeCallable IotClient::unbindScene
 	return task->get_future();
 }
 
+IotClient::UnsubscribeTopicOutcome IotClient::unsubscribeTopic(const UnsubscribeTopicRequest &request) const
+{
+	auto endpointOutcome = endpointProvider_->getEndpoint();
+	if (!endpointOutcome.isSuccess())
+		return UnsubscribeTopicOutcome(endpointOutcome.error());
+
+	auto outcome = makeRequest(endpointOutcome.result(), request);
+
+	if (outcome.isSuccess())
+		return UnsubscribeTopicOutcome(UnsubscribeTopicResult(outcome.result()));
+	else
+		return UnsubscribeTopicOutcome(outcome.error());
+}
+
+void IotClient::unsubscribeTopicAsync(const UnsubscribeTopicRequest& request, const UnsubscribeTopicAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
+{
+	auto fn = [this, request, handler, context]()
+	{
+		handler(this, request, unsubscribeTopic(request), context);
+	};
+
+	asyncExecute(new Runnable(fn));
+}
+
+IotClient::UnsubscribeTopicOutcomeCallable IotClient::unsubscribeTopicCallable(const UnsubscribeTopicRequest &request) const
+{
+	auto task = std::make_shared<std::packaged_task<UnsubscribeTopicOutcome()>>(
+			[this, request]()
+			{
+			return this->unsubscribeTopic(request);
+			});
+
+	asyncExecute(new Runnable([task]() { (*task)(); }));
+	return task->get_future();
+}
+
 IotClient::UpdateConsumerGroupOutcome IotClient::updateConsumerGroup(const UpdateConsumerGroupRequest &request) const
 {
 	auto endpointOutcome = endpointProvider_->getEndpoint();

+ 97 - 0
iot/src/model/UnsubscribeTopicRequest.cc

@@ -0,0 +1,97 @@
+/*
+ * 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/iot/model/UnsubscribeTopicRequest.h>
+
+using AlibabaCloud::Iot::Model::UnsubscribeTopicRequest;
+
+UnsubscribeTopicRequest::UnsubscribeTopicRequest() :
+	RpcServiceRequest("iot", "2018-01-20", "UnsubscribeTopic")
+{
+	setMethod(HttpRequest::Method::Post);
+}
+
+UnsubscribeTopicRequest::~UnsubscribeTopicRequest()
+{}
+
+std::string UnsubscribeTopicRequest::getIotInstanceId()const
+{
+	return iotInstanceId_;
+}
+
+void UnsubscribeTopicRequest::setIotInstanceId(const std::string& iotInstanceId)
+{
+	iotInstanceId_ = iotInstanceId;
+	setParameter("IotInstanceId", iotInstanceId);
+}
+
+std::string UnsubscribeTopicRequest::getProductKey()const
+{
+	return productKey_;
+}
+
+void UnsubscribeTopicRequest::setProductKey(const std::string& productKey)
+{
+	productKey_ = productKey;
+	setParameter("ProductKey", productKey);
+}
+
+std::string UnsubscribeTopicRequest::getApiProduct()const
+{
+	return apiProduct_;
+}
+
+void UnsubscribeTopicRequest::setApiProduct(const std::string& apiProduct)
+{
+	apiProduct_ = apiProduct;
+	setBodyParameter("ApiProduct", apiProduct);
+}
+
+std::vector<std::string> UnsubscribeTopicRequest::getTopic()const
+{
+	return topic_;
+}
+
+void UnsubscribeTopicRequest::setTopic(const std::vector<std::string>& topic)
+{
+	topic_ = topic;
+	for(int dep1 = 0; dep1!= topic.size(); dep1++) {
+		setParameter("Topic."+ std::to_string(dep1), topic.at(dep1));
+	}
+}
+
+std::string UnsubscribeTopicRequest::getApiRevision()const
+{
+	return apiRevision_;
+}
+
+void UnsubscribeTopicRequest::setApiRevision(const std::string& apiRevision)
+{
+	apiRevision_ = apiRevision;
+	setBodyParameter("ApiRevision", apiRevision);
+}
+
+std::string UnsubscribeTopicRequest::getDeviceName()const
+{
+	return deviceName_;
+}
+
+void UnsubscribeTopicRequest::setDeviceName(const std::string& deviceName)
+{
+	deviceName_ = deviceName;
+	setParameter("DeviceName", deviceName);
+}
+

+ 73 - 0
iot/src/model/UnsubscribeTopicResult.cc

@@ -0,0 +1,73 @@
+/*
+ * 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/iot/model/UnsubscribeTopicResult.h>
+#include <json/json.h>
+
+using namespace AlibabaCloud::Iot;
+using namespace AlibabaCloud::Iot::Model;
+
+UnsubscribeTopicResult::UnsubscribeTopicResult() :
+	ServiceResult()
+{}
+
+UnsubscribeTopicResult::UnsubscribeTopicResult(const std::string &payload) :
+	ServiceResult()
+{
+	parse(payload);
+}
+
+UnsubscribeTopicResult::~UnsubscribeTopicResult()
+{}
+
+void UnsubscribeTopicResult::parse(const std::string &payload)
+{
+	Json::Reader reader;
+	Json::Value value;
+	reader.parse(payload, value);
+	setRequestId(value["RequestId"].asString());
+	auto allFailureTopics = value["FailureTopics"]["topic"];
+	for (const auto &item : allFailureTopics)
+		failureTopics_.push_back(item.asString());
+	if(!value["Success"].isNull())
+		success_ = value["Success"].asString() == "true";
+	if(!value["Code"].isNull())
+		code_ = value["Code"].asString();
+	if(!value["ErrorMessage"].isNull())
+		errorMessage_ = value["ErrorMessage"].asString();
+
+}
+
+std::vector<std::string> UnsubscribeTopicResult::getFailureTopics()const
+{
+	return failureTopics_;
+}
+
+std::string UnsubscribeTopicResult::getErrorMessage()const
+{
+	return errorMessage_;
+}
+
+std::string UnsubscribeTopicResult::getCode()const
+{
+	return code_;
+}
+
+bool UnsubscribeTopicResult::getSuccess()const
+{
+	return success_;
+}
+