treeschema

class TreeSchema

Bases: object

The base object used to interact with your TreeSchema data catalog.

The TreeSchema object has entry points into retrieving or creating the users, Transformations and Data Stores. All other data assets can be retrieved from there.

You can use your email and Tree Schema secret key to instantiate a TreeSchema object

>>> from treeschema import TreeSchema
>>> ts = TreeSchema('<your email>', '<your secret key>')

Creates a singleton for the Tree Schema auth object. This allows the auth credentails to be passed in one time and to allow multiple clients to reuse the credentials without having the context of the username and secret.

Parameters
  • username – The username in Tree Schema

  • secret_key – The secret key for the username in Tree Schema

batch_load_by_id(data_store_ids: List[int] = None, schema_ids: List[int] = None, field_ids: List[int] = None, batch_size: int = 100)

Batch loads a set of data assets in a more efficient manner by reducing the API overhead. A list of IDs can be provided for data stores, schemas and fields. When a list of fields is provided for a given assset class, all parent assets will be returned as well. For example, passing in a list of field_ids will return the fields, their associated schemas and the schema’s associated data stores.

All assets are serialized and added to the TreeSchema entity holder as if they had been created individually.

>>> Example...
data_store(data_store_input: [<class 'int'>, <class 'str'>, typing.Dict]) → treeschema.catalog.data_store.DataStore

Gets or creates a data store. A data store can be retrieved by passing in the data store ID (an integer) or the name of the data store (a string). A data store can be created using this function by passing in a dicitonary of values that includes the required fields for a data field object.

If attempting to create a new data store and the name provided already exists the existing data store will be retrieved.

A data store can be created or retrieved by providing the data store ID, the name of the data store, or a dictionary of inputs which can be used to create a new data store.

>>> ds = ts.data_store(1)
>>> ds = ts.data_store('Data store name')
>>> ds = ts.data_store({'name': 'New DS', 'type': 'other'})

The required fields are managed by the API, all required fields for data stores can be found in BODY of the the API to Create a Data Store

property data_stores

A dictionary of data stores that have been fetched via the API. Note - this will not contain all of your data stores unless you explicitly fetch them with get_data_stores() first

get_data_stores(refresh: bool = False) → Dict[int, treeschema.catalog.data_store.DataStore]

Retrieves all data stores from Tree Schema

get_transformations(refresh: bool = False) → Dict[int, treeschema.catalog.transformation.Transformation]

Retrieves all transformations from Tree Schema

get_users(refresh: bool = False) → Dict[int, treeschema.catalog.user.TreeSchemaUser]

Retrieves all transformations from Tree Schema

transformation(transformation_input: [<class 'int'>, <class 'str'>, typing.Dict]) → treeschema.catalog.data_store.DataStore

Gets or creates a transformation. A transformation can be retrieved by passing in the transformation ID (an integer) or the name of the transformation (a string). A transformation can be created using this function by passing in a dicitonary of values that includes the required fields for a transformation object.

If attempting to create a new transformation and the name provided already exists the existing transformation will be retrieved.

>>> t = ts.transformation(1)
>>> t = ts.transformation('Transformation name')
>>> t = ts.transformation({'name': 'New DS', 'type': 'pub_sub_event'})

The required fields are managed by the API, all required fields for transformations can be found in BODY of the the API to Create a Transformation

property transformations

A dictionary of transformations that have been fetched via the API. Note - this will not contain all of your transformations unless you explicitly fetch them with get_transformations() first

user(user_input: [<class 'int'>, <class 'str'>]) → Dict[int, treeschema.catalog.user.TreeSchemaUser]

Retrieves a single user from the current user’s org. A user can be looked up using the user ID or email address that the user has associated to their Tree Schema account

>>> user = ts.user(1)
>>> user = ts.user('user@email.com')
property users

A dictionary of users that have been fetched via the API. Note - this will not contain all of your users unless you explicitly fetch them with get_users() first