Skip to content

Manage options (enumerations)ΒΆ

Options (or enumerations) in Atlan allow you to define a set of valid values for custom metadata attributes. Like other objects in the SDK, enumerations implement the builder pattern. This allows you to progressively build-up the list of values you want to create.

Build minimal object neededΒΆ

1.3.3 1.0.0

For example, to create an enumeration to capture a data quality dimension:

Build enumeration for creation
1
2
3
4
EnumDef enumDef = EnumDef.creator(
        "DataQualityDimensions", // 
        List.of("Accuracy", "Completeness", "Consistency", "Timeliness", "Validity", "Uniqueness")) // 2
    .build(); // 
Build enumeration for creation
1
2
3
4
5
6
from pyatlan.model.typedef import EnumDef

enum_def = EnumDef.create(
    name="DataQualityDimensions", # 
    values=["Accuracy", "Completeness", "Consistency", "Timeliness", "Validity", "Uniqueness"] # 
)
Build enumeration for creation
1
2
3
4
val enumDef = EnumDef.creator(
        "DataQualityDimensions",  // 
        listOf("Accuracy", "Completeness", "Consistency", "Timeliness", "Validity", "Uniqueness")) // 2
    .build() // 
POST /api/meta/types/typedefs
 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
32
33
34
{
  "enumDefs": [ // 
    {
      "category": "ENUM", // 
      "name": "DataQualityDimensions", // 
      "elementDefs": [ // 
        {
          "value": "Accuracy",
          "ordinal": 0
        },
        {
          "value": "Completeness",
          "ordinal": 1
        },
        {
          "value": "Consistency",
          "ordinal": 2
        },
        {
          "value": "Timeliness",
          "ordinal": 3
        },
        {
          "value": "Validity",
          "ordinal": 4
        },
        {
          "value": "Uniqueness",
          "ordinal": 5
        }
      ]
    }
  ]
}

Create the enumeration from the objectΒΆ

1.3.3 4.0.0

Now that the object is built, this enumDef object will have the required information for Atlan to create it. You can then actually create the enumeration in Atlan by calling the create() method on the object itself:

Create the enumeration
5
EnumDef response = enumDef.create(client); // 
Create the enumeration
 7
 8
 9
10
from pyatlan.client.atlan import AtlanClient

client = AtlanClient()
response = client.typedef.create(enum_def) # 
Create the enumeration
5
val response = enumDef.create(client) // 

Creation implicit in step above

The actual creation of the enumeration structure is implicit in the example above.

Use an enumeration in a custom metadata definitionΒΆ

1.3.3 4.0.0

To use an enumeration to restrain the values for an attribute in a custom metadata definition:

Build custom metadata definition for creation
 6
 7
 8
 9
10
11
12
13
14
CustomMetadataDef customMetadataDef = CustomMetadataDef.creator("DQ") // 
    .attributeDef( // 
        AttributeDef.of(client, "Dimension", // 
            AtlanCustomAttributePrimitiveType.OPTIONS, // 
            "DataQualityDimensions", // 
            false)) // 
    .options(CustomMetadataOptions.withLogoAsEmoji("πŸ”–")) // 
    .build(); // 
customMetadataDef.create(); // 
Build custom metadata definition for creation
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from pyatlan.model.typedef import AttributeDef, CustomMetadataDef
from pyatlan.model.enums import AtlanCustomAttributePrimitiveType

cm_def = CustomMetadataDef.create(display_name="DQ") # 
cm_def.attribute_defs = [ # 
    AttributeDef.create(
        display_name="Dimension", # 
        attribute_type=AtlanCustomAttributePrimitiveType.OPTIONS, # 
        options_name="DataQualityDimensions", # 
    ),
]
cm_def.options = CustomMetadataDef.Options.with_logo_as_emoji( # 
    emoji="πŸ”–"
)

from pyatlan.client.atlan import AtlanClient

client = AtlanClient()
client.typedef.create(cm_def) # 
Build custom metadata definition for creation
 6
 7
 8
 9
