CustomMetadataDef: retrieve custom metadata
TL;DR
Retrieve custom metadata structures programmatically using the Atlan Python SDK (pyatlan). Use CustomMetadataDef to access metadata definitions and attributes.
Use CustomMetadataDef in the Atlan Python SDK to programmatically retrieve custom metadata type definitions and their attributes.
You can retrieve an existing custom metadata structure:
- Java
- Python
- Kotlin
- Raw REST API
Retrieve existing custom metadata structure
CustomMetadataDef existing = client
.getCustomMetadataCache()
.getCustomMetadataDef("RACI"); // (1)
- You can retrieve the current custom metadata definition using the custom metadata cache from any client. In most cases you can simply use the default client (
Atlan.getDefaultClient()). Pass the human-readable name of the custom metadata structure to the cache.
Retrieve existing custom metadata structure
from pyatlan.client.atlan import AtlanClient
client = AtlanClient()
existing = client.custom_metadata_cache.get_custom_metadata_def(name="RACI") # (1)
- You can retrieve the current custom metadata definition using the
client.custom_metadata_cache.get_custom_metadata_def()method and passing the human-readable name of the custom metadata structure.
Retrieve existing custom metadata structure
val existing = client
.customMetadataCache
.getCustomMetadataDef("RACI") // (1)
- You can retrieve the current custom metadata definition using the custom metadata cache from any client. In most cases you can simply use the default client (
Atlan.getDefaultClient()). Pass the human-readable name of the custom metadata structure to the cache.
GET /api/meta/types/typedefs?type=BUSINESS_METADATA
{
"businessMetadataDefs": [ // (1)
}
],
"createdBy": "jsmith",
"updatedBy": "jsmith",
"createTime": 1648852296555,
"updateTime": 1649172284333,
"version": 2
}
]
}
- Each custom metadata structure will be wrapped in the top-level
businessMetadataDefsarray. - Each custom metadata structure object will have a
categoryofBUSINESS_METADATA. - The
nameof a custom metadata structure is a unique hashed-string, but isn't human-readable. This is how the custom metadata is uniquely referred to through the raw APIs. - The
displayNameof a custom metadata structure is the human-readable name you see in the UI. - Each property defined within the custom metadata structure is nested within an
attributeDefsarray. - As with the overall custom metadata structure, each attribute has a unique hashed-string
namethat'sn't human-readable. This is how the custom metadata property is uniquely referred to through the raw APIs. - As with the overall custom metadata structure, each attribute also has a
displayNamethat's the human-readable name you see in the UI. - The type of the custom metadata property is its simple type, but doesn't include custom types like SQL, users, groups and so on.
- For the precise type, you also need to look at the
customTypewithin theoptions, within the attribute definition.