Skip to content

Create Atlan tags

Like other objects in the SDK that you can create, Atlan tags implement the builder pattern.

Atlan tags vs tags in general

Note that we intentionally use the phrase Atlan tag here to differentiate tags you can structurally maintain in Atlan vs other tags in general. For example, Snowflake tags are not managed this way, since they are owned and managed in Snowflake.

Build minimal object needed

1.3.3 1.0.0

For example, to create an Atlan tag to identify personally-identifiable information:

Build Atlan tag object for creation
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
AtlanTagDef color = AtlanTagDef.creator( // (1)
        "PII", // (2)
        AtlanTagColor.RED) // (3)
    .description("Personally-Identifiable Information") // (4)
    .build(); // (5)
AtlanTagDef icon = AtlanTagDef.creator(
        "PII",
        AtlanIcon.PASSWORD, // (6)
        AtlanTagColor.RED)
    .build();
AtlanTagDef image = AtlanTagDef.creator(
        "PII",
        "http://some.example.com/image.png", // (7)
        AtlanTagColor.RED)
    .build();
  1. Use the creator() method to start building up the Atlan tag.
  2. You must provide a name for the Atlan tag (PII in this example).
  3. You must also specify the color you want to use for the Atlan tag.
  4. (Optional) You can also give the Atlan tag a description.
  5. As with all other builder patterns, you must build() the object you've defined.
  6. As an alternative, you can also specify a built-in icon to use for the tag.
  7. As an alternative, you can also specify your own image to use for the tag.
Build Atlan tag object for creation
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
import urllib.request
from pyatlan.model.typedef import AtlanTagDef
from pyatlan.model.enums import AtlanTagColor, AtlanIcon
from pyatlan.client.atlan import AtlanClient

client = AtlanClient()
atlan_tag_def = AtlanTagDef.create( # (1)
                name="PII", # (2)
                color=AtlanTagColor.RED) # (3)
atlan_tag_def.description = "Personally-Identifiable Information" # (4)
atlan_tag_def = AtlanTagDef.create(
                name="PII",
                icon=AtlanIcon.PASSWORD, # (5)
                color=AtlanTagColor.RED)
urllib.request.urlretrieve("http://some.example.com/image.png", "image.png") # (6)
with open("image.png", "rb") as img_file:
    image = client.upload_image(file=img_file, filename="image.png") # (7)
    atlan_tag_def = AtlanTagDef.create(
                    name="PII",
                    image=image, # (8)
                    color=AtlanTagColor.RED)
  1. Use the create() method to set up the Atlan tag with its minimal necessary inputs.
  2. You must provide a name for the Atlan tag (PII in this example).
  3. You must also specify the color you want to use for the Atlan tag.
  4. (Optional) You can also give the Atlan tag a description.
  5. As an alternative, you can also specify a built-in icon to use for the tag.
  6. As an alternative, you can download or use your own image file for the tag.
  7. Before you can use the image, you must upload it to Atlan.
  8. You can then specify the uploaded image to use for the tag.
Build Atlan tag object for creation
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
val color = AtlanTagDef.creator( // (1)
        "PII",  // (2)
        AtlanTagColor.RED) // (3)
    .description("Personally-Identifiable Information") // (4)
    .build() // (5)
val icon = AtlanTagDef.creator(
        "PII",
        AtlanIcon.PASSWORD,  // (6)
        AtlanTagColor.RED)
    .build()
val image = AtlanTagDef.creator(
        "PII",
        "http://some.example.com/image.png",  // (7)
        AtlanTagColor.RED)
    .build()
  1. Use the creator() method to start building up the Atlan tag.
  2. You must provide a name for the Atlan tag (PII in this example).
  3. You must also specify the color you want to use for the Atlan tag.
  4. (Optional) You can also give the Atlan tag a description.
  5. As with all other builder patterns, you must build() the object you've defined.
  6. As an alternative, you can also specify a built-in icon to use for the tag.
  7. As an alternative, you can also specify your own image to use for the tag.

Image option not shown

The option to use your own image is significantly more complicated, as it involves constructing a multipart form-encoded upload of the binary image data first, and then using the resulting uploaded object's details to use the image within the tag.

POST /api/meta/types/typedefs
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
{
  "classificationDefs": [ // (1)
    {
      "category": "CLASSIFICATION", // (2)
      "name": "PII", // (3)
      "description": "Personally-Identifiable Information",
      "displayName": "PII", // (4)
      "options": {
        "color": "Red", // (5)
        "icon": "PhPassword", // (6)
        "iconType": "icon"
      },
      "skipDisplayNameUniquenessCheck": false
    }
  ]
}
  1. All Atlan tag definitions must be specified within the classificationDefs array.
  2. Each definition must be defined with a category set to CLASSIFICATION.
  3. Whatever name you provide for the definition will be replaced by a hashed-string generated name by the back-end.
  4. Specify the name of the Atlan tag, as it should appear in the UI, to the displayName.
  5. Set the color to use for the Atlan tag within the options object.
  6. (Optional) Set a built-in icon to use within the options object. When defining an icon, you must also set options.iconType to "icon".

Where can I see each icon?

We use Phosphor for the icons. They have a beautiful icon browser on their site to search and preview the icons.

Create the Atlan tag from the object

1.3.3 1.0.0

Now that the object is built, it will have the required information for Atlan to create it:

Create the Atlan tag
6
AtlanTagDef response = atlanTagDef.create(); // (1)
  1. The create() operation will actually create the Atlan tag within Atlan.
Create the Atlan tag
8
response = client.typedef.create(atlan_tag_def) # (1)
  1. The typedef.create() operation will actually create the Atlan tag within Atlan.
Create the Atlan tag
6
val response = color.create() // (1)
  1. The create() operation will actually create the Atlan tag within Atlan.

Creation implicit in step above

The actual creation of the Atlan tag is implicit in the example above.

Now that the Atlan tag has been created, you can use it to tag assets.