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¶
For example, to create an enumeration to capture a data quality dimension:
Build enumeration for creation | |
---|---|
1 2 3 4 |
|
- When creating the enumeration, you must provide a name (
DataQualityDimensions
in this example). - You can then add as many valid values as you want: always as a list of strings.
- As with all other builder patterns, you must
build()
the object you've defined.
Build enumeration for creation | |
---|---|
1 2 3 4 5 6 |
|
- When creating the enumeration, you must provide a name (
DataQualityDimensions
in this example). - You can then add as many valid values as you want: always as a list of strings.
Build enumeration for creation | |
---|---|
1 2 3 4 |
|
- When creating the enumeration, you must provide a name (
DataQualityDimensions
in this example). - You can then add as many valid values as you want: always as a list of strings.
- As with all other builder patterns, you must
build()
the object you've defined.
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 |
|
- All enumeration definitions must be specified within the
enumDefs
array. - Each definition must be defined with a category set to
ENUM
. - The name you provide for the definition will be used both for the front and back-end.
- Within the definition, you need to define each valid value for the enumeration within the
elementDefs
array. Each valid value should have both a stringvalue
(as it will appear in the UI) and an integerordinal
. Both must be unique within the enumeration.
Create the enumeration from the object¶
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 |
|
- The
create()
operation will actually create the enumeration within Atlan, including all the valid values that were defined as part of it.
Create the enumeration | |
---|---|
7 8 9 10 |
|
- The
typedef.create()
operation will actually create the enumeration definition within Atlan, including all the valid values that were defined as part of it.
Create the enumeration | |
---|---|
5 |
|
- The
create()
operation will actually create the enumeration within Atlan, including all the valid values that were defined as part of it.
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¶
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 |
|
- When creating the custom metadata structure, you must provide a name (
DQ
in this example). - You can then add as many attributes to that structure as you want.
- Each attribute must have a name.
- Each attribute must have a type. When using the enumeration as the type (to constrain its possible values), use
AtlanCustomAttributePrimitiveType.OPTIONS
as the type. - You must then also specify the enumeration that defines the valid values for this attribute. Carrying on the same example, we give the name of the enumeration here:
DataQualityDimensions
. - You must also specify whether the attribute allows multiple values to be captured on it (
true
) or only a single value (false
). - You can specify how the custom metadata should appear (in this case, with an emoji).
- As with all other builder patterns, you must
build()
the object you've defined. - Then you can
create()
the custom metadata definition within Atlan, including this enumeration-constrained attribute that was defined as part of it.
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 |
|
- When creating the custom metadata structure, you must provide a name (
DQ
in this example). - You can then add as many attributes to that structure as you want.
- Each attribute must have a name.
- Each attribute must have a type. When using the enumeration as the type (to constrain its possible values), use
AtlanCustomAttributePrimitiveType.OPTIONS
as the type. - You must then also specify the enumeration that defines the valid values for this attribute. Carrying on the same example, we give the name of the enumeration here:
DataQualityDimensions
. - You can specify how the custom metadata should appear (in this case, with an emoji).
- Then you can create the custom metadata definition within Atlan, including this enumeration-constrained attribute that was defined as part of it.
Build custom metadata definition for creation | |
---|---|
6 7 8 9 10 11 12 13 14 |
|
- When creating the custom metadata structure, you must provide a name (
DQ
in this example). - You can then add as many attributes to that structure as you want.
- Each attribute must have a name.
- Each attribute must have a type. When using the enumeration as the type (to constrain its possible values), use
AtlanCustomAttributePrimitiveType.OPTIONS
as the type. - You must then also specify the enumeration that defines the valid values for this attribute. Carrying on the same example, we give the name of the enumeration here:
DataQualityDimensions
. - You must also specify whether the attribute allows multiple values to be captured on it (
true
) or only a single value (false
). - You can specify how the custom metadata should appear (in this case, with an emoji).
- As with all other builder patterns, you must
build()
the object you've defined. - Then you can
create()
the custom metadata definition within Atlan, including this enumeration-constrained attribute that was defined as part of it.
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 |
|
- When creating the custom metadata structure, you must provide a name (
DQ
in this example). - You can then add as many attributes to that structure as you want.
- Each attribute must have a name. Note, however, that the
name
should be sent as an empty string when creating an attribute (the name will be generated by the back-end), and it is actually thedisplayName
that gives the name as it will appear in the UI. - You must specify the enumeration that defines the valid values for this attribute. Carrying on the same example, we give the name of the enumeration here:
DataQualityDimensions
. -
Each attribute must also have a primitive type. When using the enumeration as the type (to constrain its possible values), use:
enum
as the primitive typeisEnum
set totrue
- and set
enumType
to the name of the enumeration
Update options (enumerations)¶
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 |
|
- When updating the existing enumeration, you must provide
a name (
DataQualityDimensions
in this example). - You can then add as many valid values as you want: always as a list of strings.
- You must specify whether you want to replace all existing values in the enumeration
with the new ones (
true
), or if the new ones will be appended to the existing set (false
). - As with all other builder patterns, you must
build()
the object you've defined. - The
update()
operation will actually update the enumeration within Atlan, including all the valid values that were defined as part of it.
Update existing enum structure | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 |
|
- When updating the existing enumeration, you must provide
a name (
DataQualityDimensions
in this example). - You can then add as many valid values as you want: always as a list of strings.
- You must specify whether you want to replace all existing values in the enumeration
with the new ones (
True
), or if the new ones will be appended to the existing set (False
). - The
client.typedef.update()
operation will actually update the enumeration within Atlan, including all the valid values that were defined as part of it.
Update existing enum structure | |
---|---|
1 2 3 4 5 6 7 |
|
- When updating the existing enumeration, you must provide
a name (
DataQualityDimensions
in this example). - You can then add as many valid values as you want: always as a list of strings.
- You must specify whether you want to replace all existing values in the enumeration
with the new ones (
true
), or if the new ones will be appended to the existing set (false
). - As with all other builder patterns, you must
build()
the object you've defined. - The
update()
operation will actually update the enumeration within Atlan, including all the valid values that were defined as part of it.
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 |
|
- All enumeration definitions must be specified within the
enumDefs
array. - Each definition must be defined with a category set to
ENUM
. - The name of the enumeration definition you want to update.
- You must send all valid values in the
elementDefs
array, as the existing list of elements for the enumerations will be entirely replaced by what you provide here.
Retrieve options (enumerations)¶
To retrieve options (enumeration) by name:
Retrieve existing enum structure | |
---|---|
1 2 |
|
- To retrieve the enumeration, you need to call the
client.typeDefs.get()
method with its human-readable name.
Retrieve existing enum structure | |
---|---|
1 2 3 4 |
|
- To retrieve the enumeration, you need to call the
client.typedef.get_by_name()
method with its human-readable name.
Retrieve existing enum structure | |
---|---|
1 2 |
|
- To retrieve the enumeration, you need to call the
client.typeDefs.get()
method with its human-readable name.
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)¶
To retrieve all options (enumeration):
Retrieve all enum structures | |
---|---|
1 2 |
|
- To retrieve all enumerations, call the
client.typeDefs.list()
method with the definition categoryAtlanTypeCategory.ENUM
.
Retrieve all enum structures | |
---|---|
1 2 3 4 5 |
|
- To retrieve all enumerations, call the
client.typedef.get()
method with the definition categoryAtlanTypeCategory.ENUM
. - Specifically retrieve the list of enumerations from
TypeDefResponse
.
Retrieve all enum structures | |
---|---|
1 2 |
|
- To retrieve all enumerations, call the
client.typeDefs.list()
method with the definition categoryAtlanTypeCategory.ENUM
.
GET /api/meta/types/typedefs/?type=ENUM | |
---|---|
1 |
|
Delete options (enumerations)¶
To delete options (enumeration):
Delete enum structure | |
---|---|
1 |
|
- You only need to call the
EnumDef.purge()
method with the human-readable name of the enumeration, and it will be deleted.
Delete enum structure | |
---|---|
1 2 3 4 5 |
|
- You only need to call the
clietn.typedef.purge()
method with the human-readable name of the enumeration, and it will be deleted.
Delete enum structure | |
---|---|
1 |
|
- You only need to call the
EnumDef.purge()
method with the human-readable name of the enumeration, and it will be deleted.
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
.