- Update resources: Update the configuration of a resource.
- Manage source schema: Fetch upstream schema changes or manually override the schema.
- Validate a set of fields: Apply the same validation to a set of fields, or declare filters within a validator.
- Destroy resources: Delete all resources in the project’s namespace.
- Import resources: Generate code for resources that are not present in the project.
Update resources
Resources are the configured components in your Validio environment, and include channels, credentials, sources, validators, windows, and so on. You can update the configuration of a resource by editing the resource’s declaration in the code. The Write step of the Validio Code workflow includes amain.py example with a 1-hour tumbling window. In the following example, you edit the window definition to disable the window timeout:
Python
plan command to display the pending update:
Bash
Immutable fields
Some fields are immutable because changing them would drastically change the behavior of the resource and its monitoring results. These fields are not exposed in the user interface, and changing them requires you to remove the resource and set up a new resource with the new settings. For example, the window on a validator is immutable because changing the window would invalidate all historical metrics for that validator. With IaC, changing an immutable field in the manifest automatically removes the old resource and creates the new one for you. If the resource to be recreated has child resources, such as when you change an immutable field on a source, all resources with that source as a parent (such as validators, windows, and segmentations) are also deleted and recreated. In IaC, you can review the summary of resources being removed or marked as replaced. The following example shows the output when you change the immutabletime_unit field on a tumbling window that is used by two validators:
Bash
Manage source schema
A source’s configuration includes a set of expected fields and data types, which are defined by the schema. Usually you do not interact with or modify the schema, because Validio automatically detects or infers the schema for all source types. However, you can intervene to manually update the schema to do the following:- Capture upstream schema changes
- Override the inferred schema with a modified version
Upstream schema changes
When the schema of the upstream data source changes, for example because of changes in the warehouse table, stream messages, or object storage file, it might add new fields that you would like to monitor. Pass the--update-schema flag to the plan or apply command to fetch the latest schema.
You can pass the
--update-schema flag multiple times to check several sources for updates, or use the --update-all-schemas flag to check for schema updates on all sources.Bash
Manual schema override
You can manually override the inferred schema with a modified version, with the following steps:- Download the inferred schema.
- Edit the downloaded schema file.
- Pass the contents of the modified schema file as a parameter to the source.
plan and apply commands detect a change to the source’s schema whenever the contents of the file change. For more information about interpreting and modifying the schema file, see the JSON Type Definition documentation.
The following example shows how to manually override an inferred schema with a modified schema file. First, download the inferred schema:
Bash
Python
Validate a set of fields
You can use field selectors to apply the same validation to a set of fields. Certain validators accept aFieldSelector object instead of a field name when specifying which field to monitor. The field selector is matched against the schema of the source, and declares an identical validator for every matching field.
- When you use field selectors, the name field becomes an interpolated string. Each unique validator gets a corresponding name based on the assigned field.
- You can also provide field selectors when you declare filters within a validator. Example 2 demonstrates using field selectors to declare filters in a validator.
You can only attach one field selector to a validator, either in the source field or in the filter.
FieldSelector.reference() object whenever the reference field is the same as the compared field. Example 3 demonstrates using reference source fields.
Example 1
Specify a declaration that creates validators for all numeric fields:Python
Bash
Example 2
Provide field selectors to declare filters within a validator. The following creates a null count validator for all nullable fields of the typeString:
Python
Bash
Example 3
Create a numeric distribution validator that compares the value of the assigned field with the value of the same field in the previous window. The validators use the samesource_field and reference_source_field:
Python
Destroy resources
To delete all resources in the project’s namespace, pass the--destroy flag to either the plan or apply command.
The following example uses plan to preview the resources to delete:
Bash
Import resources
Theimport command adds resources to the project. Adding resources to a project means writing out Python declarations for those resources to a file in the project directory.
Add the --import-namespace flag to name another namespace to import resources from. When you use the --import-namespace flag, the resources are moved to the namespace defined in validio.json.
Resources can exist in the project’s namespace without being part of the project. Run
import without the --import-namespace flag to add those resources to the project.import command moves the resources from other-namespace into the project’s example-namespace, as defined in validio.json. It then writes out Python declarations for those resources to the specified file, generated.py:
Bash
import command in the previous example moves an existing credential to the project’s namespace and generates a Python declaration for it. The attribute ignore_changes, which defaults to True, keeps the parameter values that already exist in the credential.
Specify resources to import
You can target specific resources to import with the--credential or --channel arguments:
- Importing a credential automatically imports all sources, filters, validators, and so on, that are attached to the credential.
- Importing a channel automatically imports all notification rules attached to the channel.
gcp-prod credential, along with its sources and validators, into the current project and namespace:
Bash
Import all resources
To import all resources in a namespace and move them to the project’s namespace, omit the--credential and --channel arguments. This is useful if you have been setting up Validio in the UI and want to start version controlling everything with IaC. To do this, move from the default namespace:
Bash