-
Notifications
You must be signed in to change notification settings - Fork 24
Generate Regional Endpoints (OPTION 2: CodeSection/Interceptor) #407
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
Generate Regional Endpoints (OPTION 2: CodeSection/Interceptor) #407
Conversation
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.
I hate that spotless reformatted all of this. It was fairly deliberately formatted to keep everything at a level so it could be read with minimal head scratching. But we're getting rid of these soon anyway so oh well.
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.
Ugh, Yeah, sorry about that :-(
For this PR I've gone ahead and reverted all of those formatting changes to make sure the actual change is clear.
| Config = TypeVar("Config", contravariant=True) | ||
|
|
||
|
|
||
| class EndpointParametersProtocol(Protocol[Config]): | ||
| @classmethod | ||
| def build(cls, config: Config) -> Self: | ||
| raise NotImplementedError() |
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.
As of python 3.12 we have proper generic declarations and inferred variance, so TypeVar is not needed.
| Config = TypeVar("Config", contravariant=True) | |
| class EndpointParametersProtocol(Protocol[Config]): | |
| @classmethod | |
| def build(cls, config: Config) -> Self: | |
| raise NotImplementedError() | |
| class EndpointParameters[C](Protocol): | |
| @classmethod | |
| def build(cls, config: C) -> Self: | |
| raise NotImplementedError() |
|
|
||
|
|
||
| class EndpointResolver(Protocol[EndpointParams]): | ||
| class EndpointResolverProtocol(Protocol[EndpointParams]): |
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.
Adding type information in the name of the type isn't a thing we should be doing. Especially in Python, where you can just alias the name on import to avoid conflicts.
Description of changes:
Based on suggestion in #394, this PR implements StandardRegionalEndpoints using CodeSections + interceptors.
Similar to the
HttpAuthGenerator, we add a standardEndpointGeneratorwhich always rendersendpoints.pywhich must define the service'sEndpointParametersandEndpointResolver[EndpointParameters]and which adds code sections for both.The AWSStandardRegionalIntegation adds the required config properties through a runtime plugin and adds interceptors that completely rewrite the endpoint param and resolver sections. For both the base and standard regional cases, we simply import generic (non service-specific) parameters and resolvers and export them. For endpoints2.0 we would generate both in place.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.