-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Smithy generator for paginator #3690
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
da909ca
61824e5
4aaac87
4074797
06b9191
29d67ab
8d52259
938db88
8b8462b
ecc126a
58410cd
1290407
e9f866b
f180197
e98b05e
2fd43f1
e38cc32
ab3fc21
f38fc51
bd95508
ecac02a
dcbba86
2a8eb0b
666e0ec
13cf71e
53e8658
4ea1230
0ec38e4
345afc3
f4e22b5
deb9baf
2e9ae4d
d20e576
ecbf152
884f98d
c4b4337
d1370ba
ae3eed2
bb8aeb7
1395993
74dc679
b409255
fe3fc77
b5d3706
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| /** | ||
| * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| * SPDX-License-Identifier: Apache-2.0. | ||
| */ | ||
|
|
||
| #pragma once | ||
| #include <aws/core/utils/pagination/Paginator.h> | ||
| #include <aws/dynamodb/DynamoDBClient.h> | ||
| #include <aws/dynamodb/model/ListContributorInsightsPaginationTraits.h> | ||
| #include <aws/dynamodb/model/ListExportsPaginationTraits.h> | ||
| #include <aws/dynamodb/model/ListImportsPaginationTraits.h> | ||
| #include <aws/dynamodb/model/ListTablesPaginationTraits.h> | ||
| #include <aws/dynamodb/model/QueryPaginationTraits.h> | ||
| #include <aws/dynamodb/model/ScanPaginationTraits.h> | ||
|
|
||
| namespace Aws { | ||
| namespace DynamoDB { | ||
|
|
||
| using ListContributorInsightsPaginator = Aws::Utils::Pagination::Paginator<DynamoDBClient, Model::ListContributorInsightsRequest, | ||
| Pagination::ListContributorInsightsPaginationTraits>; | ||
| using ListExportsPaginator = | ||
| Aws::Utils::Pagination::Paginator<DynamoDBClient, Model::ListExportsRequest, Pagination::ListExportsPaginationTraits>; | ||
| using ListImportsPaginator = | ||
| Aws::Utils::Pagination::Paginator<DynamoDBClient, Model::ListImportsRequest, Pagination::ListImportsPaginationTraits>; | ||
| using ListTablesPaginator = | ||
| Aws::Utils::Pagination::Paginator<DynamoDBClient, Model::ListTablesRequest, Pagination::ListTablesPaginationTraits>; | ||
| using QueryPaginator = Aws::Utils::Pagination::Paginator<DynamoDBClient, Model::QueryRequest, Pagination::QueryPaginationTraits>; | ||
| using ScanPaginator = Aws::Utils::Pagination::Paginator<DynamoDBClient, Model::ScanRequest, Pagination::ScanPaginationTraits>; | ||
|
|
||
| } // namespace DynamoDB | ||
| } // namespace Aws |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| /** | ||
| * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| * SPDX-License-Identifier: Apache-2.0. | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <aws/core/utils/pagination/Paginator.h> | ||
| #include <aws/dynamodb/model/ListContributorInsightsPaginationTraits.h> | ||
| #include <aws/dynamodb/model/ListExportsPaginationTraits.h> | ||
| #include <aws/dynamodb/model/ListImportsPaginationTraits.h> | ||
| #include <aws/dynamodb/model/ListTablesPaginationTraits.h> | ||
| #include <aws/dynamodb/model/QueryPaginationTraits.h> | ||
| #include <aws/dynamodb/model/ScanPaginationTraits.h> | ||
|
|
||
| #include <memory> | ||
|
|
||
| namespace Aws { | ||
| namespace DynamoDB { | ||
|
|
||
| class DynamoDBClient; | ||
|
|
||
| template <typename DerivedClient> | ||
| class DynamoDBPaginationBase { | ||
| public: | ||
| /** | ||
| * Create a paginator for ListContributorInsights operation | ||
| */ | ||
| Aws::Utils::Pagination::Paginator<DerivedClient, Model::ListContributorInsightsRequest, | ||
| Pagination::ListContributorInsightsPaginationTraits> | ||
| ListContributorInsightsPaginator(const Model::ListContributorInsightsRequest& request) { | ||
| return Aws::Utils::Pagination::Paginator<DerivedClient, Model::ListContributorInsightsRequest, | ||
| Pagination::ListContributorInsightsPaginationTraits>{ | ||
| std::shared_ptr<DerivedClient>(static_cast<DerivedClient*>(this), [](DerivedClient*) {}), request}; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. likely isnt what we want to be doing, you are creating a shared point from consider #include <iostream>
#include <thread>
template<typename crtp_t>
class thing {
public:
thing(crtp_t& ref) : ptr_(ref) {};
void do_something() {
ptr_.work();
}
private:
crtp_t& ptr_;
};
template <typename crtp_t>
class mixin {
public:
void operation() {
thing<crtp_t> operation_thing{*static_cast<crtp_t*>(this)};
operation_thing.do_something();
}
};
class widget : public mixin<widget> {
public:
void work() {
std::cout << "hello from class\n";
}
};
auto main() -> int {
widget w{};
w.operation();
return 0;
}which is long way of saying on |
||
| } | ||
|
|
||
| /** | ||
| * Create a paginator for ListExports operation | ||
| */ | ||
| Aws::Utils::Pagination::Paginator<DerivedClient, Model::ListExportsRequest, Pagination::ListExportsPaginationTraits> ListExportsPaginator( | ||
| const Model::ListExportsRequest& request) { | ||
| return Aws::Utils::Pagination::Paginator<DerivedClient, Model::ListExportsRequest, Pagination::ListExportsPaginationTraits>{ | ||
| std::shared_ptr<DerivedClient>(static_cast<DerivedClient*>(this), [](DerivedClient*) {}), request}; | ||
| } | ||
|
|
||
| /** | ||
| * Create a paginator for ListImports operation | ||
| */ | ||
| Aws::Utils::Pagination::Paginator<DerivedClient, Model::ListImportsRequest, Pagination::ListImportsPaginationTraits> ListImportsPaginator( | ||
| const Model::ListImportsRequest& request) { | ||
| return Aws::Utils::Pagination::Paginator<DerivedClient, Model::ListImportsRequest, Pagination::ListImportsPaginationTraits>{ | ||
| std::shared_ptr<DerivedClient>(static_cast<DerivedClient*>(this), [](DerivedClient*) {}), request}; | ||
| } | ||
|
|
||
| /** | ||
| * Create a paginator for ListTables operation | ||
| */ | ||
| Aws::Utils::Pagination::Paginator<DerivedClient, Model::ListTablesRequest, Pagination::ListTablesPaginationTraits> ListTablesPaginator( | ||
| const Model::ListTablesRequest& request) { | ||
| return Aws::Utils::Pagination::Paginator<DerivedClient, Model::ListTablesRequest, Pagination::ListTablesPaginationTraits>{ | ||
| std::shared_ptr<DerivedClient>(static_cast<DerivedClient*>(this), [](DerivedClient*) {}), request}; | ||
| } | ||
|
|
||
| /** | ||
| * Create a paginator for Query operation | ||
| */ | ||
| Aws::Utils::Pagination::Paginator<DerivedClient, Model::QueryRequest, Pagination::QueryPaginationTraits> QueryPaginator( | ||
| const Model::QueryRequest& request) { | ||
| return Aws::Utils::Pagination::Paginator<DerivedClient, Model::QueryRequest, Pagination::QueryPaginationTraits>{ | ||
| std::shared_ptr<DerivedClient>(static_cast<DerivedClient*>(this), [](DerivedClient*) {}), request}; | ||
| } | ||
|
|
||
| /** | ||
| * Create a paginator for Scan operation | ||
| */ | ||
| Aws::Utils::Pagination::Paginator<DerivedClient, Model::ScanRequest, Pagination::ScanPaginationTraits> ScanPaginator( | ||
| const Model::ScanRequest& request) { | ||
| return Aws::Utils::Pagination::Paginator<DerivedClient, Model::ScanRequest, Pagination::ScanPaginationTraits>{ | ||
| std::shared_ptr<DerivedClient>(static_cast<DerivedClient*>(this), [](DerivedClient*) {}), request}; | ||
| } | ||
| }; | ||
| } // namespace DynamoDB | ||
| } // namespace Aws | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| /** | ||
| * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| * SPDX-License-Identifier: Apache-2.0. | ||
| */ | ||
|
|
||
| #pragma once | ||
| #include <aws/dynamodb/DynamoDBServiceClientModel.h> | ||
| #include <aws/dynamodb/DynamoDB_EXPORTS.h> | ||
| #include <aws/dynamodb/model/ScanRequest.h> | ||
| #include <aws/dynamodb/model/ScanResult.h> | ||
|
|
||
| namespace Aws { | ||
| namespace DynamoDB { | ||
| class DynamoDBClient; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. instead of forward declaring |
||
| namespace Pagination { | ||
|
|
||
| struct ScanPaginationTraits { | ||
| using RequestType = Model::ScanRequest; | ||
| using ResultType = Model::ScanResult; | ||
| using OutcomeType = Model::ScanOutcome; | ||
| using ClientType = DynamoDBClient; | ||
|
|
||
| template <typename Client = ClientType> | ||
| static OutcomeType Invoke(Client& client, const RequestType& request) { | ||
| return client.Scan(request); | ||
| } | ||
|
|
||
| static bool HasMoreResults(const ResultType& result) { return !result.GetLastEvaluatedKey().empty(); } | ||
|
|
||
| static void SetNextRequest(const ResultType& result, RequestType& request) { request.SetExclusiveStartKey(result.GetLastEvaluatedKey()); } | ||
| }; | ||
|
|
||
| } // namespace Pagination | ||
| } // namespace DynamoDB | ||
| } // namespace Aws | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chefs kiss