Link domain and assets
Link your asset to a domain for easy discovery and governance.
Add asset to domain
You can add an asset to a domain or update an existing domain by updating the asset's domainGUIDs.
In the example below, we're adding a Table (MARKETING_SALES) to the domain (Marketing).
- dbt
- Java
- Python
- Kotlin
- Raw REST API
Add an asset to a domain
models:
- name: MARKETING_SALES # (1)
meta:
atlan:
domainName: "Marketing" # (2)
- You must give the name of the object.
- You can specify the domain as a human-readable name. Each asset can be assigned to only one domain. You can also replace an existing domain assignment by updating the
domainNameto a different domain.
Add an asset to a domain
DataDomain domain = DataDomain.findByName(client, "Marketing").get(0); // (1)
Table table = Table.updater( // (2)
"default/snowflake/1726834662/RAW/WIDEWORLDIMPORTERS/MARKETING_SALES",
"MARKETING_SALES")
.domainGUID(domain.getGuid()) // (3)
.build();
AssetMutationResponse response = table.save(client); // (4)
- You can retrieve a data domain by its human-readable
nameusing thefindByName()method. Because this operation will look up the domain in Atlan, you must provide it anAtlanClientthrough which to connect to the tenant. - Use the
updater()method of an asset by providing itsqualifiedNameandname. - To add the asset to the domain, assign the
guidof the domain to thedomainGUIDattribute. - Finally, call the
save()method to apply the changes in Atlan. Because this operation will persist the asset in Atlan, you must provide it anAtlanClientthrough which to connect to the tenant.
Add an asset to a domain
from pyatlan.client.atlan import AtlanClient
from pyatlan.model.assets import Table,
client = AtlanClient()
domain = client.asset.find_domain_by_name("Marketing") # (1)
table = Table.updater( # (2)
qualified_name="default/snowflake/1726834662/RAW/WIDEWORLDIMPORTERS/MARKETING_SALES",
name="MARKETING_SALES",
)
table.domain_g_u_i_ds = [domain.guid] # (3)
client.asset.save(table) # (4)
- You can retrieve a data domain by its human-readable
nameusing thefind_domain_by_name()method. - Use the
updater()method of an asset by providing itsqualifiedNameandname. - To add the asset to the domain, assign the
guidof the domain to theasset.domain_g_u_i_dsattribute. - Finally, call the
save()method to apply the changes in Atlan.
Add an asset to a domain
val domain = DataDomain.findByName(client, "Marketing")[0] // (1)
val table = Table.updater( // (2)
"default/snowflake/1726834662/RAW/WIDEWORLDIMPORTERS/MARKETING_SALES",
"MARKETING_SALES")
.domainGUID(domain.getGuid()) // (3)
.build()
val response = table.save(client) // (4)
- You can retrieve a data domain by its human-readable
nameusing thefindByName()method. Because this operation will look up the domain in Atlan, you must provide it anAtlanClientthrough which to connect to the tenant. - Use the
updater()method of an asset by providing itsqualifiedNameandname. - To add the asset to the domain, assign the
guidof the domain to theasset.domainGUIDattribute. - Finally, call the
save()method to apply the changes in Atlan. Because this operation will persist the asset in Atlan, you must provide it anAtlanClientthrough which to connect to the tenant.
POST /api/meta/entity/bulk
{
"entities": [
{
"typeName": "Table", // (1)
"attributes": {
"qualifiedName": "default/snowflake/1726834662/RAW/WIDEWORLDIMPORTERS/MARKETING_SALES", // (2)
"name": "MARKETING_SALES", // (3)
"domainGUIDs": [
"db711647-99a9-4c50-93c5-fab0b992a0cc" // (4)
]
}
}
]
}
- You need to specify the
typeNameof the asset; for this example, we're updating thedomainGUIDsfor a Snowflake table. - You need to specify the
qualifiedNameof the asset. - You need to specify the
nameof the asset. - To add the asset to the domain, assign the
guidof the domain to thedomainGUIDsproperty.
Retrieve Assets by Domain
You can retrieve all assets associated with a domain by filtering on the domainGUIDs.
In the example below, we retrieve all assets linked to the (Marketing) domain.
- Java
- Python
- Kotlin
Retrieve assets from a domain
String domainName = "Marketing";
DataDomain domain = DataDomain.findByName(client, domainName).get(0); // (1)
String domainGuid = domain.getGuid();
List<Asset> result = client.assets.select()
.where(Asset.DOMAIN_GUIDS.eq(domainGuid)) // (2)
.includeOnResults(Asset.NAME)
.includeOnResults(Asset.QUALIFIED_NAME) // (3)
.stream()
.toList();
result.forEach(asset -> { // (4)
System.out.println("Asset Name: " + asset.getName());
System.out.println("Qualified Name: " + asset.getQualifiedName());
});
- You can retrieve a data domain by its human-readable
nameusing thefindByName()method. Because this operation will look up the domain in Atlan, you must provide it anAtlanClientthrough which to connect to the tenant. - Query all assets linked to the domain using client.assets.select().where(Asset.DOMAIN_GUIDS.eq(domainGuid)).
- Include specific attributes (for example, Asset.NAME, Asset.QUALIFIED_NAME) in the results using .includeOnResults().
- Process the retrieved assets and print any specific attributes you need, such as name and qualifiedName in this example.
Retrieve assets from a domain
from pyatlan.client.atlan import AtlanClient
from pyatlan.model.assets import Asset, Readme
from pyatlan.model.fluent_search import CompoundQuery, FluentSearch
client = AtlanClient()
domain_name = "Marketing"
domain = client.asset.find_domain_by_name(domain_name) # (1)
domain_guid = domain.guid
response = ( # (2)
FluentSearch()
.select()
.where(Asset.DOMAIN_GUIDS.eq(domain_guid))
.include_on_results(Asset.NAME) # (3)
.include_on_results(Asset.QUALIFIED_NAME)
.execute(client=client)
)
for asset in response: # (4)
print(f"Name: {asset.name}, Qualified Name: {asset.qualified_name}")
- You can retrieve a data domain by its human-readable
nameusing thefind_domain_by_name()method. - Query all assets linked to the domain using FluentSearch.select().where(Asset.DOMAIN_GUIDS.eq(domain_guid)).
- Include specific attributes (for example, Asset.NAME, Asset.QUALIFIED_NAME) in the results using .include_on_results().
- Process the retrieved assets and print any specific attributes you need, such as name and qualifiedName in this example.
Retrieve assets from a domain
val domainName = "Marketing"
val domain = DataDomain.findByName(client, domainName)[0] // (1)
val domainGuid = domain.guid
val result = client.assets //(2)
.select()
.where(Asset.DOMAIN_GUIDS.eq(domainGuid))
.includeOnResults(Asset.NAME) // (3)
.includeOnResults(Asset.QUALIFIED_NAME)
.stream()
.toList()
for (assets in result)
- You can retrieve a data domain by its human-readable
nameusing thefindByName()method. Because this operation will look up the domain in Atlan, you must provide it anAtlanClientthrough which to connect to the tenant. - Query all assets linked to the domain using FluentSearch.search().where(Asset.DOMAIN_GUIDS.eq(domainGuid)).
- Include specific attributes (for example, Asset.NAME, Asset.QUALIFIED_NAME) in the results using .includeOnResults().
- Process the retrieved assets and print any specific attributes you need, such as name and qualifiedName in this example.
Remove asset from domain
You can remove an asset from a domain by updating the asset's domainGUIDs.
In the example below, we're removing a table (MARKETING_SALES) asset from the existing linked domain.
- dbt
- Java
- Python
- Kotlin
- Raw REST API
Remove an asset from a domain
models:
- name: MARKETING_SALES # (1)
meta:
atlan:
domainName: "" # (2)
- You must give the name of the object.
- To remove the asset from the domain, set the
domainNameto an empty string.
Remove an asset from a domain
Table table = Table.updater( // (1)
"default/snowflake/1726834662/RAW/WIDEWORLDIMPORTERS/MARKETING_SALES",
"MARKETING_SALES")
.nullField(Table.DOMAIN_GUIDS.getAtlanFieldName()) // (2)
.build();
AssetMutationResponse response = table.save(client); // (3)
- Use the
updater()method of an asset by providing itsqualifiedNameandname. - To remove the asset from the domain, set the
domainGUIDsfield as anullFieldon the builder. - Finally, call the
save()method to apply the changes in Atlan. Because this operation will persist the asset in Atlan, you must provide it anAtlanClientthrough which to connect to the tenant.
Remove an asset from a domain
from pyatlan.client.atlan import AtlanClient
from pyatlan.model.assets import Table,
client = AtlanClient()
table = Table.updater( # (1)
qualified_name="default/snowflake/1726834662/RAW/WIDEWORLDIMPORTERS/MARKETING_SALES",
name="MARKETING_SALES",
)
table.domain_g_u_i_ds = [] # (2)
client.asset.save(table) # (3)
- Use the
updater()method of an asset by providing itsqualifiedNameandname. - To remove the asset from the domain, assign the
domain_g_u_i_dsof the asset to an empty list ie.[]. - Finally, call the
save()method to apply the changes in Atlan.
Remove an asset from a domain
val table = Table.updater( // (1)
"default/snowflake/1726834662/RAW/WIDEWORLDIMPORTERS/MARKETING_SALES",
"MARKETING_SALES")
.nullField(Table.DOMAIN_GUIDS.atlanFieldName) // (2)
.build()
val response = table.save(client) // (3)
- Use the
updater()method of an asset by providing itsqualifiedNameandname. - To remove the asset from the domain, set the
domainGUIDsfield as anullFieldon the builder. - Finally, call the
save()method to apply the changes in Atlan. Because this operation will persist the asset in Atlan, you must provide it anAtlanClientthrough which to connect to the tenant.
POST /api/meta/entity/bulk
{
"entities": [
{
"typeName": "Table", // (1)
"attributes": {
"qualifiedName": "default/snowflake/1726834662/RAW/WIDEWORLDIMPORTERS/MARKETING_SALES", // (2)
"name": "MARKETING_SALES", // (3)
"domainGUIDs": [] // (4)
}
}
]
}
- You need to specify the
typeNameof the asset; for this example, we're updating thedomainGUIDsfor a Snowflake table. - You need to specify the
qualifiedNameof the asset. - You need to specify the
nameof the asset. - To remove the asset from the domain, assign the
domainGUIDsproperty of the asset to the empty array.