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

DELETE /v1/rules should return what it deleted #357

Open
frankbu opened this issue Oct 26, 2016 · 5 comments
Open

DELETE /v1/rules should return what it deleted #357

frankbu opened this issue Oct 26, 2016 · 5 comments

Comments

@frankbu
Copy link
Member

frankbu commented Oct 26, 2016

For the /v1/rules?query (GET and DELETE) rules APIs, the handling of query parameters is inconsistent.
If there are multiple id=, multiple tag=, or multiple destination= query parameters, the current API uses OR semantics (e.g., GET /v1/rules?id=123&id=456 returns two rules).
However when there is a mix of these parameters (e.g., GET /v1/rules?id=123&tag=mytag&destination=reviews) the semantics is AND, so the API currently returns only the rules that match all the specified criteria.
This should be changed to also use OR semantics. That is, the semantics should be to include all of the rules identified the set of query params.

Another semantics problem, with DELETE /v1/rules?query specifically, is that the identified list of rules that are then deleted needs to be returned in the response body (e.g., list of ids, similar to POST).
Right now there is no indication of what rules actually were deleted.

@frankbu
Copy link
Member Author

frankbu commented Oct 27, 2016

Thinking about this some more, the DELETE response body should probably include the resources that were deleted, not just a list of ids, because the id list isn't so useful once the resources no longer exist and can't be read.

@ijsnellf
Copy link
Member

One issue if we switch everything to OR semantics is that we can no longer do a query of all rules of type action with destination X. We would get all rules with type action or destination X, which isn't very useful. Similarly, if you wanted to delete all rules with the tag test for destination Y, you would have to manually filter the rule IDs you wanted to delete.

@frankbu
Copy link
Member Author

frankbu commented Oct 28, 2016

query of all rules of type action with destination X

I didn't know there was a query param for type? It's not in the API doc (https://www.amalgam8.io/api/controller/#!/default/delete_v1_rules).

delete all rules with the tag test for destination Y

Maybe adding tags query param to DELETE /v1/rules/routes/{destination} and DELETE /v1/rules/actions/{destination} would be a better way to handle this case?

@ijsnellf
Copy link
Member

ijsnellf commented Oct 31, 2016

Under the covers there is a filter for rule type that is handled the same as the other filters, like ID, tags and destinations.

@frankbu frankbu changed the title Rules API problems with GET and DELETE /v1/rules DELETE /v1/rules should return what it deleted Nov 23, 2016
@frankbu
Copy link
Member Author

frankbu commented Nov 23, 2016

It sounds like there are pros and cons to either approach (AND or OR), so I guess we leave it as is. The only part of this issue that needs to be resolved is that DELETE returns the resource it deleted. I changed the issue title correspondingly.

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

No branches or pull requests

2 participants