codegen/smithy-aws-go-codegen/src/main/java/software/amazon/smithy/aws/go/codegen/AwsHttpPresignURLClientGenerator.java
public void writePresignOptionType(
            GoWriter writer,
            Model model,
            SymbolProvider symbolProvider,
            ServiceShape serviceShape
    ) {
        writer.addUseImports(SmithyGoDependency.CONTEXT);

        // generate presign options
        writer.writeDocs(String.format("%s represents the presign client options", PRESIGN_OPTIONS));
        writer.openBlock("type $T struct {", "}", presignOptionsSymbol, () -> {
            writer.write("");
            writer.writeDocs(
                    "ClientOptions are list of functional options to mutate client options used by the presign client."
            );
            writer.write("ClientOptions []func(*Options)");

            writer.write("");
            writer.writeDocs("Presigner is the  presigner used by the presign url client");
            writer.write("Presigner $T", presignerInterfaceSymbol);

            // s3 service has an additional Expires options
            if (isS3ServiceShape(model, serviceShape)) {
                writer.write("");
                writer.writeDocs(
                        String.format("Expires sets the expiration duration for the generated presign url. This should "
                                + "be the duration in seconds the presigned URL should be considered valid for. If "
                                + "not set or set to zero, presign url would default to expire after 900 seconds."
                        )
                );
                writer.write("Expires time.Duration");
                writer.write("");

                writer.writeDocs("presignerV4a is the presigner used by the presign url client");
                writer.write("presignerV4a $T", presignerV4aInterfaceSymbol);
            }
        });

        writer.openBlock("func (o $T) copy() $T {", "}", presignOptionsSymbol, presignOptionsSymbol, () -> {
            writer.write("clientOptions := make([]func(*Options), len(o.ClientOptions))");
            writer.write("copy(clientOptions, o.ClientOptions)");
            writer.write("o.ClientOptions = clientOptions");
            writer.write("return o");
        });

        // generate WithPresignClientFromClientOptions Helper
        Symbol presignOptionsFromClientOptionsInternal = buildSymbol(PRESIGN_OPTIONS_FROM_CLIENT_OPTIONS, false);
        writer.writeDocs(
                String.format("%s is a helper utility to retrieve a function that takes PresignOption as input",
                        PRESIGN_OPTIONS_FROM_CLIENT_OPTIONS)
        );
        writer.openBlock("func $L(optFns ...func(*Options)) func($P) {", "}",
                PRESIGN_OPTIONS_FROM_CLIENT_OPTIONS, presignOptionsSymbol, () -> {
                    writer.write("return $L(optFns).options", presignOptionsFromClientOptionsInternal.getName());
        });

        writer.insertTrailingNewline();

        writer.write("type $L []func(*Options)", presignOptionsFromClientOptionsInternal.getName());
        writer.openBlock("func (w $L) options (o $P) {", "}",
                presignOptionsFromClientOptionsInternal.getName(), presignOptionsSymbol, () -> {
                    writer.write("o.ClientOptions = append(o.ClientOptions, w...)");
        }).insertTrailingNewline();


        // s3 specific helpers
        if (isS3ServiceShape(model, serviceShape)) {
            // generate WithPresignExpires Helper
            Symbol presignOptionsFromExpiresInternal = buildSymbol(PRESIGN_OPTIONS_FROM_EXPIRES, false);
            writer.writeDocs(String.format(
                    "%s is a helper utility to append Expires value on presign options optional function",
                    PRESIGN_OPTIONS_FROM_EXPIRES));
            writer.openBlock("func $L(dur time.Duration) func($P) {", "}",
                    PRESIGN_OPTIONS_FROM_EXPIRES, presignOptionsSymbol, () -> {
                        writer.write("return $L(dur).options", presignOptionsFromExpiresInternal.getName());
            });

            writer.insertTrailingNewline();

            writer.write("type $L time.Duration", presignOptionsFromExpiresInternal.getName());
            writer.openBlock("func (w $L) options (o $P) {", "}",
                    presignOptionsFromExpiresInternal.getName(), presignOptionsSymbol, () -> {
                        writer.write("o.Expires = time.Duration(w)");
            }).insertTrailingNewline();
        }
    }
