Skip to content

Commit b20cb72

Browse files
authored
Waiter codegen plugin + waiters (#3752)
* Updated waiter template to accept a templated PathMatcher per acceptor rather than per waiter * Waiter codegen project * Waiter codegen tests * Update crtp client inheritance & python script for smithy codegen * Add proper state chaining in Waiter.h * Add mapping for lost c2j errors to error code * Updated clients * Add namespace mapping to WaiterCodeGenPlugin * generate Waiter.h for clients that don't have waiters modeled * Seperate different acceptors into seperate structs/classes * Update codegen to use new Acceptor structs * Return Optional<Shape> in private methods of CollectionElementTypeResolver * Add userAgent metrics for waiters * Updated waiters * Transition the waiter to the failure state if none of the acceptors are matched and an error was encountered * change std::vector to Aws::Vector (why do i forget this everytime) * Updated waiter files * Include handling for smithy 1.0 enum modeling (string shape with enum trait) * Resolve cpp type from FilterPredicateEmitter for inner types instead of auto * Updated waiters * Resolve enum for filterOperandEmitter paths * Fix type resolution for map types * Empty waiter generation for legacy services (no smithy model) * Add medialive XXXSdkResult.h mappings * Enum resolution for ScalarEmitters (OR edge case) * dont generate waiters for deprecated operations * fix .template dependent compilation error * Refactor client integ tests that use polling logic to use waiters now * Fix windows ambigious lambda constructor issue * Explicitly define bool return type for pathMatcher lambdas * Updated waiters * Fix map collision for waiter name's that are generated and stored * Updated waiters * Fix namespace mapping default to be '{}' (dev purposes) * Remove && for pathacceptor argument * cast std::count_if to size_t since it returns a signed value * Updated waiters * ONLY static cast when we are comparing to a collection.size() * Updated waiters
1 parent c9dd965 commit b20cb72

File tree

883 files changed

+23765
-604
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

883 files changed

+23765
-604
lines changed

generated/src/aws-cpp-sdk-AWSMigrationHub/include/aws/AWSMigrationHub/MigrationHubClient.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#pragma once
77
#include <aws/AWSMigrationHub/MigrationHubPaginationBase.h>
88
#include <aws/AWSMigrationHub/MigrationHubServiceClientModel.h>
9+
#include <aws/AWSMigrationHub/MigrationHubWaiter.h>
910
#include <aws/AWSMigrationHub/MigrationHub_EXPORTS.h>
1011
#include <aws/core/client/AWSClient.h>
1112
#include <aws/core/client/AWSClientAsyncCRTP.h>
@@ -24,7 +25,8 @@ namespace MigrationHub {
2425
*/
2526
class AWS_MIGRATIONHUB_API MigrationHubClient : public Aws::Client::AWSJsonClient,
2627
public Aws::Client::ClientWithAsyncTemplateMethods<MigrationHubClient>,
27-
public MigrationHubPaginationBase<MigrationHubClient> {
28+
public MigrationHubPaginationBase<MigrationHubClient>,
29+
public MigrationHubWaiter<MigrationHubClient> {
2830
public:
2931
typedef Aws::Client::AWSJsonClient BASECLASS;
3032
static const char* GetServiceName();
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0.
4+
*/
5+
6+
#pragma once
7+
#include <aws/AWSMigrationHub/MigrationHubClient.h>
8+
#include <aws/core/utils/Waiter.h>
9+
#include <aws/core/utils/memory/AWSMemory.h>
10+
11+
#include <algorithm>
12+
13+
namespace Aws {
14+
namespace MigrationHub {
15+
16+
template <typename DerivedClient = MigrationHubClient>
17+
class MigrationHubWaiter {
18+
public:
19+
};
20+
} // namespace MigrationHub
21+
} // namespace Aws

generated/src/aws-cpp-sdk-accessanalyzer/include/aws/accessanalyzer/AccessAnalyzerClient.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#pragma once
77
#include <aws/accessanalyzer/AccessAnalyzerPaginationBase.h>
88
#include <aws/accessanalyzer/AccessAnalyzerServiceClientModel.h>
9+
#include <aws/accessanalyzer/AccessAnalyzerWaiter.h>
910
#include <aws/accessanalyzer/AccessAnalyzer_EXPORTS.h>
1011
#include <aws/core/client/AWSClient.h>
1112
#include <aws/core/client/AWSClientAsyncCRTP.h>
@@ -49,7 +50,8 @@ namespace AccessAnalyzer {
4950
*/
5051
class AWS_ACCESSANALYZER_API AccessAnalyzerClient : public Aws::Client::AWSJsonClient,
5152
public Aws::Client::ClientWithAsyncTemplateMethods<AccessAnalyzerClient>,
52-
public AccessAnalyzerPaginationBase<AccessAnalyzerClient> {
53+
public AccessAnalyzerPaginationBase<AccessAnalyzerClient>,
54+
public AccessAnalyzerWaiter<AccessAnalyzerClient> {
5355
public:
5456
typedef Aws::Client::AWSJsonClient BASECLASS;
5557
static const char* GetServiceName();
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0.
4+
*/
5+
6+
#pragma once
7+
#include <aws/accessanalyzer/AccessAnalyzerClient.h>
8+
#include <aws/core/utils/Waiter.h>
9+
#include <aws/core/utils/memory/AWSMemory.h>
10+
11+
#include <algorithm>
12+
13+
namespace Aws {
14+
namespace AccessAnalyzer {
15+
16+
template <typename DerivedClient = AccessAnalyzerClient>
17+
class AccessAnalyzerWaiter {
18+
public:
19+
};
20+
} // namespace AccessAnalyzer
21+
} // namespace Aws

generated/src/aws-cpp-sdk-account/include/aws/account/AccountClient.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#pragma once
77
#include <aws/account/AccountPaginationBase.h>
88
#include <aws/account/AccountServiceClientModel.h>
9+
#include <aws/account/AccountWaiter.h>
910
#include <aws/account/Account_EXPORTS.h>
1011
#include <aws/core/client/AWSClient.h>
1112
#include <aws/core/client/AWSClientAsyncCRTP.h>
@@ -19,7 +20,8 @@ namespace Account {
1920
*/
2021
class AWS_ACCOUNT_API AccountClient : public Aws::Client::AWSJsonClient,
2122
public Aws::Client::ClientWithAsyncTemplateMethods<AccountClient>,
22-
public AccountPaginationBase<AccountClient> {
23+
public AccountPaginationBase<AccountClient>,
24+
public AccountWaiter<AccountClient> {
2325
public:
2426
typedef Aws::Client::AWSJsonClient BASECLASS;
2527
static const char* GetServiceName();
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0.
4+
*/
5+
6+
#pragma once
7+
#include <aws/account/AccountClient.h>
8+
#include <aws/core/utils/Waiter.h>
9+
#include <aws/core/utils/memory/AWSMemory.h>
10+
11+
#include <algorithm>
12+
13+
namespace Aws {
14+
namespace Account {
15+
16+
template <typename DerivedClient = AccountClient>
17+
class AccountWaiter {
18+
public:
19+
};
20+
} // namespace Account
21+
} // namespace Aws

generated/src/aws-cpp-sdk-acm-pca/include/aws/acm-pca/ACMPCAClient.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#pragma once
77
#include <aws/acm-pca/ACMPCAPaginationBase.h>
88
#include <aws/acm-pca/ACMPCAServiceClientModel.h>
9+
#include <aws/acm-pca/ACMPCAWaiter.h>
910
#include <aws/acm-pca/ACMPCA_EXPORTS.h>
1011
#include <aws/core/client/AWSClient.h>
1112
#include <aws/core/client/AWSClientAsyncCRTP.h>
@@ -40,7 +41,8 @@ namespace ACMPCA {
4041
*/
4142
class AWS_ACMPCA_API ACMPCAClient : public Aws::Client::AWSJsonClient,
4243
public Aws::Client::ClientWithAsyncTemplateMethods<ACMPCAClient>,
43-
public ACMPCAPaginationBase<ACMPCAClient> {
44+
public ACMPCAPaginationBase<ACMPCAClient>,
45+
public ACMPCAWaiter<ACMPCAClient> {
4446
public:
4547
typedef Aws::Client::AWSJsonClient BASECLASS;
4648
static const char* GetServiceName();
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/**
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0.
4+
*/
5+
6+
#pragma once
7+
#include <aws/acm-pca/ACMPCAClient.h>
8+
#include <aws/acm-pca/model/AuditReportStatus.h>
9+
#include <aws/acm-pca/model/DescribeCertificateAuthorityAuditReportRequest.h>
10+
#include <aws/acm-pca/model/DescribeCertificateAuthorityAuditReportResult.h>
11+
#include <aws/acm-pca/model/GetCertificateAuthorityCsrRequest.h>
12+
#include <aws/acm-pca/model/GetCertificateAuthorityCsrResult.h>
13+
#include <aws/acm-pca/model/GetCertificateRequest.h>
14+
#include <aws/acm-pca/model/GetCertificateResult.h>
15+
#include <aws/core/utils/Waiter.h>
16+
#include <aws/core/utils/memory/AWSMemory.h>
17+
18+
#include <algorithm>
19+
20+
namespace Aws {
21+
namespace ACMPCA {
22+
23+
template <typename DerivedClient = ACMPCAClient>
24+
class ACMPCAWaiter {
25+
public:
26+
Aws::Utils::WaiterOutcome<Model::DescribeCertificateAuthorityAuditReportOutcome> WaitUntilAuditReportCreated(
27+
const Model::DescribeCertificateAuthorityAuditReportRequest& request) {
28+
using OutcomeT = Model::DescribeCertificateAuthorityAuditReportOutcome;
29+
using RequestT = Model::DescribeCertificateAuthorityAuditReportRequest;
30+
Aws::Vector<Aws::UniquePtr<Aws::Utils::Acceptor<OutcomeT>>> acceptors;
31+
acceptors.emplace_back(Aws::MakeUnique<Aws::Utils::PathAcceptor<OutcomeT>>(
32+
"AuditReportCreatedWaiter", Aws::Utils::WaiterState::SUCCESS, Aws::String("SUCCESS"),
33+
[](const Model::DescribeCertificateAuthorityAuditReportOutcome& outcome, const Aws::Utils::ExpectedValue& expected) -> bool {
34+
if (!outcome.IsSuccess()) return false;
35+
const auto& result = outcome.GetResult();
36+
return Model::AuditReportStatusMapper::GetNameForAuditReportStatus(result.GetAuditReportStatus()) == expected.get<Aws::String>();
37+
}));
38+
acceptors.emplace_back(Aws::MakeUnique<Aws::Utils::PathAcceptor<OutcomeT>>(
39+
"AuditReportCreatedWaiter", Aws::Utils::WaiterState::FAILURE, Aws::String("FAILED"),
40+
[](const Model::DescribeCertificateAuthorityAuditReportOutcome& outcome, const Aws::Utils::ExpectedValue& expected) -> bool {
41+
if (!outcome.IsSuccess()) return false;
42+
const auto& result = outcome.GetResult();
43+
return Model::AuditReportStatusMapper::GetNameForAuditReportStatus(result.GetAuditReportStatus()) == expected.get<Aws::String>();
44+
}));
45+
acceptors.emplace_back(Aws::MakeUnique<Aws::Utils::ErrorAcceptor<OutcomeT>>(
46+
"AuditReportCreatedWaiter", Aws::Utils::WaiterState::FAILURE, Aws::String("AccessDeniedException")));
47+
48+
auto operation = [this](const RequestT& req) {
49+
return static_cast<DerivedClient*>(this)->DescribeCertificateAuthorityAuditReport(req);
50+
};
51+
Aws::Utils::Waiter<RequestT, OutcomeT> waiter(3, 60, std::move(acceptors), operation, "WaitUntilAuditReportCreated");
52+
return waiter.Wait(request);
53+
}
54+
55+
Aws::Utils::WaiterOutcome<Model::GetCertificateOutcome> WaitUntilCertificateIssued(const Model::GetCertificateRequest& request) {
56+
using OutcomeT = Model::GetCertificateOutcome;
57+
using RequestT = Model::GetCertificateRequest;
58+
Aws::Vector<Aws::UniquePtr<Aws::Utils::Acceptor<OutcomeT>>> acceptors;
59+
acceptors.emplace_back(
60+
Aws::MakeUnique<Aws::Utils::ErrorAcceptor<OutcomeT>>("CertificateIssuedWaiter", Aws::Utils::WaiterState::SUCCESS, false));
61+
acceptors.emplace_back(Aws::MakeUnique<Aws::Utils::ErrorAcceptor<OutcomeT>>("CertificateIssuedWaiter", Aws::Utils::WaiterState::RETRY,
62+
Aws::String("RequestInProgressException")));
63+
acceptors.emplace_back(Aws::MakeUnique<Aws::Utils::ErrorAcceptor<OutcomeT>>("CertificateIssuedWaiter", Aws::Utils::WaiterState::FAILURE,
64+
Aws::String("AccessDeniedException")));
65+
66+
auto operation = [this](const RequestT& req) { return static_cast<DerivedClient*>(this)->GetCertificate(req); };
67+
Aws::Utils::Waiter<RequestT, OutcomeT> waiter(1, 60, std::move(acceptors), operation, "WaitUntilCertificateIssued");
68+
return waiter.Wait(request);
69+
}
70+
71+
Aws::Utils::WaiterOutcome<Model::GetCertificateAuthorityCsrOutcome> WaitUntilCertificateAuthorityCSRCreated(
72+
const Model::GetCertificateAuthorityCsrRequest& request) {
73+
using OutcomeT = Model::GetCertificateAuthorityCsrOutcome;
74+
using RequestT = Model::GetCertificateAuthorityCsrRequest;
75+
Aws::Vector<Aws::UniquePtr<Aws::Utils::Acceptor<OutcomeT>>> acceptors;
76+
acceptors.emplace_back(Aws::MakeUnique<Aws::Utils::ErrorAcceptor<OutcomeT>>("CertificateAuthorityCSRCreatedWaiter",
77+
Aws::Utils::WaiterState::SUCCESS, false));
78+
acceptors.emplace_back(Aws::MakeUnique<Aws::Utils::ErrorAcceptor<OutcomeT>>(
79+
"CertificateAuthorityCSRCreatedWaiter", Aws::Utils::WaiterState::RETRY, Aws::String("RequestInProgressException")));
80+
acceptors.emplace_back(Aws::MakeUnique<Aws::Utils::ErrorAcceptor<OutcomeT>>(
81+
"CertificateAuthorityCSRCreatedWaiter", Aws::Utils::WaiterState::FAILURE, Aws::String("AccessDeniedException")));
82+
83+
auto operation = [this](const RequestT& req) { return static_cast<DerivedClient*>(this)->GetCertificateAuthorityCsr(req); };
84+
Aws::Utils::Waiter<RequestT, OutcomeT> waiter(3, 60, std::move(acceptors), operation, "WaitUntilCertificateAuthorityCSRCreated");
85+
return waiter.Wait(request);
86+
}
87+
};
88+
} // namespace ACMPCA
89+
} // namespace Aws

generated/src/aws-cpp-sdk-acm/include/aws/acm/ACMClient.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#pragma once
77
#include <aws/acm/ACMPaginationBase.h>
88
#include <aws/acm/ACMServiceClientModel.h>
9+
#include <aws/acm/ACMWaiter.h>
910
#include <aws/acm/ACM_EXPORTS.h>
1011
#include <aws/core/client/AWSClient.h>
1112
#include <aws/core/client/AWSClientAsyncCRTP.h>
@@ -23,7 +24,8 @@ namespace ACM {
2324
*/
2425
class AWS_ACM_API ACMClient : public Aws::Client::AWSJsonClient,
2526
public Aws::Client::ClientWithAsyncTemplateMethods<ACMClient>,
26-
public ACMPaginationBase<ACMClient> {
27+
public ACMPaginationBase<ACMClient>,
28+
public ACMWaiter<ACMClient> {
2729
public:
2830
typedef Aws::Client::AWSJsonClient BASECLASS;
2931
static const char* GetServiceName();
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/**
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0.
4+
*/
5+
6+
#pragma once
7+
#include <aws/acm/ACMClient.h>
8+
#include <aws/acm/model/CertificateStatus.h>
9+
#include <aws/acm/model/DescribeCertificateRequest.h>
10+
#include <aws/acm/model/DescribeCertificateResult.h>
11+
#include <aws/acm/model/DomainStatus.h>
12+
#include <aws/core/utils/Waiter.h>
13+
#include <aws/core/utils/memory/AWSMemory.h>
14+
15+
#include <algorithm>
16+
17+
namespace Aws {
18+
namespace ACM {
19+
20+
template <typename DerivedClient = ACMClient>
21+
class ACMWaiter {
22+
public:
23+
Aws::Utils::WaiterOutcome<Model::DescribeCertificateOutcome> WaitUntilCertificateValidated(
24+
const Model::DescribeCertificateRequest& request) {
25+
using OutcomeT = Model::DescribeCertificateOutcome;
26+
using RequestT = Model::DescribeCertificateRequest;
27+
Aws::Vector<Aws::UniquePtr<Aws::Utils::Acceptor<OutcomeT>>> acceptors;
28+
acceptors.emplace_back(Aws::MakeUnique<Aws::Utils::PathAcceptor<OutcomeT>>(
29+
"CertificateValidatedWaiter", Aws::Utils::WaiterState::SUCCESS, Aws::String("SUCCESS"),
30+
[](const Model::DescribeCertificateOutcome& outcome, const Aws::Utils::ExpectedValue& expected) -> bool {
31+
if (!outcome.IsSuccess()) return false;
32+
const auto& result = outcome.GetResult();
33+
return std::all_of(result.GetCertificate().GetDomainValidationOptions().begin(),
34+
result.GetCertificate().GetDomainValidationOptions().end(), [&](const Model::DomainValidation& item) {
35+
return Model::DomainStatusMapper::GetNameForDomainStatus(item.GetValidationStatus()) ==
36+
expected.get<Aws::String>();
37+
});
38+
}));
39+
acceptors.emplace_back(Aws::MakeUnique<Aws::Utils::PathAcceptor<OutcomeT>>(
40+
"CertificateValidatedWaiter", Aws::Utils::WaiterState::RETRY, Aws::String("PENDING_VALIDATION"),
41+
[](const Model::DescribeCertificateOutcome& outcome, const Aws::Utils::ExpectedValue& expected) -> bool {
42+
if (!outcome.IsSuccess()) return false;
43+
const auto& result = outcome.GetResult();
44+
return std::any_of(result.GetCertificate().GetDomainValidationOptions().begin(),
45+
result.GetCertificate().GetDomainValidationOptions().end(), [&](const Model::DomainValidation& item) {
46+
return Model::DomainStatusMapper::GetNameForDomainStatus(item.GetValidationStatus()) ==
47+
expected.get<Aws::String>();
48+
});
49+
}));
50+
acceptors.emplace_back(Aws::MakeUnique<Aws::Utils::PathAcceptor<OutcomeT>>(
51+
"CertificateValidatedWaiter", Aws::Utils::WaiterState::FAILURE, Aws::String("FAILED"),
52+
[](const Model::DescribeCertificateOutcome& outcome, const Aws::Utils::ExpectedValue& expected) -> bool {
53+
if (!outcome.IsSuccess()) return false;
54+
const auto& result = outcome.GetResult();
55+
return Model::CertificateStatusMapper::GetNameForCertificateStatus(result.GetCertificate().GetStatus()) ==
56+
expected.get<Aws::String>();
57+
}));
58+
acceptors.emplace_back(Aws::MakeUnique<Aws::Utils::ErrorAcceptor<OutcomeT>>(
59+
"CertificateValidatedWaiter", Aws::Utils::WaiterState::FAILURE, Aws::String("ResourceNotFoundException")));
60+
61+
auto operation = [this](const RequestT& req) { return static_cast<DerivedClient*>(this)->DescribeCertificate(req); };
62+
Aws::Utils::Waiter<RequestT, OutcomeT> waiter(60, 2, std::move(acceptors), operation, "WaitUntilCertificateValidated");
63+
return waiter.Wait(request);
64+
}
65+
};
66+
} // namespace ACM
67+
} // namespace Aws

0 commit comments

Comments
 (0)