Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import software.amazon.awssdk.codegen.poet.rules.EndpointProviderTestSpec;
import software.amazon.awssdk.codegen.poet.rules.EndpointResolverUtilsSpec;
import software.amazon.awssdk.codegen.poet.rules.EndpointRulesClientTestSpec;
import software.amazon.awssdk.codegen.poet.rules2.EndpointProviderSpec2;

public final class EndpointProviderTasks extends BaseGeneratorTasks {
private final GeneratorTaskParams generatorTaskParams;
Expand All @@ -49,14 +48,8 @@ protected List<GeneratorTask> createTasks() throws Exception {
List<GeneratorTask> tasks = new ArrayList<>();
tasks.add(generateInterface());
tasks.add(generateParams());
if (shouldGenerateCompiledEndpointRules()) {
tasks.add(generateDefaultProvider2());
tasks.add(new RulesEngineRuntimeLiteGeneratorTask(generatorTaskParams));
tasks.add(new RulesEngineRuntimeGeneratorTask2(generatorTaskParams));
} else {
tasks.add(generateDefaultProvider());
tasks.add(new RulesEngineRuntimeGeneratorTask(generatorTaskParams));
}
tasks.add(generateDefaultProvider2());
tasks.add(new RulesEngineRuntimeGeneratorTask(generatorTaskParams));
if (shouldGenerateJmesPathRuntime()) {
tasks.add(new JmesPathRuntimeGeneratorTask(generatorTaskParams));
}
Expand All @@ -82,24 +75,15 @@ private GeneratorTask generateParams() {
return new PoetGeneratorTask(endpointRulesDir(), model.getFileHeader(), new EndpointParametersClassSpec(model));
}

private GeneratorTask generateDefaultProvider() {
return new PoetGeneratorTask(endpointRulesInternalDir(), model.getFileHeader(), new EndpointProviderSpec(model));
}

private GeneratorTask generateDefaultProvider2() {
return new PoetGeneratorTask(endpointRulesInternalDir(), model.getFileHeader(), new EndpointProviderSpec2(model));
return new PoetGeneratorTask(endpointRulesInternalDir(), model.getFileHeader(), new EndpointProviderSpec(model));
}

private GeneratorTask generateDefaultPartitionsProvider() {
return new PoetGeneratorTask(endpointRulesInternalDir(), model.getFileHeader(),
new DefaultPartitionDataProviderSpec(model));
}

private boolean shouldGenerateCompiledEndpointRules() {
CustomizationConfig customizationConfig = generatorTaskParams.getModel().getCustomizationConfig();
return customizationConfig.isEnableGenerateCompiledEndpointRules();
}

private Collection<GeneratorTask> generateInterceptors() {
return Arrays.asList(
new PoetGeneratorTask(endpointRulesInternalDir(), model.getFileHeader(), new EndpointResolverUtilsSpec(model)));
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -314,11 +314,6 @@ public class CustomizationConfig {

private boolean s3ExpressAuthSupport;

/**
* Set to true to enable compiled endpoint rules. Currently defaults to false.
*/
private boolean enableGenerateCompiledEndpointRules = false;

/**
* Customization related to auth scheme derived from endpoints.
*/
Expand Down Expand Up @@ -817,14 +812,6 @@ public void setUseS3ExpressSessionAuth(boolean useS3ExpressSessionAuth) {
this.useS3ExpressSessionAuth = useS3ExpressSessionAuth;
}

public boolean isEnableGenerateCompiledEndpointRules() {
return enableGenerateCompiledEndpointRules;
}

public void setEnableGenerateCompiledEndpointRules(boolean enableGenerateCompiledEndpointRules) {
this.enableGenerateCompiledEndpointRules = enableGenerateCompiledEndpointRules;
}

public Map<String, String> getSkipEndpointTests() {
return skipEndpointTests;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,13 @@ private void addAccessorMethods(TypeSpec.Builder b) {
.addJavadoc("Returns the region. The region parameter may be used with the $S auth scheme.",
AwsV4AuthScheme.SCHEME_ID)
.build());
b.addMethod(MethodSpec.methodBuilder("regionId")
.addModifiers(Modifier.PUBLIC, Modifier.DEFAULT)
.returns(String.class)
.addJavadoc("Returns the region ID as a string. Returns null if region is not set.")
.addStatement("$T region = region()", Region.class)
.addStatement("return region == null ? null : region.id()")
.build());
}

if (authSchemeSpecUtils.hasSigV4aSupport()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,13 @@ private void addFieldsAndAccessors(TypeSpec.Builder b) {
.returns(Region.class)
.addStatement("return region")
.build());

b.addMethod(MethodSpec.methodBuilder("regionId")
.addModifiers(Modifier.PUBLIC)
.addAnnotation(Override.class)
.returns(String.class)
.addStatement("return region == null ? null : region.id()")
.build());
}

if (authSchemeSpecUtils.hasSigV4aSupport()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* permissions and limitations under the License.
*/

package software.amazon.awssdk.codegen.poet.rules2;
package software.amazon.awssdk.codegen.poet.rules;

/**
* Assigns an identifier to each rule then we use as a name for the generated method.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* permissions and limitations under the License.
*/

package software.amazon.awssdk.codegen.poet.rules2;
package software.amazon.awssdk.codegen.poet.rules;

import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* permissions and limitations under the License.
*/

package software.amazon.awssdk.codegen.poet.rules2;
package software.amazon.awssdk.codegen.poet.rules;

import java.util.ArrayList;
import java.util.Collections;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* permissions and limitations under the License.
*/

package software.amazon.awssdk.codegen.poet.rules2;
package software.amazon.awssdk.codegen.poet.rules;

import java.util.Objects;
import software.amazon.awssdk.utils.Validate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* permissions and limitations under the License.
*/

package software.amazon.awssdk.codegen.poet.rules2;
package software.amazon.awssdk.codegen.poet.rules;

import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.CodeBlock;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* permissions and limitations under the License.
*/

package software.amazon.awssdk.codegen.poet.rules2;
package software.amazon.awssdk.codegen.poet.rules;

import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -64,10 +64,6 @@ public RuleSetExpression root() {
return root;
}

public String regionParamName() {
return symbolTable.regionParamName();
}

public SymbolTable symbolTable() {
return symbolTable;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* permissions and limitations under the License.
*/

package software.amazon.awssdk.codegen.poet.rules2;
package software.amazon.awssdk.codegen.poet.rules;

import java.util.ArrayDeque;
import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* permissions and limitations under the License.
*/

package software.amazon.awssdk.codegen.poet.rules2;
package software.amazon.awssdk.codegen.poet.rules;

import java.util.Objects;
import software.amazon.awssdk.utils.Validate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import javax.lang.model.element.Modifier;
import software.amazon.awssdk.annotations.SdkPublicApi;
import software.amazon.awssdk.codegen.model.intermediate.IntermediateModel;
import software.amazon.awssdk.codegen.model.rules.endpoints.BuiltInParameter;
import software.amazon.awssdk.codegen.model.rules.endpoints.ParameterModel;
import software.amazon.awssdk.codegen.poet.ClassSpec;
import software.amazon.awssdk.codegen.poet.PoetUtils;
Expand Down Expand Up @@ -56,6 +57,12 @@ public TypeSpec poetSpec() {
parameters().forEach((name, model) -> {
b.addField(endpointRulesSpecUtils.parameterClassField(name, model));
b.addMethod(endpointRulesSpecUtils.parameterClassAccessorMethod(name, model));
// For Region-typed params, add a "{name}Id()" convenience method that returns the
// region ID as a String (null-safe). This is used by the compiled endpoint rules
// which operate on String values.
if (model.getBuiltInEnum() == BuiltInParameter.AWS_REGION) {
b.addMethod(regionIdAccessorMethod(name));
}
});

b.addMethod(toBuilderMethod());
Expand Down Expand Up @@ -156,6 +163,26 @@ private String variableName(String name) {
return intermediateModel.getNamingStrategy().getVariableName(name);
}

/**
* Creates a convenience accessor for Region-typed parameters that returns the region ID as a String.
* For instance, for a parameter named "Region":
*
* <pre>
* public String regionId() {
* return region == null ? null : region.id();
* }
* </pre>
*/
private MethodSpec regionIdAccessorMethod(String name) {
String varName = variableName(name);
String methodName = endpointRulesSpecUtils.paramMethodName(name) + "Id";
return MethodSpec.methodBuilder(methodName)
.addModifiers(Modifier.PUBLIC)
.returns(String.class)
.addStatement("return $N == null ? null : $N.id()", varName, varName)
.build();
}

private MethodSpec.Builder toBuilderConstructor() {
MethodSpec.Builder constructorBuilder = MethodSpec.constructorBuilder();
constructorBuilder.addModifiers(Modifier.PRIVATE);
Expand Down
Loading
Loading