10
11
12
13
14
val customMetadataDef = CustomMetadataDef.creator("DQ") // 
    .attributeDef( // 
        AttributeDef.of(client, "Dimension",  // 
            AtlanCustomAttributePrimitiveType.OPTIONS,  // 
            "DataQualityDimensions",  // 
            false)) // 
    .options(CustomMetadataOptions.withLogoAsEmoji("πŸ”–")) // 
    .build() // 
customMetadataDef.create() // 
POST /api/meta/types/typedefs
 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
{
  "businessMetadataDefs": [
    {
      "category": "BUSINESS_METADATA",
      "name": "DQ", // 
      "attributeDefs": [ // 
        {
          "name": "", // 
          "displayName": "Dimension",
          "description": "",
          "typeName": "DataQualityDimensions", // 
          "isOptional": true,
          "cardinality": "SINGLE",
          "valuesMinCount": 0,
          "valuesMaxCount": 1,
          "isUnique": false,
          "isIndexable": true,
          "includeInNotification": false,
          "options": {
            "applicableEntityTypes": "[\"Asset\"]",
            "customApplicableEntityTypes": "[\"PowerBIMeasure\",\"TableauWorkbook\",\"LookerModel\",\"MetabaseCollection\",\"ModeQuery\",\"GCSBucket\",\"LookerTile\",\"Table\",\"PowerBITile\",\"PowerBIPage\",\"SalesforceOrganization\",\"PresetWorkspace\",\"TableauDatasource\",\"PresetDataset\",\"TableauCalculatedField\",\"LookerFolder\",\"TableauWorksheet\",\"MetabaseQuestion\",\"AtlasGlossary\",\"PresetChart\",\"PowerBITable\",\"LookerProject\",\"SnowflakePipe\",\"PowerBIReport\",\"SigmaDatasetColumn\",\"TableauDatasourceField\",\"TablePartition\",\"AtlasGlossaryTerm\",\"SigmaDataElementField\",\"Schema\",\"Database\",\"DbtColumnProcess\",\"S3Object\",\"LookerLook\",\"TableauSite\",\"SnowflakeStream\",\"ModeCollection\",\"LookerDashboard\",\"PowerBIWorkspace\",\"Collection\",\"AtlasGlossaryCategory\",\"TableauFlow\",\"LookerView\",\"TableauProject\",\"LookerExplore\",\"ModeReport\",\"PowerBIColumn\",\"Query\",\"ColumnProcess\",\"SalesforceDashboard\",\"SalesforceObject\",\"BIProcess\",\"DbtModelColumn\",\"S3Bucket\",\"SigmaDataElement\",\"DataStudioAsset\",\"DbtProcess\",\"DbtModel\",\"PowerBIDataset\",\"Column\",\"DbtMetric\",\"TableauDashboard\",\"SigmaDataset\",\"LookerQuery\",\"APISpec\",\"MetabaseDashboard\",\"Process\",\"PowerBIDashboard\",\"APIPath\",\"ModeChart\",\"PowerBIDataflow\",\"SalesforceField\",\"GCSObject\",\"SalesforceReport\",\"View\",\"Folder\",\"TableauMetric\",\"MaterialisedView\",\"PresetDashboard\",\"PowerBIDatasource\",\"ModeWorkspace\",\"SigmaPage\",\"LookerField\",\"SigmaWorkbook\"]",
            "allowSearch": false,
            "maxStrLength": "100000000",
            "allowFiltering": true,
            "multiValueSelect": false,
            "showInOverview": false,
            "primitiveType": "enum", // 
            "isEnum": true,
            "enumType": "DataQualityDimensions"
          },
          "isNew": true,
          "enumValues": [
            "Accuracy",
            "Completeness",
            "Consistency",
            "Timeliness",
            "Validity",
            "Uniqueness"
          ]
        }
      ],
      "displayName": "DQ",
      "options": {
        "logoType": "emoji",
        "emoji": "πŸ”–"
      }
    }
  ]
}

Update options (enumerations)ΒΆ

2.1.0 4.0.0

For example, to update our data quality dimension enumeration by adding a new set of valid values.

Update existing enum structure
1
2
3
4
5
6
7
EnumDef enumDef = EnumDef.updater(
        client, "DataQualityDimensions", // 
        List.of("Unknown", "Others"),  // 
        false // 
    ).build(); // 

