compass icon indicating copy to clipboard operation
compass copied to clipboard

add update feature in v1beta1/assets

Open anjali9791 opened this issue 3 years ago • 6 comments

Is your feature request related to a problem? Please describe. Currently we have upsert functionality in assets api wherein it searches for an asset based on urn, type and service. In case it is not found, it inserts a new row. I think we can add one more function which only updates and returns error if matching asset is not found. We have use cases where we are creating an asset from a different service and wish to update it with certain fields from a different service. Currently while updating it is also adding assets which were not present earlier which is creating a problem.

Describe the solution you'd like We can either add a new function for update or add a flag in the upsert function which checks whether to insert in case the asset is not found.

anjali9791 avatar Jan 24 '23 06:01 anjali9791

Would suggest performing a lookup for the asset using the URN first. Make the update call only if the asset is found.

sudo-suhas avatar Jan 27 '23 05:01 sudo-suhas

If I understand correctly, in case of upsert we do 1 lookup already before updating, if I add another look up outside, we would be performing 2 lookups for 1 update.

anjali9791 avatar Jan 27 '23 05:01 anjali9791

Lets say we add a POST endpoint that only creates a new entry if it isn't already present. In that case, also you would need 2 API calls in case the asset exists. Changing the behaviour of PUT endpoint based on a flag would not be preferred.

sudo-suhas avatar Jan 27 '23 05:01 sudo-suhas

Currently we already have an API which only creates a new entry if it isn't already present. - Upsert How about we add a new PUT API for update which will only update and not create a new entry. Now, the user should be clear if they want the create behaviour or not and call update or upsert accordingly. This way there would be only 1 lookup.

anjali9791 avatar Jan 27 '23 05:01 anjali9791

Yes, but what you are describing is a POST endpoint - Create a resource if it doesn't already exist. Doing the suggested change will muddle up rest conventions. With the suggested approach of GET followed by PUT, one additional lookup should not be a concern.

sudo-suhas avatar Jan 27 '23 06:01 sudo-suhas

Closing as already implemented. Both UpsertAssetRequest and UpsertPatchAssetRequest support an update_only flag that returns empty instead of inserting when the asset is not found.

ravisuhag avatar Mar 28 '26 16:03 ravisuhag