Skip to content

Deleting assets

Deleting an asset uses a similar pattern to the retrieval operations. For this you can use static methods provided by the Asset class.

Avoid deleting connections

If you want to delete a connection and all of its assets, consider using the connection delete package instead. In particular, avoid deleting a connection directly (using the methods below) without first deleting the assets contained within it. Once you delete a connection, you will be unable to delete any assets that were within it.

Soft-delete an asset

Soft-deletes (also called an archive) are a reversible operation. The status of the asset is changed to DELETED and it no longer appears in the UI, but the asset is still present in Atlan's back-end.

1.4.0 1.0.0

To soft-delete (archive) an asset, you only need to provide the GUID:

Soft-delete an asset
1
2
3
4
5
6
7
AssetMutationResponse response =
        Asset.delete("b4113341-251b-4adc-81fb-2420501c30e6"); // (1)
Asset deleted = response.getDeletedAssets().get(0); // (2)
Glossary glossary;
if (deleted instanceof Glossary) {
    glossary = (Glossary) deleted; // (3)
}
  1. The delete() method returns the deleted form of the asset.
  2. You can distinguish what was deleted through the getDeletedAssets() method. This lists only the assets deleted by the operation.
  3. The Asset class is a superclass of all assets. So you need to cast to more specific types (like Glossary) after verifying the object that was actually returned.
Soft-delete an asset
1
2
3
4
5
6
7
from pyatlan.client.atlan import AtlanClient
from pyatlan.model.assets import AtlasGlossary

client = AtlanClient()
response = client.asset.delete_by_guid("b4113341-251b-4adc-81fb-2420501c30e6") # (1)
if deleted := response.assets_deleted(asset_type=AtlasGlossary): # (2)
    term = deleted[0] # (3)
  1. The asset.delete_by_guid() method returns the deleted form of the asset.
  2. The assets_deleted(asset_type=AtlasGlossary) method returns a list of the assets of the given type that were deleted.
  3. If an asset of the given type was deleted, then the deleted form of the asset is available.
Soft-delete an asset
1
2
3
4
val response =
    Asset.delete("b4113341-251b-4adc-81fb-2420501c30e6") // (1)
val deleted = response.deletedAssets[0] // (2)
val glossary = if (deleted is Glossary) deleted else null // (3)
  1. The delete() method returns the deleted form of the asset.
  2. You can distinguish what was deleted through the deletedAssets method. This lists only the assets deleted by the operation.
  3. The Asset class is a superclass of all assets. So you need to cast to more specific types (like Glossary) after verifying the object that was actually returned.
DELETE /api/meta/entity/bulk?guid=b4113341-251b-4adc-81fb-2420501c30e6&deleteType=SOFT
1
// (1)
  1. In the case of deleting an asset, all necessary information is included in the URL of the request. There is no payload for the body of the request. To archive an asset, use deleteType of SOFT.

Hard-delete an asset

Hard-deletes (also called a purge) are irreversible operations. The asset is removed from Atlan entirely, so no longer appears in the UI and also no longer exists in Atlan's back-end.

1.4.0 1.0.0

To hard-delete (purge) an asset, you only need to provide the GUID:

Hard-delete (purge) an asset
1
2
3
4
5
6
7
AssetMutationResponse response =
        Asset.purge("b4113341-251b-4adc-81fb-2420501c30e6"); // (1)
Asset deleted = response.getDeletedAssets().get(0); // (2)
Glossary glossary;
if (deleted instanceof Glossary) {
    glossary = (Glossary) deleted; // (3)
}
  1. The purge() method returns the purged form of the asset.
  2. You can distinguish what was purged through the getDeletedAssets() method. This lists only the assets deleted by the operation.
  3. The Asset class is a superclass of all assets. So you need to cast to more specific types (like Glossary) after verifying the object that was actually returned.
Hard-delete (purge) an asset
1
2
3
4
5
6
7
from pyatlan.client.atlan import AtlanClient
from pyatlan.model.assets import AtlasGlossary

client = AtlanClient()
response = client.asset.purge_by_guid("b4113341-251b-4adc-81fb-2420501c30e6") # (1)
if deleted := response.assets_deleted(asset_type=AtlasGlossary): # (2)
    term = deleted[0] # (3)
  1. The asset.purge_by_guid() method returns the deleted form of the asset.
  2. The assets_deleted(asset_type=AtlasGlossary) method returns a list of the assets of the given type that were deleted.
  3. If an asset of the given type was deleted, then the deleted form of the asset is available.
Hard-delete (purge) an asset
1
2
3
4
val response =
    Asset.purge("b4113341-251b-4adc-81fb-2420501c30e6") // (1)