EnumDef response = enumDef.update(client); // 
Update existing enum structure
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
from pyatlan.model.typedef import EnumDef
from pyatlan.client.atlan import AtlanClient

client = AtlanClient()

enum_def = EnumDef.update(
    name="DataQualityDimensions", # 
    values=["Unknown", "Others"] # 
    replace_existing=False # 
)

response = client.typedef.update(enum_def) # 
Update existing enum structure
1
2
3
4
5
6
7
val enumDef = EnumDef.updater(
        client, "DataQualityDimensions", // 
        listOf("Unknown", "Others"),  // 
        false // 
    ).build() // 

val response = enumDef.update(client) // 
PUT /api/meta/types/typedefs
 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
32
33
34
35
36
37
38
39
40
41
42
{
  "enumDefs": [ // 
    {
      "category": "ENUM", // 
      "name": "DataQualityDimensions", // 
      "elementDefs": [ // 
        {
          "value": "Accuracy",
          "ordinal": 0
        },
        {
          "value": "Completeness",
          "ordinal": 1
        },
        {
          "value": "Consistency",
          "ordinal": 2
        },
        {
          "value": "Timeliness",
          "ordinal": 3
        },
        {
          "value": "Validity",
          "ordinal": 4
        },
        {
          "value": "Uniqueness",
          "ordinal": 5
        },
        {
          "value": "Unknown",
          "ordinal": 6
        },
        {
          "value": "Others",
          "ordinal": 7
        }
      ]
    }
  ]
}

Retrieve options (enumerations)ΒΆ

2.1.0 1.0.0

To retrieve options (enumeration) by name:

Retrieve existing enum structure
1
TypeDef enumDef = client.typeDefs.get("DataQualityDimensions"); // 
Retrieve existing enum structure
1
2
3
4
from pyatlan.client.atlan import AtlanClient

client = AtlanClient()
enum_def = client.typedef.get_by_name("DataQualityDimensions") # 
Retrieve existing enum structure
1
val enumDef = client.typeDefs.get("DataQualityDimensions") // 
GET /api/meta/types/typedef/name/DataQualityDimensions
1

Options (enumerations) do not have a hashed-string representation

Note that unlike a custom metadata structure, options (enumerations) do not have a hashed-string name. Therefore, use their human-readable name when retrieving its structure.

URL-encoding

However, since this name is embedded in the URL for retrieval, it does need to be url-encoded. For example, if the name contains spaces these need to be replaced with %20.

Retrieve all options (enumerations)ΒΆ

1.3.3 4.0.0

To retrieve all options (enumeration):

Retrieve all enum structures
1
TypeDefResponse enumDefs = client.typeDefs.list(AtlanTypeCategory.ENUM); // 
Retrieve all enum structures
1
2
3
4
5
from pyatlan.client.atlan import AtlanClient

client = AtlanClient()
response = client.typedef.get(type_category=AtlanTypeCategory.ENUM) # 
enum_defs = response.enum_defs # 
Retrieve all enum structures
1
val enumDefs = client.typeDefs.list(AtlanTypeCategory.ENUM) // 
GET /api/meta/types/typedefs/?type=ENUM
1

Delete options (enumerations)ΒΆ

1.3.3 4.0.0

To delete options (enumeration):

Delete enum structure
1
EnumDef.purge(client, "DataQualityDimensions"); // 
Delete enum structure
1
2
3
4
5
from pyatlan.model.typedef import EnumDef
from pyatlan.client.atlan import AtlanClient

client = AtlanClient()
client.typedef.purge("DataQualityDimensions", EnumDef) # 
Delete enum structure
1
EnumDef.purge("DataQualityDimensions") // 
DELETE /api/meta/types/typedef/name/DataQualityDimensions
1

Options (enumerations) do not have a hashed-string representation

Note that unlike a custom metadata structure, options (enumerations) do not have a hashed-string name. Therefore, use their human-readable name when deleting.

URL-encoding

However, since this name is embedded in the URL for deletion, it does need to be url-encoded. For example, if the name contains spaces these need to be replaced with %20.