Operate on multiple assets at the 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 | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
|
- Define our object directly into an element of a
List
, rather than managing a separate object. - Use the
updater()
method to initialize the object with all necessary attributes for updating it. - Directly chain our enrichment methods to add the certificate and message onto the
updater()
method's result. - Call the
build()
method to build the enriched object. - Use the
updater()
method to initialize the object for another asset. - Chain the enrichment and
build()
methods like we did for the previous asset. - 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 a client to send all of the requests in bulk. (In this example we use the default client, but if you want to configure your own client you could also use that here instead.) - 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.
- The response will include all n assets that were updated.
Add certificate to multiple existing assets | |
---|---|
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 |
|
- Use the
updater()
method to initialize the object with all necessary attributes for updating it. - Set the certificate_status.
- Set the certificate_status_message.
- Use the
updater()
method to initialize another object with all necessary attributes for updating it. - Set the certificate_status.
- Set the certificate_status_message.
- 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. Here we pass list of assets — this makes 1 API call to update all n assets at the same time. - The response will include all n assets that were updated.
Add certificate to multiple existing assets | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
|
- Define our object directly into an element of a
List
, rather than managing a separate object. - Use the
updater()
method to initialize the object with all necessary attributes for updating it. - Directly chain our enrichment methods to add the certificate and message onto the
updater()
method's result. - Call the
build()
method to build the enriched object. - Use the
updater()
method to initialize the object for another asset. - Chain the enrichment and
build()
methods like we did for the previous asset. - 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 a client to send all of the requests in bulk. (In this example we use the default client, but if you want to configure your own client you could also use that here instead.) - 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.
- The response will include all n assets that were updated.
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 30 |
|
- All details must still be included in an outer
entities
array. - You need to specify the type for each asset you are updating.
- You need to specify other required attributes for each asset, such as its name and qualifiedName. (And in the case of terms and categories, also the parent glossary they exist within.)
- Add on any other attributes or relationships you want to set on the asset, such as in this example for a deprecation certificate.
- Add another object to the payload to represent another asset that should be updated by the same API call. Once again specify all the required information for that kind of asset, and any of the details for attributes or relationships you want to set.
And you can naturally combine this with multiple operations per asset — to make many changes to many assets, all in a single API call.
Be aware of how much you're updating per request
While this is great for reducing the number of API calls for better performance, do be aware of how many objects you're trying to update per request. There will be a limit beyond which you are trying to send too much information through a single API call and you could see other impacts such as failed requests due to network timeouts.
As a starting point, we would suggest using a maximum of 20 assets per batch.