@@ -41,30 +41,40 @@ def process_kpi(self, **args):
4141
4242 return item
4343
44- def _push_json (self , data = {}):
44+ def _push_json (self , data = None , path = "/" ):
45+ if data is not None :
46+ data = json_dumps (data )
47+
4548 response = requests .post (
46- self .push_host ,
49+ self .push_host + path ,
4750 auth = HTTPBasicAuth (self .push_token , '' ),
4851 headers = {'Content-Type' : 'application/json' },
49- data = json_dumps ( data )
52+ data = data
5053 )
5154
52- return response .json ()[ 'status' ] == 'ok'
55+ return response .json ()
5356
5457 def push (self , key , value , date = None ):
5558 return self ._push_json ({
5659 'data' : [self .process_kpi (key = key , value = value , date = date )]
57- })
60+ })[ 'status' ] == 'ok'
5861
5962 def insert_all (self , rows ):
6063 return self ._push_json ({
6164 'data' : [self .process_kpi (** row ) for row in rows ]
62- })
65+ })['status' ] == 'ok'
66+
67+ def last_push (self ):
68+ return self ._push_json (path = '/lastpushes/1' )
6369
6470
6571def push (key , value , date = None , token = None ):
6672 return Client (token ).push (key , value , date )
6773
6874
6975def insert_all (rows = [], token = None ):
70- return Client (token ).insert_all (rows )
76+ return Client (token ).insert_all (rows )
77+
78+
79+ def last_push (token = None ):
80+ return Client (token ).last_push ()
0 commit comments