Validio SDK

The Validio SDK provides functionality to interact with the Validio API using Python.

Validio SDK

The Validio Software Development Kit (SDK) provides functionality to interact with the Validio API, through an auto-generated GraphQL client. The SDK is written in Python and all its public functions are documented according to pydoc using Sphinx documentation.

The Validio SDK enables:

  • Type safe request-response cycle.
  • Automatic in-line documentation on types and functions.
  • Integration with tools and support for automation.

The Validio SDK provides functionality to interact with the API, through a GraphQL client. Based on your configured credentials, the GraphQL client sets up authentication and uses proper types for both requests and responses.

The SDK also supports other functionality, such as Infrastructure-as-Code and local configuration management. You can view hints and information on functionality in your editor or IDE.

Here is an example of how to use the SDK to print the name of all sources. Note that this example assumes validio config has been run, in order for your credentials to be applied automatically:

import asyncio

from validio_sdk.validio_client import ValidioAPIClient

async def main():
    client = ValidioAPIClient()
    sources = await client.list_sources()
    for source in sources:
        print(source.name)


if __name__ == "__main__":
    asyncio.run(main())

📘

More information

For more information, refer to the complete Validio SDK documentation..

Install the Validio SDK

The Validio SDK is published as Python packages on PyPI as validio-sdk.

You can use a Python package installer, such as ‘pip’, to install the SDK in your desired environment:

pip install validio-sdk

Structure of the code

The GraphQL client, all queries, mutations, and associated input and output types are generated from the GraphQL schema. This consistency offers a familiar pattern to guide you through both the documentation and the code base.

Naming

The names of all generated types follow a pattern:

  • Types implementing an interface are named <interface-name><implementation-name>
  • Types returned from an endpoint are named <query-or-mutation-name><return-type>

Here is an example of how the naming pattern applies to certain resources:

GetSource is an endpoint whose return type is an implementation of an interface. GetSource<return-type> therefore becomes GetSource<interface-name><implementation-name>. An interface name here is Source, and a corresponding implementation name is GcpBigQuerySource. The full return type therefore becomes GetSourceSourceGcpBigQuerySource. This may seem verbose, but the upside is that it gives all information about both the request and the response types.

The client

In our examples, we use a client named ValidioAPIClient. This is just a thin wrapper around the generated client to add headers such as authorization and user-agent, sensible timeouts and other quality of life things.

This base client has all queries and mutations as class methods, making it the source for supported requests.

👍

If customization is required, you can extend the BaseClient available at validio_sdk.graphql_client.client.

Input- and output types

Every method expects an input type and produces an output type. You therefore never pass raw GraphQL queries, nor receive untyped data structures.

Input types are found in validio_sdk.graphql_client.input_types. These adhere to PEP8 naming conventions, translating camelCase fields from the GraphQL schema into snake_case. For instance, resourceNamespace in the schema translates to resource_namespace in the generated class.

Output types are tailored per method and stored in distinct files. As an example, output types for the list_sources method can be found in validio_sdk.graphql_client.list_sources.

Enums used in the GraphQL schema are generated to validio_sdk.graphql_client.enums. An example of an enum is the set of time units used when creating a Window.

📘

All classes are built using Pydantic, enabling support for field aliases. While this allows the use of original camelCase names, be aware that some IDEs and editors might encounter issues with it.

Resource types

Types designated for Infrastructure-as-Code (IaC) are located in the resource module and are not derived from the GraphQL schema. SDK users will come across these types when interfacing with IaC endpoints. For example, when invoking get_source for a Google BigQuery source, the return type is validio_sdk.graphql_client.get_source.GetSourceSourceGcpBigQuerySource and not validio_sdk.resource.GcpBigQuerySource.