val deleted = response.deletedAssets[0] // (2)
val glossary = if (deleted is Glossary) deleted else null // (3)
  1. The purge() method returns the purged form of the asset.
  2. You can distinguish what was purged through the deletedAssets method. This lists only the assets deleted by the operation.
  3. The Asset class is a superclass of all assets. So you need to cast to more specific types (like Glossary) after verifying the object that was actually returned.
DELETE /api/meta/entity/bulk?guid=b4113341-251b-4adc-81fb-2420501c30e6&deleteType=PURGE
1
// (1)
  1. In the case of deleting an asset, all necessary information is included in the URL of the request. There is no payload for the body of the request. To permanently and irreversibly remove an asset, use deleteType of PURGE.

Bulk-delete assets

1.4.0 1.0.0

You can also delete a number of assets at the same time:

Up to a limit

You cannot send an unlimited number of assets to be deleted in a single request. As you can see from the Raw REST API tab, each GUID will be sent as a query parameter in the URI — so there is a maximum beyond which the URI is too long.

We generally recommend sending no more than 20-50 GUIDs at a time using this approach.

Hard-delete (purge) multiple assets
1
2
3
4
5
6
7
AssetMutationResponse response =
        Atlan.getDefaultClient().assets.delete( // (1)
            List.of("b4113341-251b-4adc-81fb-2420501c30e6", // (2)
                    "21e5be62-7a0b-4547-ab7a-6ddf273d0640",
                    "a0fb35e5-690d-4a5b-8918-9ee267c8fa55"),
            AtlanDeleteType.PURGE); // (3)
List<Asset> deleted = response.getDeletedAssets(); // (4)
  1. The delete() method on the endpoint itself can be used to either archive (soft-delete) or purge (hard-delete).
  2. You can provide a list of any number of assets to delete (their GUIDs).
  3. You need to also specify whether you want to soft-delete (archive) using AtlanDeleteType.SOFT or hard-delete (purge) the assets using AtlanDeleteType.PURGE.
  4. The response will contain details of all of the assets that were deleted.
Hard-delete (purge) multiple assets
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
from pyatlan.client.atlan import AtlanClient
from pyatlan.model.assets import AtlasGlossary

client = AtlanClient()
response = client.asset.purge_by_guid([  # (1)
    "b4113341-251b-4adc-81fb-2420501c30e6",
    "21e5be62-7a0b-4547-ab7a-6ddf273d0640",
    "a0fb35e5-690d-4a5b-8918-9ee267c8fa55"
])
if deleted := response.assets_deleted(asset_type=AtlasGlossary):  # (2)
    term = deleted[0]  # (3)
  1. You can alternatively provide either the asset.purge_by_guid() or asset.delete_by_guid() methods with a list of any number of assets to delete (their GUIDs).
  2. The assets_deleted(asset_type=AtlasGlossary) method returns a list of the assets of the given type that were deleted.
  3. If an asset of the given type was deleted, then the deleted form of the asset is available.
Hard-delete (purge) multiple assets
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
val response =
    Atlan.getDefaultClient().assets.delete( // (1)
        listOf(
            "b4113341-251b-4adc-81fb-2420501c30e6",  // (2)
            "21e5be62-7a0b-4547-ab7a-6ddf273d0640",
            "a0fb35e5-690d-4a5b-8918-9ee267c8fa55"
        ),
        AtlanDeleteType.PURGE // (3)
    )
val deleted = response.deletedAssets // (4)
  1. The delete() method on the endpoint itself can be used to either archive (soft-delete) or purge (hard-delete).
  2. You can provide a list of any number of assets to delete (their GUIDs).
  3. You need to also specify whether you want to soft-delete (archive) using AtlanDeleteType.SOFT or hard-delete (purge) the assets using AtlanDeleteType.PURGE.
  4. The response will contain details of all of the assets that were deleted.
DELETE /api/meta/entity/bulk?guid=b4113341-251b-4adc-81fb-2420501c30e6&guid=21e5be62-7a0b-4547-ab7a-6ddf273d0640&guid=a0fb35e5-690d-4a5b-8918-9ee267c8fa55&deleteType=SOFT
1
// (1)
  1. In the case of deleting multiple assets, all necessary information is included in the URL of the request. Each separate asset's GUID should be given after a guid= query parameter. There is no payload for the body of the request.

Bulk deletion occurs asynchronously

Be aware that bulk deleting assets occurs asynchronously. The response above will come back indicating the deleted assets; however, there can still be a delay before those assets are fully deleted in Atlan.