diff --git a/CHANGELOG b/CHANGELOG index 8272ba4be..19fe88f92 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +2022-02-11 Version: 1.36.1053 +- Add OTA API, including ReupgradeOTATask. + 2022-02-10 Version: 1.36.1052 - Add deleteNacosInstance. diff --git a/VERSION b/VERSION index 2dd433f5a..83f311ffa 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.36.1052 \ No newline at end of file +1.36.1053 \ No newline at end of file diff --git a/iot/CMakeLists.txt b/iot/CMakeLists.txt index 0fcfc5b48..70066b243 100644 --- a/iot/CMakeLists.txt +++ b/iot/CMakeLists.txt @@ -565,6 +565,8 @@ set(iot_public_header_model include/alibabacloud/iot/model/ResetConsumerGroupPositionResult.h include/alibabacloud/iot/model/ResetThingRequest.h include/alibabacloud/iot/model/ResetThingResult.h + include/alibabacloud/iot/model/ReupgradeOTATaskRequest.h + include/alibabacloud/iot/model/ReupgradeOTATaskResult.h include/alibabacloud/iot/model/SaveDevicePropRequest.h include/alibabacloud/iot/model/SaveDevicePropResult.h include/alibabacloud/iot/model/SetDeviceDesiredPropertyRequest.h @@ -1200,6 +1202,8 @@ set(iot_src src/model/ResetConsumerGroupPositionResult.cc src/model/ResetThingRequest.cc src/model/ResetThingResult.cc + src/model/ReupgradeOTATaskRequest.cc + src/model/ReupgradeOTATaskResult.cc src/model/SaveDevicePropRequest.cc src/model/SaveDevicePropResult.cc src/model/SetDeviceDesiredPropertyRequest.cc diff --git a/iot/include/alibabacloud/iot/IotClient.h b/iot/include/alibabacloud/iot/IotClient.h index fba6467d0..070af2d54 100644 --- a/iot/include/alibabacloud/iot/IotClient.h +++ b/iot/include/alibabacloud/iot/IotClient.h @@ -566,6 +566,8 @@ #include "model/ResetConsumerGroupPositionResult.h" #include "model/ResetThingRequest.h" #include "model/ResetThingResult.h" +#include "model/ReupgradeOTATaskRequest.h" +#include "model/ReupgradeOTATaskResult.h" #include "model/SaveDevicePropRequest.h" #include "model/SaveDevicePropResult.h" #include "model/SetDeviceDesiredPropertyRequest.h" @@ -1479,6 +1481,9 @@ namespace AlibabaCloud typedef Outcome ResetThingOutcome; typedef std::future ResetThingOutcomeCallable; typedef std::function&)> ResetThingAsyncHandler; + typedef Outcome ReupgradeOTATaskOutcome; + typedef std::future ReupgradeOTATaskOutcomeCallable; + typedef std::function&)> ReupgradeOTATaskAsyncHandler; typedef Outcome SaveDevicePropOutcome; typedef std::future SaveDevicePropOutcomeCallable; typedef std::function&)> SaveDevicePropAsyncHandler; @@ -2432,6 +2437,9 @@ namespace AlibabaCloud ResetThingOutcome resetThing(const Model::ResetThingRequest &request)const; void resetThingAsync(const Model::ResetThingRequest& request, const ResetThingAsyncHandler& handler, const std::shared_ptr& context = nullptr) const; ResetThingOutcomeCallable resetThingCallable(const Model::ResetThingRequest& request) const; + ReupgradeOTATaskOutcome reupgradeOTATask(const Model::ReupgradeOTATaskRequest &request)const; + void reupgradeOTATaskAsync(const Model::ReupgradeOTATaskRequest& request, const ReupgradeOTATaskAsyncHandler& handler, const std::shared_ptr& context = nullptr) const; + ReupgradeOTATaskOutcomeCallable reupgradeOTATaskCallable(const Model::ReupgradeOTATaskRequest& request) const; SaveDevicePropOutcome saveDeviceProp(const Model::SaveDevicePropRequest &request)const; void saveDevicePropAsync(const Model::SaveDevicePropRequest& request, const SaveDevicePropAsyncHandler& handler, const std::shared_ptr& context = nullptr) const; SaveDevicePropOutcomeCallable saveDevicePropCallable(const Model::SaveDevicePropRequest& request) const; diff --git a/iot/include/alibabacloud/iot/model/ReupgradeOTATaskRequest.h b/iot/include/alibabacloud/iot/model/ReupgradeOTATaskRequest.h new file mode 100644 index 000000000..22d526915 --- /dev/null +++ b/iot/include/alibabacloud/iot/model/ReupgradeOTATaskRequest.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_REUPGRADEOTATASKREQUEST_H_ +#define ALIBABACLOUD_IOT_MODEL_REUPGRADEOTATASKREQUEST_H_ + +#include +#include +#include +#include + +namespace AlibabaCloud +{ + namespace Iot + { + namespace Model + { + class ALIBABACLOUD_IOT_EXPORT ReupgradeOTATaskRequest : public RpcServiceRequest + { + + public: + ReupgradeOTATaskRequest(); + ~ReupgradeOTATaskRequest(); + + std::string getAccessKeyId()const; + void setAccessKeyId(const std::string& accessKeyId); + std::string getJobId()const; + void setJobId(const std::string& jobId); + std::string getIotInstanceId()const; + void setIotInstanceId(const std::string& iotInstanceId); + std::vector getTaskId()const; + void setTaskId(const std::vector& taskId); + std::string getApiProduct()const; + void setApiProduct(const std::string& apiProduct); + std::string getApiRevision()const; + void setApiRevision(const std::string& apiRevision); + + private: + std::string accessKeyId_; + std::string jobId_; + std::string iotInstanceId_; + std::vector taskId_; + std::string apiProduct_; + std::string apiRevision_; + + }; + } + } +} +#endif // !ALIBABACLOUD_IOT_MODEL_REUPGRADEOTATASKREQUEST_H_ \ No newline at end of file diff --git a/iot/include/alibabacloud/iot/model/ReupgradeOTATaskResult.h b/iot/include/alibabacloud/iot/model/ReupgradeOTATaskResult.h new file mode 100644 index 000000000..2b81268e6 --- /dev/null +++ b/iot/include/alibabacloud/iot/model/ReupgradeOTATaskResult.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_IOT_MODEL_REUPGRADEOTATASKRESULT_H_ +#define ALIBABACLOUD_IOT_MODEL_REUPGRADEOTATASKRESULT_H_ + +#include +#include +#include +#include +#include + +namespace AlibabaCloud +{ + namespace Iot + { + namespace Model + { + class ALIBABACLOUD_IOT_EXPORT ReupgradeOTATaskResult : public ServiceResult + { + public: + + + ReupgradeOTATaskResult(); + explicit ReupgradeOTATaskResult(const std::string &payload); + ~ReupgradeOTATaskResult(); + std::string getErrorMessage()const; + std::string getCode()const; + bool getSuccess()const; + + protected: + void parse(const std::string &payload); + private: + std::string errorMessage_; + std::string code_; + bool success_; + + }; + } + } +} +#endif // !ALIBABACLOUD_IOT_MODEL_REUPGRADEOTATASKRESULT_H_ \ No newline at end of file diff --git a/iot/src/IotClient.cc b/iot/src/IotClient.cc index 6d85d4d0f..2823c93bd 100644 --- a/iot/src/IotClient.cc +++ b/iot/src/IotClient.cc @@ -31,21 +31,21 @@ IotClient::IotClient(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, ""); + endpointProvider_ = std::make_shared(locationClient, configuration.regionId(), SERVICE_NAME, "iot"); } IotClient::IotClient(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, ""); + endpointProvider_ = std::make_shared(locationClient, configuration.regionId(), SERVICE_NAME, "iot"); } IotClient::IotClient(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, ""); + endpointProvider_ = std::make_shared(locationClient, configuration.regionId(), SERVICE_NAME, "iot"); } IotClient::~IotClient() @@ -9843,6 +9843,42 @@ IotClient::ResetThingOutcomeCallable IotClient::resetThingCallable(const ResetTh return task->get_future(); } +IotClient::ReupgradeOTATaskOutcome IotClient::reupgradeOTATask(const ReupgradeOTATaskRequest &request) const +{ + auto endpointOutcome = endpointProvider_->getEndpoint(); + if (!endpointOutcome.isSuccess()) + return ReupgradeOTATaskOutcome(endpointOutcome.error()); + + auto outcome = makeRequest(endpointOutcome.result(), request); + + if (outcome.isSuccess()) + return ReupgradeOTATaskOutcome(ReupgradeOTATaskResult(outcome.result())); + else + return ReupgradeOTATaskOutcome(outcome.error()); +} + +void IotClient::reupgradeOTATaskAsync(const ReupgradeOTATaskRequest& request, const ReupgradeOTATaskAsyncHandler& handler, const std::shared_ptr& context) const +{ + auto fn = [this, request, handler, context]() + { + handler(this, request, reupgradeOTATask(request), context); + }; + + asyncExecute(new Runnable(fn)); +} + +IotClient::ReupgradeOTATaskOutcomeCallable IotClient::reupgradeOTATaskCallable(const ReupgradeOTATaskRequest &request) const +{ + auto task = std::make_shared>( + [this, request]() + { + return this->reupgradeOTATask(request); + }); + + asyncExecute(new Runnable([task]() { (*task)(); })); + return task->get_future(); +} + IotClient::SaveDevicePropOutcome IotClient::saveDeviceProp(const SaveDevicePropRequest &request) const { auto endpointOutcome = endpointProvider_->getEndpoint(); diff --git a/iot/src/model/ReupgradeOTATaskRequest.cc b/iot/src/model/ReupgradeOTATaskRequest.cc new file mode 100644 index 000000000..1f41b047d --- /dev/null +++ b/iot/src/model/ReupgradeOTATaskRequest.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 + +using AlibabaCloud::Iot::Model::ReupgradeOTATaskRequest; + +ReupgradeOTATaskRequest::ReupgradeOTATaskRequest() : + RpcServiceRequest("iot", "2018-01-20", "ReupgradeOTATask") +{ + setMethod(HttpRequest::Method::Post); +} + +ReupgradeOTATaskRequest::~ReupgradeOTATaskRequest() +{} + +std::string ReupgradeOTATaskRequest::getAccessKeyId()const +{ + return accessKeyId_; +} + +void ReupgradeOTATaskRequest::setAccessKeyId(const std::string& accessKeyId) +{ + accessKeyId_ = accessKeyId; + setParameter("AccessKeyId", accessKeyId); +} + +std::string ReupgradeOTATaskRequest::getJobId()const +{ + return jobId_; +} + +void ReupgradeOTATaskRequest::setJobId(const std::string& jobId) +{ + jobId_ = jobId; + setParameter("JobId", jobId); +} + +std::string ReupgradeOTATaskRequest::getIotInstanceId()const +{ + return iotInstanceId_; +} + +void ReupgradeOTATaskRequest::setIotInstanceId(const std::string& iotInstanceId) +{ + iotInstanceId_ = iotInstanceId; + setParameter("IotInstanceId", iotInstanceId); +} + +std::vector ReupgradeOTATaskRequest::getTaskId()const +{ + return taskId_; +} + +void ReupgradeOTATaskRequest::setTaskId(const std::vector& taskId) +{ + taskId_ = taskId; + for(int dep1 = 0; dep1!= taskId.size(); dep1++) { + setParameter("TaskId."+ std::to_string(dep1), taskId.at(dep1)); + } +} + +std::string ReupgradeOTATaskRequest::getApiProduct()const +{ + return apiProduct_; +} + +void ReupgradeOTATaskRequest::setApiProduct(const std::string& apiProduct) +{ + apiProduct_ = apiProduct; + setBodyParameter("ApiProduct", apiProduct); +} + +std::string ReupgradeOTATaskRequest::getApiRevision()const +{ + return apiRevision_; +} + +void ReupgradeOTATaskRequest::setApiRevision(const std::string& apiRevision) +{ + apiRevision_ = apiRevision; + setBodyParameter("ApiRevision", apiRevision); +} + diff --git a/iot/src/model/ReupgradeOTATaskResult.cc b/iot/src/model/ReupgradeOTATaskResult.cc new file mode 100644 index 000000000..f4251463f --- /dev/null +++ b/iot/src/model/ReupgradeOTATaskResult.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::Iot; +using namespace AlibabaCloud::Iot::Model; + +ReupgradeOTATaskResult::ReupgradeOTATaskResult() : + ServiceResult() +{} + +ReupgradeOTATaskResult::ReupgradeOTATaskResult(const std::string &payload) : + ServiceResult() +{ + parse(payload); +} + +ReupgradeOTATaskResult::~ReupgradeOTATaskResult() +{} + +void ReupgradeOTATaskResult::parse(const std::string &payload) +{ + Json::Reader reader; + Json::Value value; + reader.parse(payload, value); + setRequestId(value["RequestId"].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::string ReupgradeOTATaskResult::getErrorMessage()const +{ + return errorMessage_; +} + +std::string ReupgradeOTATaskResult::getCode()const +{ + return code_; +} + +bool ReupgradeOTATaskResult::getSuccess()const +{ + return success_; +} +