Skip to content

Manage custom metadata badges

You can use badges in Atlan to provide quick indicators of key signals from custom metadata. They appear in the Overview of the asset, rather than nested within the custom metadata tab.

Badges are a kind of asset

Badges are actually modeled as just another kind of asset in Atlan. This means all the standard CRUD operations apply to badges the same as any other asset.

Create a badge

1.4.0 1.0.0

For example, to create a badge for custom metadata capturing a count of data quality checks that have run:

Build a badge
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
Badge badge = Badge.creator( // (1)
        "DQ Count", // (2)
        "Data Quality", // (3)
        "Count") // (4)
    .userDescription("How many data quality checks ran against this asset.") // (5)
    .badgeCondition( // (6)
        BadgeCondition.of(
            BadgeComparisonOperator.GTE, // (7)
            5, // (8)
            BadgeConditionColor.GREEN)) // (9)
    .badgeCondition(
        BadgeCondition.of(
            BadgeComparisonOperator.LT,
            5,
            BadgeConditionColor.YELLOW))
    .badgeCondition(
        BadgeCondition.of(
            BadgeComparisonOperator.LTE,
            2,
            BadgeConditionColor.RED))
    .build(); // (10)
AssetMutationResponse response = badge.save(); // (11)
  1. Like with any other asset, use the creator() method to ensure you provide the minimal information required to create a badge.
  2. You must provide a name for the badge.
  3. You must specify the name of the custom metadata set the badge will summarize.
  4. You must provide the name of the custom metadata property within that set the badge will represent.
  5. You can optionally provide other details about the badge, like with any other asset. In this example we provide a description for the badge.
  6. You can then specify any number of conditions to represent in the badge.
  7. Each condition is comprised of an operator (standard mathematical comparisons),
  8. ...a value against which to compare the asset's value for the property,
  9. ...and the color to apply to the badge if the asset's value for the property matches the value (as compared through the operator). This can be one of the predefined colors, or any RGB-based hex value for a custom color.
  10. As with all other builder patterns, you must build() the object you've defined.
  11. The save() operation will actually create the badge within Atlan, including its conditions.
Build a badge
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from pyatlan.client.atlan import AtlanClient
from pyatlan.model.assets import Badge
from pyatlan.model.enums import BadgeConditionColor, BadgeComparisonOperator
from pyatlan.model.structs import BadgeCondition

