Skip to end of metadata
Go to start of metadata

This tutorial teaches you how to interact with FishEye/Crucible's REST interface from a Python program.

We'll write a Python script which lists the users who are uncompleted reviewers of at least one open review.

This tutorial assumes that you have Python 2.6.3 installed. Note that the default version on Mac OS X 10.6 is 2.5.

Create a new directory to write your client in and cd into it.

First you'll need to install the python-rest-client package. Download the 0.2 distribution and unpack it in your current directory.

Set your PYTHONPATH environment variable to include the python-rest-client:

To get all open reviews we use the URL /reviews-v1/filter/{filter}, setting {filter} to allOpenReviews, and to get the incomplete reviewers for each of these reviews we use the URL /reviews-v1/{id}/reviewers/uncompleted

Icon

When JSON produces lists of objects, the structures produced depend on the number of items in the list.
If the /reviews-v1/filter URL returns a single review, the JSON will look like this:

but if several reviews are returned the JSON will be:

and if there are no reviews it will simply be:

The toList function in the code below normalises each of the responses shown above to a list:

  • No labels