Add a new RESTful API model for Review Board

Review Request #1571 — Created May 2, 2010 and submitted


Review Board


This introduces a new RESTful API/resource tree for Review Board. It's more formalized and organized than the old one, with support for standard HTTP methods and error codes. Resources are linked together, making the entire tree browsable.

The tree is composed of WebAPIResource classes linked together in parent/child relationships. The resources define the fields they support, the HTTP methods that operate on them, and handlers for the methods. This is far more maintainable than what we had before and should allow us to easily augment the tree down the road. It should also give us a more flexible mechanism later on (with some modifications) for extensions to provide their own resources that can auto-link to other resources in the tree.

The new tree lives in /api/. The old /api/json/ still exists for backwards-compatibility and is unaffected by this change. Clients that wish to support both the old and new APIs should first check to see if /api/ returns an HTTP 200 instead of a 404 (which indicates that the new resource tree exists) and fall back on /api/json/ if it's a 404.

This doesn't move the web UI onto the new resource tree. That is coming in a subsequent change.

You will notice that this change is long. My apologies :) Most of it should be fairly straight-forward, though.

This is not 100% complete but it's about where I want it for now. Future changes will fill in a couple small TODOs in the code.

(Note: Ignore the change to diffviewer.js. This is an older version of the fix in /r/1524 that was merged into this tree, and this change will go in after the proper fix for that goes in).
Ran both the standard and Selenium test suites, which both passed. Spent a lot of time browsing around the API and things looked as I expected.
Review request changed
  1. It looks like most of the bulk of this is pulled from the existing API implementations with different classes wrapping it all up. I didn't see anything obviously wrong but it's definitely possible I missed something.
    1. Thanks. I know it was a less than easy review :)
      For beta 2, I'm not going to have the UI updated to use this, so that nothing will break. I want to do a beta 3 with the updated UI.