Skip to content

Commit ab75b9c

Browse files
Merge pull request #700 from aws/staging/4ccd67b0-5ca3-46b4-81b0-9ce1357c4117
Pull request: release <- staging/4ccd67b0-5ca3-46b4-81b0-9ce1357c4117
2 parents 0040127 + 496adaa commit ab75b9c

File tree

285 files changed

+5218
-2231
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

285 files changed

+5218
-2231
lines changed

.changes/2.10.33.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"version": "2.10.33",
3+
"date": "2019-12-11",
4+
"entries": [
5+
{
6+
"type": "feature",
7+
"category": "Amazon Elastic Compute Cloud",
8+
"description": "This release allows customers to attach multiple Elastic Inference Accelerators to a single EC2 instance. It adds support for a Count parameter for each Elastic Inference Accelerator type you specify on the RunInstances and LaunchTemplate APIs."
9+
},
10+
{
11+
"type": "feature",
12+
"category": "AWS SDK for Java v2",
13+
"description": "Adds a `has*` method to requests and responses that have a List or Map property."
14+
}
15+
]
16+
}

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# __2.10.33__ __2019-12-11__
2+
## __AWS SDK for Java v2__
3+
- ### Features
4+
- Adds a `has*` method to requests and responses that have a List or Map property.
5+
6+
## __Amazon Elastic Compute Cloud__
7+
- ### Features
8+
- This release allows customers to attach multiple Elastic Inference Accelerators to a single EC2 instance. It adds support for a Count parameter for each Elastic Inference Accelerator type you specify on the RunInstances and LaunchTemplate APIs.
9+
110
# __2.10.32__ __2019-12-10__
211
## __AWSKendraFrontendService__
312
- ### Features

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ To automatically manage module versions (currently all modules have the same ver
4848
<dependency>
4949
<groupId>software.amazon.awssdk</groupId>
5050
<artifactId>bom</artifactId>
51-
<version>2.10.32</version>
51+
<version>2.10.33</version>
5252
<type>pom</type>
5353
<scope>import</scope>
5454
</dependency>
@@ -82,12 +82,12 @@ Alternatively you can add dependencies for the specific services you use only:
8282
<dependency>
8383
<groupId>software.amazon.awssdk</groupId>
8484
<artifactId>ec2</artifactId>
85-
<version>2.10.32</version>
85+
<version>2.10.33</version>
8686
</dependency>
8787
<dependency>
8888
<groupId>software.amazon.awssdk</groupId>
8989
<artifactId>s3</artifactId>
90-
<version>2.10.32</version>
90+
<version>2.10.33</version>
9191
</dependency>
9292
```
9393

@@ -99,7 +99,7 @@ You can import the whole SDK into your project (includes *ALL* services). Please
9999
<dependency>
100100
<groupId>software.amazon.awssdk</groupId>
101101
<artifactId>aws-sdk-java</artifactId>
102-
<version>2.10.32</version>
102+
<version>2.10.33</version>
103103
</dependency>
104104
```
105105

aws-sdk-java/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>software.amazon.awssdk</groupId>
66
<artifactId>aws-sdk-java-pom</artifactId>
7-
<version>2.10.32</version>
7+
<version>2.10.33</version>
88
<relativePath>../pom.xml</relativePath>
99
</parent>
1010
<artifactId>aws-sdk-java</artifactId>

bom-internal/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>aws-sdk-java-pom</artifactId>
77
<groupId>software.amazon.awssdk</groupId>
8-
<version>2.10.32</version>
8+
<version>2.10.33</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

bom/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>software.amazon.awssdk</groupId>
66
<artifactId>aws-sdk-java-pom</artifactId>
7-
<version>2.10.32</version>
7+
<version>2.10.33</version>
88
<relativePath>../pom.xml</relativePath>
99
</parent>
1010
<artifactId>bom</artifactId>

bundle/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<parent>
2222
<groupId>software.amazon.awssdk</groupId>
2323
<artifactId>aws-sdk-java-pom</artifactId>
24-
<version>2.10.32</version>
24+
<version>2.10.33</version>
2525
</parent>
2626
<artifactId>bundle</artifactId>
2727
<packaging>jar</packaging>

codegen-lite-maven-plugin/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>software.amazon.awssdk</groupId>
99
<artifactId>aws-sdk-java-pom</artifactId>
10-
<version>2.10.32</version>
10+
<version>2.10.33</version>
1111
<relativePath>../pom.xml</relativePath>
1212
</parent>
1313
<artifactId>codegen-lite-maven-plugin</artifactId>

codegen-lite/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>software.amazon.awssdk</groupId>
88
<artifactId>aws-sdk-java-pom</artifactId>
9-
<version>2.10.32</version>
9+
<version>2.10.33</version>
1010
</parent>
1111
<artifactId>codegen-lite</artifactId>
1212
<name>AWS Java SDK :: Code Generator Lite</name>

codegen-maven-plugin/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<parent>
2323
<groupId>software.amazon.awssdk</groupId>
2424
<artifactId>aws-sdk-java-pom</artifactId>
25-
<version>2.10.32</version>
25+
<version>2.10.33</version>
2626
<relativePath>../pom.xml</relativePath>
2727
</parent>
2828
<artifactId>codegen-maven-plugin</artifactId>

codegen/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<parent>
2222
<groupId>software.amazon.awssdk</groupId>
2323
<artifactId>aws-sdk-java-pom</artifactId>
24-
<version>2.10.32</version>
24+
<version>2.10.33</version>
2525
</parent>
2626
<artifactId>codegen</artifactId>
2727
<name>AWS Java SDK :: Code Generator</name>

codegen/src/main/java/software/amazon/awssdk/codegen/AddShapes.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ private MemberModel generateMemberModel(String c2jMemberName, Member c2jMemberDe
179179
.withFluentEnumGetterMethodName(namingStrategy.getFluentEnumGetterMethodName(c2jMemberName, parentShape, shape))
180180
.withFluentSetterMethodName(namingStrategy.getFluentSetterMethodName(c2jMemberName, parentShape, shape))
181181
.withFluentEnumSetterMethodName(namingStrategy.getFluentEnumSetterMethodName(c2jMemberName, parentShape, shape))
182+
.withExistenceCheckMethodName(namingStrategy.getExistenceCheckMethodName(c2jMemberName, parentShape))
182183
.withBeanStyleGetterMethodName(namingStrategy.getBeanStyleGetterMethodName(c2jMemberName, parentShape, shape))
183184
.withBeanStyleSetterMethodName(namingStrategy.getBeanStyleSetterMethodName(c2jMemberName, parentShape, shape));
184185
memberModel.setIdempotencyToken(c2jMemberDefinition.isIdempotencyToken());

codegen/src/main/java/software/amazon/awssdk/codegen/internal/DocumentationUtils.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ public final class DocumentationUtils {
3636

3737
private static final String DEFAULT_GETTER_PARAM = "The value of the %s property for this object.";
3838

39+
private static final String DEFAULT_EXISTENCE_CHECK = "Returns true if the %s property was specified by the sender "
40+
+ "(it may be empty), or false if the sender did not specify "
41+
+ "the value (it will be empty). For responses returned by the SDK, "
42+
+ "the sender is the AWS service.";
43+
3944
private static final String DEFAULT_FLUENT_RETURN =
4045
"Returns a reference to this object so that method calls can be chained together.";
4146

@@ -164,4 +169,8 @@ public static String defaultGetterParam() {
164169
public static String defaultFluentReturn() {
165170
return DEFAULT_FLUENT_RETURN;
166171
}
172+
173+
public static String defaultExistenceCheck() {
174+
return DEFAULT_EXISTENCE_CHECK;
175+
}
167176
}

codegen/src/main/java/software/amazon/awssdk/codegen/model/intermediate/MemberModel.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package software.amazon.awssdk.codegen.model.intermediate;
1717

1818
import static software.amazon.awssdk.codegen.internal.Constant.LF;
19+
import static software.amazon.awssdk.codegen.internal.DocumentationUtils.defaultExistenceCheck;
1920
import static software.amazon.awssdk.codegen.internal.DocumentationUtils.defaultFluentReturn;
2021
import static software.amazon.awssdk.codegen.internal.DocumentationUtils.defaultGetter;
2122
import static software.amazon.awssdk.codegen.internal.DocumentationUtils.defaultGetterParam;
@@ -24,11 +25,15 @@
2425
import static software.amazon.awssdk.codegen.internal.DocumentationUtils.stripHtmlTags;
2526

2627
import com.fasterxml.jackson.annotation.JsonIgnore;
28+
import com.squareup.javapoet.ClassName;
2729
import java.util.List;
2830
import java.util.Map;
31+
import java.util.Optional;
2932
import software.amazon.awssdk.codegen.internal.TypeUtils;
3033
import software.amazon.awssdk.core.SdkBytes;
3134
import software.amazon.awssdk.core.protocol.MarshallingType;
35+
import software.amazon.awssdk.core.util.SdkAutoConstructList;
36+
import software.amazon.awssdk.core.util.SdkAutoConstructMap;
3237
import software.amazon.awssdk.protocols.core.PathMarshaller;
3338
import software.amazon.awssdk.utils.StringUtils;
3439

@@ -70,6 +75,8 @@ public class MemberModel extends DocumentationModel {
7075

7176
private String fluentEnumSetterMethodName;
7277

78+
private String existenceCheckMethodName;
79+
7380
private String beanStyleGetterName;
7481

7582
private String beanStyleSetterName;
@@ -247,6 +254,19 @@ public MemberModel withFluentEnumSetterMethodName(String fluentEnumSetterMethodN
247254
return this;
248255
}
249256

257+
public String getExistenceCheckMethodName() {
258+
return existenceCheckMethodName;
259+
}
260+
261+
public void setExistenceCheckMethodName(String existenceCheckMethodName) {
262+
this.existenceCheckMethodName = existenceCheckMethodName;
263+
}
264+
265+
public MemberModel withExistenceCheckMethodName(String existenceCheckMethodName) {
266+
setExistenceCheckMethodName(existenceCheckMethodName);
267+
return this;
268+
}
269+
250270
public ReturnTypeModel getGetterModel() {
251271
return getterModel;
252272
}
@@ -408,6 +428,12 @@ public String getGetterDocumentation() {
408428
}
409429
}
410430

431+
if (getAutoConstructClassIfExists().isPresent()) {
432+
appendParagraph(docBuilder,
433+
"You can use {@link #%s()} to see if a value was sent in this field.",
434+
getExistenceCheckMethodName());
435+
}
436+
411437
String variableDesc = StringUtils.isNotBlank(documentation) ? documentation : defaultGetterParam().replace("%s", name);
412438

413439
docBuilder.append("@return ")
@@ -429,6 +455,10 @@ public String getFluentSetterDocumentation() {
429455
+ getEnumDoc();
430456
}
431457

458+
public String getExistenceCheckDocumentation() {
459+
return defaultExistenceCheck().replace("%s", name) + LF;
460+
}
461+
432462
public String getDefaultConsumerFluentSetterDocumentation() {
433463
return (StringUtils.isNotBlank(documentation) ? documentation : defaultSetter().replace("%s", name) + "\n")
434464
+ LF
@@ -613,4 +643,14 @@ private void appendParagraph(StringBuilder builder, String content, Object... co
613643
.append("</p>")
614644
.append(LF);
615645
}
646+
647+
public Optional<ClassName> getAutoConstructClassIfExists() {
648+
if (isList()) {
649+
return Optional.of(ClassName.get(SdkAutoConstructList.class));
650+
} else if (isMap()) {
651+
return Optional.of(ClassName.get(SdkAutoConstructMap.class));
652+
}
653+
654+
return Optional.empty();
655+
}
616656
}

codegen/src/main/java/software/amazon/awssdk/codegen/naming/DefaultNamingStrategy.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,13 @@ public String getFluentEnumGetterMethodName(String memberName, Shape parentShape
292292
return getterMethodName;
293293
}
294294

295+
@Override
296+
public String getExistenceCheckMethodName(String memberName, Shape parentShape) {
297+
String existenceCheckMethodName = Utils.unCapitalize(memberName);
298+
existenceCheckMethodName = rewriteInvalidMemberName(existenceCheckMethodName, parentShape);
299+
return String.format("has%s", Utils.capitalize(existenceCheckMethodName));
300+
}
301+
295302
@Override
296303
public String getBeanStyleGetterMethodName(String memberName, Shape parentShape, Shape c2jShape) {
297304
String fluentGetterMethodName = getFluentGetterMethodName(memberName, parentShape, c2jShape);

codegen/src/main/java/software/amazon/awssdk/codegen/naming/NamingStrategy.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,4 +146,13 @@ public interface NamingStrategy {
146146
* @return Name of field for {@link SdkField} pojo.
147147
*/
148148
String getSdkFieldFieldName(MemberModel memberModel);
149+
150+
/**
151+
* Names a method that would check for existence of the member in the response.
152+
*
153+
* @param memberName The member name to get the method name for.
154+
* @param parentShape The shape containing the member.
155+
* @return Name of an existence check method.
156+
*/
157+
String getExistenceCheckMethodName(String memberName, Shape parentShape);
149158
}

codegen/src/main/java/software/amazon/awssdk/codegen/poet/model/AwsServiceModel.java

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -233,12 +233,12 @@ private MethodSpec.Builder acceptMethodSpec(ClassName modelClass, ClassName resp
233233
return MethodSpec.methodBuilder("accept")
234234
.addModifiers(PUBLIC)
235235
.addJavadoc(new DocumentationBuilder()
236-
.description("Calls the appropriate visit method depending on "
237-
+ "the subtype of {@link $T}.")
238-
.param("visitor", "Visitor to invoke.")
239-
.build(), modelClass)
236+
.description("Calls the appropriate visit method depending on "
237+
+ "the subtype of {@link $T}.")
238+
.param("visitor", "Visitor to invoke.")
239+
.build(), modelClass)
240240
.addParameter(responseHandlerClass
241-
.nestedClass("Visitor"), "visitor");
241+
.nestedClass("Visitor"), "visitor");
242242
}
243243

244244
@Override
@@ -295,7 +295,7 @@ private TypeName responseBaseClass() {
295295

296296
private ClassName exceptionBaseClass() {
297297
String customExceptionBase = intermediateModel.getCustomizationConfig()
298-
.getSdkModeledExceptionBaseClassName();
298+
.getSdkModeledExceptionBaseClassName();
299299
if (customExceptionBase != null) {
300300
return poetExtensions.getModelClass(customExceptionBase);
301301
}
@@ -304,8 +304,8 @@ private ClassName exceptionBaseClass() {
304304

305305
private TypeName toCopyableBuilderInterface() {
306306
return ParameterizedTypeName.get(ClassName.get(ToCopyableBuilder.class),
307-
className().nestedClass("Builder"),
308-
className());
307+
className().nestedClass("Builder"),
308+
className());
309309
}
310310

311311
private List<MethodSpec> modelClassMethods() {
@@ -381,14 +381,16 @@ private Stream<MethodSpec> memberGetters(MemberModel member) {
381381
result.add(enumMemberGetter(member));
382382
}
383383

384+
member.getAutoConstructClassIfExists()
385+
.ifPresent(autoConstructClass -> result.add(existenceCheckGetter(member, autoConstructClass)));
386+
384387
result.add(memberGetter(member));
385388

386389
return result.stream();
387390
}
388391

389392
private boolean shouldGenerateEnumGetter(MemberModel member) {
390393
return member.getEnumType() != null || MemberCopierSpec.isEnumCopyAvailable(member);
391-
392394
}
393395

394396
private MethodSpec enumMemberGetter(MemberModel member) {
@@ -409,6 +411,20 @@ private MethodSpec memberGetter(MemberModel member) {
409411
.build();
410412
}
411413

414+
private MethodSpec existenceCheckGetter(MemberModel member, ClassName autoConstructClass) {
415+
return MethodSpec.methodBuilder(member.getExistenceCheckMethodName())
416+
.addJavadoc("$L", member.getExistenceCheckDocumentation())
417+
.addModifiers(PUBLIC)
418+
.returns(TypeName.BOOLEAN)
419+
.addCode(existenceCheckStatement(member, autoConstructClass))
420+
.build();
421+
}
422+
423+
private CodeBlock existenceCheckStatement(MemberModel member, ClassName autoConstructClass) {
424+
String variableName = member.getVariable().getVariableName();
425+
return CodeBlock.of("return $N != null && !($N instanceof $T);", variableName, variableName, autoConstructClass);
426+
}
427+
412428
private CodeBlock enumGetterStatement(MemberModel member) {
413429
String fieldName = member.getVariable().getVariableName();
414430
if (member.isList() || member.isMap()) {

0 commit comments

Comments
 (0)