Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public class ServiceConfig {

private boolean hasAccelerateModeEnabledProperty = false;

private boolean hasCrossRegionBucketAccessEnabledProperty = false;

public String getClassName() {
return className;
}
Expand Down Expand Up @@ -95,6 +97,14 @@ public void setHasPathStyleAccessEnabledProperty(boolean hasPathStyleAccessEnabl
this.hasPathStyleAccessEnabledProperty = hasPathStyleAccessEnabledProperty;
}

public boolean hasCrossRegionAccessEnabledProperty() {
return hasCrossRegionBucketAccessEnabledProperty;
}

public void setHasCrossRegionBucketAccessEnabledProperty(boolean hasCrossRegionBucketAccessEnabledProperty) {
this.hasCrossRegionBucketAccessEnabledProperty = hasCrossRegionBucketAccessEnabledProperty;
}

public boolean hasAccelerateModeEnabledProperty() {
return hasAccelerateModeEnabledProperty;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import software.amazon.awssdk.codegen.utils.AuthUtils;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
import software.amazon.awssdk.core.client.config.SdkClientOption;
import software.amazon.awssdk.endpoints.EndpointProvider;

public class AsyncClientBuilderClass implements ClassSpec {
private final IntermediateModel model;
Expand Down Expand Up @@ -126,15 +127,21 @@ private MethodSpec buildClientMethod() {
.addStatement("$T clientConfiguration = super.asyncClientConfiguration()", SdkClientConfiguration.class)
.addStatement("this.validateClientOptions(clientConfiguration)")
.addStatement("$T endpointOverride = null", URI.class)
.addStatement("$T endpointProvider = null", EndpointProvider.class)
.addCode("if (clientConfiguration.option($T.ENDPOINT_OVERRIDDEN) != null"
+ "&& $T.TRUE.equals(clientConfiguration.option($T.ENDPOINT_OVERRIDDEN))) {"
+ "endpointOverride = clientConfiguration.option($T.ENDPOINT);"
+ "}",
SdkClientOption.class, Boolean.class, SdkClientOption.class, SdkClientOption.class)
.addCode("if (clientConfiguration.option($T.ENDPOINT_PROVIDER) != null) {"
+ "endpointProvider = clientConfiguration.option($T.ENDPOINT_PROVIDER);"
+ "}",
SdkClientOption.class, SdkClientOption.class)
.addStatement("$T serviceClientConfiguration = $T.builder()"
+ ".overrideConfiguration(overrideConfiguration())"
+ ".region(clientConfiguration.option($T.AWS_REGION))"
+ ".endpointOverride(endpointOverride)"
+ ".endpointProvider(endpointProvider)"
+ ".build()",
serviceConfigClassName, serviceConfigClassName, AwsClientOption.class)
.addStatement("return new $T(serviceClientConfiguration, clientConfiguration)", clientClassName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import software.amazon.awssdk.codegen.utils.AuthUtils;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
import software.amazon.awssdk.core.client.config.SdkClientOption;
import software.amazon.awssdk.endpoints.EndpointProvider;

public class SyncClientBuilderClass implements ClassSpec {
private final IntermediateModel model;
Expand Down Expand Up @@ -126,15 +127,22 @@ private MethodSpec buildClientMethod() {
.addStatement("$T clientConfiguration = super.syncClientConfiguration()", SdkClientConfiguration.class)
.addStatement("this.validateClientOptions(clientConfiguration)")
.addStatement("$T endpointOverride = null", URI.class)
.addStatement("$T endpointProvider = null", EndpointProvider.class)
.addCode("if (clientConfiguration.option($T.ENDPOINT_OVERRIDDEN) != null"
+ "&& $T.TRUE.equals(clientConfiguration.option($T.ENDPOINT_OVERRIDDEN))) {"
+ "endpointOverride = clientConfiguration.option($T.ENDPOINT);"

+ "}",
SdkClientOption.class, Boolean.class, SdkClientOption.class, SdkClientOption.class)
.addCode("if (clientConfiguration.option($T.ENDPOINT_PROVIDER) != null) {"
+ "endpointProvider = clientConfiguration.option($T.ENDPOINT_PROVIDER);"
+ "}",
SdkClientOption.class, SdkClientOption.class)
.addStatement("$T serviceClientConfiguration = $T.builder()"
+ ".overrideConfiguration(overrideConfiguration())"
+ ".region(clientConfiguration.option($T.AWS_REGION))"
+ ".endpointOverride(endpointOverride)"
+ ".endpointProvider(endpointProvider)"
+ ".build()",
serviceConfigClassName, serviceConfigClassName, AwsClientOption.class)
.addStatement("return new $T(serviceClientConfiguration, clientConfiguration)", clientClassName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import software.amazon.awssdk.codegen.poet.ClassSpec;
import software.amazon.awssdk.codegen.poet.PoetUtils;
import software.amazon.awssdk.core.client.config.ClientOverrideConfiguration;
import software.amazon.awssdk.endpoints.EndpointProvider;
import software.amazon.awssdk.regions.Region;

public class ServiceClientConfigurationClass implements ClassSpec {
Expand Down Expand Up @@ -110,6 +111,13 @@ private TypeSpec builderInterfaceSpec() {
.returns(className().nestedClass("Builder"))
.addJavadoc("Configure the client override configuration")
.build())
.addMethod(MethodSpec.methodBuilder("endpointProvider")
.addAnnotation(Override.class)
.addModifiers(PUBLIC, ABSTRACT)
.addParameter(EndpointProvider.class, "endpointProvider")
.returns(className().nestedClass("Builder"))
.addJavadoc("Configure the endpointProvider")
.build())
.build();
}

Expand Down Expand Up @@ -150,6 +158,14 @@ private TypeSpec builderImplSpec() {
.addStatement("this.endpointOverride = endpointOverride")
.addStatement("return this")
.build())
.addMethod(MethodSpec.methodBuilder("endpointProvider")
.addAnnotation(Override.class)
.addModifiers(PUBLIC)
.addParameter(EndpointProvider.class, "endpointProvider")
.returns(className().nestedClass("Builder"))
.addStatement("this.endpointProvider = endpointProvider")
.addStatement("return this")
.build())
.addMethod(MethodSpec.methodBuilder("build")
.addAnnotation(Override.class)
.addModifiers(PUBLIC)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import software.amazon.awssdk.awscore.client.config.AwsClientOption;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
import software.amazon.awssdk.core.client.config.SdkClientOption;
import software.amazon.awssdk.endpoints.EndpointProvider;
import software.amazon.awssdk.services.json.endpoints.JsonEndpointProvider;

/**
Expand All @@ -33,13 +34,17 @@ protected final JsonAsyncClient buildClient() {
SdkClientConfiguration clientConfiguration = super.asyncClientConfiguration();
this.validateClientOptions(clientConfiguration);
URI endpointOverride = null;
EndpointProvider endpointProvider = null;
if (clientConfiguration.option(SdkClientOption.ENDPOINT_OVERRIDDEN) != null
&& Boolean.TRUE.equals(clientConfiguration.option(SdkClientOption.ENDPOINT_OVERRIDDEN))) {
endpointOverride = clientConfiguration.option(SdkClientOption.ENDPOINT);
}
if (clientConfiguration.option(SdkClientOption.ENDPOINT_PROVIDER) != null) {
endpointProvider = clientConfiguration.option(SdkClientOption.ENDPOINT_PROVIDER);
}
JsonServiceClientConfiguration serviceClientConfiguration = JsonServiceClientConfiguration.builder()
.overrideConfiguration(overrideConfiguration()).region(clientConfiguration.option(AwsClientOption.AWS_REGION))
.endpointOverride(endpointOverride).build();
.endpointOverride(endpointOverride).endpointProvider(endpointProvider).build();
return new DefaultJsonAsyncClient(serviceClientConfiguration, clientConfiguration);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import software.amazon.awssdk.awscore.client.config.AwsClientOption;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
import software.amazon.awssdk.core.client.config.SdkClientOption;
import software.amazon.awssdk.endpoints.EndpointProvider;
import software.amazon.awssdk.services.json.endpoints.JsonEndpointProvider;

/**
Expand All @@ -33,13 +34,17 @@ protected final JsonClient buildClient() {
SdkClientConfiguration clientConfiguration = super.syncClientConfiguration();
this.validateClientOptions(clientConfiguration);
URI endpointOverride = null;
EndpointProvider endpointProvider = null;
if (clientConfiguration.option(SdkClientOption.ENDPOINT_OVERRIDDEN) != null
&& Boolean.TRUE.equals(clientConfiguration.option(SdkClientOption.ENDPOINT_OVERRIDDEN))) {
endpointOverride = clientConfiguration.option(SdkClientOption.ENDPOINT);
}
if (clientConfiguration.option(SdkClientOption.ENDPOINT_PROVIDER) != null) {
endpointProvider = clientConfiguration.option(SdkClientOption.ENDPOINT_PROVIDER);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

clientConfiguration.option(SdkClientOption.ENDPOINT_PROVIDER) != null seems unnecessary.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

removed

JsonServiceClientConfiguration serviceClientConfiguration = JsonServiceClientConfiguration.builder()
.overrideConfiguration(overrideConfiguration()).region(clientConfiguration.option(AwsClientOption.AWS_REGION))
.endpointOverride(endpointOverride).build();
.endpointOverride(endpointOverride).endpointProvider(endpointProvider).build();
return new DefaultJsonClient(serviceClientConfiguration, clientConfiguration);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import software.amazon.awssdk.annotations.SdkPublicApi;
import software.amazon.awssdk.awscore.AwsServiceClientConfiguration;
import software.amazon.awssdk.core.client.config.ClientOverrideConfiguration;
import software.amazon.awssdk.endpoints.EndpointProvider;
import software.amazon.awssdk.regions.Region;

/**
Expand Down Expand Up @@ -45,6 +46,13 @@ public interface Builder extends AwsServiceClientConfiguration.Builder {
*/
@Override
Builder overrideConfiguration(ClientOverrideConfiguration clientOverrideConfiguration);

/**
* Configure the endpointProvider
*/
@Override
Builder endpointProvider(EndpointProvider endpointProvider);

}

private static final class BuilderImpl extends AwsServiceClientConfiguration.BuilderImpl implements Builder {
Expand Down Expand Up @@ -73,6 +81,12 @@ public Builder endpointOverride(URI endpointOverride) {
return this;
}

@Override
public Builder endpointProvider(EndpointProvider endpointProvider) {
this.endpointProvider = endpointProvider;
return this;
}

@Override
public JsonProtocolTestsServiceClientConfiguration build() {
return new JsonProtocolTestsServiceClientConfiguration(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import software.amazon.awssdk.annotations.SdkPublicApi;
import software.amazon.awssdk.core.SdkServiceClientConfiguration;
import software.amazon.awssdk.core.client.config.ClientOverrideConfiguration;
import software.amazon.awssdk.endpoints.EndpointProvider;
import software.amazon.awssdk.regions.Region;

/**
Expand Down Expand Up @@ -89,6 +90,7 @@ protected abstract static class BuilderImpl implements Builder {
protected ClientOverrideConfiguration overrideConfiguration;
protected Region region;
protected URI endpointOverride;
protected EndpointProvider endpointProvider;

protected BuilderImpl() {
}
Expand All @@ -97,6 +99,7 @@ protected BuilderImpl(AwsServiceClientConfiguration awsServiceClientConfiguratio
this.overrideConfiguration = awsServiceClientConfiguration.overrideConfiguration();
this.region = awsServiceClientConfiguration.region();
this.endpointOverride = awsServiceClientConfiguration.endpointOverride().orElse(null);
this.endpointProvider = awsServiceClientConfiguration.endpointProvider().orElse(null);
}

@Override
Expand All @@ -113,6 +116,17 @@ public final Region region() {
public final URI endpointOverride() {
return endpointOverride;
}

@Override
public final EndpointProvider endpointProvider() {
return endpointProvider;
}

@Override
public Builder endpointProvider(EndpointProvider endpointProvider) {
Comment thread
joviegas marked this conversation as resolved.
Outdated
this.endpointProvider = endpointProvider;
return this;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import software.amazon.awssdk.core.interceptor.ExecutionAttribute;
import software.amazon.awssdk.core.interceptor.ExecutionAttributes;
import software.amazon.awssdk.core.signer.Signer;
import software.amazon.awssdk.endpoints.EndpointProvider;
import software.amazon.awssdk.metrics.MetricPublisher;
import software.amazon.awssdk.utils.CollectionUtils;
import software.amazon.awssdk.utils.Validate;
Expand All @@ -51,6 +52,8 @@ public abstract class RequestOverrideConfiguration {
private final List<MetricPublisher> metricPublishers;
private final ExecutionAttributes executionAttributes;

private final EndpointProvider endpointProvider;

protected RequestOverrideConfiguration(Builder<?> builder) {
this.headers = CollectionUtils.deepUnmodifiableMap(builder.headers(), () -> new TreeMap<>(String.CASE_INSENSITIVE_ORDER));
this.rawQueryParameters = CollectionUtils.deepUnmodifiableMap(builder.rawQueryParameters());
Expand All @@ -60,6 +63,7 @@ protected RequestOverrideConfiguration(Builder<?> builder) {
this.signer = builder.signer();
this.metricPublishers = Collections.unmodifiableList(new ArrayList<>(builder.metricPublishers()));
this.executionAttributes = ExecutionAttributes.unmodifiableExecutionAttributes(builder.executionAttributes());
this.endpointProvider = builder.endpointProvider();
}

/**
Expand Down Expand Up @@ -169,7 +173,8 @@ public boolean equals(Object o) {
Objects.equals(apiCallAttemptTimeout, that.apiCallAttemptTimeout) &&
Objects.equals(signer, that.signer) &&
Objects.equals(metricPublishers, that.metricPublishers) &&
Objects.equals(executionAttributes, that.executionAttributes);
Objects.equals(executionAttributes, that.executionAttributes) &&
Objects.equals(endpointProvider, that.endpointProvider);
}

@Override
Expand All @@ -183,6 +188,7 @@ public int hashCode() {
hashCode = 31 * hashCode + Objects.hashCode(signer);
hashCode = 31 * hashCode + Objects.hashCode(metricPublishers);
hashCode = 31 * hashCode + Objects.hashCode(executionAttributes);
hashCode = 31 * hashCode + Objects.hashCode(endpointProvider);
return hashCode;
}

Expand Down Expand Up @@ -412,6 +418,27 @@ default B putRawQueryParameter(String name, String value) {

ExecutionAttributes executionAttributes();

/**
Comment thread
joviegas marked this conversation as resolved.
Outdated
* Sets the signer to use for signing the request. This signer get priority over the signer set on the client while
* signing the requests. If this value is null, then the client level signer is used for signing the request.
*
* @param signer Signer for signing the request
* @return This object for method chaining
*/


/**
* Sets the endpointProvider to use for resolving the endpoint of the request. This endpointProvider gets priority
* over the endpointProvider set on the client while resolving the endpoint for the requests.
* If this value is null, then the client level endpointProvider is used for resolving the endpoint.
*
* @param endpointProvider Endpoint Provider that will override the resolving the endpoint for the request.
* @return This object for method chaining
*/
B endpointProvider(EndpointProvider endpointProvider);
Comment thread
zoewangg marked this conversation as resolved.

EndpointProvider endpointProvider();

/**
* Create a new {@code SdkRequestOverrideConfiguration} with the properties set on this builder.
*
Expand All @@ -430,6 +457,9 @@ protected abstract static class BuilderImpl<B extends Builder> implements Builde
private List<MetricPublisher> metricPublishers = new ArrayList<>();
private ExecutionAttributes.Builder executionAttributesBuilder = ExecutionAttributes.builder();

private EndpointProvider endpointProvider;


protected BuilderImpl() {
}

Expand All @@ -442,6 +472,7 @@ protected BuilderImpl(RequestOverrideConfiguration sdkRequestOverrideConfig) {
signer(sdkRequestOverrideConfig.signer().orElse(null));
metricPublishers(sdkRequestOverrideConfig.metricPublishers());
executionAttributes(sdkRequestOverrideConfig.executionAttributes());
endpointProvider(sdkRequestOverrideConfig.endpointProvider);
}

@Override
Expand Down Expand Up @@ -595,5 +626,21 @@ public ExecutionAttributes executionAttributes() {
public void setExecutionAttributes(ExecutionAttributes executionAttributes) {
executionAttributes(executionAttributes);
}


@Override
public B endpointProvider(EndpointProvider endpointProvider) {
this.endpointProvider = endpointProvider;
return (B) this;
}

public void setEndpointProvider(EndpointProvider endpointProvider) {
endpointProvider(endpointProvider);
}

@Override
public EndpointProvider endpointProvider() {
return endpointProvider;
}
}
}
Loading