Restful Versioning

In a discussion of restful features the other day, a good question came up: where's the back button? POST and PUT are easy to understand, but how about rolling back or undoing changes? I have a simple solution which is going to look pretty familiar to Subversion users.

Let's beginning by modifying a feature:

PUT /features/1
{ ... }

The curly braces and ellipsis stand in for a JSON object, the details of which aren't important now. From a versioning feature resource, I'd want to get a response like:

200 OK
feature: http://example.org/features/1
revision: http://example.org/features/1/revisions/1

Representations of the feature and its most recent revision are identical. Want to rollback this change? First, let's get the previous revision:

GET /features/1/revisions/0
{ ... // revision 0 }

and then put it back:

PUT /features/1
{ ... // revision 0 }

With the response:

200 OK
feature: http://example.org/features/1
revision: http://example.org/features/1/revisions/2

That's the restful equivalent of:

$ svn merge -r 1:0 http://example.org/features
$ svn commit

OSM, by the way, has node history, but no URIs for node revisions.

Comments

Re: Restful Versioning

Author: Christopher Schmidt

Actually, there's a strong reason that I don't like this: this is less like: svn merge -r 1:0 http://example.org/features and more like: svn merge -r 1:0 http://example.org/features/1 How do I roll back an entire feature storage by a single revision? Is the version for the feature per item, or for the whole repository of features? I think OSM's model here is lacking: what they really want is the ability to do multiple edits in a single transaction, and to roll them back just as easily -- but maybe this doesn't apply in other arenas.

Re: Restful Versioning

Author: Bill Thorp

"I have a simple solution which is going to look pretty familiar to Subversion users" Seeing that WebDav is shall-we-say "RESTful", and Subversion relies on the Delta-V extension to WebDav, perhaps... oh forget it.

Re: Restful Versioning

Author: Sean

I'm a believer in repository-wide revision numbering. Maybe /features/tags/foo/1 is a better URL than /features/1/revisions/42. But you can't roll back changes to many features at once in a single go without using yet another protocol to bundle the changes. Personally, I'm sick and tired of new procotols. What was that, Bill? Put all our features in Subversion (as JSON or GML) with auxiliary spatial and text indexes? Maybe we will :)

Re: Restful Versioning

Author: Bill Thorp

Proxy Subversion with a spatial transformation engine and I'm sold. "layer/1/feature/1/asGML" or "layer/1/features/1/asWKT" Heck, you write the transformation engine and I'll write the proxy for you!