rest: granularity is also a Timespan

Change the REST API so it handles the granularity as a Timespan type
too.

Change-Id: I4949d345f578fc24efbe045eecda4ade95e435c7