/**
     * Writes the Presign client's type and methods.
     *
     * @param writer writer to write to
     */
Writes the Presign client's type and methods.
@param writer writer to write to
Writes the Presign client ' s type and methods . @param writer writer to write to
public void writePresignOptionType(
            GoWriter writer,
            Model model,
            SymbolProvider symbolProvider,
            ServiceShape serviceShape
    ) {
        writer.addUseImports(SmithyGoDependency.CONTEXT);
        writer.writeDocs(String.format("%s represents the presign client options", PRESIGN_OPTIONS));
        writer.openBlock("type $T struct {", "}", presignOptionsSymbol, () -> {
            writer.write("");
            writer.writeDocs(
                    "ClientOptions are list of functional options to mutate client options used by the presign client."
            );
            writer.write("ClientOptions []func(*Options)");
            writer.write("");
            writer.writeDocs("Presigner is the  presigner used by the presign url client");
            writer.write("Presigner $T", presignerInterfaceSymbol);
            if (isS3ServiceShape(model, serviceShape)) {
                writer.write("");
                writer.writeDocs(
                        String.format("Expires sets the expiration duration for the generated presign url. This should "
                                + "be the duration in seconds the presigned URL should be considered valid for. If "
                                + "not set or set to zero, presign url would default to expire after 900 seconds."
                        )
                );
                writer.write("Expires time.Duration");
                writer.write("");
                writer.writeDocs("presignerV4a is the presigner used by the presign url client");
                writer.write("presignerV4a $T", presignerV4aInterfaceSymbol);
            }
        });
        writer.openBlock("func (o $T) copy() $T {", "}", presignOptionsSymbol, presignOptionsSymbol, () -> {
            writer.write("clientOptions := make([]func(*Options), len(o.ClientOptions))");
            writer.write("copy(clientOptions, o.ClientOptions)");
            writer.write("o.ClientOptions = clientOptions");
            writer.write("return o");
        });
        Symbol presignOptionsFromClientOptionsInternal = buildSymbol(PRESIGN_OPTIONS_FROM_CLIENT_OPTIONS, false);
        writer.writeDocs(
                String.format("%s is a helper utility to retrieve a function that takes PresignOption as input",
                        PRESIGN_OPTIONS_FROM_CLIENT_OPTIONS)
        );
        writer.openBlock("func $L(optFns ...func(*Options)) func($P) {", "}",
                PRESIGN_OPTIONS_FROM_CLIENT_OPTIONS, presignOptionsSymbol, () -> {
                    writer.write("return $L(optFns).options", presignOptionsFromClientOptionsInternal.getName());
        });
        writer.insertTrailingNewline();
        writer.write("type $L []func(*Options)", presignOptionsFromClientOptionsInternal.getName());
        writer.openBlock("func (w $L) options (o $P) {", "}",
                presignOptionsFromClientOptionsInternal.getName(), presignOptionsSymbol, () -> {
                    writer.write("o.ClientOptions = append(o.ClientOptions, w...)");
        }).insertTrailingNewline();
        if (isS3ServiceShape(model, serviceShape)) {
            Symbol presignOptionsFromExpiresInternal = buildSymbol(PRESIGN_OPTIONS_FROM_EXPIRES, false);
            writer.writeDocs(String.format(
                    "%s is a helper utility to append Expires value on presign options optional function",
                    PRESIGN_OPTIONS_FROM_EXPIRES));
            writer.openBlock("func $L(dur time.Duration) func($P) {", "}",
                    PRESIGN_OPTIONS_FROM_EXPIRES, presignOptionsSymbol, () -> {
                        writer.write("return $L(dur).options", presignOptionsFromExpiresInternal.getName());
            });
            writer.insertTrailingNewline();
            writer.write("type $L time.Duration", presignOptionsFromExpiresInternal.getName());
            writer.openBlock("func (w $L) options (o $P) {", "}",
                    presignOptionsFromExpiresInternal.getName(), presignOptionsSymbol, () -> {
                        writer.write("o.Expires = time.Duration(w)");
            }).insertTrailingNewline();
        }
    }
