Skip to content

Commit e356fe6

Browse files
author
Rahji Abdurehman
committed
update client to subscription methods
1 parent 88aa6dc commit e356fe6

File tree

1 file changed

+99
-0
lines changed

1 file changed

+99
-0
lines changed

influxdb/client.py

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,3 +760,102 @@ def drop_shard(self, database):
760760
)
761761

762762
return True
763+
764+
def get_subscriptions(self, database):
765+
"""
766+
Get list of subscriptions
767+
"""
768+
url = "db/{0}/subscriptions".format(database)
769+
770+
response = self.request(
771+
url=url,
772+
method='GET',
773+
status_code=200
774+
)
775+
776+
return response.json()
777+
778+
def subscribe_ts(self, database, keyword_list, duration, start, end):
779+
"""
780+
Subscribe to a time series
781+
"""
782+
url = "db/{0}/subscriptions".format(database)
783+
784+
data = {
785+
'kws': keyword_list,
786+
'duration': duration,
787+
'startTm': start,
788+
'endTm': end
789+
}
790+
791+
self.request(
792+
url=url,
793+
method='POST',
794+
data=data,
795+
status_code=200
796+
)
797+
798+
return True
799+
800+
def delete_subscription(self, database, keyword):
801+
"""
802+
Delete a subscription
803+
"""
804+
url = "db/{0}/subscriptions/{1}".format(database, keyword)
805+
806+
self.request(
807+
url=url,
808+
method='DELETE',
809+
status_code=204
810+
)
811+
812+
return True
813+
814+
def query_subscriptions(self, database):
815+
"""
816+
Return the data from querying the subscriptions
817+
"""
818+
url = "db/{0}/query_subscriptions".format(database)
819+
820+
request = self.request(
821+
url=url,
822+
method='POST',
823+
status_code=200
824+
)
825+
826+
return request.json()
827+
828+
def query_current(self, database):
829+
"""
830+
Query the current value
831+
"""
832+
url = "db/{0}/query_current".format(database)
833+
834+
request = self.request(
835+
url=url,
836+
method='POST',
837+
status_code=200
838+
)
839+
840+
return request.json()
841+
842+
def query_follow(self, database, keyword, start, end):
843+
"""
844+
Make a query which follows the values
845+
"""
846+
url = "db/{0}/query_follow".format(database)
847+
848+
data = {
849+
'kw': keyword,
850+
'startTime': start,
851+
'endTime': end
852+
}
853+
854+
request = self.request(
855+
url=url,
856+
method='POST',
857+
data=data,
858+
status_code=200
859+
)
860+
861+
return request.json()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy