-
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?
Conversation
...-codegen/src/main/java/com/amazonaws/util/awsclientsmithygenerator/generators/CppWriter.java
Show resolved
Hide resolved
0fd0691 to
661e748
Compare
| implementation("software.amazon.smithy:smithy-aws-traits:1.51.0") | ||
| implementation("software.amazon.smithy:smithy-waiters:1.51.0") | ||
| implementation("software.amazon.smithy:smithy-rules-engine:1.51.0") | ||
| implementation("software.amazon.smithy:smithy-aws-endpoints:1.51.0") |
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.
Why do we need this? It's not like we're going to be using smithy based endpoints rule traits right?
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.
Ah, this was from copying the pattern used in our codegen-workshop.
I will refactor the build script to use our existing pattern from smoke-test gen
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.
Smithy actually needs all the above dependencies, in the current set up we are not accepting any unknown traits
.../util/awsclientsmithygenerator/generators/pagination/PaginationCompilationTestGenerator.java
Outdated
Show resolved
Hide resolved
20097ca to
7433789
Compare
Fix pagination traits generator for nested tokens andle explicit nested tokens like "EngineDefaults.Marker" correctly
abbreviation and servicename mismatch
Backward compatibility map for operations that must use "SdkResult" suffix.
S3's ListParts operation has NextPartNumberMarker as integer in C2J but string in Smithy.
…nPlugin to templates
…mber variable tableName
…hods for pagination, and smithy generator to make the base client templates. comment out the integration test. move the model traits into the service model dir instead of pagination dir erated/src/aws-cpp-sdk-bedrock-agentcore-control/include/aws/bedrock-agentcore-control/model/CreateOnlineEvaluationConfigRequest.h
feb8542 to
491f11f
Compare
2e48a84 to
bb8aeb7
Compare
a426d02 to
03ae46d
Compare
| namespace Aws { | ||
| namespace DynamoDB { | ||
|
|
||
| using ListContributorInsightsPaginator = Aws::Utils::Pagination::PagePaginator<DynamoDBClient, Model::ListContributorInsightsRequest, |
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.
lets change PagePaginator to Paginator, unless you feel strongly about the name
|
|
||
| namespace Aws { | ||
| namespace DynamoDB { | ||
| class DynamoDBClient; |
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.
instead of forward declaring DynamoDB why not have ScanPaginationTraits take a template parameter template <typename Client = ClientType> like you have on Invoke then the entire class is tempalted. You already pass DynamoDBClient as a template parameter in DynamoDBClientPagination.h
generated/src/aws-cpp-sdk-dynamodb/include/aws/dynamodb/DynamoDBClient.h
Show resolved
Hide resolved
| ListContributorInsightsPaginator(const Model::ListContributorInsightsRequest& request) { | ||
| return Aws::Utils::Pagination::PagePaginator<DerivedClient, Model::ListContributorInsightsRequest, | ||
| Pagination::ListContributorInsightsPaginationTraits>{ | ||
| std::shared_ptr<DerivedClient>(static_cast<DerivedClient*>(this), [](DerivedClient*) {}), request}; |
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.
likely isnt what we want to be doing, you are creating a shared point from this then have a custom deleter [](DerivedClient*) {} that does nothing when delete is called. you are essentially trying to fit this into a shared pointer without using the actual properties of shared.
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 PagePaginator make client a reference not a pointer
generated/tests/dynamodb-gen-tests/DynamoDBPaginationCompilationTests.cpp
Show resolved
Hide resolved
|
|
||
| class ScanPaginationTest : public Aws::Testing::AwsCppSdkGTestSuite { | ||
| protected: | ||
| std::shared_ptr<DynamoDBClient> dynamoClient; |
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.
nit: why shared pointer and not stack varable?
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.
The other integration test had similar pattern tests/aws-cpp-sdk-dynamodb-integration-tests/TableOperationTest.cpp in using shared pointer,
I will go ahead and use a stack variable here
| print(f"Code generation done, (re)generated {len(done)} packages.") # Including defaults and partitions | ||
|
|
||
| # Format generated client code | ||
| generated_clients = [service for service in self.c2j_models.keys()] |
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.
is this not needed in this code path anymore?
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.
Yup, we moved the clang formatting to tools/scripts/run_code_generation.py so it can run after all files have been generated instead of just c2j generated codes
| "cloudwatch-logs":"logs", | ||
| "directory-service":"ds", | ||
| "elasticsearch-service ":"es", | ||
| "elasticsearch-service":"es", |
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.
nit: whitespace change
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.
Original code had an inconsistency that made my custom parsing logic failed. I already fixed my custom parsing logic and went ahead to fix the inconsistency as well
| var model = context.getModel(); | ||
|
|
||
| // Handle legacy services without Smithy models | ||
| if (context.getProjectionName().endsWith(".mock")) { |
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.
how is ".mock" generated in the projection name?
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.
We have a small logic in tools/code-generation/smithy/cpp-codegen/build.gradle.kts that generates these projections that do not exist in smithy but does exist in coral so we can maintain backwards compatibility.
// Legacy services without full Smithy models - generate mock projections for base classes
val legacyServices = mapOf("importexport" to "ImportExport", "sdb" to "SimpleDB", "s3-crt" to "S3Crt")
legacyServices.forEach { (c2jName, serviceName) ->
if (filteredServiceList.isEmpty() || c2jName in filteredServiceList) {
val mockProjectionContents = Node.objectNodeBuilder()
.withMember("plugins", Node.objectNode()
.withMember("smithy-cpp-codegen", Node.objectNodeBuilder()
.withMember("c2jMap", Node.from(c2jMapStr))
.build()))
.build()
projectionsBuilder.withMember("$c2jName.mock", mockProjectionContents)
}
e7a992b to
239688c
Compare
239688c to
fe3fc77
Compare
...m/amazonaws/util/awsclientsmithygenerator/generators/pagination/PaginationCodegenPlugin.java
Outdated
Show resolved
Hide resolved
...m/amazonaws/util/awsclientsmithygenerator/generators/pagination/PaginationCodegenPlugin.java
Outdated
Show resolved
Hide resolved
...m/amazonaws/util/awsclientsmithygenerator/generators/pagination/PaginationCodegenPlugin.java
Outdated
Show resolved
Hide resolved
...m/amazonaws/util/awsclientsmithygenerator/generators/pagination/PaginationCodegenPlugin.java
Show resolved
Hide resolved
.../main/java/com/amazonaws/util/awsclientsmithygenerator/generators/ClientCodegenSettings.java
Outdated
Show resolved
Hide resolved
...-codegen/src/main/java/com/amazonaws/util/awsclientsmithygenerator/generators/ShapeUtil.java
Outdated
Show resolved
Hide resolved
...amazonaws/util/awsclientsmithygenerator/generators/pagination/PaginationTraitsGenerator.java
Outdated
Show resolved
Hide resolved
b5d3706 to
921f8cd
Compare
…dessed some nits change codegen to create templated pagination traits instead of forward declaring
1ae723e to
1143296
Compare
Issue #, if available:
Description of changes:
Smithy-based code generator for paginators
Check all that applies:
Check which platforms you have built SDK on to verify the correctness of this PR.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.