Get all assets that are linked to a specific term¶
This example finds all assets that are linked to a specific glossary term. (And could be extended to do find assets linked to any one of a number of glossary terms.) In this specific example we will find any assets linked to a glossary term named Revenue in a glossary named Metrics.
You'll need the qualifiedName of the glossary term
To find the assets linked to the glossary term, you'll need to search using the qualifiedName of the term. This is not the human-readable name you see in the UI. So this example is split into two parts:
Finding the qualifiedName of the glossary term from its human-readable name and the result of (1).
The GlossaryTerm.findByName() helper method will retrieve the glossary term by its human-readable name, given the name of the glossary in which it should exist. If the term does not exist (within that glossary), it will throw a NotFoundException.
If no exception was thrown, you can retrieve the qualifiedName of the glossary term.
Start with a client to run the search through. For the default client, you can always use Atlan.getDefaultClient().
To search across all assets, you can use the assets.select() convenience method on a client.
When searching for assets linked to one or more terms, you need to use the qualifiedName of the term(s). (This example shows searching for just one term, but you could search for any number of them in the list. The search will find assets that are assigned at least one of those terms in the list.)
The search will only run when you call the stream() method, which will then lazily-load each page of results into a stream.
This is the pattern for iterating through all results (across pages) covered in the Searching for assets portion of the SDK documentation.
Start with a client to run the search through. For the default client, you can always use AtlanClient().
The asset.find_term_by_name() helper method will retrieve the glossary term by its human-readable name, given the name of the glossary in which it should exist. If the term does not exist (within that glossary), it will throw a NotFoundError.
If no exception was thrown, you can retrieve the qualified_name of the glossary term.
The GlossaryTerm.findByName() helper method will retrieve the glossary term by its human-readable name, given the name of the glossary in which it should exist. If the term does not exist (within that glossary), it will throw a NotFoundException.
If no exception was thrown, you can retrieve the qualifiedName of the glossary term.
Start with a client to run the search through. For the default client, you can always use Atlan.getDefaultClient().
To search across all assets, you can use the assets.select() convenience method on a client.
When searching for assets linked to one or more terms, you need to use the qualifiedName of the term(s). (This example shows searching for just one term, but you could search for any number of them in the list. The search will find assets that are assigned at least one of those terms in the list.)
The search will only run when you call the stream() method, which will then lazily-load each page of results into a stream.
This is the pattern for iterating through all results (across pages) covered in the Searching for assets portion of the SDK documentation.
Requires multiple API operations
Before you can search for assets linked to a term, you first need to have the qualifiedName of the term. You will likely need to first find the term by its name.