def read(self, start, end, interval="", function="", ids=[], keys=[], tags=[], attributes={}, tz=""): params = {'start': start.isoformat(), 'end': end.isoformat()} if ids: params['id'] = ids if keys: params['key'] = keys if interval: params['interval'] = interval if function: params['function'] = function if tags: params['tag'] = tags if attributes: params['attr'] = attributes if tz: params['tz'] = tz url = '/data/' json = self.request(url, method='GET', params=params) return [DataSet.from_json(j) for j in json]
def _read(self, series_type, series_val, start, end, interval="", function="", tz=""): params = { 'start': start.isoformat(), 'end': end.isoformat(), } # add rollup interval and function if supplied if interval: params['interval'] = interval if function: params['function'] = function if tz: params['tz'] = tz url = '/series/%s/%s/data/' % (series_type, urllib2.quote(series_val, "")) json = self.request(url, method='GET', params=params) #we got an error if 'error' in json: return json return DataSet.from_json(json)
def test_from_json(self): json = { 'series': { 'id': 'id', 'key': 'key', 'name': 'name', 'tags': ['tag1', 'tag2'], 'attributes': {'key1': 'value1'}, }, 'start': '2012-03-27T00:00:00.000Z', 'end': '2012-03-28T00:00:00.000Z', 'data': [], 'summary': {'min': 45.5} } dataset = DataSet.from_json(json) series = Series('id', 'key', 'name', {'key1': 'value1'}, ['tag1', 'tag2']) start = datetime.datetime(2012, 3, 27) end = datetime.datetime(2012, 3, 28) data = [] summary = Summary(min=45.5) expected = DataSet(series, start, end, data, summary) self.assertEqual(dataset, expected)
def read(self, start, end, interval="", function="", ids=[], keys=[], tags=[], attributes={}, tz=""): params = { 'start': start.isoformat(), 'end': end.isoformat() } if ids: params['id'] = ids if keys: params['key'] = keys if interval: params['interval'] = interval if function: params['function'] = function if tags: params['tag'] = tags if attributes: params['attr'] = attributes if tz: params['tz'] = tz url = '/data/' json = self.request(url, method='GET', params=params) return [DataSet.from_json(j) for j in json]