-
Notifications
You must be signed in to change notification settings - Fork 931
URI Cache for DynamoDB Account Id based Endpoints #6244
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"type": "feature", | ||
"category": "Amazon DyanmoDB", | ||
"contributor": "", | ||
"description": "Enable caching calls to URI constructors for account-id based endpoints" | ||
davidh44 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...urces/software/amazon/awssdk/codegen/poet/client/c2j/query/customization-uri-cache.config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"authPolicyActions" : { | ||
"skip" : true | ||
}, | ||
"skipEndpointTests": { | ||
"test case 4": "Does not work" | ||
}, | ||
"endpointParameters": { | ||
"CustomEndpointArray": { | ||
"required": false, | ||
"documentation": "Parameter from the customization config", | ||
"type": "StringArray" | ||
}, | ||
"ArnList": { | ||
"required": false, | ||
"documentation": "Parameter from the customization config", | ||
"type": "StringArray" | ||
} | ||
}, | ||
"customOperationContextParams": [ | ||
{ | ||
"operationName": "OperationWithCustomizedOperationContextParam", | ||
"operationContextParamsMap": { | ||
"customEndpointArray": { | ||
"path": "ListMember.StringList[*].LeafString" | ||
} | ||
} | ||
} | ||
], | ||
"preClientExecutionRequestCustomizer": { | ||
"OperationWithCustomMember": { | ||
"methodName": "dummyRequestModifier", | ||
"className": "software.amazon.awssdk.codegen.internal.UtilsTest" | ||
} | ||
}, | ||
"enableEndpointProviderUriCaching": true | ||
} |
155 changes: 155 additions & 0 deletions
155
...sources/software/amazon/awssdk/codegen/poet/rules2/endpoint-provider-uri-cache-class.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
package software.amazon.awssdk.services.query.endpoints.internal; | ||
|
||
import java.util.Arrays; | ||
import java.util.concurrent.CompletableFuture; | ||
import software.amazon.awssdk.annotations.Generated; | ||
import software.amazon.awssdk.annotations.SdkInternalApi; | ||
import software.amazon.awssdk.awscore.endpoints.AwsEndpointAttribute; | ||
import software.amazon.awssdk.awscore.endpoints.authscheme.SigV4AuthScheme; | ||
import software.amazon.awssdk.awscore.endpoints.authscheme.SigV4aAuthScheme; | ||
import software.amazon.awssdk.core.exception.SdkClientException; | ||
import software.amazon.awssdk.endpoints.Endpoint; | ||
import software.amazon.awssdk.regions.Region; | ||
import software.amazon.awssdk.services.query.endpoints.QueryEndpointParams; | ||
import software.amazon.awssdk.services.query.endpoints.QueryEndpointProvider; | ||
import software.amazon.awssdk.utils.CompletableFutureUtils; | ||
import software.amazon.awssdk.utils.Validate; | ||
import software.amazon.awssdk.utils.uri.SdkUri; | ||
|
||
@Generated("software.amazon.awssdk:codegen") | ||
@SdkInternalApi | ||
public final class DefaultQueryEndpointProvider implements QueryEndpointProvider { | ||
@Override | ||
public CompletableFuture<Endpoint> resolveEndpoint(QueryEndpointParams params) { | ||
Validate.notNull(params.region(), "Parameter 'region' must not be null"); | ||
try { | ||
Region region = params.region(); | ||
String regionId = region == null ? null : region.id(); | ||
RuleResult result = endpointRule0(params, regionId); | ||
if (result.canContinue()) { | ||
throw SdkClientException.create("Rule engine did not reach an error or endpoint result"); | ||
} | ||
if (result.isError()) { | ||
String errorMsg = result.error(); | ||
if (errorMsg.contains("Invalid ARN") && errorMsg.contains(":s3:::")) { | ||
errorMsg += ". Use the bucket name instead of simple bucket ARNs in GetBucketLocationRequest."; | ||
} | ||
throw SdkClientException.create(errorMsg); | ||
} | ||
return CompletableFuture.completedFuture(result.endpoint()); | ||
} catch (Exception error) { | ||
return CompletableFutureUtils.failedFuture(error); | ||
} | ||
} | ||
|
||
private static RuleResult endpointRule0(QueryEndpointParams params, String region) { | ||
return endpointRule1(params, region); | ||
} | ||
|
||
private static RuleResult endpointRule1(QueryEndpointParams params, String region) { | ||
RulePartition partitionResult = RulesFunctions.awsPartition(region); | ||
if (partitionResult != null) { | ||
RuleResult result = endpointRule2(params, partitionResult); | ||
if (result.isResolved()) { | ||
return result; | ||
} | ||
result = endpointRule6(params, region, partitionResult); | ||
if (result.isResolved()) { | ||
return result; | ||
} | ||
return RuleResult.error(region + " is not a valid HTTP host-label"); | ||
if (params.useFipsEndpoint() == null && params.useDualStackEndpoint() != null && params.useDualStackEndpoint() | ||
&& params.arnList() != null) { | ||
String firstArn = RulesFunctions.listAccess(params.arnList(), 0); | ||
if (firstArn != null) { | ||
RuleArn parsedArn = RulesFunctions.awsParseArn(firstArn); | ||
if (parsedArn != null) { | ||
return RuleResult.endpoint(Endpoint | ||
.builder() | ||
.url(SdkUri.getInstance().create( | ||
"https://" + params.endpointId() + ".query." + partitionResult.dualStackDnsSuffix())) | ||
.putAttribute( | ||
AwsEndpointAttribute.AUTH_SCHEMES, | ||
Arrays.asList(SigV4aAuthScheme.builder().signingName("query") | ||
.signingRegionSet(Arrays.asList("*")).build())).build()); | ||
} | ||
} | ||
} | ||
} | ||
return RuleResult.carryOn(); | ||
} | ||
|
||
private static RuleResult endpointRule2(QueryEndpointParams params, RulePartition partitionResult) { | ||
if (params.endpointId() != null) { | ||
if (params.useFipsEndpoint() != null && params.useFipsEndpoint()) { | ||
return RuleResult.error("FIPS endpoints not supported with multi-region endpoints"); | ||
} | ||
if (params.useFipsEndpoint() == null && params.useDualStackEndpoint() != null && params.useDualStackEndpoint()) { | ||
return RuleResult.endpoint(Endpoint | ||
.builder() | ||
.url(SdkUri.getInstance().create( | ||
"https://" + params.endpointId() + ".query." + partitionResult.dualStackDnsSuffix())) | ||
.putAttribute( | ||
AwsEndpointAttribute.AUTH_SCHEMES, | ||
Arrays.asList(SigV4aAuthScheme.builder().signingName("query") | ||
.signingRegionSet(Arrays.asList("*")).build())).build()); | ||
} | ||
return RuleResult.endpoint(Endpoint | ||
.builder() | ||
.url(SdkUri.getInstance().create("https://" + params.endpointId() + ".query." + partitionResult.dnsSuffix())) | ||
.putAttribute( | ||
AwsEndpointAttribute.AUTH_SCHEMES, | ||
Arrays.asList(SigV4aAuthScheme.builder().signingName("query").signingRegionSet(Arrays.asList("*")) | ||
.build())).build()); | ||
} | ||
return RuleResult.carryOn(); | ||
} | ||
|
||
private static RuleResult endpointRule6(QueryEndpointParams params, String region, RulePartition partitionResult) { | ||
if (RulesFunctions.isValidHostLabel(region, false)) { | ||
if (params.useFipsEndpoint() != null && params.useFipsEndpoint() && params.useDualStackEndpoint() == null) { | ||
return RuleResult.endpoint(Endpoint | ||
.builder() | ||
.url(SdkUri.getInstance().create("https://query-fips." + region + "." + partitionResult.dnsSuffix())) | ||
.putAttribute( | ||
AwsEndpointAttribute.AUTH_SCHEMES, | ||
Arrays.asList(SigV4aAuthScheme.builder().signingName("query") | ||
.signingRegionSet(Arrays.asList("*")).build())).build()); | ||
} | ||
if (params.useDualStackEndpoint() != null && params.useDualStackEndpoint() && params.useFipsEndpoint() == null) { | ||
return RuleResult.endpoint(Endpoint | ||
.builder() | ||
.url(SdkUri.getInstance().create("https://query." + region + "." + partitionResult.dualStackDnsSuffix())) | ||
.putAttribute( | ||
AwsEndpointAttribute.AUTH_SCHEMES, | ||
Arrays.asList(SigV4aAuthScheme.builder().signingName("query") | ||
.signingRegionSet(Arrays.asList("*")).build(), | ||
SigV4AuthScheme.builder().signingName("query").signingRegion(region).build())).build()); | ||
} | ||
if (params.useDualStackEndpoint() != null && params.useFipsEndpoint() != null && params.useDualStackEndpoint() | ||
&& params.useFipsEndpoint()) { | ||
return RuleResult.endpoint(Endpoint | ||
.builder() | ||
.url(SdkUri.getInstance().create( | ||
"https://query-fips." + region + "." + partitionResult.dualStackDnsSuffix())) | ||
.putAttribute( | ||
AwsEndpointAttribute.AUTH_SCHEMES, | ||
Arrays.asList(SigV4aAuthScheme.builder().signingName("query") | ||
.signingRegionSet(Arrays.asList("*")).build())).build()); | ||
} | ||
return RuleResult.endpoint(Endpoint.builder() | ||
.url(SdkUri.getInstance().create("https://query." + region + "." + partitionResult.dnsSuffix())).build()); | ||
} | ||
return RuleResult.carryOn(); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object rhs) { | ||
return rhs != null && getClass().equals(rhs.getClass()); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return getClass().hashCode(); | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.