public void writePresignOptionType ( GoWriter writer , Model model , SymbolProvider symbolProvider , ServiceShape serviceShape ) { writer . addUseImports ( SmithyGoDependency . CONTEXT ) ; writer . writeDocs ( String . format ( "%s represents the presign client options" , PRESIGN_OPTIONS ) ) ; writer . openBlock ( "type $T struct {" , "}" , presignOptionsSymbol , ( ) -> { writer . write ( "" ) ; writer . writeDocs ( "ClientOptions are list of functional options to mutate client options used by the presign client." ) ; writer . write ( "ClientOptions []func(*Options)" ) ; writer . write ( "" ) ; writer . writeDocs ( "Presigner is the  presigner used by the presign url client" ) ; writer . write ( "Presigner $T" , presignerInterfaceSymbol ) ; if ( isS3ServiceShape ( model , serviceShape ) ) { writer . write ( "" ) ; writer . writeDocs ( String . format ( "Expires sets the expiration duration for the generated presign url. This should " + "be the duration in seconds the presigned URL should be considered valid for. If " + "not set or set to zero, presign url would default to expire after 900 seconds." ) ) ; writer . write ( "Expires time.Duration" ) ; writer . write ( "" ) ; writer . writeDocs ( "presignerV4a is the presigner used by the presign url client" ) ; writer . write ( "presignerV4a $T" , presignerV4aInterfaceSymbol ) ; } } ) ; writer . openBlock ( "func (o $T) copy() $T {" , "}" , presignOptionsSymbol , presignOptionsSymbol , ( ) -> { writer . write ( "clientOptions := make([]func(*Options), len(o.ClientOptions))" ) ; writer . write ( "copy(clientOptions, o.ClientOptions)" ) ; writer . write ( "o.ClientOptions = clientOptions" ) ; writer . write ( "return o" ) ; } ) ; Symbol presignOptionsFromClientOptionsInternal = buildSymbol ( PRESIGN_OPTIONS_FROM_CLIENT_OPTIONS , false ) ; writer . writeDocs ( String . format ( "%s is a helper utility to retrieve a function that takes PresignOption as input" , PRESIGN_OPTIONS_FROM_CLIENT_OPTIONS ) ) ; writer . openBlock ( "func $L(optFns ...func(*Options)) func($P) {" , "}" , PRESIGN_OPTIONS_FROM_CLIENT_OPTIONS , presignOptionsSymbol , ( ) -> { writer . write ( "return $L(optFns).options" , presignOptionsFromClientOptionsInternal . getName ( ) ) ; } ) ; writer . insertTrailingNewline ( ) ; writer . write ( "type $L []func(*Options)" , presignOptionsFromClientOptionsInternal . getName ( ) ) ; writer . openBlock ( "func (w $L) options (o $P) {" , "}" , presignOptionsFromClientOptionsInternal . getName ( ) , presignOptionsSymbol , ( ) -> { writer . write ( "o.ClientOptions = append(o.ClientOptions, w...)" ) ; } ) . insertTrailingNewline ( ) ; if ( isS3ServiceShape ( model , serviceShape ) ) { Symbol presignOptionsFromExpiresInternal = buildSymbol ( PRESIGN_OPTIONS_FROM_EXPIRES , false ) ; writer . writeDocs ( String . format ( "%s is a helper utility to append Expires value on presign options optional function" , PRESIGN_OPTIONS_FROM_EXPIRES ) ) ; writer . openBlock ( "func $L(dur time.Duration) func($P) {" , "}" , PRESIGN_OPTIONS_FROM_EXPIRES , presignOptionsSymbol , ( ) -> { writer . write ( "return $L(dur).options" , presignOptionsFromExpiresInternal . getName ( ) ) ; } ) ; writer . insertTrailingNewline ( ) ; writer . write ( "type $L time.Duration" , presignOptionsFromExpiresInternal . getName ( ) ) ; writer . openBlock ( "func (w $L) options (o $P) {" , "}" , presignOptionsFromExpiresInternal . getName ( ) , presignOptionsSymbol , ( ) -> { writer . write ( "o.Expires = time.Duration(w)" ) ; } ) . insertTrailingNewline ( ) ; } }
Writes the Presign client's type and methods.
Writes the Presign client ' s type and methods .
// generate presign options // s3 service has an additional Expires options // generate WithPresignClientFromClientOptions Helper // s3 specific helpers // generate WithPresignExpires Helper