Skip to main content

Operate on multiple assets at same time

You may also want to make changes to many assets at the same time.

Optimize changes to many assets

If you need to create or update many assets it will be more efficient to do this with fewer API calls than one API call per asset. The approach outlined below allows you to bundle together these multiple actions into a single API call.

For example:

Add certificate to multiple existing assets
List<Asset> assets = new ArrayList<>();
assets.add(GlossaryTerm // (1)
.updater("gsNccqJraDZqM6WyGP3ea@FzCMyPR2LxkPFgr8eNGrq", // (2)
"Example Term",
"b4113341-251b-4adc-81fb-2420501c30e6")
.certificateStatus(CertificateStatus.DEPRECATED) // (3)
.certificateStatusMessage("This asset should no longer be used.")
.build()); // (4)
assets.add(GlossaryTerm
.updater("sduw38sCas83Ca8sdf982@FzCMyPR2LxkPFgr8eNGrq", // (5)
"Another Term",
"b267858d-8316-4c41-a56a-6e9b840cef4a")
.certificateStatus(CertificateStatus.DEPRECATED)
.certificateStatusMessage("This asset should no longer be used.")
.build()); // (6)
AssetMutationResponse response = client // (7)
.assets.save(assets, false); // (8)
assert response.getUpdatedAssets().size() == 2 // (9)
  1. Define our object directly into an element of a List, rather than managing a separate object.
  2. Use the updater() method to initialize the object with all necessary attributes for updating it.
  3. Directly chain our enrichment methods to add the certificate and message onto the updater() method's result.
  4. Call the build() method to build the enriched object.
  5. Use the updater() method to initialize the object for another asset.
  6. Chain the enrichment and build() methods like we did for the previous asset.
  7. To optimize our update, we want to limit the number of API calls we make. If we called save() against each of n assets individually, we would have n API calls. To avoid this we use an AtlanClient through which to connect to the tenant.
  8. Here we use the client directly with a list of assets—this makes 1 API call to update all n assets at the same time.
  9. The response will include all n assets that were updated.
Was this page helpful?