Overview
You can use the client to call the API as part of a Validio Code (IaC) setup. This is useful, for example, to copy a standard set of validators from another namespace, or to use values from a predetermined resource. This recipe reads the dynamic threshold of an existing validator and applies the same threshold to a validator declared in code.Steps
1
Get the sensitivity and decision bounds
Write a function that accepts a validator name and the namespace it’s in, and returns its threshold configuration. The validator could be a template validator, or one that is known to do the same thing as the validator you’re declaring.
2
Call the function
Get the threshold configuration by calling the function. The client requires an asynchronous runtime, so use
asyncio.run to run the request.3
Declare the validator
Declare a validator in the global context as usual, and use the values from the other validator as input to its threshold. The window and segmentation are resources declared elsewhere in your Validio Code program.
Full code sample
Python