sdk

No menu items for this category

Python SDK for Tags

In this guide, we will use the Python SDK to create Tags.

A prerequisite for this section is to have previously gone through the following docs.

In the following sections we will:

  • Create a Database Service, a Database, a Schema and one Table,
  • Create a Classification,
  • Create a Tag for the Classification and add it to the Table.

To prepare the necessary ingredients, execute the following steps.

We are mocking a MySQL instance. Note how we need to pass the right configuration class MysqlConnection, as a parameter for the generic DatabaseConnection type.

Any Entity that is created and linked to another Entity, has to hold the fullyQualifiedName to the Entity it relates to. In this case, a Database is bound to a specific service.

The same happens with the Schemas. They are related to a Database.

We are doing a simple example with a single column.

Classifications are the entities we use to group tag definitions. Let's create a sample one:

Once there is an existing classification, we create tags within that given classification:

Now that we have the Tag, we can proceed and tag a specific asset. In this example, we'll tag the Table we created above. For that, the API uses a PATCH request, but the Python SDK has a helper method that handles most of the work:

If we now check the tags for the Table, the new tag will be appearing in there.

Note that we now used the patch_tag method because the Table already existed. If we can control the Tag creation process when the Table metadata is generated, we can assign the tags in the tags property of CreateTableRequest.

The same idea can be replicated to tag a column: