36
36
*/
37
37
public class EventStreamGenerator implements TypeScriptIntegration {
38
38
39
- public static final boolean hasEventStream (
40
- Model model ,
41
- ServiceShape service
42
- ) {
43
- TopDownIndex topDownIndex = model .getKnowledge (TopDownIndex .class );
44
- Set <OperationShape > operations = topDownIndex .getContainedOperations (service );
45
- for (OperationShape operation : operations ) {
46
- if (operationHasEventStream (model , service , operation )) {
47
- return true ;
48
- }
49
- }
50
- return false ;
51
- }
52
-
53
- public static final boolean operationHasEventStream (
54
- Model model ,
55
- ServiceShape service ,
56
- OperationShape operation
57
- ) {
58
- if (operationHasEventStreamInput (model , operation ) || operationHasEventStreamOutput (model , operation )) {
59
- return true ;
60
- }
61
- return false ;
62
- }
63
-
64
- public static final boolean operationHasEventStreamInput (
65
- Model model ,
66
- OperationShape operation
67
- ) {
68
- EventStreamIndex eventStreamIndex = model .getKnowledge (EventStreamIndex .class );
69
- if (eventStreamIndex .getInputInfo (operation ).isPresent ()) {
70
- return true ;
71
- }
72
- return false ;
73
- }
74
-
75
- public static final boolean operationHasEventStreamOutput (
76
- Model model ,
77
- OperationShape operation
78
- ) {
79
- EventStreamIndex eventStreamIndex = model .getKnowledge (EventStreamIndex .class );
80
- if (eventStreamIndex .getOutputInfo (operation ).isPresent ()) {
81
- return true ;
82
- }
83
- return false ;
84
- }
85
-
86
- public static String getEventHeaderType (Shape shape ) {
87
- switch (shape .getType ()) {
88
- case BOOLEAN :
89
- case BYTE :
90
- case SHORT :
91
- case INTEGER :
92
- case LONG :
93
- case STRING :
94
- case TIMESTAMP :
95
- return shape .getType ().toString ();
96
- case BLOB :
97
- return "binary" ;
98
- default :
99
- return "binary" ;
100
- }
101
-
102
- }
103
-
104
39
@ Override
105
40
public List <RuntimeClientPlugin > getClientPlugins () {
106
41
return ListUtils .of (
107
42
RuntimeClientPlugin .builder ()
108
43
.withConventions (
109
- TypeScriptDependency .MIDDLEWARE_EVENT_STREAM .dependency ,
44
+ TypeScriptDependency .AWS_SDK_EVENTSTREAM_SERDE_CONFIG_RESOLVER .dependency ,
110
45
"EventStream" ,
111
46
RuntimeClientPlugin .Convention .HAS_CONFIG
112
47
)
113
48
.servicePredicate (EventStreamGenerator ::hasEventStream )
114
- .build (),
115
- RuntimeClientPlugin .builder ()
116
- .withConventions (
117
- TypeScriptDependency .MIDDLEWARE_EVENT_STREAM .dependency ,
118
- "EventStream"
119
- ).operationPredicate ((m , s , o ) -> operationHasEventStreamInput (m , o )).build ()
49
+ .build ()
120
50
);
121
51
}
122
52
@@ -153,11 +83,11 @@ public void addRuntimeConfigValues(
153
83
154
84
switch (target ) {
155
85
case NODE :
156
- writer .addDependency (TypeScriptDependency .AWS_SDK_UTIL_EVENT_STREAM_NODE );
86
+ writer .addDependency (TypeScriptDependency .AWS_SDK_EVENTSTREAM_SERDE_NODE );
157
87
writer .addImport (
158
88
"eventStreamSerdeProvider" ,
159
89
"eventStreamSerdeProvider" ,
160
- TypeScriptDependency .AWS_SDK_UTIL_EVENT_STREAM_NODE .packageName
90
+ TypeScriptDependency .AWS_SDK_EVENTSTREAM_SERDE_NODE .packageName
161
91
);
162
92
writer .write ("eventStreamSerdeProvider" );
163
93
break ;
@@ -175,4 +105,71 @@ public void addRuntimeConfigValues(
175
105
// do nothing
176
106
}
177
107
}
108
+
109
+ public static final boolean hasEventStream (
110
+ Model model ,
111
+ ServiceShape service
112
+ ) {
113
+ TopDownIndex topDownIndex = model .getKnowledge (TopDownIndex .class );
114
+ Set <OperationShape > operations = topDownIndex .getContainedOperations (service );
115
+ for (OperationShape operation : operations ) {
116
+ if (operationHasEventStream (model , service , operation )) {
117
+ return true ;
118
+ }
119
+ }
120
+ return false ;
121
+ }
122
+
123
+ public static final boolean operationHasEventStream (
124
+ Model model ,
125
+ ServiceShape service ,
126
+ OperationShape operation
127
+ ) {
128
+ if (operationHasEventStreamInput (model , operation ) || operationHasEventStreamOutput (model , operation )) {
129
+ return true ;
130
+ }
131
+ return false ;
132
+ }
133
+
134
+ public static final boolean operationHasEventStreamInput (
135
+ Model model ,
136
+ OperationShape operation
137
+ ) {
138
+ EventStreamIndex eventStreamIndex = model .getKnowledge (EventStreamIndex .class );
139
+ if (eventStreamIndex .getInputInfo (operation ).isPresent ()) {
140
+ return true ;
141
+ }
142
+ return false ;
143
+ }
144
+
145
+ public static final boolean operationHasEventStreamOutput (
146
+ Model model ,
147
+ OperationShape operation
148
+ ) {
149
+ EventStreamIndex eventStreamIndex = model .getKnowledge (EventStreamIndex .class );
150
+ if (eventStreamIndex .getOutputInfo (operation ).isPresent ()) {
151
+ return true ;
152
+ }
153
+ return false ;
154
+ }
155
+
156
+ /**
157
+ * The value of event header 'type' property of given shape.
158
+ */
159
+ public static String getEventHeaderType (Shape shape ) {
160
+ switch (shape .getType ()) {
161
+ case BOOLEAN :
162
+ case BYTE :
163
+ case SHORT :
164
+ case INTEGER :
165
+ case LONG :
166
+ case STRING :
167
+ case TIMESTAMP :
168
+ return shape .getType ().toString ();
169
+ case BLOB :
170
+ return "binary" ;
171
+ default :
172
+ return "binary" ;
173
+ }
174
+ }
178
175
}
0 commit comments