I want to add actions to my REST API that would move 'resources' between different 'stores'.
For instance, suppose my resources are normally accessed by the following URL:
/resources
/resources/{resourceId}
Now suppose I want to 'deactivate' some resource, i.e. conceptually move it to another sub-folder. The most straightforward way to allow this would be as followed.
'Deactivate' the resource, i.e. cause it to be unavailable under /resources. Conceptually, it 'moves' the object to the '/resources/deactivated/' subfolder:
POST /resources/{resourceId}/deactivate
Or alternatively:
POST /resources/deactivated/{resourceId}
Get all the deactivated objects:
GET /resources/deactivated
Reverse the 'deactivate' action, i.e. conceptually move the object from the '/resources/deactivated/' subfolder back to the main one ('/resources').
Either
POST /resources/{resourceId}/reactivate
Or
POST /resources/deactivated/{resourceId}/restore
This API seems rather intuitive for me. But it seems to violate the 'prefer nouns' rules that I have seen in many best practices-articles on REST API: I use verbs and adjectives instead of nouns!
Note that I might have parameters for all the endpoints, e.g. GET /resources/deactivated?createdBefore=01022017
Are there any better alternatives for my REST API? I.e. more RESTful, but not less intuitive ones?
Good resources that I could find on the topic:
- Confusion Between Noun vs. Verb in Rest URLs
- GitHub's usage of verbs (POST /gists/:id/star, DELETE /gists/:id/star): https://stackoverflow.com/a/19648997/1847482
- Good point on needing to look for 'another object type': https://stackoverflow.com/a/2022938/1847482