Add an API call to subscribe to a list of streams.
(imported from commit 0a5d46d5f54fb4c8ebfad8c9adb777c0b4938dfa)
This commit is contained in:
parent
717186a149
commit
60464f7976
|
@ -56,6 +56,11 @@ class HumbugAPI():
|
|||
def get_subscriptions(self, request = {}):
|
||||
return self.do_api_query(request, "/api/v1/get_subscriptions")
|
||||
|
||||
def subscribe(self, streams):
|
||||
request = {}
|
||||
request["streams"] = simplejson.dumps(streams)
|
||||
return self.do_api_query(request, "/api/v1/subscribe")
|
||||
|
||||
def call_on_each_message(self, callback, options = {}):
|
||||
max_message_id = None
|
||||
while True:
|
||||
|
|
41
examples/subscribe
Normal file
41
examples/subscribe
Normal file
|
@ -0,0 +1,41 @@
|
|||
#!/usr/bin/python
|
||||
import sys
|
||||
import os
|
||||
import optparse
|
||||
|
||||
usage = """subscribe --user=<email address> [options] --streams=<streams>
|
||||
|
||||
Ensures the user is subscribed to the listed streams.
|
||||
|
||||
Example: subscribe --user=tabbott@humbughq.com --site=http://127.0.0.1:8000
|
||||
"""
|
||||
parser = optparse.OptionParser(usage=usage)
|
||||
parser.add_option('--site',
|
||||
dest='site',
|
||||
default="https://app.humbughq.com/",
|
||||
action='store')
|
||||
parser.add_option('--api-key',
|
||||
dest='api_key',
|
||||
default="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||
action='store')
|
||||
parser.add_option('--streams',
|
||||
dest='streams',
|
||||
default="",
|
||||
action='store')
|
||||
parser.add_option('--user',
|
||||
dest='user',
|
||||
action='store')
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
|
||||
import api.common
|
||||
client = api.common.HumbugAPI(email=options.user,
|
||||
api_key=options.api_key,
|
||||
verbose=True,
|
||||
site=options.site)
|
||||
|
||||
if options.streams == "":
|
||||
print >>sys.stderr, "Usage:", parser.usage
|
||||
sys.exit(1)
|
||||
|
||||
print client.subscribe(options.streams.split())
|
Loading…
Reference in a new issue