Skip to content

Conversation

@alextwoods
Copy link
Contributor

Description of changes:
Adds a hook for integrations to register an endpoints generator that is responsible for generating client configuration and resolution logic.

Adds an Aws Standard Regional Endpoints generation path that adds region to client config and generates logic to use a simple pattern based regional endpoint resolver.

The generic hook for endpoint generation can be used in the future to implement Endpoints2.0 both generically or in Aws flavors (specifically accounting for AWS builtins / std lib functions).

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@alextwoods alextwoods marked this pull request as ready for review March 4, 2025 22:43
@alextwoods alextwoods requested a review from a team as a code owner March 4, 2025 22:43
@alextwoods alextwoods changed the title [Draft] Generate Regional endpoints Generate Regional endpoints Mar 4, 2025
Copy link
Contributor

@nateprewitt nateprewitt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two minor comments, otherwise looks good!

nateprewitt
nateprewitt previously approved these changes Mar 4, 2025
endpoint = await config.endpoint_resolver.resolve_endpoint(
StaticEndpointParams(uri=config.endpoint_uri)
)
context.endpointsGenerator().renderEndpointParameterConstruction(context, writer);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a prime use case for a CodeSection. You would create a section like this called EndpointParamSection or something like that with the necessary context, and then a PythonIntegration would return a CodeInterceptor in its interceptors method.

Then here you'd have something like:

writer.pushState(new EndpointParamsSection(context));
// Default implementation. Interceptors can be blow it away.
writer.write("""
    endpoint_parameters = StaticEndpointParams(uri=config.endpoint_uri)
""");
writer.popState();

You can then get rid of the EndpointsGenerator entirely.

smithy-python doesn't use sections or interceptors much currently, but it should.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For an implementation of an approach using CodeSections and CodeInterceptor see: #407

@JordonPhillips
Copy link
Contributor

I prefer option 2

@alextwoods alextwoods closed this Mar 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants