Add OTA API, including ReupgradeOTATask.
This commit is contained in:
@@ -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.
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<Error, Model::ResetThingResult> ResetThingOutcome;
|
||||
typedef std::future<ResetThingOutcome> ResetThingOutcomeCallable;
|
||||
typedef std::function<void(const IotClient*, const Model::ResetThingRequest&, const ResetThingOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> ResetThingAsyncHandler;
|
||||
typedef Outcome<Error, Model::ReupgradeOTATaskResult> ReupgradeOTATaskOutcome;
|
||||
typedef std::future<ReupgradeOTATaskOutcome> ReupgradeOTATaskOutcomeCallable;
|
||||
typedef std::function<void(const IotClient*, const Model::ReupgradeOTATaskRequest&, const ReupgradeOTATaskOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> ReupgradeOTATaskAsyncHandler;
|
||||
typedef Outcome<Error, Model::SaveDevicePropResult> SaveDevicePropOutcome;
|
||||
typedef std::future<SaveDevicePropOutcome> SaveDevicePropOutcomeCallable;
|
||||
typedef std::function<void(const IotClient*, const Model::SaveDevicePropRequest&, const SaveDevicePropOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> 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<const AsyncCallerContext>& 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<const AsyncCallerContext>& 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<const AsyncCallerContext>& context = nullptr) const;
|
||||
SaveDevicePropOutcomeCallable saveDevicePropCallable(const Model::SaveDevicePropRequest& request) const;
|
||||
|
||||
63
iot/include/alibabacloud/iot/model/ReupgradeOTATaskRequest.h
Normal file
63
iot/include/alibabacloud/iot/model/ReupgradeOTATaskRequest.h
Normal file
@@ -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 <string>
|
||||
#include <vector>
|
||||
#include <alibabacloud/core/RpcServiceRequest.h>
|
||||
#include <alibabacloud/iot/IotExport.h>
|
||||
|
||||
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<std::string> getTaskId()const;
|
||||
void setTaskId(const std::vector<std::string>& 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<std::string> taskId_;
|
||||
std::string apiProduct_;
|
||||
std::string apiRevision_;
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // !ALIBABACLOUD_IOT_MODEL_REUPGRADEOTATASKREQUEST_H_
|
||||
55
iot/include/alibabacloud/iot/model/ReupgradeOTATaskResult.h
Normal file
55
iot/include/alibabacloud/iot/model/ReupgradeOTATaskResult.h
Normal file
@@ -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 <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 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_
|
||||
@@ -31,21 +31,21 @@ IotClient::IotClient(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, "");
|
||||
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "iot");
|
||||
}
|
||||
|
||||
IotClient::IotClient(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, "");
|
||||
endpointProvider_ = std::make_shared<EndpointProvider>(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<SimpleCredentialsProvider>(accessKeyId, accessKeySecret), configuration)
|
||||
{
|
||||
auto locationClient = std::make_shared<LocationClient>(accessKeyId, accessKeySecret, configuration);
|
||||
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "");
|
||||
endpointProvider_ = std::make_shared<EndpointProvider>(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<const AsyncCallerContext>& 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<std::packaged_task<ReupgradeOTATaskOutcome()>>(
|
||||
[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();
|
||||
|
||||
97
iot/src/model/ReupgradeOTATaskRequest.cc
Normal file
97
iot/src/model/ReupgradeOTATaskRequest.cc
Normal file
@@ -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/ReupgradeOTATaskRequest.h>
|
||||
|
||||
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<std::string> ReupgradeOTATaskRequest::getTaskId()const
|
||||
{
|
||||
return taskId_;
|
||||
}
|
||||
|
||||
void ReupgradeOTATaskRequest::setTaskId(const std::vector<std::string>& 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);
|
||||
}
|
||||
|
||||
65
iot/src/model/ReupgradeOTATaskResult.cc
Normal file
65
iot/src/model/ReupgradeOTATaskResult.cc
Normal file
@@ -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/iot/model/ReupgradeOTATaskResult.h>
|
||||
#include <json/json.h>
|
||||
|
||||
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_;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user