@@ -72,6 +72,12 @@ public class AwsHttpPresignURLClientGenerator implements GoIntegration {
7272 private static final Symbol presignerInterfaceSymbol = SymbolUtils .createPointableSymbolBuilder (
7373 "HTTPPresignerV4"
7474 ).build ();
75+
76+ private static final Symbol presignerV4aInterfaceSymbol = SymbolUtils .createPointableSymbolBuilder (
77+ "httpPresignerV4a"
78+ ).build ();
79+
80+
7581 private static final Symbol v4NewPresignerSymbol = SymbolUtils .createPointableSymbolBuilder (
7682 "NewSigner" , AwsGoDependency .AWS_SIGNER_V4
7783 ).build ();
@@ -176,6 +182,9 @@ public void writeAdditionalFiles(
176182 // generate presigner interface
177183 writePresignInterface (writer , model , symbolProvider , serviceShape );
178184
185+ // generate s3 sigv4a presigner interface
186+ writePresignV4aInterface (writer , model , symbolProvider , serviceShape );
187+
179188 // generate presign options and helpers per service
180189 writePresignOptionType (writer , model , symbolProvider , serviceShape );
181190
@@ -371,6 +380,37 @@ private void writeConvertToPresignMiddleware(
371380
372381 // s3 service needs expires and sets unsignedPayload if input is stream
373382 if (isS3ServiceShape (model , serviceShape )) {
383+
384+ writer .write ("" );
385+ writer .write ("// add multi-region access point presigner" );
386+
387+ // ==== multi-region access point support
388+ Symbol PresignConstructor = SymbolUtils .createValueSymbolBuilder (
389+ "NewPresignHTTPRequestMiddleware" , AwsCustomGoDependency .S3_CUSTOMIZATION
390+ ).build ();
391+
392+ Symbol PresignOptions = SymbolUtils .createValueSymbolBuilder (
393+ "PresignHTTPRequestMiddlewareOptions" , AwsCustomGoDependency .S3_CUSTOMIZATION
394+ ).build ();
395+
396+ Symbol RegisterPresigningMiddleware = SymbolUtils .createValueSymbolBuilder (
397+ "RegisterPreSigningMiddleware" , AwsCustomGoDependency .S3_CUSTOMIZATION
398+ ).build ();
399+
400+ 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+ });
407+
408+ writer .write ("err = $T(stack, signermv)" , RegisterPresigningMiddleware );
409+ writer .write ("if err != nil { return err }" );
410+ writer .write ("" );
411+
412+ // =======
413+
374414 writer .openBlock ("if c.Expires < 0 {" , "}" , () -> {
375415 writer .addUseImports (SmithyGoDependency .FMT );
376416 writer .write (
@@ -437,6 +477,13 @@ private void writePresignClientType(
437477 });
438478 writer .write ("" );
439479
480+ if (isS3ServiceShape (model , serviceShape )) {
481+ writer .openBlock ("if options.presignerV4a == nil {" , "}" , () -> {
482+ writer .write ("options.presignerV4a = $L(c.options)" , AwsSignatureVersion4 .NEW_SIGNER_V4A_FUNC_NAME );
483+ });
484+ writer .write ("" );
485+ }
486+
440487 writer .openBlock ("return &$L{" , "}" , presignClientSymbol , () -> {
441488 writer .write ("client: c," );
442489 writer .write ("options: options," );
@@ -494,6 +541,38 @@ public void writePresignInterface(
494541 writer .write ("" );
495542 }
496543
544+
545+ /**
546+ * Writes the presigner sigv4a interface used by the presign url client
547+ */
548+ public void writePresignV4aInterface (
549+ GoWriter writer ,
550+ Model model ,
551+ SymbolProvider symbolProvider ,
552+ ServiceShape serviceShape
553+ ) {
554+ if (!isS3ServiceShape (model , serviceShape )) {
555+ return ;
556+ }
557+
558+ Symbol signerOptionsSymbol = SymbolUtils .createPointableSymbolBuilder (
559+ "SignerOptions" , AwsCustomGoDependency .S3_SIGV4A_CUSTOMIZATION ).build ();
560+
561+ writer .writeDocs (
562+ String .format ("%s represents sigv4a presigner interface used by presign url client" ,
563+ presignerV4aInterfaceSymbol .getName ())
564+ );
565+ writer .openBlock ("type $T interface {" , "}" , presignerV4aInterfaceSymbol , () -> {
566+ writer .write ("PresignHTTP(" );
567+ writer .write ("ctx context.Context, credentials v4a.Credentials, r *http.Request," );
568+ writer .write ("payloadHash string, service string, regionSet []string, signingTime time.Time," );
569+ writer .write ("optFns ...func($P)," , signerOptionsSymbol );
570+ writer .write (") (url string, signedHeader http.Header, err error)" );
571+ });
572+
573+ writer .write ("" );
574+ }
575+
497576 /**
498577 * Writes the Presign client's type and methods.
499578 *
@@ -530,8 +609,13 @@ public void writePresignOptionType(
530609 )
531610 );
532611 writer .write ("Expires time.Duration" );
612+ writer .write ("" );
613+
614+ writer .writeDocs ("presignerV4a is the presigner used by the presign url client" );
615+ writer .write ("presignerV4a $T" , presignerV4aInterfaceSymbol );
533616 }
534617 });
618+
535619 writer .openBlock ("func (o $T) copy() $T {" , "}" , presignOptionsSymbol , presignOptionsSymbol , () -> {
536620 writer .write ("clientOptions := make([]func(*Options), len(o.ClientOptions))" );
537621 writer .write ("copy(clientOptions, o.ClientOptions)" );
@@ -548,15 +632,15 @@ public void writePresignOptionType(
548632 writer .openBlock ("func $L(optFns ...func(*Options)) func($P) {" , "}" ,
549633 PRESIGN_OPTIONS_FROM_CLIENT_OPTIONS , presignOptionsSymbol , () -> {
550634 writer .write ("return $L(optFns).options" , presignOptionsFromClientOptionsInternal .getName ());
551- });
635+ });
552636
553637 writer .insertTrailingNewline ();
554638
555639 writer .write ("type $L []func(*Options)" , presignOptionsFromClientOptionsInternal .getName ());
556640 writer .openBlock ("func (w $L) options (o $P) {" , "}" ,
557641 presignOptionsFromClientOptionsInternal .getName (), presignOptionsSymbol , () -> {
558642 writer .write ("o.ClientOptions = append(o.ClientOptions, w...)" );
559- }).insertTrailingNewline ();
643+ }).insertTrailingNewline ();
560644
561645
562646 // s3 specific helpers
@@ -569,15 +653,15 @@ public void writePresignOptionType(
569653 writer .openBlock ("func $L(dur time.Duration) func($P) {" , "}" ,
570654 PRESIGN_OPTIONS_FROM_EXPIRES , presignOptionsSymbol , () -> {
571655 writer .write ("return $L(dur).options" , presignOptionsFromExpiresInternal .getName ());
572- });
656+ });
573657
574658 writer .insertTrailingNewline ();
575659
576660 writer .write ("type $L time.Duration" , presignOptionsFromExpiresInternal .getName ());
577661 writer .openBlock ("func (w $L) options (o $P) {" , "}" ,
578662 presignOptionsFromExpiresInternal .getName (), presignOptionsSymbol , () -> {
579663 writer .write ("o.Expires = time.Duration(w)" );
580- }).insertTrailingNewline ();
664+ }).insertTrailingNewline ();
581665 }
582666 }
583667
0 commit comments