Add API queries to show public streams and the user's subscriptions.
(imported from commit 5f24e35a9bdd1e40406e2acb0c3713a6517d139b)
This commit is contained in:
parent
705dc202bf
commit
468a3cbe98
|
@ -50,6 +50,12 @@ class HumbugAPI():
|
|||
def get_messages(self, request = {}):
|
||||
return self.do_api_query(request, "/api/v1/get_messages")
|
||||
|
||||
def get_public_streams(self, request = {}):
|
||||
return self.do_api_query(request, "/api/v1/get_public_streams")
|
||||
|
||||
def get_subscriptions(self, request = {}):
|
||||
return self.do_api_query(request, "/api/v1/get_subscriptions")
|
||||
|
||||
def call_on_each_message(self, callback, options = {}):
|
||||
max_message_id = None
|
||||
while True:
|
||||
|
|
33
examples/get-public-streams
Normal file
33
examples/get-public-streams
Normal file
|
@ -0,0 +1,33 @@
|
|||
#!/usr/bin/python
|
||||
import sys
|
||||
import os
|
||||
import optparse
|
||||
|
||||
usage = """get-public-streams --user=<email address> [options]
|
||||
|
||||
Prints out each message received by the indicated user.
|
||||
|
||||
Example: get-public-streams --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('--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)
|
||||
|
||||
print client.get_public_streams()
|
33
examples/get-subscriptions
Normal file
33
examples/get-subscriptions
Normal file
|
@ -0,0 +1,33 @@
|
|||
#!/usr/bin/python
|
||||
import sys
|
||||
import os
|
||||
import optparse
|
||||
|
||||
usage = """get-subscriptions --user=<email address> [options]
|
||||
|
||||
Prints out each message received by the indicated user.
|
||||
|
||||
Example: get-subscriptions --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('--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)
|
||||
|
||||
print client.get_subscriptions()
|
Loading…
Reference in a new issue