|
15 | 15 |
|
16 | 16 | package software.amazon.smithy.go.codegen.integration;
|
17 | 17 |
|
| 18 | +import static software.amazon.smithy.go.codegen.GoWriter.autoDocTemplate; |
| 19 | +import static software.amazon.smithy.go.codegen.GoWriter.goTemplate; |
| 20 | + |
18 | 21 | import java.util.Map;
|
19 | 22 | import java.util.Optional;
|
20 | 23 | import software.amazon.smithy.codegen.core.CodegenException;
|
21 | 24 | import software.amazon.smithy.codegen.core.Symbol;
|
22 | 25 | import software.amazon.smithy.codegen.core.SymbolProvider;
|
| 26 | +import software.amazon.smithy.go.codegen.ClientOptions; |
23 | 27 | import software.amazon.smithy.go.codegen.GoDelegator;
|
24 | 28 | import software.amazon.smithy.go.codegen.GoSettings;
|
25 | 29 | import software.amazon.smithy.go.codegen.GoWriter;
|
@@ -139,15 +143,31 @@ private void generateWaiterOptions(
|
139 | 143 | writer.addUseImports(SmithyGoDependency.TIME);
|
140 | 144 |
|
141 | 145 | writer.write("");
|
142 |
| - writer.writeDocs( |
143 |
| - "Set of options to modify how an operation is invoked. These apply to all operations " |
144 |
| - + "invoked for this client. Use functional options on operation call to modify " |
145 |
| - + "this list for per operation behavior." |
146 |
| - ); |
| 146 | + var apiOptionsDocs = autoDocTemplate(""" |
| 147 | + Set of options to modify how an operation is invoked. These apply to all operations invoked |
| 148 | + for this client. Use functional options on operation call to modify this list for per |
| 149 | + operation behavior. |
| 150 | +
|
| 151 | + Passing options here is functionally equivalent to passing values to this config's |
| 152 | + ClientOptions field that extend the inner client's APIOptions directly."""); |
147 | 153 | Symbol stackSymbol = SymbolUtils.createPointableSymbolBuilder("Stack",
|
148 | 154 | SmithyGoDependency.SMITHY_MIDDLEWARE)
|
149 | 155 | .build();
|
150 |
| - writer.write("APIOptions []func($P) error", stackSymbol); |
| 156 | + writer.write(goTemplate(""" |
| 157 | + $W |
| 158 | + APIOptions []func($P) error |
| 159 | + """, apiOptionsDocs, stackSymbol)); |
| 160 | + |
| 161 | + var clientOptionsDocs = autoDocTemplate(""" |
| 162 | + Functional options to be passed to all operations invoked by this client. |
| 163 | +
|
| 164 | + Function values that modify the inner APIOptions are applied after the waiter config's own |
| 165 | + APIOptions modifiers."""); |
| 166 | + writer.write(""); |
| 167 | + writer.write(goTemplate(""" |
| 168 | + $W |
| 169 | + ClientOptions []func(*$L) |
| 170 | + """, clientOptionsDocs, ClientOptions.NAME)); |
151 | 171 |
|
152 | 172 | writer.write("");
|
153 | 173 | writer.writeDocs(
|
@@ -423,6 +443,10 @@ private void generateWaiterInvokerWithOutput(
|
423 | 443 | writer.openBlock("out, err := w.client.$T(ctx, params, func (o *Options) { ", "})",
|
424 | 444 | operationSymbol, () -> {
|
425 | 445 | writer.write("o.APIOptions = append(o.APIOptions, apiOptions...)");
|
| 446 | + writer.write(""" |
| 447 | + for _, opt := range options.ClientOptions { |
| 448 | + opt(o) |
| 449 | + }"""); |
426 | 450 | });
|
427 | 451 | writer.write("");
|
428 | 452 |
|
|
0 commit comments