Skip to content

Commit 0041c0b

Browse files
committed
Add support for generating waiter acceptors.
This required the following changes: 1. Added a JMES Path interpreter based on the JMES Path parser from a previous commit. This interpreter is in the code generator and creates the Java instructions for executing the acceptor logic. 2. Added the code generator logic for specifying the acceptors. 3. Added a Waiters runtime that is currently shared between all service clients, used by the acceptors of all services. 4. Added a "MemberName" field to the SDK field metadata, so that it can be referenced by the waiter code (waiters refer to the member names from the C2J). 5. Added tests for the two most complex waiter classes: AutoScaling and ECS 6. Added support for acceptors matching supertypes of the response type. Waiters should mostly be working now, but there are a few remaining tasks: 1. There's a WaitersRuntime component in sdk-core that should be copied to each of the service to remove them as a protected API. 2. Waiters currently only support the JMESPath syntax currently used by services. We should add support for some of the other 'easier' JMESPath syntax so that we're future-compatible with more waiters.
1 parent 9b9a59a commit 0041c0b

File tree

56 files changed

+1737
-381
lines changed

Some content is hidden

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

56 files changed

+1737
-381
lines changed

codegen/src/main/java/software/amazon/awssdk/codegen/jmespath/component/BracketSpecifier.java

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
package software.amazon.awssdk.codegen.jmespath.component;
1717

18+
import software.amazon.awssdk.codegen.jmespath.parser.JmesPathVisitor;
1819
import software.amazon.awssdk.utils.Validate;
1920

