feat(hos_client_create, hos_client_destory): 多次调用destory不会导致重复释放

This commit is contained in:
彭宣正
2020-12-14 17:24:58 +08:00
parent 505d529c32
commit 10b370e486
55976 changed files with 8544395 additions and 2 deletions

View File

@@ -0,0 +1,248 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/core/utils/Outcome.h>
#include <aws/core/auth/AWSAuthSigner.h>
#include <aws/core/client/CoreErrors.h>
#include <aws/core/client/RetryStrategy.h>
#include <aws/core/http/HttpClient.h>
#include <aws/core/http/HttpResponse.h>
#include <aws/core/http/HttpClientFactory.h>
#include <aws/core/auth/AWSCredentialsProviderChain.h>
#include <aws/core/utils/json/JsonSerializer.h>
#include <aws/core/utils/memory/stl/AWSStringStream.h>
#include <aws/core/utils/threading/Executor.h>
#include <aws/core/utils/DNS.h>
#include <aws/core/utils/logging/LogMacros.h>
#include <aws/iot-jobs-data/IoTJobsDataPlaneClient.h>
#include <aws/iot-jobs-data/IoTJobsDataPlaneEndpoint.h>
#include <aws/iot-jobs-data/IoTJobsDataPlaneErrorMarshaller.h>
#include <aws/iot-jobs-data/model/DescribeJobExecutionRequest.h>
#include <aws/iot-jobs-data/model/GetPendingJobExecutionsRequest.h>
#include <aws/iot-jobs-data/model/StartNextPendingJobExecutionRequest.h>
#include <aws/iot-jobs-data/model/UpdateJobExecutionRequest.h>
using namespace Aws;
using namespace Aws::Auth;
using namespace Aws::Client;
using namespace Aws::IoTJobsDataPlane;
using namespace Aws::IoTJobsDataPlane::Model;
using namespace Aws::Http;
using namespace Aws::Utils::Json;
static const char* SERVICE_NAME = "iot-jobs-data";
static const char* ALLOCATION_TAG = "IoTJobsDataPlaneClient";
IoTJobsDataPlaneClient::IoTJobsDataPlaneClient(const Client::ClientConfiguration& clientConfiguration) :
BASECLASS(clientConfiguration,
Aws::MakeShared<AWSAuthV4Signer>(ALLOCATION_TAG, Aws::MakeShared<DefaultAWSCredentialsProviderChain>(ALLOCATION_TAG),
SERVICE_NAME, Aws::Region::ComputeSignerRegion(clientConfiguration.region)),
Aws::MakeShared<IoTJobsDataPlaneErrorMarshaller>(ALLOCATION_TAG)),
m_executor(clientConfiguration.executor)
{
init(clientConfiguration);
}
IoTJobsDataPlaneClient::IoTJobsDataPlaneClient(const AWSCredentials& credentials, const Client::ClientConfiguration& clientConfiguration) :
BASECLASS(clientConfiguration,
Aws::MakeShared<AWSAuthV4Signer>(ALLOCATION_TAG, Aws::MakeShared<SimpleAWSCredentialsProvider>(ALLOCATION_TAG, credentials),
SERVICE_NAME, Aws::Region::ComputeSignerRegion(clientConfiguration.region)),
Aws::MakeShared<IoTJobsDataPlaneErrorMarshaller>(ALLOCATION_TAG)),
m_executor(clientConfiguration.executor)
{
init(clientConfiguration);
}
IoTJobsDataPlaneClient::IoTJobsDataPlaneClient(const std::shared_ptr<AWSCredentialsProvider>& credentialsProvider,
const Client::ClientConfiguration& clientConfiguration) :
BASECLASS(clientConfiguration,
Aws::MakeShared<AWSAuthV4Signer>(ALLOCATION_TAG, credentialsProvider,
SERVICE_NAME, Aws::Region::ComputeSignerRegion(clientConfiguration.region)),
Aws::MakeShared<IoTJobsDataPlaneErrorMarshaller>(ALLOCATION_TAG)),
m_executor(clientConfiguration.executor)
{
init(clientConfiguration);
}
IoTJobsDataPlaneClient::~IoTJobsDataPlaneClient()
{
}
void IoTJobsDataPlaneClient::init(const ClientConfiguration& config)
{
SetServiceClientName("IoT Jobs Data Plane");
m_configScheme = SchemeMapper::ToString(config.scheme);
if (config.endpointOverride.empty())
{
m_uri = m_configScheme + "://" + IoTJobsDataPlaneEndpoint::ForRegion(config.region, config.useDualStack);
}
else
{
OverrideEndpoint(config.endpointOverride);
}
}
void IoTJobsDataPlaneClient::OverrideEndpoint(const Aws::String& endpoint)
{
if (endpoint.compare(0, 7, "http://") == 0 || endpoint.compare(0, 8, "https://") == 0)
{
m_uri = endpoint;
}
else
{
m_uri = m_configScheme + "://" + endpoint;
}
}
DescribeJobExecutionOutcome IoTJobsDataPlaneClient::DescribeJobExecution(const DescribeJobExecutionRequest& request) const
{
if (!request.JobIdHasBeenSet())
{
AWS_LOGSTREAM_ERROR("DescribeJobExecution", "Required field: JobId, is not set");
return DescribeJobExecutionOutcome(Aws::Client::AWSError<IoTJobsDataPlaneErrors>(IoTJobsDataPlaneErrors::MISSING_PARAMETER, "MISSING_PARAMETER", "Missing required field [JobId]", false));
}
if (!request.ThingNameHasBeenSet())
{
AWS_LOGSTREAM_ERROR("DescribeJobExecution", "Required field: ThingName, is not set");
return DescribeJobExecutionOutcome(Aws::Client::AWSError<IoTJobsDataPlaneErrors>(IoTJobsDataPlaneErrors::MISSING_PARAMETER, "MISSING_PARAMETER", "Missing required field [ThingName]", false));
}
Aws::Http::URI uri = m_uri;
Aws::StringStream ss;
ss << "/things/";
ss << request.GetThingName();
ss << "/jobs/";
ss << request.GetJobId();
uri.SetPath(uri.GetPath() + ss.str());
return DescribeJobExecutionOutcome(MakeRequest(uri, request, Aws::Http::HttpMethod::HTTP_GET, Aws::Auth::SIGV4_SIGNER));
}
DescribeJobExecutionOutcomeCallable IoTJobsDataPlaneClient::DescribeJobExecutionCallable(const DescribeJobExecutionRequest& request) const
{
auto task = Aws::MakeShared< std::packaged_task< DescribeJobExecutionOutcome() > >(ALLOCATION_TAG, [this, request](){ return this->DescribeJobExecution(request); } );
auto packagedFunction = [task]() { (*task)(); };
m_executor->Submit(packagedFunction);
return task->get_future();
}
void IoTJobsDataPlaneClient::DescribeJobExecutionAsync(const DescribeJobExecutionRequest& request, const DescribeJobExecutionResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const
{
m_executor->Submit( [this, request, handler, context](){ this->DescribeJobExecutionAsyncHelper( request, handler, context ); } );
}
void IoTJobsDataPlaneClient::DescribeJobExecutionAsyncHelper(const DescribeJobExecutionRequest& request, const DescribeJobExecutionResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const
{
handler(this, request, DescribeJobExecution(request), context);
}
GetPendingJobExecutionsOutcome IoTJobsDataPlaneClient::GetPendingJobExecutions(const GetPendingJobExecutionsRequest& request) const
{
if (!request.ThingNameHasBeenSet())
{
AWS_LOGSTREAM_ERROR("GetPendingJobExecutions", "Required field: ThingName, is not set");
return GetPendingJobExecutionsOutcome(Aws::Client::AWSError<IoTJobsDataPlaneErrors>(IoTJobsDataPlaneErrors::MISSING_PARAMETER, "MISSING_PARAMETER", "Missing required field [ThingName]", false));
}
Aws::Http::URI uri = m_uri;
Aws::StringStream ss;
ss << "/things/";
ss << request.GetThingName();
ss << "/jobs";
uri.SetPath(uri.GetPath() + ss.str());
return GetPendingJobExecutionsOutcome(MakeRequest(uri, request, Aws::Http::HttpMethod::HTTP_GET, Aws::Auth::SIGV4_SIGNER));
}
GetPendingJobExecutionsOutcomeCallable IoTJobsDataPlaneClient::GetPendingJobExecutionsCallable(const GetPendingJobExecutionsRequest& request) const
{
auto task = Aws::MakeShared< std::packaged_task< GetPendingJobExecutionsOutcome() > >(ALLOCATION_TAG, [this, request](){ return this->GetPendingJobExecutions(request); } );
auto packagedFunction = [task]() { (*task)(); };
m_executor->Submit(packagedFunction);
return task->get_future();
}
void IoTJobsDataPlaneClient::GetPendingJobExecutionsAsync(const GetPendingJobExecutionsRequest& request, const GetPendingJobExecutionsResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const
{
m_executor->Submit( [this, request, handler, context](){ this->GetPendingJobExecutionsAsyncHelper( request, handler, context ); } );
}
void IoTJobsDataPlaneClient::GetPendingJobExecutionsAsyncHelper(const GetPendingJobExecutionsRequest& request, const GetPendingJobExecutionsResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const
{
handler(this, request, GetPendingJobExecutions(request), context);
}
StartNextPendingJobExecutionOutcome IoTJobsDataPlaneClient::StartNextPendingJobExecution(const StartNextPendingJobExecutionRequest& request) const
{
if (!request.ThingNameHasBeenSet())
{
AWS_LOGSTREAM_ERROR("StartNextPendingJobExecution", "Required field: ThingName, is not set");
return StartNextPendingJobExecutionOutcome(Aws::Client::AWSError<IoTJobsDataPlaneErrors>(IoTJobsDataPlaneErrors::MISSING_PARAMETER, "MISSING_PARAMETER", "Missing required field [ThingName]", false));
}
Aws::Http::URI uri = m_uri;
Aws::StringStream ss;
ss << "/things/";
ss << request.GetThingName();
ss << "/jobs/$next";
uri.SetPath(uri.GetPath() + ss.str());
return StartNextPendingJobExecutionOutcome(MakeRequest(uri, request, Aws::Http::HttpMethod::HTTP_PUT, Aws::Auth::SIGV4_SIGNER));
}
StartNextPendingJobExecutionOutcomeCallable IoTJobsDataPlaneClient::StartNextPendingJobExecutionCallable(const StartNextPendingJobExecutionRequest& request) const
{
auto task = Aws::MakeShared< std::packaged_task< StartNextPendingJobExecutionOutcome() > >(ALLOCATION_TAG, [this, request](){ return this->StartNextPendingJobExecution(request); } );
auto packagedFunction = [task]() { (*task)(); };
m_executor->Submit(packagedFunction);
return task->get_future();
}
void IoTJobsDataPlaneClient::StartNextPendingJobExecutionAsync(const StartNextPendingJobExecutionRequest& request, const StartNextPendingJobExecutionResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const
{
m_executor->Submit( [this, request, handler, context](){ this->StartNextPendingJobExecutionAsyncHelper( request, handler, context ); } );
}
void IoTJobsDataPlaneClient::StartNextPendingJobExecutionAsyncHelper(const StartNextPendingJobExecutionRequest& request, const StartNextPendingJobExecutionResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const
{
handler(this, request, StartNextPendingJobExecution(request), context);
}
UpdateJobExecutionOutcome IoTJobsDataPlaneClient::UpdateJobExecution(const UpdateJobExecutionRequest& request) const
{
if (!request.JobIdHasBeenSet())
{
AWS_LOGSTREAM_ERROR("UpdateJobExecution", "Required field: JobId, is not set");
return UpdateJobExecutionOutcome(Aws::Client::AWSError<IoTJobsDataPlaneErrors>(IoTJobsDataPlaneErrors::MISSING_PARAMETER, "MISSING_PARAMETER", "Missing required field [JobId]", false));
}
if (!request.ThingNameHasBeenSet())
{
AWS_LOGSTREAM_ERROR("UpdateJobExecution", "Required field: ThingName, is not set");
return UpdateJobExecutionOutcome(Aws::Client::AWSError<IoTJobsDataPlaneErrors>(IoTJobsDataPlaneErrors::MISSING_PARAMETER, "MISSING_PARAMETER", "Missing required field [ThingName]", false));
}
Aws::Http::URI uri = m_uri;
Aws::StringStream ss;
ss << "/things/";
ss << request.GetThingName();
ss << "/jobs/";
ss << request.GetJobId();
uri.SetPath(uri.GetPath() + ss.str());
return UpdateJobExecutionOutcome(MakeRequest(uri, request, Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER));
}
UpdateJobExecutionOutcomeCallable IoTJobsDataPlaneClient::UpdateJobExecutionCallable(const UpdateJobExecutionRequest& request) const
{
auto task = Aws::MakeShared< std::packaged_task< UpdateJobExecutionOutcome() > >(ALLOCATION_TAG, [this, request](){ return this->UpdateJobExecution(request); } );
auto packagedFunction = [task]() { (*task)(); };
m_executor->Submit(packagedFunction);
return task->get_future();
}
void IoTJobsDataPlaneClient::UpdateJobExecutionAsync(const UpdateJobExecutionRequest& request, const UpdateJobExecutionResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const
{
m_executor->Submit( [this, request, handler, context](){ this->UpdateJobExecutionAsyncHelper( request, handler, context ); } );
}
void IoTJobsDataPlaneClient::UpdateJobExecutionAsyncHelper(const UpdateJobExecutionRequest& request, const UpdateJobExecutionResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const
{
handler(this, request, UpdateJobExecution(request), context);
}

View File

@@ -0,0 +1,64 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/iot-jobs-data/IoTJobsDataPlaneEndpoint.h>
#include <aws/core/utils/memory/stl/AWSStringStream.h>
#include <aws/core/utils/HashingUtils.h>
using namespace Aws;
using namespace Aws::IoTJobsDataPlane;
namespace Aws
{
namespace IoTJobsDataPlane
{
namespace IoTJobsDataPlaneEndpoint
{
static const int CN_NORTH_1_HASH = Aws::Utils::HashingUtils::HashString("cn-north-1");
static const int CN_NORTHWEST_1_HASH = Aws::Utils::HashingUtils::HashString("cn-northwest-1");
static const int US_ISO_EAST_1_HASH = Aws::Utils::HashingUtils::HashString("us-iso-east-1");
static const int US_ISOB_EAST_1_HASH = Aws::Utils::HashingUtils::HashString("us-isob-east-1");
Aws::String ForRegion(const Aws::String& regionName, bool useDualStack)
{
// Fallback to us-east-1 if global endpoint does not exists.
Aws::String region = regionName == Aws::Region::AWS_GLOBAL ? Aws::Region::US_EAST_1 : regionName;
auto hash = Aws::Utils::HashingUtils::HashString(region.c_str());
Aws::StringStream ss;
ss << "data.jobs.iot" << ".";
if(useDualStack)
{
ss << "dualstack.";
}
ss << region;
if (hash == CN_NORTH_1_HASH || hash == CN_NORTHWEST_1_HASH)
{
ss << ".amazonaws.com.cn";
}
else if (hash == US_ISO_EAST_1_HASH)
{
ss << ".c2s.ic.gov";
}
else if (hash == US_ISOB_EAST_1_HASH)
{
ss << ".sc2s.sgov.gov";
}
else
{
ss << ".amazonaws.com";
}
return ss.str();
}
} // namespace IoTJobsDataPlaneEndpoint
} // namespace IoTJobsDataPlane
} // namespace Aws

View File

@@ -0,0 +1,22 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/core/client/AWSError.h>
#include <aws/iot-jobs-data/IoTJobsDataPlaneErrorMarshaller.h>
#include <aws/iot-jobs-data/IoTJobsDataPlaneErrors.h>
using namespace Aws::Client;
using namespace Aws::IoTJobsDataPlane;
AWSError<CoreErrors> IoTJobsDataPlaneErrorMarshaller::FindErrorByName(const char* errorName) const
{
AWSError<CoreErrors> error = IoTJobsDataPlaneErrorMapper::GetErrorForName(errorName);
if(error.GetErrorType() != CoreErrors::UNKNOWN)
{
return error;
}
return AWSErrorMarshaller::FindErrorByName(errorName);
}

View File

@@ -0,0 +1,60 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/core/client/AWSError.h>
#include <aws/core/utils/HashingUtils.h>
#include <aws/iot-jobs-data/IoTJobsDataPlaneErrors.h>
#include <aws/iot-jobs-data/model/ThrottlingException.h>
using namespace Aws::Client;
using namespace Aws::Utils;
using namespace Aws::IoTJobsDataPlane;
using namespace Aws::IoTJobsDataPlane::Model;
namespace Aws
{
namespace IoTJobsDataPlane
{
template<> AWS_IOTJOBSDATAPLANE_API ThrottlingException IoTJobsDataPlaneError::GetModeledError()
{
assert(this->GetErrorType() == IoTJobsDataPlaneErrors::THROTTLING);
return ThrottlingException(this->GetJsonPayload().View());
}
namespace IoTJobsDataPlaneErrorMapper
{
static const int TERMINAL_STATE_HASH = HashingUtils::HashString("TerminalStateException");
static const int INVALID_REQUEST_HASH = HashingUtils::HashString("InvalidRequestException");
static const int CERTIFICATE_VALIDATION_HASH = HashingUtils::HashString("CertificateValidationException");
static const int INVALID_STATE_TRANSITION_HASH = HashingUtils::HashString("InvalidStateTransitionException");
AWSError<CoreErrors> GetErrorForName(const char* errorName)
{
int hashCode = HashingUtils::HashString(errorName);
if (hashCode == TERMINAL_STATE_HASH)
{
return AWSError<CoreErrors>(static_cast<CoreErrors>(IoTJobsDataPlaneErrors::TERMINAL_STATE), false);
}
else if (hashCode == INVALID_REQUEST_HASH)
{
return AWSError<CoreErrors>(static_cast<CoreErrors>(IoTJobsDataPlaneErrors::INVALID_REQUEST), false);
}
else if (hashCode == CERTIFICATE_VALIDATION_HASH)
{
return AWSError<CoreErrors>(static_cast<CoreErrors>(IoTJobsDataPlaneErrors::CERTIFICATE_VALIDATION), false);
}
else if (hashCode == INVALID_STATE_TRANSITION_HASH)
{
return AWSError<CoreErrors>(static_cast<CoreErrors>(IoTJobsDataPlaneErrors::INVALID_STATE_TRANSITION), false);
}
return AWSError<CoreErrors>(CoreErrors::UNKNOWN, false);
}
} // namespace IoTJobsDataPlaneErrorMapper
} // namespace IoTJobsDataPlane
} // namespace Aws

View File

@@ -0,0 +1,53 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/iot-jobs-data/model/DescribeJobExecutionRequest.h>
#include <aws/core/utils/json/JsonSerializer.h>
#include <aws/core/http/URI.h>
#include <aws/core/utils/memory/stl/AWSStringStream.h>
#include <utility>
using namespace Aws::IoTJobsDataPlane::Model;
using namespace Aws::Utils::Json;
using namespace Aws::Utils;
using namespace Aws::Http;
DescribeJobExecutionRequest::DescribeJobExecutionRequest() :
m_jobIdHasBeenSet(false),
m_thingNameHasBeenSet(false),
m_includeJobDocument(false),
m_includeJobDocumentHasBeenSet(false),
m_executionNumber(0),
m_executionNumberHasBeenSet(false)
{
}
Aws::String DescribeJobExecutionRequest::SerializePayload() const
{
return {};
}
void DescribeJobExecutionRequest::AddQueryStringParameters(URI& uri) const
{
Aws::StringStream ss;
if(m_includeJobDocumentHasBeenSet)
{
ss << m_includeJobDocument;
uri.AddQueryStringParameter("includeJobDocument", ss.str());
ss.str("");
}
if(m_executionNumberHasBeenSet)
{
ss << m_executionNumber;
uri.AddQueryStringParameter("executionNumber", ss.str());
ss.str("");
}
}

View File

@@ -0,0 +1,40 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/iot-jobs-data/model/DescribeJobExecutionResult.h>
#include <aws/core/utils/json/JsonSerializer.h>
#include <aws/core/AmazonWebServiceResult.h>
#include <aws/core/utils/StringUtils.h>
#include <aws/core/utils/UnreferencedParam.h>
#include <utility>
using namespace Aws::IoTJobsDataPlane::Model;
using namespace Aws::Utils::Json;
using namespace Aws::Utils;
using namespace Aws;
DescribeJobExecutionResult::DescribeJobExecutionResult()
{
}
DescribeJobExecutionResult::DescribeJobExecutionResult(const Aws::AmazonWebServiceResult<JsonValue>& result)
{
*this = result;
}
DescribeJobExecutionResult& DescribeJobExecutionResult::operator =(const Aws::AmazonWebServiceResult<JsonValue>& result)
{
JsonView jsonValue = result.GetPayload().View();
if(jsonValue.ValueExists("execution"))
{
m_execution = jsonValue.GetObject("execution");
}
return *this;
}

View File

@@ -0,0 +1,27 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/iot-jobs-data/model/GetPendingJobExecutionsRequest.h>
#include <aws/core/utils/json/JsonSerializer.h>
#include <utility>
using namespace Aws::IoTJobsDataPlane::Model;
using namespace Aws::Utils::Json;
using namespace Aws::Utils;
GetPendingJobExecutionsRequest::GetPendingJobExecutionsRequest() :
m_thingNameHasBeenSet(false)
{
}
Aws::String GetPendingJobExecutionsRequest::SerializePayload() const
{
return {};
}

View File

@@ -0,0 +1,52 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/iot-jobs-data/model/GetPendingJobExecutionsResult.h>
#include <aws/core/utils/json/JsonSerializer.h>
#include <aws/core/AmazonWebServiceResult.h>
#include <aws/core/utils/StringUtils.h>
#include <aws/core/utils/UnreferencedParam.h>
#include <utility>
using namespace Aws::IoTJobsDataPlane::Model;
using namespace Aws::Utils::Json;
using namespace Aws::Utils;
using namespace Aws;
GetPendingJobExecutionsResult::GetPendingJobExecutionsResult()
{
}
GetPendingJobExecutionsResult::GetPendingJobExecutionsResult(const Aws::AmazonWebServiceResult<JsonValue>& result)
{
*this = result;
}
GetPendingJobExecutionsResult& GetPendingJobExecutionsResult::operator =(const Aws::AmazonWebServiceResult<JsonValue>& result)
{
JsonView jsonValue = result.GetPayload().View();
if(jsonValue.ValueExists("inProgressJobs"))
{
Array<JsonView> inProgressJobsJsonList = jsonValue.GetArray("inProgressJobs");
for(unsigned inProgressJobsIndex = 0; inProgressJobsIndex < inProgressJobsJsonList.GetLength(); ++inProgressJobsIndex)
{
m_inProgressJobs.push_back(inProgressJobsJsonList[inProgressJobsIndex].AsObject());
}
}
if(jsonValue.ValueExists("queuedJobs"))
{
Array<JsonView> queuedJobsJsonList = jsonValue.GetArray("queuedJobs");
for(unsigned queuedJobsIndex = 0; queuedJobsIndex < queuedJobsJsonList.GetLength(); ++queuedJobsIndex)
{
m_queuedJobs.push_back(queuedJobsJsonList[queuedJobsIndex].AsObject());
}
}
return *this;
}

View File

@@ -0,0 +1,230 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/iot-jobs-data/model/JobExecution.h>
#include <aws/core/utils/json/JsonSerializer.h>
#include <utility>
using namespace Aws::Utils::Json;
using namespace Aws::Utils;
namespace Aws
{
namespace IoTJobsDataPlane
{
namespace Model
{
JobExecution::JobExecution() :
m_jobIdHasBeenSet(false),
m_thingNameHasBeenSet(false),
m_status(JobExecutionStatus::NOT_SET),
m_statusHasBeenSet(false),
m_statusDetailsHasBeenSet(false),
m_queuedAt(0),
m_queuedAtHasBeenSet(false),
m_startedAt(0),
m_startedAtHasBeenSet(false),
m_lastUpdatedAt(0),
m_lastUpdatedAtHasBeenSet(false),
m_approximateSecondsBeforeTimedOut(0),
m_approximateSecondsBeforeTimedOutHasBeenSet(false),
m_versionNumber(0),
m_versionNumberHasBeenSet(false),
m_executionNumber(0),
m_executionNumberHasBeenSet(false),
m_jobDocumentHasBeenSet(false)
{
}
JobExecution::JobExecution(JsonView jsonValue) :
m_jobIdHasBeenSet(false),
m_thingNameHasBeenSet(false),
m_status(JobExecutionStatus::NOT_SET),
m_statusHasBeenSet(false),
m_statusDetailsHasBeenSet(false),
m_queuedAt(0),
m_queuedAtHasBeenSet(false),
m_startedAt(0),
m_startedAtHasBeenSet(false),
m_lastUpdatedAt(0),
m_lastUpdatedAtHasBeenSet(false),
m_approximateSecondsBeforeTimedOut(0),
m_approximateSecondsBeforeTimedOutHasBeenSet(false),
m_versionNumber(0),
m_versionNumberHasBeenSet(false),
m_executionNumber(0),
m_executionNumberHasBeenSet(false),
m_jobDocumentHasBeenSet(false)
{
*this = jsonValue;
}
JobExecution& JobExecution::operator =(JsonView jsonValue)
{
if(jsonValue.ValueExists("jobId"))
{
m_jobId = jsonValue.GetString("jobId");
m_jobIdHasBeenSet = true;
}
if(jsonValue.ValueExists("thingName"))
{
m_thingName = jsonValue.GetString("thingName");
m_thingNameHasBeenSet = true;
}
if(jsonValue.ValueExists("status"))
{
m_status = JobExecutionStatusMapper::GetJobExecutionStatusForName(jsonValue.GetString("status"));
m_statusHasBeenSet = true;
}
if(jsonValue.ValueExists("statusDetails"))
{
Aws::Map<Aws::String, JsonView> statusDetailsJsonMap = jsonValue.GetObject("statusDetails").GetAllObjects();
for(auto& statusDetailsItem : statusDetailsJsonMap)
{
m_statusDetails[statusDetailsItem.first] = statusDetailsItem.second.AsString();
}
m_statusDetailsHasBeenSet = true;
}
if(jsonValue.ValueExists("queuedAt"))
{
m_queuedAt = jsonValue.GetInt64("queuedAt");
m_queuedAtHasBeenSet = true;
}
if(jsonValue.ValueExists("startedAt"))
{
m_startedAt = jsonValue.GetInt64("startedAt");
m_startedAtHasBeenSet = true;
}
if(jsonValue.ValueExists("lastUpdatedAt"))
{
m_lastUpdatedAt = jsonValue.GetInt64("lastUpdatedAt");
m_lastUpdatedAtHasBeenSet = true;
}
if(jsonValue.ValueExists("approximateSecondsBeforeTimedOut"))
{
m_approximateSecondsBeforeTimedOut = jsonValue.GetInt64("approximateSecondsBeforeTimedOut");
m_approximateSecondsBeforeTimedOutHasBeenSet = true;
}
if(jsonValue.ValueExists("versionNumber"))
{
m_versionNumber = jsonValue.GetInt64("versionNumber");
m_versionNumberHasBeenSet = true;
}
if(jsonValue.ValueExists("executionNumber"))
{
m_executionNumber = jsonValue.GetInt64("executionNumber");
m_executionNumberHasBeenSet = true;
}
if(jsonValue.ValueExists("jobDocument"))
{
m_jobDocument = jsonValue.GetString("jobDocument");
m_jobDocumentHasBeenSet = true;
}
return *this;
}
JsonValue JobExecution::Jsonize() const
{
JsonValue payload;
if(m_jobIdHasBeenSet)
{
payload.WithString("jobId", m_jobId);
}
if(m_thingNameHasBeenSet)
{
payload.WithString("thingName", m_thingName);
}
if(m_statusHasBeenSet)
{
payload.WithString("status", JobExecutionStatusMapper::GetNameForJobExecutionStatus(m_status));
}
if(m_statusDetailsHasBeenSet)
{
JsonValue statusDetailsJsonMap;
for(auto& statusDetailsItem : m_statusDetails)
{
statusDetailsJsonMap.WithString(statusDetailsItem.first, statusDetailsItem.second);
}
payload.WithObject("statusDetails", std::move(statusDetailsJsonMap));
}
if(m_queuedAtHasBeenSet)
{
payload.WithInt64("queuedAt", m_queuedAt);
}
if(m_startedAtHasBeenSet)
{
payload.WithInt64("startedAt", m_startedAt);
}
if(m_lastUpdatedAtHasBeenSet)
{
payload.WithInt64("lastUpdatedAt", m_lastUpdatedAt);
}
if(m_approximateSecondsBeforeTimedOutHasBeenSet)
{
payload.WithInt64("approximateSecondsBeforeTimedOut", m_approximateSecondsBeforeTimedOut);
}
if(m_versionNumberHasBeenSet)
{
payload.WithInt64("versionNumber", m_versionNumber);
}
if(m_executionNumberHasBeenSet)
{
payload.WithInt64("executionNumber", m_executionNumber);
}
if(m_jobDocumentHasBeenSet)
{
payload.WithString("jobDocument", m_jobDocument);
}
return payload;
}
} // namespace Model
} // namespace IoTJobsDataPlane
} // namespace Aws

View File

@@ -0,0 +1,100 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/iot-jobs-data/model/JobExecutionState.h>
#include <aws/core/utils/json/JsonSerializer.h>
#include <utility>
using namespace Aws::Utils::Json;
using namespace Aws::Utils;
namespace Aws
{
namespace IoTJobsDataPlane
{
namespace Model
{
JobExecutionState::JobExecutionState() :
m_status(JobExecutionStatus::NOT_SET),
m_statusHasBeenSet(false),
m_statusDetailsHasBeenSet(false),
m_versionNumber(0),
m_versionNumberHasBeenSet(false)
{
}
JobExecutionState::JobExecutionState(JsonView jsonValue) :
m_status(JobExecutionStatus::NOT_SET),
m_statusHasBeenSet(false),
m_statusDetailsHasBeenSet(false),
m_versionNumber(0),
m_versionNumberHasBeenSet(false)
{
*this = jsonValue;
}
JobExecutionState& JobExecutionState::operator =(JsonView jsonValue)
{
if(jsonValue.ValueExists("status"))
{
m_status = JobExecutionStatusMapper::GetJobExecutionStatusForName(jsonValue.GetString("status"));
m_statusHasBeenSet = true;
}
if(jsonValue.ValueExists("statusDetails"))
{
Aws::Map<Aws::String, JsonView> statusDetailsJsonMap = jsonValue.GetObject("statusDetails").GetAllObjects();
for(auto& statusDetailsItem : statusDetailsJsonMap)
{
m_statusDetails[statusDetailsItem.first] = statusDetailsItem.second.AsString();
}
m_statusDetailsHasBeenSet = true;
}
if(jsonValue.ValueExists("versionNumber"))
{
m_versionNumber = jsonValue.GetInt64("versionNumber");
m_versionNumberHasBeenSet = true;
}
return *this;
}
JsonValue JobExecutionState::Jsonize() const
{
JsonValue payload;
if(m_statusHasBeenSet)
{
payload.WithString("status", JobExecutionStatusMapper::GetNameForJobExecutionStatus(m_status));
}
if(m_statusDetailsHasBeenSet)
{
JsonValue statusDetailsJsonMap;
for(auto& statusDetailsItem : m_statusDetails)
{
statusDetailsJsonMap.WithString(statusDetailsItem.first, statusDetailsItem.second);
}
payload.WithObject("statusDetails", std::move(statusDetailsJsonMap));
}
if(m_versionNumberHasBeenSet)
{
payload.WithInt64("versionNumber", m_versionNumber);
}
return payload;
}
} // namespace Model
} // namespace IoTJobsDataPlane
} // namespace Aws

View File

@@ -0,0 +1,112 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/iot-jobs-data/model/JobExecutionStatus.h>
#include <aws/core/utils/HashingUtils.h>
#include <aws/core/Globals.h>
#include <aws/core/utils/EnumParseOverflowContainer.h>
using namespace Aws::Utils;
namespace Aws
{
namespace IoTJobsDataPlane
{
namespace Model
{
namespace JobExecutionStatusMapper
{
static const int QUEUED_HASH = HashingUtils::HashString("QUEUED");
static const int IN_PROGRESS_HASH = HashingUtils::HashString("IN_PROGRESS");
static const int SUCCEEDED_HASH = HashingUtils::HashString("SUCCEEDED");
static const int FAILED_HASH = HashingUtils::HashString("FAILED");
static const int TIMED_OUT_HASH = HashingUtils::HashString("TIMED_OUT");
static const int REJECTED_HASH = HashingUtils::HashString("REJECTED");
static const int REMOVED_HASH = HashingUtils::HashString("REMOVED");
static const int CANCELED_HASH = HashingUtils::HashString("CANCELED");
JobExecutionStatus GetJobExecutionStatusForName(const Aws::String& name)
{
int hashCode = HashingUtils::HashString(name.c_str());
if (hashCode == QUEUED_HASH)
{
return JobExecutionStatus::QUEUED;
}
else if (hashCode == IN_PROGRESS_HASH)
{
return JobExecutionStatus::IN_PROGRESS;
}
else if (hashCode == SUCCEEDED_HASH)
{
return JobExecutionStatus::SUCCEEDED;
}
else if (hashCode == FAILED_HASH)
{
return JobExecutionStatus::FAILED;
}
else if (hashCode == TIMED_OUT_HASH)
{
return JobExecutionStatus::TIMED_OUT;
}
else if (hashCode == REJECTED_HASH)
{
return JobExecutionStatus::REJECTED;
}
else if (hashCode == REMOVED_HASH)
{
return JobExecutionStatus::REMOVED;
}
else if (hashCode == CANCELED_HASH)
{
return JobExecutionStatus::CANCELED;
}
EnumParseOverflowContainer* overflowContainer = Aws::GetEnumOverflowContainer();
if(overflowContainer)
{
overflowContainer->StoreOverflow(hashCode, name);
return static_cast<JobExecutionStatus>(hashCode);
}
return JobExecutionStatus::NOT_SET;
}
Aws::String GetNameForJobExecutionStatus(JobExecutionStatus enumValue)
{
switch(enumValue)
{
case JobExecutionStatus::QUEUED:
return "QUEUED";
case JobExecutionStatus::IN_PROGRESS:
return "IN_PROGRESS";
case JobExecutionStatus::SUCCEEDED:
return "SUCCEEDED";
case JobExecutionStatus::FAILED:
return "FAILED";
case JobExecutionStatus::TIMED_OUT:
return "TIMED_OUT";
case JobExecutionStatus::REJECTED:
return "REJECTED";
case JobExecutionStatus::REMOVED:
return "REMOVED";
case JobExecutionStatus::CANCELED:
return "CANCELED";
default:
EnumParseOverflowContainer* overflowContainer = Aws::GetEnumOverflowContainer();
if(overflowContainer)
{
return overflowContainer->RetrieveOverflow(static_cast<int>(enumValue));
}
return {};
}
}
} // namespace JobExecutionStatusMapper
} // namespace Model
} // namespace IoTJobsDataPlane
} // namespace Aws

View File

@@ -0,0 +1,144 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/iot-jobs-data/model/JobExecutionSummary.h>
#include <aws/core/utils/json/JsonSerializer.h>
#include <utility>
using namespace Aws::Utils::Json;
using namespace Aws::Utils;
namespace Aws
{
namespace IoTJobsDataPlane
{
namespace Model
{
JobExecutionSummary::JobExecutionSummary() :
m_jobIdHasBeenSet(false),
m_queuedAt(0),
m_queuedAtHasBeenSet(false),
m_startedAt(0),
m_startedAtHasBeenSet(false),
m_lastUpdatedAt(0),
m_lastUpdatedAtHasBeenSet(false),
m_versionNumber(0),
m_versionNumberHasBeenSet(false),
m_executionNumber(0),
m_executionNumberHasBeenSet(false)
{
}
JobExecutionSummary::JobExecutionSummary(JsonView jsonValue) :
m_jobIdHasBeenSet(false),
m_queuedAt(0),
m_queuedAtHasBeenSet(false),
m_startedAt(0),
m_startedAtHasBeenSet(false),
m_lastUpdatedAt(0),
m_lastUpdatedAtHasBeenSet(false),
m_versionNumber(0),
m_versionNumberHasBeenSet(false),
m_executionNumber(0),
m_executionNumberHasBeenSet(false)
{
*this = jsonValue;
}
JobExecutionSummary& JobExecutionSummary::operator =(JsonView jsonValue)
{
if(jsonValue.ValueExists("jobId"))
{
m_jobId = jsonValue.GetString("jobId");
m_jobIdHasBeenSet = true;
}
if(jsonValue.ValueExists("queuedAt"))
{
m_queuedAt = jsonValue.GetInt64("queuedAt");
m_queuedAtHasBeenSet = true;
}
if(jsonValue.ValueExists("startedAt"))
{
m_startedAt = jsonValue.GetInt64("startedAt");
m_startedAtHasBeenSet = true;
}
if(jsonValue.ValueExists("lastUpdatedAt"))
{
m_lastUpdatedAt = jsonValue.GetInt64("lastUpdatedAt");
m_lastUpdatedAtHasBeenSet = true;
}
if(jsonValue.ValueExists("versionNumber"))
{
m_versionNumber = jsonValue.GetInt64("versionNumber");
m_versionNumberHasBeenSet = true;
}
if(jsonValue.ValueExists("executionNumber"))
{
m_executionNumber = jsonValue.GetInt64("executionNumber");
m_executionNumberHasBeenSet = true;
}
return *this;
}
JsonValue JobExecutionSummary::Jsonize() const
{
JsonValue payload;
if(m_jobIdHasBeenSet)
{
payload.WithString("jobId", m_jobId);
}
if(m_queuedAtHasBeenSet)
{
payload.WithInt64("queuedAt", m_queuedAt);
}
if(m_startedAtHasBeenSet)
{
payload.WithInt64("startedAt", m_startedAt);
}
if(m_lastUpdatedAtHasBeenSet)
{
payload.WithInt64("lastUpdatedAt", m_lastUpdatedAt);
}
if(m_versionNumberHasBeenSet)
{
payload.WithInt64("versionNumber", m_versionNumber);
}
if(m_executionNumberHasBeenSet)
{
payload.WithInt64("executionNumber", m_executionNumber);
}
return payload;
}
} // namespace Model
} // namespace IoTJobsDataPlane
} // namespace Aws

View File

@@ -0,0 +1,49 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/iot-jobs-data/model/StartNextPendingJobExecutionRequest.h>
#include <aws/core/utils/json/JsonSerializer.h>
#include <utility>
using namespace Aws::IoTJobsDataPlane::Model;
using namespace Aws::Utils::Json;
using namespace Aws::Utils;
StartNextPendingJobExecutionRequest::StartNextPendingJobExecutionRequest() :
m_thingNameHasBeenSet(false),
m_statusDetailsHasBeenSet(false),
m_stepTimeoutInMinutes(0),
m_stepTimeoutInMinutesHasBeenSet(false)
{
}
Aws::String StartNextPendingJobExecutionRequest::SerializePayload() const
{
JsonValue payload;
if(m_statusDetailsHasBeenSet)
{
JsonValue statusDetailsJsonMap;
for(auto& statusDetailsItem : m_statusDetails)
{
statusDetailsJsonMap.WithString(statusDetailsItem.first, statusDetailsItem.second);
}
payload.WithObject("statusDetails", std::move(statusDetailsJsonMap));
}
if(m_stepTimeoutInMinutesHasBeenSet)
{
payload.WithInt64("stepTimeoutInMinutes", m_stepTimeoutInMinutes);
}
return payload.View().WriteReadable();
}

View File

@@ -0,0 +1,40 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/iot-jobs-data/model/StartNextPendingJobExecutionResult.h>
#include <aws/core/utils/json/JsonSerializer.h>
#include <aws/core/AmazonWebServiceResult.h>
#include <aws/core/utils/StringUtils.h>
#include <aws/core/utils/UnreferencedParam.h>
#include <utility>
using namespace Aws::IoTJobsDataPlane::Model;
using namespace Aws::Utils::Json;
using namespace Aws::Utils;
using namespace Aws;
StartNextPendingJobExecutionResult::StartNextPendingJobExecutionResult()
{
}
StartNextPendingJobExecutionResult::StartNextPendingJobExecutionResult(const Aws::AmazonWebServiceResult<JsonValue>& result)
{
*this = result;
}
StartNextPendingJobExecutionResult& StartNextPendingJobExecutionResult::operator =(const Aws::AmazonWebServiceResult<JsonValue>& result)
{
JsonView jsonValue = result.GetPayload().View();
if(jsonValue.ValueExists("execution"))
{
m_execution = jsonValue.GetObject("execution");
}
return *this;
}

View File

@@ -0,0 +1,73 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/iot-jobs-data/model/ThrottlingException.h>
#include <aws/core/utils/json/JsonSerializer.h>
#include <aws/core/utils/HashingUtils.h>
#include <utility>
using namespace Aws::Utils::Json;
using namespace Aws::Utils;
namespace Aws
{
namespace IoTJobsDataPlane
{
namespace Model
{
ThrottlingException::ThrottlingException() :
m_messageHasBeenSet(false),
m_payloadHasBeenSet(false)
{
}
ThrottlingException::ThrottlingException(JsonView jsonValue) :
m_messageHasBeenSet(false),
m_payloadHasBeenSet(false)
{
*this = jsonValue;
}
ThrottlingException& ThrottlingException::operator =(JsonView jsonValue)
{
if(jsonValue.ValueExists("message"))
{
m_message = jsonValue.GetString("message");
m_messageHasBeenSet = true;
}
if(jsonValue.ValueExists("payload"))
{
m_payload = HashingUtils::Base64Decode(jsonValue.GetString("payload"));
m_payloadHasBeenSet = true;
}
return *this;
}
JsonValue ThrottlingException::Jsonize() const
{
JsonValue payload;
if(m_messageHasBeenSet)
{
payload.WithString("message", m_message);
}
if(m_payloadHasBeenSet)
{
payload.WithString("payload", HashingUtils::Base64Encode(m_payload));
}
return payload;
}
} // namespace Model
} // namespace IoTJobsDataPlane
} // namespace Aws

View File

@@ -0,0 +1,89 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/iot-jobs-data/model/UpdateJobExecutionRequest.h>
#include <aws/core/utils/json/JsonSerializer.h>
#include <utility>
using namespace Aws::IoTJobsDataPlane::Model;
using namespace Aws::Utils::Json;
using namespace Aws::Utils;
UpdateJobExecutionRequest::UpdateJobExecutionRequest() :
m_jobIdHasBeenSet(false),
m_thingNameHasBeenSet(false),
m_status(JobExecutionStatus::NOT_SET),
m_statusHasBeenSet(false),
m_statusDetailsHasBeenSet(false),
m_stepTimeoutInMinutes(0),
m_stepTimeoutInMinutesHasBeenSet(false),
m_expectedVersion(0),
m_expectedVersionHasBeenSet(false),
m_includeJobExecutionState(false),
m_includeJobExecutionStateHasBeenSet(false),
m_includeJobDocument(false),
m_includeJobDocumentHasBeenSet(false),
m_executionNumber(0),
m_executionNumberHasBeenSet(false)
{
}
Aws::String UpdateJobExecutionRequest::SerializePayload() const
{
JsonValue payload;
if(m_statusHasBeenSet)
{
payload.WithString("status", JobExecutionStatusMapper::GetNameForJobExecutionStatus(m_status));
}
if(m_statusDetailsHasBeenSet)
{
JsonValue statusDetailsJsonMap;
for(auto& statusDetailsItem : m_statusDetails)
{
statusDetailsJsonMap.WithString(statusDetailsItem.first, statusDetailsItem.second);
}
payload.WithObject("statusDetails", std::move(statusDetailsJsonMap));
}
if(m_stepTimeoutInMinutesHasBeenSet)
{
payload.WithInt64("stepTimeoutInMinutes", m_stepTimeoutInMinutes);
}
if(m_expectedVersionHasBeenSet)
{
payload.WithInt64("expectedVersion", m_expectedVersion);
}
if(m_includeJobExecutionStateHasBeenSet)
{
payload.WithBool("includeJobExecutionState", m_includeJobExecutionState);
}
if(m_includeJobDocumentHasBeenSet)
{
payload.WithBool("includeJobDocument", m_includeJobDocument);
}
if(m_executionNumberHasBeenSet)
{
payload.WithInt64("executionNumber", m_executionNumber);
}
return payload.View().WriteReadable();
}

View File

@@ -0,0 +1,46 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/iot-jobs-data/model/UpdateJobExecutionResult.h>
#include <aws/core/utils/json/JsonSerializer.h>
#include <aws/core/AmazonWebServiceResult.h>
#include <aws/core/utils/StringUtils.h>
#include <aws/core/utils/UnreferencedParam.h>
#include <utility>
using namespace Aws::IoTJobsDataPlane::Model;
using namespace Aws::Utils::Json;
using namespace Aws::Utils;
using namespace Aws;
UpdateJobExecutionResult::UpdateJobExecutionResult()
{
}
UpdateJobExecutionResult::UpdateJobExecutionResult(const Aws::AmazonWebServiceResult<JsonValue>& result)
{
*this = result;
}
UpdateJobExecutionResult& UpdateJobExecutionResult::operator =(const Aws::AmazonWebServiceResult<JsonValue>& result)
{
JsonView jsonValue = result.GetPayload().View();
if(jsonValue.ValueExists("executionState"))
{
m_executionState = jsonValue.GetObject("executionState");
}
if(jsonValue.ValueExists("jobDocument"))
{
m_jobDocument = jsonValue.GetString("jobDocument");
}
return *this;
}