@@ -54,7 +54,7 @@ def __init__(
54
54
params : Sequence [Parameter ],
55
55
required_authn_params : Mapping [str , list [str ]],
56
56
auth_service_token_getters : Mapping [str , Callable [[], str ]],
57
- bound_params : Mapping [str , Union [Callable [[], Any ], Any ]] = {} ,
57
+ bound_params : Mapping [str , Union [Callable [[], Any ], Any ]],
58
58
):
59
59
"""
60
60
Initializes a callable that will trigger the tool invocation through the
@@ -71,6 +71,9 @@ def __init__(
71
71
of services that provide values for them.
72
72
auth_service_token_getters: A dict of authService -> token (or callables that
73
73
produce a token)
74
+ bound_params: A mapping of parameter names to bind to specific values or
75
+ callables that are called to produce values as needed.
76
+
74
77
"""
75
78
76
79
# used to invoke the toolbox API
@@ -92,7 +95,7 @@ def __init__(
92
95
self .__required_authn_params = required_authn_params
93
96
# map of authService -> token_getter
94
97
self .__auth_service_token_getters = auth_service_token_getters
95
- # map of parameter name to value or Callable
98
+ # map of parameter name to value ( or callable that produces that value)
96
99
self .__bound_parameters = bound_params
97
100
98
101
def __copy (
@@ -120,6 +123,8 @@ def __copy(
120
123
a auth_service_token_getter set for them yet.
121
124
auth_service_token_getters: A dict of authService -> token (or callables
122
125
that produce a token)
126
+ bound_params: A mapping of parameter names to bind to specific values or
127
+ callables that are called to produce values as needed.
123
128
124
129
"""
125
130
check = lambda val , default : val if val is not None else default
@@ -235,7 +240,7 @@ def add_auth_token_getters(
235
240
)
236
241
237
242
def bind_parameters (
238
- self , bound_params : Mapping [str , Callable [[], str ]]
243
+ self , bound_params : Mapping [str , Union [ Callable [[], Any ], Any ]]
239
244
) -> "ToolboxTool" :
240
245
"""
241
246
Binds parameters to values or callables that produce values.
@@ -247,9 +252,9 @@ def bind_parameters(
247
252
Returns:
248
253
A new ToolboxTool instance with the specified parameters bound.
249
254
"""
250
- all_params = set (p .name for p in self .__params )
255
+ param_names = set (p .name for p in self .__params )
251
256
for name in bound_params .keys ():
252
- if name not in all_params :
257
+ if name not in param_names :
253
258
raise Exception (f"unable to bind parameters: no parameter named { name } " )
254
259
255
260
new_params = []
@@ -267,28 +272,28 @@ def identify_required_authn_params(
267
272
req_authn_params : Mapping [str , list [str ]], auth_service_names : Iterable [str ]
268
273
) -> dict [str , list [str ]]:
269
274
"""
270
- <<<<<<< HEAD
271
- Identifies authentication parameters that are still required; or not covered by
272
- the provided `auth_service_names`.
273
- =======
274
- Utility function for reducing 'req_authn_params' to a subset of parameters that
275
- aren't supplied by a least one service in auth_services.
276
- >>>>>>> 744ade9 (feat: add support for bound parameters)
277
-
278
- Args:
279
- req_authn_params: A mapping of parameter names to sets of required
280
- authentication services.
281
- auth_service_names: An iterable of authentication service names for which
282
- token getters are available.
283
-
284
- Returns:
285
- <<<<<<< HEAD
286
- A new dictionary representing the subset of required authentication
287
- parameters that are not covered by the provided `auth_service_names`.
288
- =======
289
- A new dictionary representing the subset of required authentication parameters
290
- that are not covered by the provided `auth_services`.
291
- >>>>>>> 744ade9 (feat: add support for bound parameters)
275
+ <<<<<<< HEAD
276
+ Identifies authentication parameters that are still required; or not covered by
277
+ the provided `auth_service_names`.
278
+ =======
279
+ Utility function for reducing 'req_authn_params' to a subset of parameters that
280
+ aren't supplied by a least one service in auth_services.
281
+ >>>>>>> 744ade9 (feat: add support for bound parameters)
282
+
283
+ Args:
284
+ req_authn_params: A mapping of parameter names to sets of required
285
+ authentication services.
286
+ auth_service_names: An iterable of authentication service names for which
287
+ token getters are available.
288
+
289
+ Returns:
290
+ <<<<<<< HEAD
291
+ A new dictionary representing the subset of required authentication
292
+ parameters that are not covered by the provided `auth_service_names`.
293
+ =======
294
+ A new dictionary representing the subset of required authentication parameters
295
+ that are not covered by the provided `auth_services`.
296
+ >>>>>>> 744ade9 (feat: add support for bound parameters)
292
297
"""
293
298
required_params = {} # params that are still required with provided auth_services
294
299
for param , services in req_authn_params .items ():
0 commit comments