Updating an asset¶
All objects in the SDK that you can update within Atlan implement the builder pattern. This allows you to progressively build-up the object you want to update. In addition, each object provides a method that takes the minimal set of required fields to update that asset, when it already exists in Atlan.
Include only your intended changes, nothing more
When enriching an asset in Atlan, you only need to specify the information you want to change. Any information you do not include in your update will be left untouched on the asset in Atlan. This way you do not need to:
- try to reproduce the complete asset in your request to do targeted updates to specific attributes
- worry about other changes that may be made to the asset in parallel to the changes you will be making to the asset
Build minimal object needed¶
For example, to update a glossary term we need to provide the qualifiedName
and name of the term, and the GUID of the glossary in which it exists:
Build minimal asset necessary for update | |
---|---|
1 2 3 4 |
|
- The
qualifiedName
of the existing term, which must match exactly (case-sensitive). Note that for some assets (like terms), this may be a strange-looking Atlan-internal string. - The name of the existing term. This must match exactly (case-sensitive).
- The GUID of the glossary in which the term exists.
Build minimal asset necessary for update | |
---|---|
1 2 3 4 5 6 7 8 9 10 |
|
- The
qualifiedName
of the existing term, which must match exactly (case-sensitive). Note that for some assets (like terms), this may be a strange-looking Atlan-internal string. - The name of the existing term. This must match exactly (case-sensitive).
- The GUID of the glossary in which the term exists.
Build minimal asset necessary for update | |
---|---|
1 2 3 4 5 6 |
|
- The
qualifiedName
of the existing term, which must match exactly (case-sensitive). Note that for some assets (like terms), this may be a strange-looking Atlan-internal string. - The name of the existing term. This must match exactly (case-sensitive).
- The GUID of the glossary in which the term exists.
Implicit in the API calls below
There is nothing specific to do for this step when using the raw APIs — constructing the object is simply what you place in the payload of the API calls in the steps below.
What if I already have an asset (for example, from a search)?
Since you should only include your intended changes, and nothing more, the SDKs provide a convenience method to reduce an asset down to its minimal properties. You should use this method to trim an object in your code down to a starting point for the changes you want to make to that asset:
Trim existing asset to minimal properties | |
---|---|
4 |
|
- Assuming you have an existing asset in a variable called
existing
, you can calltrimToRequired()
to reduce it to a builder with the minimal properties needed to update that asset.
Trim existing asset to minimal properties | |
---|---|
10 |
|
- Assuming you have an existing asset in a variable called
existing
, you can calltrim_to_required()
to reduce it to an object with the minimal properties needed to update that asset.
Enrich before updating¶
The term
object now has the minimal required information for Atlan to update it. Without any additional enrichment, though, there isn't really anything to update...
So first you should enrich the object:
Enrich the asset before updating it | |
---|---|
5 6 7 8 9 10 |
|
- We'll create an object we can take actions on from this updater.
- In this example, we're adding a certificate to the object.
- Note that you can chain any number of enrichments together. Here we are also adding an announcement to the asset.
-
To persist the enrichment back to the object, we must
build()
the builder.Assign the result back
Remember to assign the result of the
build()
operation back to your original object. Otherwise the result is not persisted back into any variable! (In this case we're assigning to theterm
variable back on line 5.)
Enrich the asset before updating it | |
---|---|
11 12 13 14 15 16 17 |
|
- In this example, we're adding a certificate to the object.
- In this example, we're adding an announcement to the object.
Enrich the asset before updating it | |
---|---|
7 8 9 10 11 12 |
|
- We'll create an object we can take actions on from this updater.
- In this example, we're adding a certificate to the object.
- Note that you can chain any number of enrichments together. Here we are also adding an announcement to the asset.
-
To persist the enrichment back to the object, we must
build()
the builder.Assign the result back
Remember to assign the result of the
build()
operation back to your original object. Otherwise the result is not persisted back into any variable! (In this case we're assigning to theterm
variable back on line 5.)
Implicit in the API calls below
There is nothing specific to do for this step when using the raw APIs — constructing the object is simply what you place in the payload of the API calls in the steps below.
Update the asset from the object¶
You can then actually update the object in Atlan1:
Update (or create) the asset | |
---|---|
11 12 13 14 15 16 |
|
- The
save()
method will either update an existing asset (if Atlan already has a term with the same name andqualifiedName
in the same glossary) or create a new asset (if Atlan does not have a term with the same name in the same glossary). -
You can distinguish what was created or updated:
getCreatedAssets()
lists assets that were createdgetUpdatedAssets()
lists assets that were updated
Note that the
save()
method always returns objects of typeAsset
, though. -
The
Asset
class is a superclass of all assets. So we need to cast to more specific types (likeGlossaryTerm
) after verifying the object that was actually returned.
Strictly update the asset | |
---|---|
11 12 13 14 15 16 17 18 19 20 |
|
-
The
updateMergingCM()
method will only update an existing asset (if Atlan already has an asset of the same type with the same namequalifiedName
). Depending on the update behavior you want, you could also use:updateMergingCM(false)
to only overwrite any custom metadata provided in your update (leaving anything you don't provide untouched on the existing asset), while leaving any Atlan tags on the existing asset untouchedupdateMergingCM(true)
to only overwrite any custom metadata provided in your update (leaving anything you don't provide untouched on the existing asset), while replacing any Atlan tags on the existing assetupdateReplacingCM(false)
to overwrite all custom metadata on the existing asset with what you're providing in your update, while leaving any Atlan tags on the existing asset untouchedupdateReplacingCM(true)
to overwrite all custom metadata on the existing asset with what you're providing in your update, while replacing any Atlan tags on the existing asset
-
You can distinguish what was created or updated:
getUpdatedAssets()
lists assets that were updated
Note that the
update...()
methods always returns objects of typeAsset
, though. -
The
Asset
class is a superclass of all assets. So we need to cast to more specific types (likeGlossaryTerm
) after verifying the object that was actually returned. -
Since the
update...()
methods strictly update (and never create) an asset, if the asset you are trying to update does not exist the operation will throw aNotFoundException
.
Update (or create) the asset | |
---|---|
18 19 20 |
|
- The
save(term)
method will either update an existing asset (if Atlan already has a term with the same name andqualifiedName
in the same glossary) or (create a new asset, if Atlan does not have a term with the same name in the same glossary). -
You can distinguish what was created or updated:
assets_created(asset_type = AtlasGlossaryType)
returns a list assets of the specified type that were created.assets_updated(asset_type = AtlasGlossaryType)
returns a list assets of the specified type that were updated.
-
If the returned list is not empty, get the term that was updated.
Strictly update the asset | |
---|---|
18 19 20 21 22 23 |
|
-
The
update_merging_cm()
method will only update an existing asset (if Atlan already has an asset of the same type with the same namequalified_name
). Depending on the update behavior you want, you could also use:update_merging_cm(replace_atlan_tags=False)
to only overwrite any custom metadata provided in your update (leaving anything you don't provide untouched on the existing asset), while leaving any Atlan tags on the existing asset untouchedupdate_merging_cm(replace_atlan_tags=True)
to only overwrite any custom metadata provided in your update (leaving anything you don't provide untouched on the existing asset), while replacing any Atlan tags on the existing assetupdate_replacing_cm(replace_atlan_tags=False)
to overwrite all custom metadata on the existing asset with what you're providing in your update, while leaving any Atlan tags on the existing asset untouchedupdate_replacing_cm(replace_atlan_tags=True)
to overwrite all custom metadata on the existing asset with what you're providing in your update, while replacing any Atlan tags on the existing asset
-
You can distinguish what was created or updated:
assets_updated(asset_type = AtlasGlossaryType)
returns a list assets of the specified type that were updated.
-
Since the
update...()
methods strictly update (and never create) an asset, if the asset you are trying to update does not exist the operation will throw aNotFoundError
.
Update (or create) the asset | |
---|---|
13 14 15 |
|
- The
save()
method will either update an existing asset (if Atlan already has a term with the same name andqualifiedName
in the same glossary) or create a new asset (if Atlan does not have a term with the same name in the same glossary). -
You can distinguish what was created or updated:
createdAssets
lists assets that were createdupdatedAssets
lists assets that were updated
Note that the
save()
method always returns objects of typeAsset
, though. -
The
Asset
class is a superclass of all assets. So we need to cast to more specific types (likeGlossaryTerm
) after verifying the object that was actually returned.
Strictly update the asset | |
---|---|
13 14 15 16 17 18 19 |
|
-
The
updateMergingCM()
method will only update an existing asset (if Atlan already has an asset of the same type with the same namequalifiedName
). Depending on the update behavior you want, you could also use:updateMergingCM(false)
to only overwrite any custom metadata provided in your update (leaving anything you don't provide untouched on the existing asset), while leaving any Atlan tags on the existing asset untouchedupdateMergingCM(true)
to only overwrite any custom metadata provided in your update (leaving anything you don't provide untouched on the existing asset), while replacing any Atlan tags on the existing assetupdateReplacingCM(false)
to overwrite all custom metadata on the existing asset with what you're providing in your update, while leaving any Atlan tags on the existing asset untouchedupdateReplacingCM(true)
to overwrite all custom metadata on the existing asset with what you're providing in your update, while replacing any Atlan tags on the existing asset
-
You can distinguish what was created or updated:
getUpdatedAssets()
lists assets that were updated
Note that the
update...()
methods always returns objects of typeAsset
, though. -
The
Asset
class is a superclass of all assets. So we need to cast to more specific types (likeGlossaryTerm
) after verifying the object that was actually returned. -
Since the
update...()
methods strictly update (and never create) an asset, if the asset you are trying to update does not exist the operation will throw aNotFoundException
.
POST /api/meta/entity/bulk | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|
- All assets must be wrapped in an
entities
array. - You must provide the exact type name for the asset (case-sensitive). For a term, this is
AtlasGlossaryTerm
. - You must provide the exact name of the existing asset (case-sensitive). (Unless you want to change its name, in which case you can provide the new name instead.)
-
You must provide the exact
qualifiedName
of the existing asset (case-sensitive).Must exactly match the
qualifiedName
of an existing assetIf this does not exactly match the
qualifiedName
of an existing asset, the API call will instead create a new asset rather than updating an existing one. -
For most assets, you do not need to re-specify the parent object for an update. However, for glossary assets (like terms), you are required to re-specify the parent glossary.
- In this example, we're adding a certificate to the object.
- Note that you can include any number of enrichments together. Here we are also adding an announcement to the asset.
Case-sensitive, exact match
If you use a different capitalization or spelling for the qualifiedName
, you may accidentally create a new asset rather than updating the existing one.2
Remove information from an asset¶
As mentioned in Enrich before updating section, only the information in your request will be updated on the object. But what if you want to remove some information that already exists on the asset in Atlan?
Enrich and update the asset | |
---|---|
5 6 7 8 9 10 11 12 13 14 |
|
- We'll create an object we can take actions on from this updater.
- In this example, we'll remove any existing certificate from the object in Atlan.
- Note that you can chain any number of enrichments together. Here we are also removing any announcement from the asset.
-
To persist the enrichment back to the object, we must
build()
the builder.Assign the result back
Remember to assign the result of the
build()
operation back to your original object. Otherwise the result is not persisted back into any variable! (In this case we're assigning to theterm
variable back on line 5.) -
The
save()
method will either:- Update an existing asset, if Atlan already has a term with the same name and
qualifiedName
in the same glossary. - Create a new asset, if Atlan does not have a term with the same name in the same glossary.
- Update an existing asset, if Atlan already has a term with the same name and
-
You can distinguish what was created or updated:
getCreatedAssets()
lists assets that were createdgetUpdatedAssets()
lists assets that were updated
Note that the
save()
method always returns objects of typeAsset
, though. -
The
Asset
class is a superclass of all assets. So we need to cast to more specific types (likeGlossaryTerm
) after verifying the object that was actually returned.
Enrich and update the asset | |
---|---|
11 12 13 14 15 |
|
- In this example we will remove an existing certificate from any existing certificate from the object.
- In this example we will remove any existing announcement from the object.
Enrich and update the asset | |
---|---|
7 8 9 10 11 12 13 |
|
- We'll create an object we can take actions on from this updater.
- In this example, we'll remove any existing certificate from the object in Atlan.
- Note that you can chain any number of enrichments together. Here we are also removing any announcement from the asset.
-
To persist the enrichment back to the object, we must
build()
the builder.Assign the result back
Remember to assign the result of the
build()
operation back to your original object. Otherwise the result is not persisted back into any variable! (In this case we're assigning to theterm
variable back on line 5.) -
The
save()
method will either:- Update an existing asset, if Atlan already has a term with the same name and
qualifiedName
in the same glossary. - Create a new asset, if Atlan does not have a term with the same name in the same glossary.
- Update an existing asset, if Atlan already has a term with the same name and
-
You can distinguish what was created or updated:
createdAssets
lists assets that were createdupdatedAssets
lists assets that were updated
Note that the
save()
method always returns objects of typeAsset
, though. -
The
Asset
class is a superclass of all assets. So we need to cast to more specific types (likeGlossaryTerm
) after verifying the object that was actually returned.
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 |
|
- All assets must be wrapped in an
entities
array. - You must provide the exact type name for the asset (case-sensitive). For a term, this is
AtlasGlossaryTerm
. - You must provide the exact name of the existing asset (case-sensitive). (Unless you want to change its name, in which case you can provide the new name instead.)
-
You must provide the exact
qualifiedName
of the existing asset (case-sensitive).Must exactly match the
qualifiedName
of an existing assetIf this does not exactly match the
qualifiedName
of an existing asset, the API call will instead create a new asset rather than updating an existing one. -
For most assets, you do not need to re-specify the parent object for an update. However, for glossary assets (like terms), you are required to re-specify the parent glossary.
- In this example, we're removing any existing certificate information from the object in Atlan (by sending
null
). - Note that you can include any number of enrichments together. Here we are also removing any announcement from the asset.
-
Atlan automatically detects changes to determine whether to create or update an asset — see the Importance of identifiers for a more detailed explanation. To strictly update (and avoid creating) an asset, you must first look for the existing asset and only if found proceed with your update. When the SDKs provide such strict update functionality, this is what they are doing behind-the-scenes. Be aware that this will impact performance, so you should only do this where strictly necessary for your logic. ↩
-
This is because Atlan uses the exact
qualifiedName
to determine whether it should do an update. For a more detailed explanation, see the Importance of identifiers. ↩