27
27
from collections import defaultdict
28
28
from collector import SensorCollector , QueryPolicy
29
29
from utils import getTimeMultiplier , execution_time , cond_execution_time
30
- from typing import List
30
+ from typing import List , TypeVar
31
+
32
+ T = TypeVar ('T' , dict , list )
31
33
32
34
33
35
class OpenTsdbApi (object ):
@@ -158,6 +160,9 @@ def build_collector(self, jreq: dict) -> SensorCollector:
158
160
args ['filters' ] = filters
159
161
args ['grouptags' ] = grouptags
160
162
163
+ if 'arrays' in jreq :
164
+ args ['dpsArrays' ] = jreq ['arrays' ]
165
+
161
166
args ['rawData' ] = q .get ('explicitTags' , False )
162
167
163
168
args ['sensor' ] = sensor
@@ -379,7 +384,7 @@ def GET(self, **params):
379
384
@cherrypy .config (** {'tools.json_in.force' : False })
380
385
@cherrypy .tools .json_in () # @UndefinedVariable
381
386
@cherrypy .tools .json_out () # @UndefinedVariable
382
- def POST (self ):
387
+ def POST (self , ** params ):
383
388
''' Process POST. tools.json_in.force is set to False for
384
389
compatability between versions of grafana < 3 and version 3.'''
385
390
@@ -399,6 +404,9 @@ def POST(self):
399
404
self .logger .error (MSG ['QueryError' ].format ('empty' ))
400
405
raise cherrypy .HTTPError (400 , ERR [400 ])
401
406
407
+ if params and params .get ('arrays' ) == 'true' :
408
+ jreq ['arrays' ] = True
409
+
402
410
return self .query (jreq )
403
411
404
412
def OPTIONS (self ):
@@ -446,7 +454,7 @@ def __init__(self, inputQuery, showQuery=False,
446
454
self .tags = tags or defaultdict (list )
447
455
self .aggregatedTags = aggrTags or []
448
456
449
- def to_dict (self , dps : dict = None ):
457
+ def to_dict (self , dps : T = None ):
450
458
''' Converts the SingleTimeSeriesResponse object to dict. '''
451
459
res = self .__dict__
452
460
# Since a single Timeseries might have a huge number of datapoints (dps),
0 commit comments