@@ -119,26 +119,31 @@ private void generateClientCommand() {
119
119
String name = symbol .getName ();
120
120
writer .writeShapeDocs (operation , shapeDoc -> shapeDoc + "\n " + getCommandExample (serviceSymbol .getName (),
121
121
configType , name , inputType .getName (), outputType .getName ()));
122
- writer .openBlock ("export class $L extends $$Command<$T, $T, $L> {" , "}" , name , inputType , outputType ,
123
- configType , () -> {
124
-
125
- // Section for adding custom command properties.
126
- writer .write ("// Start section: $L" , COMMAND_PROPERTIES_SECTION );
127
- writer .pushState (COMMAND_PROPERTIES_SECTION ).popState ();
128
- writer .write ("// End section: $L" , COMMAND_PROPERTIES_SECTION );
129
- writer .write ("" );
130
-
131
- generateCommandConstructor ();
132
- writer .write ("" );
133
- generateCommandMiddlewareResolver (configType );
134
- writeSerde ();
135
-
136
- // Hook for adding more methods to the command.
137
- writer .write ("// Start section: $L" , COMMAND_BODY_EXTRA_SECTION )
122
+ writer .openBlock (
123
+ "export class $L extends $$Command<$T, $T, $L> {" , "}" ,
124
+ name , inputType , outputType ,
125
+ configType , () -> {
126
+
127
+ // Section for adding custom command properties.
128
+ writer .write ("// Start section: $L" , COMMAND_PROPERTIES_SECTION );
129
+ writer .pushState (COMMAND_PROPERTIES_SECTION ).popState ();
130
+ writer .write ("// End section: $L" , COMMAND_PROPERTIES_SECTION );
131
+ writer .write ("" );
132
+ generateEndpointParameterInstructionProvider ();
133
+ writer .write ("" );
134
+
135
+ generateCommandConstructor ();
136
+ writer .write ("" );
137
+ generateCommandMiddlewareResolver (configType );
138
+ writeSerde ();
139
+
140
+ // Hook for adding more methods to the command.
141
+ writer .write ("// Start section: $L" , COMMAND_BODY_EXTRA_SECTION )
138
142
.pushState (COMMAND_BODY_EXTRA_SECTION )
139
143
.popState ()
140
144
.write ("// End section: $L" , COMMAND_BODY_EXTRA_SECTION );
141
- });
145
+ }
146
+ );
142
147
}
143
148
144
149
private String getCommandExample (String serviceName , String configName , String commandName , String commandInput ,
@@ -172,32 +177,16 @@ private void generateCommandConstructor() {
172
177
});
173
178
}
174
179
175
- private void generateCommandMiddlewareResolver (String configType ) {
176
- Symbol serde = TypeScriptDependency .MIDDLEWARE_SERDE .createSymbol ("getSerdePlugin" );
177
- writer .writeDocs ("@internal" );
178
- writer .write ("resolveMiddleware(" )
179
- .indent ()
180
- .write ("clientStack: MiddlewareStack<$L, $L>," , "ServiceInputTypes" , "ServiceOutputTypes" )
181
- .write ("configuration: $L," , configType )
182
- .write ("options?: $T" , applicationProtocol .getOptionsType ())
183
- .dedent ();
184
- writer .openBlock ("): Handler<$T, $T> {" , "}" , inputType , outputType , () -> {
185
- // Add serialization and deserialization plugin.
186
- writer .write ("this.middlewareStack.use($T(configuration, this.serialize, this.deserialize));" , serde );
187
-
188
- // Add customizations.
189
- addCommandSpecificPlugins ();
190
-
191
- // EndpointsV2
192
- if (service .hasTrait (EndpointRuleSetTrait .class )) {
193
- writer .addImport (
194
- "getEndpointPlugin" ,
195
- "getEndpointPlugin" ,
196
- "@aws-sdk/middleware-endpoint"
197
- );
180
+ private void generateEndpointParameterInstructionProvider () {
181
+ if (!service .hasTrait (EndpointRuleSetTrait .class )) {
182
+ return ;
183
+ }
184
+ writer .addImport ("EndpointParameterInstructions" , null , "@aws-sdk/middleware-endpoint" );
185
+ writer .openBlock (
186
+ "public static getEndpointParameterInstructions(): EndpointParameterInstructions {" , "}" ,
187
+ () -> {
198
188
writer .openBlock (
199
- "this.middlewareStack.use(getEndpointPlugin(configuration, {" ,
200
- "}));" ,
189
+ "return {" , "};" ,
201
190
() -> {
202
191
RuleSetParameterFinder parameterFinder = new RuleSetParameterFinder (service );
203
192
parameterFinder .getBuiltInParams ().forEach ((name , type ) -> {
@@ -227,6 +216,40 @@ private void generateCommandMiddlewareResolver(String configType) {
227
216
}
228
217
);
229
218
}
219
+ );
220
+ }
221
+
222
+ private void generateCommandMiddlewareResolver (String configType ) {
223
+ Symbol serde = TypeScriptDependency .MIDDLEWARE_SERDE .createSymbol ("getSerdePlugin" );
224
+ writer .writeDocs ("@internal" );
225
+ writer .write ("resolveMiddleware(" )
226
+ .indent ()
227
+ .write ("clientStack: MiddlewareStack<$L, $L>," , "ServiceInputTypes" , "ServiceOutputTypes" )
228
+ .write ("configuration: $L," , configType )
229
+ .write ("options?: $T" , applicationProtocol .getOptionsType ())
230
+ .dedent ();
231
+ writer .openBlock ("): Handler<$T, $T> {" , "}" , inputType , outputType , () -> {
232
+ // Add serialization and deserialization plugin.
233
+ writer .write ("this.middlewareStack.use($T(configuration, this.serialize, this.deserialize));" , serde );
234
+
235
+ // Add customizations.
236
+ addCommandSpecificPlugins ();
237
+
238
+ // EndpointsV2
239
+ if (service .hasTrait (EndpointRuleSetTrait .class )) {
240
+ writer .addImport (
241
+ "getEndpointPlugin" ,
242
+ "getEndpointPlugin" ,
243
+ "@aws-sdk/middleware-endpoint"
244
+ );
245
+ writer .openBlock (
246
+ "this.middlewareStack.use(getEndpointPlugin(configuration, " ,
247
+ "));" ,
248
+ () -> {
249
+ writer .write ("$L.getEndpointParameterInstructions()" , symbol .getName ());
250
+ }
251
+ );
252
+ }
230
253
231
254
// Resolve the middleware stack.
232
255
writer .write ("\n const stack = clientStack.concat(this.middlewareStack);\n " );
0 commit comments