@@ -51,6 +51,7 @@ public final class RuntimeClientPlugin implements ToSmithyBuilder<RuntimeClientP
51
51
private final SymbolReference resolveFunction ;
52
52
private final List <String > additionalResolveFunctionParameters ;
53
53
private final SymbolReference pluginFunction ;
54
+ private final List <String > additionalPluginFunctionParameters ;
54
55
private final SymbolReference destroyFunction ;
55
56
private final BiPredicate <Model , ServiceShape > servicePredicate ;
56
57
private final OperationPredicate operationPredicate ;
@@ -61,6 +62,7 @@ private RuntimeClientPlugin(Builder builder) {
61
62
resolveFunction = builder .resolveFunction ;
62
63
additionalResolveFunctionParameters = ListUtils .copyOf (builder .additionalResolveFunctionParameters );
63
64
pluginFunction = builder .pluginFunction ;
65
+ additionalPluginFunctionParameters = ListUtils .copyOf (builder .additionalPluginFunctionParameters );
64
66
destroyFunction = builder .destroyFunction ;
65
67
operationPredicate = builder .operationPredicate ;
66
68
servicePredicate = builder .servicePredicate ;
@@ -69,6 +71,10 @@ private RuntimeClientPlugin(Builder builder) {
69
71
throw new IllegalStateException ("Additional parameters can only be set if a resolve function is set." );
70
72
}
71
73
74
+ if (!additionalPluginFunctionParameters .isEmpty () && pluginFunction == null ) {
75
+ throw new IllegalStateException ("Additional parameters can only be set if a plugin function is set." );
76
+ }
77
+
72
78
boolean allNull = (inputConfig == null ) && (resolvedConfig == null ) && (resolveFunction == null );
73
79
boolean allSet = (inputConfig != null ) && (resolvedConfig != null ) && (resolveFunction != null );
74
80
if (!(allNull || allSet )) {
@@ -202,6 +208,19 @@ public Optional<SymbolReference> getPluginFunction() {
202
208
return Optional .ofNullable (pluginFunction );
203
209
}
204
210
211
+ /**
212
+ * Gets a list of additional parameters to be supplied to the
213
+ * plugin function. These parameters are to be supplied to plugin
214
+ * function as an options hash. The list is empty if
215
+ * there are no additional parameters.
216
+ *
217
+ * @return Returns the optionally present list of parameters.
218
+ * @see #getPluginFunction()
219
+ */
220
+ public List <String > getAdditionalPluginFunctionParameters () {
221
+ return additionalPluginFunctionParameters ;
222
+ }
223
+
205
224
/**
206
225
* Gets the optionally present symbol reference that points to the
207
226
* function that is used to clean up any resources when a client is
@@ -283,6 +302,7 @@ public String toString() {
283
302
+ ", resolveFunction=" + resolveFunction
284
303
+ ", additionalResolveFunctionParameters=" + additionalResolveFunctionParameters
285
304
+ ", pluginFunction=" + pluginFunction
305
+ + ", additionalPluginFunctionParameters=" + additionalPluginFunctionParameters
286
306
+ ", destroyFunction=" + destroyFunction
287
307
+ '}' ;
288
308
}
@@ -301,6 +321,7 @@ public boolean equals(Object o) {
301
321
&& Objects .equals (resolveFunction , that .resolveFunction )
302
322
&& Objects .equals (additionalResolveFunctionParameters , that .additionalResolveFunctionParameters )
303
323
&& Objects .equals (pluginFunction , that .pluginFunction )
324
+ && Objects .equals (additionalPluginFunctionParameters , that .additionalPluginFunctionParameters )
304
325
&& Objects .equals (destroyFunction , that .destroyFunction )
305
326
&& servicePredicate .equals (that .servicePredicate )
306
327
&& operationPredicate .equals (that .operationPredicate );
@@ -320,6 +341,7 @@ public static final class Builder implements SmithyBuilder<RuntimeClientPlugin>
320
341
private SymbolReference resolveFunction ;
321
342
private List <String > additionalResolveFunctionParameters = new ArrayList <>();
322
343
private SymbolReference pluginFunction ;
344
+ private List <String > additionalPluginFunctionParameters = new ArrayList <>();
323
345
private SymbolReference destroyFunction ;
324
346
private BiPredicate <Model , ServiceShape > servicePredicate = (model , service ) -> true ;
325
347
private OperationPredicate operationPredicate = (model , service , operation ) -> false ;
@@ -481,6 +503,21 @@ public Builder pluginFunction(SymbolReference pluginFunction) {
481
503
return this ;
482
504
}
483
505
506
+ /**
507
+ * Sets a function symbol reference used to configure clients and
508
+ * commands to use a specific middleware function.
509
+ *
510
+ * @param pluginFunction Plugin function symbol to invoke.
511
+ * @param additionalParameters Additional parameters to be generated as plugin function input.
512
+ * @return Returns the builder.
513
+ * @see #getPluginFunction()
514
+ */
515
+ public Builder pluginFunction (SymbolReference pluginFunction , String ... additionalParameters ) {
516
+ this .pluginFunction = pluginFunction ;
517
+ this .additionalPluginFunctionParameters = ListUtils .of (additionalParameters );
518
+ return this ;
519
+ }
520
+
484
521
/**
485
522
* Sets a function symbol used to configure clients and commands to
486
523
* use a specific middleware function.
@@ -493,6 +530,32 @@ public Builder pluginFunction(Symbol pluginFunction) {
493
530
return pluginFunction (SymbolReference .builder ().symbol (pluginFunction ).build ());
494
531
}
495
532
533
+ /**
534
+ * Sets a function symbol used to configure clients and commands to
535
+ * use a specific middleware function.
536
+ *
537
+ * @param pluginFunction Plugin function symbol to invoke.
538
+ * @param additionalParameters Additional parameters to be generated as plugin function input.
539
+ * @return Returns the builder.
540
+ * @see #getPluginFunction()
541
+ */
542
+ public Builder pluginFunction (Symbol pluginFunction , String ... additionalParameters ) {
543
+ return pluginFunction (SymbolReference .builder ().symbol (pluginFunction ).build (), additionalParameters );
544
+ }
545
+
546
+ /**
547
+ * Set additional positional input parameters to plugin function. Set
548
+ * this with no arguments to remove the current parameters.
549
+ *
550
+ * @param additionalParameters Additional parameters to be generated as plugin function input.
551
+ * @return Returns the builder.
552
+ * @see #getPluginFunction()
553
+ */
554
+ public Builder additionalPluginFunctionParameters (String ... additionalParameters ) {
555
+ this .additionalPluginFunctionParameters = ListUtils .of (additionalParameters );
556
+ return this ;
557
+ }
558
+
496
559
/**
497
560
* Sets a function symbol reference to call from a client in the
498
561
* {@code destroy} function of a TypeScript client.
0 commit comments