SpectoLabs / hoverfly

Lightweight service virtualization/ API simulation / API mocking tool for developers and testers
https://hoverfly.io
Apache License 2.0
2.36k stars 208 forks source link

API/method to overwrite specific request without using PUT api as it completely overwrites the entire data #992

Open atif-github-venture opened 3 years ago

atif-github-venture commented 3 years ago

This appends the supplied simulation JSON to the existing simulation data in Hoverfly. Any pair that has request data identical to the existing ones will not be added.

As per the documentation POST adds the supplied JSON, but lets say I have need to overwrite the existing content just for single request match NOT the whole simulations set, and API suitable for just this will be helpful.

We are looking for alternative to our existing mock solution. So in hoverfly we are looking for a way to not bring down a service and also NOT overwrite the whole set, but for something which can support multiple team members to use the same service in their own way. And many a times we end up changing the stubbed data, so we can not afford to overwrite and disrupt others.

If you have more questions, please let me know.

kapishmalik commented 1 year ago

Hoverfly hardly takes any time to update the entire simulation data as it is in memory and takes exclusive locks before modifying the simulation data. It won't disrupt the other services but at times call will be slower.

You are probably asking for a PATCH call but there is no mechanism to identify that request/response pair.

kapishmalik commented 8 months ago

@tommysitu do you want to do this?

tommysitu commented 8 months ago

@tommysitu do you want to do this?

We need a way to identify the request-response pair first. Have you got any idea?

kapishmalik commented 8 months ago

@tommysitu we can add auto generated id to each request response pair and identify using the same. What do you say?

aahmedvictoria commented 6 months ago

Hey guys, any update on this?

kapishmalik commented 1 month ago

@tommysitu what do you say about this?

we can add auto generated id to each request response pair and identify using the same. What do you say?

tommysitu commented 1 month ago

you can compute a hash code for the request struct and use the code for checking equality.

kapishmalik commented 1 month ago

sure @tommysitu I can proceed in that way.

kapishmalik commented 1 month ago

@atif-github-venture I will start working on this and get back with more updates.

tommysitu commented 1 month ago

@kapishmalik what's your plan? Are you creating a new admin API or updating the POST simulation API?

kapishmalik commented 1 month ago

@tommysitu I am planning to create new PATCH admin API endpoint to update a particular request. Shall I go ahead with that?

tommysitu commented 1 month ago

Cool, let's do a PATCH API that can merge the new data with the old data, so:

We probably want to deprecated the POST API in the future, I don't know if that's useful or not, it has quite a lot of overlap with this new proposed PATCH API.

Thanks @kapishmalik

kapishmalik commented 1 month ago

Yup, that's an idea. I will get back in few days with PR.