client = AtlanClient()
badge = Badge.create( # (1)
    name="DQ Count", # (2)
    cm_name="Data Quality", # (3)
    cm_attribute="count", # (4)
    badge_conditions=[ # (5)
        BadgeCondition.create( # (6)
            badge_condition_operator=BadgeComparisonOperator.GTE, # (7)
            badge_condition_value="5", # (8)
            badge_condition_colorhex=BadgeConditionColor.GREEN, # (9)
        ),
        BadgeCondition.create(
            badge_condition_operator=BadgeComparisonOperator.LT,
            badge_condition_value="5",
            badge_condition_colorhex=BadgeConditionColor.YELLOW,
        ),
        BadgeCondition.create(
            badge_condition_operator=BadgeComparisonOperator.LTE,
            badge_condition_value="2",
            badge_condition_colorhex=BadgeConditionColor.RED,
        ),
    ],
)
badge.user_description = "How many data quality checks ran against this asset." # (10)
response = client.asset.save(badge) # (11)
assert (assets := response.assets_created(asset_type=Badge) # (12)
  1. Like with any other asset, use the create() method to ensure you provide the minimal information required to create a badge.
  2. You must provide a name for the badge.
  3. You must specify the name of the custom metadata set the badge will summarize.
  4. You must provide the name of the custom metadata property within that set the badge will represent.

    Property is renamed

    The property names used have been converted to the standard python form, i.e. lowercase with spaces replaced with an underscore.

  5. You can then specify any number of conditions to represent in the badge.

  6. Use the 'create()' method to provide the information needed to create the BadgeCondition.
  7. Each condition is comprised of an operator (standard mathematical comparisons),
  8. ...a value against which to compare the asset's value for the property,
  9. ...and the color to apply to the badge if the asset's value for the property matches the value (as compared through the operator). This can be one of the predefined colors, or any RGB-based hex value for a custom color.
  10. You can optionally provide other details about the badge, like with any other asset. In this example we provide a description for the badge.
  11. The save() operation will actually create the badge within Atlan, including its conditions.
  12. Check that the Badge was created.
Build a badge
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
val badge = Badge.creator( // (1)
        "DQ Count",  // (2)
        "Data Quality",  // (3)
        "Count") // (4)
    .userDescription("How many data quality checks ran against this asset.") // (5)
    .badgeCondition( // (6)
        BadgeCondition.of(
            BadgeComparisonOperator.GTE,  // (7)
            5,  // (8)
            BadgeConditionColor.GREEN)) // (9)
    .badgeCondition(
        BadgeCondition.of(
            BadgeComparisonOperator.LT,
            5,
            BadgeConditionColor.YELLOW))
    .badgeCondition(
        BadgeCondition.of(
            BadgeComparisonOperator.LTE,
            2,
            BadgeConditionColor.RED))
    .build() // (10)
val response = badge.save() // (11)
  1. Like with any other asset, use the creator() method to ensure you provide the minimal information required to create a badge.
  2. You must provide a name for the badge.
  3. You must specify the name of the custom metadata set the badge will summarize.
  4. You must provide the name of the custom metadata property within that set the badge will represent.
  5. You can optionally provide other details about the badge, like with any other asset. In this example we provide a description for the badge.
  6. You can then specify any number of conditions to represent in the badge.
  7. Each condition is comprised of an operator (standard mathematical comparisons),
  8. ...a value against which to compare the asset's value for the property,
  9. ...and the color to apply to the badge if the asset's value for the property matches the value (as compared through the operator). This can be one of the predefined colors, or any RGB-based hex value for a custom color.
  10. As with all other builder patterns, you must build() the object you've defined.
  11. The save() operation will actually create the badge within Atlan, including its conditions.
POST /api/entity/bulk
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
{
  "entities": [ // (1)
    {
      "typeName": "Badge", // (2)
      "attributes": {
        "name": "Count", // (3)
        "badgeMetadataAttribute": "gA1HGY8JClmG8wXxC9i4EX.NYcrFDTHGVpBKHv0Ihk8xC", // (4)
        "qualifiedName": "badges/global/gA1HGY8JClmG8wXxC9i4EX.NYcrFDTHGVpBKHv0Ihk8xC", // (5)
        "userDescription": "How many data quality checks ran against this asset.", // (6)
        "badgeConditions": [ // (7)
          {
            "badgeConditionOperator": "gte", // (8)
            "badgeConditionValue": "5", // (9)
            "badgeConditionColorhex": "#047960" // (10)
          },
          {
            "badgeConditionOperator": "lt",
            "badgeConditionValue": "5",
            "badgeConditionColorhex": "#F7B43D"
          },
          {
            "badgeConditionOperator": "lte",
            "badgeConditionValue": "2",
            "badgeConditionColorhex": "#BF1B1B"
          }
        ]
      }
    }
  ]
}
  1. Like with any other asset, define the badge within an entities array.
  2. You must use the exact value Badge as the typeName for a badge.
  3. You must provide a name for the badge.
  4. You must specify the full name of the custom metadata property (its set and property name). These must also use Atlan's internal hashed-string representation.
  5. You must provide a qualifiedName for the badge that uses the format: badges/global/<custom-metadata-property>, where ` is the full name of the custom metadata property (using Atlan's internal hashed-string representation).
  6. You can optionally provide other details about the badge, like with any other asset. In this example we provide a description for the badge.
  7. You can then specify any number of conditions to represent in the badge.
  8. Each condition is comprised of an operator (standard mathematical comparisons),
  9. ...a value against which to compare the asset's value for the property,

    Must be a string in the JSON

    The value you provide must always be a string in JSON. For actual string values (for text fields and options fields), you must further wrap the string itself in double-quotes.

  10. ...and the color to apply to the badge if the asset's value for the property matches the value (as compared through the operator). This should be an RGB-based hex value. (The colors given in this example are the standard green, amber, red used in the UI.)

Now that the badge has been created, any assets with a value set for the custom metadata will show the badge on its overview tab.

Delete a badge

1.4.0 1.0.0

You can delete a badge at any time using:

Delete a badge
1
AssetDeletionResponse response = Badge.purge("1c932bbb-fbe6-4bbc-9d0d-3df2f1fa4f81"); // (1)
  1. The purge() operation will permanently delete the badge, given the GUID of the badge.
Delete a badge
1
response = client.asset.purge_by_guid("1c932bbb-fbe6-4bbc-9d0d-3df2f1fa4f81") # (1)
  1. The asset.purge_by_guid() operation will permanently delete the badge, given the GUID of the badge.
Delete a badge
1
val response = Badge.purge("1c932bbb-fbe6-4bbc-9d0d-3df2f1fa4f81") // (1)
  1. The purge() operation will permanently delete the badge, given the GUID of the badge.
DELETE /api/meta/entity/bulk?guid=1c932bbb-fbe6-4bbc-9d0d-3df2f1fa4f81&deleteType=PURGE
1
// (1)
  1. All information needed to permanently delete the badge is provided in the URL (in particular the GUID of the badge).

Now that the badge has been deleted, no assets will show it on their overview tab.