@@ -51,6 +51,7 @@ public final class RuntimeClientPlugin implements ToSmithyBuilder<RuntimeClientP
5151 private final SymbolReference resolveFunction ;
5252 private final List <String > additionalResolveFunctionParameters ;
5353 private final SymbolReference pluginFunction ;
54+ private final List <String > additionalPluginFunctionParameters ;
5455 private final SymbolReference destroyFunction ;
5556 private final BiPredicate <Model , ServiceShape > servicePredicate ;
5657 private final OperationPredicate operationPredicate ;
@@ -61,6 +62,7 @@ private RuntimeClientPlugin(Builder builder) {
6162 resolveFunction = builder .resolveFunction ;
6263 additionalResolveFunctionParameters = ListUtils .copyOf (builder .additionalResolveFunctionParameters );
6364 pluginFunction = builder .pluginFunction ;
65+ additionalPluginFunctionParameters = ListUtils .copyOf (builder .additionalPluginFunctionParameters );
6466 destroyFunction = builder .destroyFunction ;
6567 operationPredicate = builder .operationPredicate ;
6668 servicePredicate = builder .servicePredicate ;
@@ -69,6 +71,10 @@ private RuntimeClientPlugin(Builder builder) {
6971 throw new IllegalStateException ("Additional parameters can only be set if a resolve function is set." );
7072 }
7173
74+ if (!additionalPluginFunctionParameters .isEmpty () && pluginFunction == null ) {
75+ throw new IllegalStateException ("Additional parameters can only be set if a plugin function is set." );
76+ }
77+
7278 boolean allNull = (inputConfig == null ) && (resolvedConfig == null ) && (resolveFunction == null );
7379 boolean allSet = (inputConfig != null ) && (resolvedConfig != null ) && (resolveFunction != null );
7480 if (!(allNull || allSet )) {
@@ -202,6 +208,19 @@ public Optional<SymbolReference> getPluginFunction() {
202208 return Optional .ofNullable (pluginFunction );
203209 }
204210
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+
205224 /**
206225 * Gets the optionally present symbol reference that points to the
207226 * function that is used to clean up any resources when a client is
@@ -283,6 +302,7 @@ public String toString() {
283302 + ", resolveFunction=" + resolveFunction
284303 + ", additionalResolveFunctionParameters=" + additionalResolveFunctionParameters
285304 + ", pluginFunction=" + pluginFunction
305+ + ", additionalPluginFunctionParameters=" + additionalPluginFunctionParameters
286306 + ", destroyFunction=" + destroyFunction
287307 + '}' ;
288308 }
@@ -301,6 +321,7 @@ public boolean equals(Object o) {
301321 && Objects .equals (resolveFunction , that .resolveFunction )
302322 && Objects .equals (additionalResolveFunctionParameters , that .additionalResolveFunctionParameters )
303323 && Objects .equals (pluginFunction , that .pluginFunction )
324+ && Objects .equals (additionalPluginFunctionParameters , that .additionalPluginFunctionParameters )
304325 && Objects .equals (destroyFunction , that .destroyFunction )
305326 && servicePredicate .equals (that .servicePredicate )
306327 && operationPredicate .equals (that .operationPredicate );
@@ -320,6 +341,7 @@ public static final class Builder implements SmithyBuilder<RuntimeClientPlugin>
320341 private SymbolReference resolveFunction ;
321342 private List <String > additionalResolveFunctionParameters = new ArrayList <>();
322343 private SymbolReference pluginFunction ;
344+ private List <String > additionalPluginFunctionParameters = new ArrayList <>();
323345 private SymbolReference destroyFunction ;
324346 private BiPredicate <Model , ServiceShape > servicePredicate = (model , service ) -> true ;
325347 private OperationPredicate operationPredicate = (model , service , operation ) -> false ;
@@ -481,6 +503,21 @@ public Builder pluginFunction(SymbolReference pluginFunction) {
481503 return this ;
482504 }
483505
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+
484521 /**
485522 * Sets a function symbol used to configure clients and commands to
486523 * use a specific middleware function.
@@ -493,6 +530,32 @@ public Builder pluginFunction(Symbol pluginFunction) {
493530 return pluginFunction (SymbolReference .builder ().symbol (pluginFunction ).build ());
494531 }
495532
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+
496559 /**
497560 * Sets a function symbol reference to call from a client in the
498561 * {@code destroy} function of a TypeScript client.
0 commit comments