3636import software .amazon .smithy .go .codegen .SymbolUtils ;
3737import software .amazon .smithy .go .codegen .integration .GoIntegration ;
3838import software .amazon .smithy .model .Model ;
39+ import software .amazon .smithy .model .knowledge .TopDownIndex ;
3940import software .amazon .smithy .model .shapes .OperationShape ;
4041import software .amazon .smithy .model .shapes .ServiceShape ;
4142import software .amazon .smithy .model .shapes .Shape ;
@@ -198,8 +199,7 @@ public void writeAdditionalFiles(
198199 writeConvertToPresignMiddleware (writer , model , symbolProvider , serviceShape );
199200 });
200201
201- for (ShapeId operationId : serviceShape .getAllOperations ()) {
202- OperationShape operationShape = model .expectShape (operationId , OperationShape .class );
202+ for (OperationShape operationShape : TopDownIndex .of (model ).getContainedOperations (serviceShape )) {
203203 if (!validOperations .contains (operationShape .getId ())) {
204204 continue ;
205205 }
@@ -229,11 +229,11 @@ private void writePresignOperationFunction(
229229 writer .writeDocs (
230230 String .format (
231231 "Presign%s is used to generate a presigned HTTP Request which contains presigned URL, signed headers "
232- + "and HTTP method used." , operationSymbol .getName ())
232+ + "and HTTP method used." , operationSymbol .getName ())
233233 );
234234 writer .openBlock (
235235 "func (c *$T) Presign$T(ctx context.Context, params $P, optFns ...func($P)) "
236- + "($P, error) {" , "}" , presignClientSymbol , operationSymbol ,
236+ + "($P, error) {" , "}" , presignClientSymbol , operationSymbol ,
237237 operationInputSymbol , presignOptionsSymbol , v4PresignedHTTPRequestSymbol ,
238238 () -> {
239239 writer .write ("if params == nil { params = &$T{} }" , operationInputSymbol ).insertTrailingNewline ();
@@ -338,17 +338,17 @@ private void writeConvertToPresignMiddleware(
338338 smithyStack ,
339339 () -> {
340340 Symbol smithyAfter = SymbolUtils .createValueSymbolBuilder ("After" ,
341- SmithyGoDependency .SMITHY_MIDDLEWARE )
341+ SmithyGoDependency .SMITHY_MIDDLEWARE )
342342 .build ();
343343
344344 // Middleware to remove
345345 Symbol requestInvocationID = SymbolUtils .createPointableSymbolBuilder (
346- "ClientRequestID" ,
347- AwsGoDependency .AWS_MIDDLEWARE )
346+ "ClientRequestID" ,
347+ AwsGoDependency .AWS_MIDDLEWARE )
348348 .build ();
349349
350350 Symbol presignMiddleware = SymbolUtils .createValueSymbolBuilder ("NewPresignHTTPRequestMiddleware" ,
351- AwsGoDependency .AWS_SIGNER_V4 )
351+ AwsGoDependency .AWS_SIGNER_V4 )
352352 .build ();
353353
354354 // Middleware to add
@@ -385,25 +385,25 @@ private void writeConvertToPresignMiddleware(
385385 writer .write ("// add multi-region access point presigner" );
386386
387387 // ==== multi-region access point support
388- Symbol PresignConstructor = SymbolUtils .createValueSymbolBuilder (
389- "NewPresignHTTPRequestMiddleware" , AwsCustomGoDependency .S3_CUSTOMIZATION
390- ).build ();
388+ Symbol PresignConstructor = SymbolUtils .createValueSymbolBuilder (
389+ "NewPresignHTTPRequestMiddleware" , AwsCustomGoDependency .S3_CUSTOMIZATION
390+ ).build ();
391391
392- Symbol PresignOptions = SymbolUtils .createValueSymbolBuilder (
393- "PresignHTTPRequestMiddlewareOptions" , AwsCustomGoDependency .S3_CUSTOMIZATION
394- ).build ();
392+ Symbol PresignOptions = SymbolUtils .createValueSymbolBuilder (
393+ "PresignHTTPRequestMiddlewareOptions" , AwsCustomGoDependency .S3_CUSTOMIZATION
394+ ).build ();
395395
396- Symbol RegisterPresigningMiddleware = SymbolUtils .createValueSymbolBuilder (
397- "RegisterPreSigningMiddleware" , AwsCustomGoDependency .S3_CUSTOMIZATION
398- ).build ();
396+ Symbol RegisterPresigningMiddleware = SymbolUtils .createValueSymbolBuilder (
397+ "RegisterPreSigningMiddleware" , AwsCustomGoDependency .S3_CUSTOMIZATION
398+ ).build ();
399399
400400 writer .openBlock ("signermv := $T($T{" , "})" ,
401- PresignConstructor ,PresignOptions , () -> {
402- writer .write ("CredentialsProvider : options.Credentials," );
403- writer .write ("V4Presigner : c.Presigner," );
404- writer .write ("V4aPresigner : c.presignerV4a," );
405- writer .write ("LogSigning : options.ClientLogMode.IsSigning()," );
406- });
401+ PresignConstructor , PresignOptions , () -> {
402+ writer .write ("CredentialsProvider : options.Credentials," );
403+ writer .write ("V4Presigner : c.Presigner," );
404+ writer .write ("V4aPresigner : c.presignerV4a," );
405+ writer .write ("LogSigning : options.ClientLogMode.IsSigning()," );
406+ });
407407
408408 writer .write ("err = $T(stack, signermv)" , RegisterPresigningMiddleware );
409409 writer .write ("if err != nil { return err }" );
@@ -420,7 +420,7 @@ private void writeConvertToPresignMiddleware(
420420 "AddExpiresOnPresignedURL" ,
421421 AwsCustomGoDependency .S3_CUSTOMIZATION ).build ();
422422 writer .writeDocs ("add middleware to set expiration for s3 presigned url, "
423- + " if expiration is set to 0, this middleware sets a default expiration of 900 seconds" );
423+ + " if expiration is set to 0, this middleware sets a default expiration of 900 seconds" );
424424 writer .write ("err = stack.Build.Add(&$T{ Expires: c.Expires, }, middleware.After)" ,
425425 expiresAsHeaderMiddleware );
426426 writer .write ("if err != nil { return err }" );
@@ -506,7 +506,7 @@ private void writePresignClientHelpers(
506506 // Helper function for NopClient
507507 writer .openBlock ("func $L(o *Options) {" , "}" , NOP_HTTP_CLIENT_OPTION_FUNC_NAME , () -> {
508508 Symbol nopClientSymbol = SymbolUtils .createPointableSymbolBuilder ("NopClient" ,
509- SmithyGoDependency .SMITHY_HTTP_TRANSPORT )
509+ SmithyGoDependency .SMITHY_HTTP_TRANSPORT )
510510 .build ();
511511
512512 writer .write ("o.HTTPClient = $T{}" , nopClientSymbol );
@@ -604,8 +604,8 @@ public void writePresignOptionType(
604604 writer .write ("" );
605605 writer .writeDocs (
606606 String .format ("Expires sets the expiration duration for the generated presign url. This should "
607- + "be the duration in seconds the presigned URL should be considered valid for. If "
608- + "not set or set to zero, presign url would default to expire after 900 seconds."
607+ + "be the duration in seconds the presigned URL should be considered valid for. If "
608+ + "not set or set to zero, presign url would default to expire after 900 seconds."
609609 )
610610 );
611611 writer .write ("Expires time.Duration" );
@@ -632,15 +632,15 @@ public void writePresignOptionType(
632632 writer .openBlock ("func $L(optFns ...func(*Options)) func($P) {" , "}" ,
633633 PRESIGN_OPTIONS_FROM_CLIENT_OPTIONS , presignOptionsSymbol , () -> {
634634 writer .write ("return $L(optFns).options" , presignOptionsFromClientOptionsInternal .getName ());
635- });
635+ });
636636
637637 writer .insertTrailingNewline ();
638638
639639 writer .write ("type $L []func(*Options)" , presignOptionsFromClientOptionsInternal .getName ());
640640 writer .openBlock ("func (w $L) options (o $P) {" , "}" ,
641641 presignOptionsFromClientOptionsInternal .getName (), presignOptionsSymbol , () -> {
642642 writer .write ("o.ClientOptions = append(o.ClientOptions, w...)" );
643- }).insertTrailingNewline ();
643+ }).insertTrailingNewline ();
644644
645645
646646 // s3 specific helpers
@@ -653,15 +653,15 @@ public void writePresignOptionType(
653653 writer .openBlock ("func $L(dur time.Duration) func($P) {" , "}" ,
654654 PRESIGN_OPTIONS_FROM_EXPIRES , presignOptionsSymbol , () -> {
655655 writer .write ("return $L(dur).options" , presignOptionsFromExpiresInternal .getName ());
656- });
656+ });
657657
658658 writer .insertTrailingNewline ();
659659
660660 writer .write ("type $L time.Duration" , presignOptionsFromExpiresInternal .getName ());
661661 writer .openBlock ("func (w $L) options (o $P) {" , "}" ,
662662 presignOptionsFromExpiresInternal .getName (), presignOptionsSymbol , () -> {
663663 writer .write ("o.Expires = time.Duration(w)" );
664- }).insertTrailingNewline ();
664+ }).insertTrailingNewline ();
665665 }
666666 }
667667
0 commit comments