Most of these options are great choices. A lot of everything is just your choice of style at the end. Here are my comments on each of your options.
Disclaimer for cloning a resource object to a consumer
In general, I have no problem with this solution. This parameter is very simple for the user to understand and implement. This might be better than coming up with some proprietary cloning features that your users should learn how to use.
Using WebDAV HTTP Extensions that Provide the COPY Method
I like to stick to standard methods. I would not use COPY , but I would not be shocked if you did.
POSTing to / {resource}? resourceIdToClone = {id}
This is the perfect solution. From a REST perspective, you really have no conflict with the rest of your API. A URI with a request parameter identifies a different resource than a URI without a request parameter. Request parameters is a URI function for identifying resources that cannot be referenced hierarchically. However, it can be difficult to separate them in your code due to the way most REST frameworks work. You can do something similar to this, with the exception of a hierarchical URI, such as /{resource}/clone . You can send a POST to this URI and pass resource_source_id in the body.
Adding a new resource called "CloneableResource" and doing POST to / CloneableResource / {resource_type} / {resource_source_id}
There is nothing wrong with this approach in terms of REST, but I think adding a new type is unnecessary and cluttering the API. However, I do not agree with your intuition that there may be a problem with a resource that only has a POST operation. It happens. In the real world, not everything fits perfectly in GET, PUT or DELETE.
GET vs / resource / {id}? method = clone
This is the only option that I cannot indulge. From your description, it seems that you already understand why this is a bad idea, so I'm not sure why you are considering this. However, all you have to do to make this a good solution is to change the GET to POST. Then it becomes very similar to solution No. 3. A URI can also be hierarchical rather than using a query parameter. POST /resource/{id}/clone will work just as well.
Hope this was helpful. Good luck with your decision.
Jason source share