Add OTA API, including ReupgradeOTATask.
This commit is contained in:
@@ -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