Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add update feature in v1beta1/assets #200

Open
anjali9791 opened this issue Jan 24, 2023 · 5 comments
Open

add update feature in v1beta1/assets #200

anjali9791 opened this issue Jan 24, 2023 · 5 comments

Comments

@anjali9791
Copy link
Collaborator

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.

@sudo-suhas
Copy link
Contributor

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

@anjali9791
Copy link
Collaborator Author

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.

@sudo-suhas
Copy link
Contributor

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.

@anjali9791
Copy link
Collaborator Author

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.

@sudo-suhas
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants