Manage asset relationships with attributes¶
Atlan supports relationships between assets that can include attributes, similar to how assets themselves have attributes. These relationship-level attributes provide additional context and metadata about the connection between assets.
The SDK enables you to create, retrieve, and delete these attributed relationships programmatically.
Relationships with attribute support¶
The following relationship types support attributes that you can set via the SDK:
Available attributed relationships
AtlasGlossaryAntonym
AtlasGlossarySynonym
AtlasGlossaryReplacementTerm
AtlasGlossarySemanticAssignment
AtlasGlossaryPreferredTerm
AtlasGlossaryRelatedTerm
AtlasGlossaryTermCategorization
AtlasGlossaryTranslation
AtlasGlossaryValidValue
AtlasGlossaryIsARelationship
CustomParentEntityCustomChildEntities
CustomRelatedFromEntitiesCustomRelatedToEntities
UserDefRelationship
Add user-defined relationship¶
This example demonstrates how to add UserDefRelationship
between glossary terms. While this relationship type is currently visible in the Atlan UI for glossary terms, you can create any other supported relationship types that have attributes (as listed above) between any asset types using similar steps shown in the snippet below. All these relationships will be persisted in the backend (metastore) even if they're not currently visible in the Atlan UI.
Add user-defined relationship between terms | |
---|---|
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 |
|
- Create an updater for the source term using
.updater()
with thequalified_name
,name
, andglossary_guid
of the term you want to add the relationship to. - Create a reference to the target term using
ref_by_guid()
orref_by_qualified_name()
. - Define the relationship by creating a
UserDefRelationship
object with attributes likefrom_type_label
andto_type_label
. - Build the relationship using the
user_def_relationship_to()
method and assign it to theuser_def_relationship_to
attribute. - Save the changes using
client.asset.save()
to persist the relationship in Atlan.
Coming soon
POST /api/meta/entity/bulk | |
---|---|
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 |
|
- Provide source asset details: Include the required attributes
name
,qualifiedName
, and glossaryguid
for the term you want to add the relationship to. - Reference the target asset: Create a reference to the target term using its
guid
. - Define relationship attributes: Provide the necessary attributes for the
UserDefRelationship
, includingtoTypeLabel
andfromTypeLabel
.
Relationship visibility
User-defined relationships between glossary terms are visible in the Atlan UI. For other asset types, relationships are stored in the backend but may not be visible in the UI until support is added.
Remove user-defined relationship¶
This example demonstrates how to remove UserDefRelationship
between glossary terms. You can use the same approach to remove any attributed relationship type (as listed above) between any asset types using the steps shown in the snippet below.
Remove user-defined relationship between terms | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
|
- Create an updater for the source term using
.updater()
with thequalified_name
,name
, andglossary_guid
of the term you want to remove relationships from. - Clear relationships by assigning an empty list
[]
touser_def_relationship_to
to remove all existing outgoing relationships. - Save the changes using
client.asset.save()
to persist the removal in Atlan.
Coming soon
POST /api/meta/entity/bulk | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
|
- Provide source asset details: Include the required attributes
name
,qualifiedName
, and glossaryguid
for the term you want to add the relationship to. - Clear relationships by assigning an empty array
[]
touserDefRelationshipTo
to remove all existing outgoing relationships.
Complete removal
Setting user_def_relationship_to = []
removes all outgoing user-defined relationships from the asset. To remove only specific relationships while keeping others, you would need to retrieve the existing relationships first and reconstruct the list without the unwanted ones.
Retrieve user-defined relationship¶
This example demonstrates how to retrieve UserDefRelationship
between glossary terms. You can use the same approach to retrieve any attributed relationship type (as listed above) between any asset types. While UserDefRelationship
is visible in the UI for glossary terms, all relationships are persisted in the backend regardless of UI visibility.
Retrieve user-defined relationships between terms | |
---|---|
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 |
|
- Search for source term: Provide the GUID of the source term (relationship origin -
USER_DEF_RELATIONSHIP_TO
). - Search for target term: Provide the GUID of the target term (relationship destination -
USER_DEF_RELATIONSHIP_FROM
). - Include outgoing relationships: Ensure results include the
USER_DEF_RELATIONSHIP_TO
attribute. - Include incoming relationships: Ensure results include the
USER_DEF_RELATIONSHIP_FROM
attribute. - Include relationship attributes: Set to
True
to retrieve attributes for each relationship. - Execute search: Run the search request using
client.asset.search()
. - Verify results: Since we're retrieving two specific terms with relationships,
results.count
should be2
. - Access results: Iterate through results or use
current_page()[index]
to access specific terms.
Coming soon
POST /api/meta/search/indexsearch | |
---|---|
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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
|
- Include outgoing relationships: Ensure results include the
USER_DEF_RELATIONSHIP_TO
attribute. - Include incoming relationships: Ensure results include the
USER_DEF_RELATIONSHIP_FROM
attribute. - Search for source term: Provide the GUID of the source term (relationship origin -
USER_DEF_RELATIONSHIP_TO
). - Search for target term: Provide the GUID of the target term (relationship destination -
USER_DEF_RELATIONSHIP_FROM
). - Include relationship attributes: Set to
true
to retrieve attributes for each relationship.
Relationship direction
USER_DEF_RELATIONSHIP_TO
: Outgoing relationships from this assetUSER_DEF_RELATIONSHIP_FROM
: Incoming relationships to this asset
Accessing attributes
Relationship attributes are nested under relationship.attributes.relationship_attributes.attributes
. Make sure to include include_relationship_attributes(True)
in your search to retrieve these values.