2021
/**
@@ -89,7 +90,7 @@ public BracketSpecifierWithQuestionMark asBracketSpecifierWithQuestionMark() {
8990
return bracketSpecifierWithQuestionMark;
9091
}
9192

92-
public void visit(Visitor visitor) {
93+
public void visit(JmesPathVisitor visitor) {
9394
if (isBracketSpecifierWithContents()) {
9495
visitor.visitBracketSpecifierWithContents(asBracketSpecifierWithContents());
9596
} else if (isBracketSpecifierWithoutContents()) {
@@ -100,15 +101,4 @@ public void visit(Visitor visitor) {
100101
throw new IllegalStateException();
101102
}
102103
}
103-
104-
public interface Visitor {
105-
default void visitBracketSpecifierWithContents(BracketSpecifierWithContents bracketSpecifierWithContents) {
106-
}
107-
108-
default void visitBracketSpecifierWithoutContents(BracketSpecifierWithoutContents bracketSpecifierWithContents) {
109-
}
110-
111-
default void visitBracketSpecifierWithQuestionMark(BracketSpecifierWithQuestionMark bracketSpecifierWithContents) {
112-
}
113-
}
114104
}

codegen/src/main/java/software/amazon/awssdk/codegen/jmespath/component/BracketSpecifierWithContents.java

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
package software.amazon.awssdk.codegen.jmespath.component;
1717

18+
import software.amazon.awssdk.codegen.jmespath.parser.JmesPathVisitor;
1819
import software.amazon.awssdk.utils.Validate;
1920

2021
/**
@@ -81,7 +82,7 @@ public SliceExpression asSliceExpression() {
8182
return sliceExpression;
8283
}
8384

84-
public void visit(Visitor visitor) {
85+
public void visit(JmesPathVisitor visitor) {
8586
if (isNumber()) {
8687
visitor.visitNumber(asNumber());
8788
} else if (isWildcardExpression()) {
@@ -92,15 +93,4 @@ public void visit(Visitor visitor) {
9293
throw new IllegalStateException();
9394
}
9495
}
95-
96-
public interface Visitor {
97-
default void visitNumber(int asNumber) {
98-
}
99-
100-
default void visitWildcardExpression(WildcardExpression asWildcardExpression) {
101-
}
102-
103-
default void visitSliceExpression(SliceExpression asSliceExpression) {
104-
}
105-
}
10696
}

codegen/src/main/java/software/amazon/awssdk/codegen/jmespath/component/Expression.java

Lines changed: 2 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
package software.amazon.awssdk.codegen.jmespath.component;
1717

18+
import software.amazon.awssdk.codegen.jmespath.parser.JmesPathVisitor;
1819
import software.amazon.awssdk.utils.Validate;
1920

2021
/**
@@ -297,7 +298,7 @@ public CurrentNode asCurrentNode() {
297298
return currentNode;
298299
}
299300

300-
public void visit(Visitor visitor) {
301+
public void visit(JmesPathVisitor visitor) {
301302
if (isSubExpression()) {
302303
visitor.visitSubExpression(asSubExpression());
303304
} else if (isSubExpression()) {
@@ -336,57 +337,4 @@ public void visit(Visitor visitor) {
336337
throw new IllegalStateException();
337338
}
338339
}
339-
340-
public interface Visitor {
341-
default void visitExpression(Expression expression) {
342-
}
343-
344-
default void visitSubExpression(SubExpression subExpression) {
345-
}
346-
347-
default void visitIndexExpression(IndexExpression indexExpression) {
348-
}
349-
350-
default void visitComparatorExpression(ComparatorExpression comparatorExpression) {
351-
}
352-
353-
default void visitOrExpression(OrExpression orExpression) {
354-
}
355-
356-
default void visitIdentifier(String identifier) {
357-
}
358-
359-
default void visitAndExpression(AndExpression andExpression) {
360-
}
361-
362-
default void visitNotExpression(NotExpression notExpression) {
363-
}
364-
365-
default void visitParenExpression(ParenExpression parenExpression) {
366-
}
367-
368-
default void visitWildcardExpression(WildcardExpression star) {
369-
}
370-
371-
default void visitMultiSelectList(MultiSelectList multiSelectList) {
372-
}
373-
374-
default void visitMultiSelectHash(MultiSelectHash multiSelectHash) {
375-
}
376-
377-
default void visitLiteral(Literal literal) {
378-
}
379-
380-
default void visitFunctionExpression(FunctionExpression functionExpression) {
381-
}
382-
383-
default void visitPipeExpression(PipeExpression pipeExpression) {
384-
}
385-
386-
default void visitRawString(String rawString) {
387-
}
388-
389-
default void visitCurrentNode(CurrentNode currentNode) {
390-
}
391-
}
392340
}

codegen/src/main/java/software/amazon/awssdk/codegen/jmespath/component/FunctionArg.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package software.amazon.awssdk.codegen.jmespath.component;
1717

1818

19+
import software.amazon.awssdk.codegen.jmespath.parser.JmesPathVisitor;
1920
import software.amazon.awssdk.utils.Validate;
2021

2122
/**
@@ -62,7 +63,7 @@ public ExpressionType asExpressionType() {
6263
return expressionType;
6364
}
6465

65-
public void visit(Visitor visitor) {
66+
public void visit(JmesPathVisitor visitor) {
6667
if (isExpression()) {
6768
visitor.visitExpression(asExpression());
6869
} else if (isExpressionType()) {
@@ -71,12 +72,4 @@ public void visit(Visitor visitor) {
7172
throw new IllegalStateException();
7273
}
7374
}
74-
75-
interface Visitor {
76-
default void visitExpression(Expression expression) {
77-
}
78-
79-
default void visitExpressionType(ExpressionType expressionType) {
80-
}
81-
}
8275
}

codegen/src/main/java/software/amazon/awssdk/codegen/jmespath/component/SubExpressionRight.java

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
package software.amazon.awssdk.codegen.jmespath.component;
1717

18+
import software.amazon.awssdk.codegen.jmespath.parser.JmesPathVisitor;
1819
import software.amazon.awssdk.utils.Validate;
1920

2021
/**
@@ -108,8 +109,7 @@ public WildcardExpression asWildcardExpression() {
108109
return wildcardExpression;
109110
}
110111

111-
112-
public void visit(Visitor visitor) {
112+
public void visit(JmesPathVisitor visitor) {
113113
if (isIdentifier()) {
114114
visitor.visitIdentifier(asIdentifier());
115115
} else if (isMultiSelectList()) {
@@ -124,21 +124,4 @@ public void visit(Visitor visitor) {
124124
throw new IllegalStateException();
125125
}
126126
}
127-
128-
interface Visitor {
129-
default void visitIdentifier(String identifier) {
130-
}
131-
132-
default void visitMultiSelectList(MultiSelectList multiSelectList) {
133-
}
134-
135-
default void visitMultiSelectHash(MultiSelectHash multiSelectHash) {
136-
}
137-
138-
default void visitFunctionExpression(FunctionExpression functionExpression) {
139-
}
140-
141-
default void visitWildcardExpression(WildcardExpression wildcardExpression) {
142-
}
143-
}
144127
}

codegen/src/main/java/software/amazon/awssdk/codegen/jmespath/parser/JmesPathParser.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,18 +97,18 @@ private ParseResult<Expression> parseExpression(int startPosition, int endPositi
9797

9898
return CompositeParser.firstTry(this::parseSubExpression, Expression::subExpression)
9999
.thenTry(this::parseIndexExpression, Expression::indexExpression)
100-
.thenTry(this::parseComparatorExpression, Expression::comparatorExpression)
100+
.thenTry(this::parseNotExpression, Expression::notExpression)
101+
.thenTry(this::parseAndExpression, Expression::andExpression)
101102
.thenTry(this::parseOrExpression, Expression::orExpression)
103+
.thenTry(this::parseComparatorExpression, Expression::comparatorExpression)
104+
.thenTry(this::parsePipeExpression, Expression::pipeExpression)
102105
.thenTry(this::parseIdentifier, Expression::identifier)
103-
.thenTry(this::parseAndExpression, Expression::andExpression)
104-
.thenTry(this::parseNotExpression, Expression::notExpression)
105106
.thenTry(this::parseParenExpression, Expression::parenExpression)
106107
.thenTry(this::parseWildcardExpression, Expression::wildcardExpression)
107108
.thenTry(this::parseMultiSelectList, Expression::multiSelectList)
108109
.thenTry(this::parseMultiSelectHash, Expression::multiSelectHash)
109110
.thenTry(this::parseLiteral, Expression::literal)
110111
.thenTry(this::parseFunctionExpression, Expression::functionExpression)
111-
.thenTry(this::parsePipeExpression, Expression::pipeExpression)
112112
.thenTry(this::parseRawString, Expression::rawString)
113113
.thenTry(this::parseCurrentNode, Expression::currentNode)
114114
.parse(startPosition, endPosition);
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://aws.amazon.com/apache2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
16+
package software.amazon.awssdk.codegen.jmespath.parser;
17+
18+
import software.amazon.awssdk.codegen.jmespath.component.AndExpression;
19+
import software.amazon.awssdk.codegen.jmespath.component.BracketSpecifier;
20+
import software.amazon.awssdk.codegen.jmespath.component.BracketSpecifierWithContents;
21+
import software.amazon.awssdk.codegen.jmespath.component.BracketSpecifierWithQuestionMark;
22+
import software.amazon.awssdk.codegen.jmespath.component.BracketSpecifierWithoutContents;
23+
import software.amazon.awssdk.codegen.jmespath.component.ComparatorExpression;
24+
import software.amazon.awssdk.codegen.jmespath.component.CurrentNode;
25+
import software.amazon.awssdk.codegen.jmespath.component.Expression;
26+
import software.amazon.awssdk.codegen.jmespath.component.ExpressionType;
27+
import software.amazon.awssdk.codegen.jmespath.component.FunctionExpression;
28+
import software.amazon.awssdk.codegen.jmespath.component.IndexExpression;
29+
import software.amazon.awssdk.codegen.jmespath.component.Literal;
30+
import software.amazon.awssdk.codegen.jmespath.component.MultiSelectHash;
31+
import software.amazon.awssdk.codegen.jmespath.component.MultiSelectList;
32+
import software.amazon.awssdk.codegen.jmespath.component.NotExpression;
33+
import software.amazon.awssdk.codegen.jmespath.component.OrExpression;
34+
import software.amazon.awssdk.codegen.jmespath.component.ParenExpression;
35+
import software.amazon.awssdk.codegen.jmespath.component.PipeExpression;
36+
import software.amazon.awssdk.codegen.jmespath.component.SliceExpression;
37+
import software.amazon.awssdk.codegen.jmespath.component.SubExpression;
38+
import software.amazon.awssdk.codegen.jmespath.component.SubExpressionRight;
39+
import software.amazon.awssdk.codegen.jmespath.component.WildcardExpression;
40+
41+
/**
42+
* A visitor across all of the JMESPath expression types. This can be passed to any 'union' type visitors, like
43+
* {@link Expression#visit(JmesPathVisitor)}.
44+
*/
45+
public interface JmesPathVisitor {
46+
void visitExpression(Expression input);
47+
48+
void visitSubExpression(SubExpression input);
49+
50+
void visitSubExpressionRight(SubExpressionRight input);
51+
52+
void visitIndexExpression(IndexExpression input);
53+
54+
void visitBracketSpecifier(BracketSpecifier input);
55+
56+
void visitBracketSpecifierWithContents(BracketSpecifierWithContents input);
57+
58+
void visitSliceExpression(SliceExpression input);
59+
60+
void visitBracketSpecifierWithoutContents(BracketSpecifierWithoutContents input);
61+
62+
void visitBracketSpecifierWithQuestionMark(BracketSpecifierWithQuestionMark input);
63+
64+
void visitComparatorExpression(ComparatorExpression input);
65+
66+
void visitOrExpression(OrExpression input);
67+
68+
void visitIdentifier(String input);
69+
70+
void visitAndExpression(AndExpression input);
71+
72+
void visitNotExpression(NotExpression input);
73+
74+
void visitParenExpression(ParenExpression input);
75+
76+
void visitWildcardExpression(WildcardExpression input);
77+
78+
void visitMultiSelectList(MultiSelectList input);
79+
80+
void visitMultiSelectHash(MultiSelectHash input);
81+
82+
void visitExpressionType(ExpressionType asExpressionType);
83+
84+
void visitLiteral(Literal input);
85+
86+
void visitFunctionExpression(FunctionExpression input);
87+
88+
void visitPipeExpression(PipeExpression input);
89+
90+
void visitRawString(String input);
91+
92+
void visitCurrentNode(CurrentNode input);
93+
94+
void visitNumber(int input);
95+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ private CodeBlock sdkFieldInitializer(MemberModel m) {
128128
.add("$T.<$T>builder($T.$L)\n",
129129
sdkFieldType, typeProvider.fieldType(m),
130130
ClassName.get(MarshallingType.class), m.getMarshallingType())
131+
.add(".memberName($S)\n", m.getC2jName())
131132
.add(".getter(getter($T::$L))\n",
132133
className(), m.getFluentGetterMethodName())
133134
.add(".setter(setter($T::$L))\n",

0 commit comments

Comments
 (0)