Monday, November 6, 2017

RBTools and Review Board's Web API

In Review Board RBTools Example I developed a simple client using RBTools. Here I explore another approach using the URI templates provided by Review Board's Web API.

The Review Board Web API embeds a lot of functionality. It enables client development, the documentation describes how to ensure forward compatibility and legacy APIs are managed. It's a nice piece of documentation for a rich API.

The entire API can be obtained using the Root Resource List. This resource insulates clients from URI changes. The URI Templates identify how to obtain specific resources.  To obtain a resource published by the API use the URI template for that resource and fill in the variables.

For example, to obtain a diff in a review request use the URI template for a diff [1].

https://reviews.reviewboard.org/api/review-requests/{review_request_id}/diffs/{diff_revision}/

Obtain the URI, review_request_id and diff_revision as follows:

Although crude, this client uses the Web API in a forward compatible manner. It also provides insight on the relationship between the URI templates and the values to populate to access a resource.

A good next step might be to develop a discovery mechanism using the URI templates and the linked resources so that tools can be created using the Web API.

[1] URI Template.

No comments:

Post a Comment