Rename class HumbugAPI to Client
(imported from commit 4270f31fc5febcd9c444d0d133a1dad3860618f0)
This commit is contained in:
parent
f9f8a6e603
commit
b9325a09fa
|
@ -36,7 +36,7 @@ humbug_user = 'tabbott/extra@mit.edu'
|
||||||
sys.path.append(".")
|
sys.path.append(".")
|
||||||
sys.path.append(path.join(path.dirname(__file__), '..'))
|
sys.path.append(path.join(path.dirname(__file__), '..'))
|
||||||
import humbug
|
import humbug
|
||||||
humbug_client = humbug.HumbugAPI(
|
humbug_client = humbug.Client(
|
||||||
email=humbug_user,
|
email=humbug_user,
|
||||||
api_key="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
api_key="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||||
verbose=True,
|
verbose=True,
|
||||||
|
|
|
@ -6,12 +6,12 @@ from os import path
|
||||||
|
|
||||||
sys.path.append(path.join(path.dirname(__file__), '..'))
|
sys.path.append(path.join(path.dirname(__file__), '..'))
|
||||||
import humbug
|
import humbug
|
||||||
prod_client = humbug.HumbugAPI(
|
prod_client = humbug.Client(
|
||||||
email="feedback@humbughq.com",
|
email="feedback@humbughq.com",
|
||||||
api_key="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
api_key="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||||
verbose=True,
|
verbose=True,
|
||||||
site="https://humbughq.com")
|
site="https://humbughq.com")
|
||||||
staging_client = humbug.HumbugAPI(
|
staging_client = humbug.Client(
|
||||||
email="feedback@humbughq.com",
|
email="feedback@humbughq.com",
|
||||||
api_key="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
api_key="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||||
verbose=True,
|
verbose=True,
|
||||||
|
|
|
@ -91,7 +91,7 @@ def get_calendar_url():
|
||||||
|
|
||||||
calendar_url = get_calendar_url()
|
calendar_url = get_calendar_url()
|
||||||
|
|
||||||
humbug = humbug.HumbugAPI(
|
humbug = humbug.Client(
|
||||||
email=options.user,
|
email=options.user,
|
||||||
api_key=options.api_key,
|
api_key=options.api_key,
|
||||||
site=options.site,
|
site=options.site,
|
||||||
|
|
|
@ -20,7 +20,7 @@ import sys
|
||||||
|
|
||||||
sys.path.append("/home/humbug/humbug/api")
|
sys.path.append("/home/humbug/humbug/api")
|
||||||
import humbug
|
import humbug
|
||||||
client = humbug.HumbugAPI(
|
client = humbug.Client(
|
||||||
email="humbug+trac@humbughq.com",
|
email="humbug+trac@humbughq.com",
|
||||||
site="https://staging.humbughq.com",
|
site="https://staging.humbughq.com",
|
||||||
api_key="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
|
api_key="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
|
||||||
|
|
|
@ -43,7 +43,7 @@ if output:
|
||||||
# Block-quote any command output.
|
# Block-quote any command output.
|
||||||
msg['content'] += ('\n\n' + '\n'.join('> ' + ln for ln in output.splitlines()))
|
msg['content'] += ('\n\n' + '\n'.join('> ' + ln for ln in output.splitlines()))
|
||||||
|
|
||||||
client = humbug.HumbugAPI(
|
client = humbug.Client(
|
||||||
email = 'humbug+nagios@humbughq.com',
|
email = 'humbug+nagios@humbughq.com',
|
||||||
api_key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
|
api_key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
|
||||||
site = 'https://staging.humbughq.com')
|
site = 'https://staging.humbughq.com')
|
||||||
|
|
|
@ -797,7 +797,7 @@ or specify the --api-key-file option.""" % (options.api_key_file,)))
|
||||||
os.environ["HUMBUG_API_KEY"] = api_key
|
os.environ["HUMBUG_API_KEY"] = api_key
|
||||||
|
|
||||||
import humbug
|
import humbug
|
||||||
humbug_client = humbug.HumbugAPI(
|
humbug_client = humbug.Client(
|
||||||
email=options.user + "@mit.edu",
|
email=options.user + "@mit.edu",
|
||||||
api_key=api_key,
|
api_key=api_key,
|
||||||
verbose=True,
|
verbose=True,
|
||||||
|
|
|
@ -39,7 +39,7 @@ parser.add_option('--user')
|
||||||
|
|
||||||
sys.path.append(path.join(path.dirname(__file__), '..'))
|
sys.path.append(path.join(path.dirname(__file__), '..'))
|
||||||
import humbug
|
import humbug
|
||||||
client = humbug.HumbugAPI(
|
client = humbug.Client(
|
||||||
email=options.user,
|
email=options.user,
|
||||||
api_key=options.api_key,
|
api_key=options.api_key,
|
||||||
verbose=True,
|
verbose=True,
|
||||||
|
|
|
@ -39,7 +39,7 @@ parser.add_option('--user')
|
||||||
|
|
||||||
sys.path.append(path.join(path.dirname(__file__), '..'))
|
sys.path.append(path.join(path.dirname(__file__), '..'))
|
||||||
import humbug
|
import humbug
|
||||||
client = humbug.HumbugAPI(
|
client = humbug.Client(
|
||||||
email=options.user,
|
email=options.user,
|
||||||
api_key=options.api_key,
|
api_key=options.api_key,
|
||||||
verbose=True,
|
verbose=True,
|
||||||
|
|
|
@ -39,7 +39,7 @@ parser.add_option('--user')
|
||||||
|
|
||||||
sys.path.append(path.join(path.dirname(__file__), '..'))
|
sys.path.append(path.join(path.dirname(__file__), '..'))
|
||||||
import humbug
|
import humbug
|
||||||
client = humbug.HumbugAPI(
|
client = humbug.Client(
|
||||||
email=options.user,
|
email=options.user,
|
||||||
api_key=options.api_key,
|
api_key=options.api_key,
|
||||||
verbose=True,
|
verbose=True,
|
||||||
|
|
|
@ -39,7 +39,7 @@ parser.add_option('--user')
|
||||||
|
|
||||||
sys.path.append(path.join(path.dirname(__file__), '..'))
|
sys.path.append(path.join(path.dirname(__file__), '..'))
|
||||||
import humbug
|
import humbug
|
||||||
client = humbug.HumbugAPI(
|
client = humbug.Client(
|
||||||
email=options.user,
|
email=options.user,
|
||||||
api_key=options.api_key,
|
api_key=options.api_key,
|
||||||
verbose=True,
|
verbose=True,
|
||||||
|
|
|
@ -46,7 +46,7 @@ if len(args) == 0:
|
||||||
|
|
||||||
sys.path.append(path.join(path.dirname(__file__), '..'))
|
sys.path.append(path.join(path.dirname(__file__), '..'))
|
||||||
import humbug
|
import humbug
|
||||||
client = humbug.HumbugAPI(
|
client = humbug.Client(
|
||||||
email=options.sender,
|
email=options.sender,
|
||||||
api_key=options.api_key,
|
api_key=options.api_key,
|
||||||
verbose=True,
|
verbose=True,
|
||||||
|
|
|
@ -40,7 +40,7 @@ parser.add_option('--streams', default='')
|
||||||
|
|
||||||
sys.path.append(path.join(path.dirname(__file__), '..'))
|
sys.path.append(path.join(path.dirname(__file__), '..'))
|
||||||
import humbug
|
import humbug
|
||||||
client = humbug.HumbugAPI(
|
client = humbug.Client(
|
||||||
email=options.user,
|
email=options.user,
|
||||||
api_key=options.api_key,
|
api_key=options.api_key,
|
||||||
verbose=True,
|
verbose=True,
|
||||||
|
|
|
@ -40,7 +40,7 @@ parser.add_option('--streams', default='')
|
||||||
|
|
||||||
sys.path.append(path.join(path.dirname(__file__), '..'))
|
sys.path.append(path.join(path.dirname(__file__), '..'))
|
||||||
import humbug
|
import humbug
|
||||||
client = humbug.HumbugAPI(
|
client = humbug.Client(
|
||||||
email=options.user,
|
email=options.user,
|
||||||
api_key=options.api_key,
|
api_key=options.api_key,
|
||||||
verbose=True,
|
verbose=True,
|
||||||
|
|
16
humbug.py
16
humbug.py
|
@ -34,7 +34,7 @@ import os
|
||||||
assert(requests.__version__ > '0.12')
|
assert(requests.__version__ > '0.12')
|
||||||
API_VERSTRING = "/api/v1/"
|
API_VERSTRING = "/api/v1/"
|
||||||
|
|
||||||
class HumbugAPI(object):
|
class Client(object):
|
||||||
def __init__(self, email, api_key=None, api_key_file=None,
|
def __init__(self, email, api_key=None, api_key_file=None,
|
||||||
verbose=False, retry_on_errors=True,
|
verbose=False, retry_on_errors=True,
|
||||||
site="https://humbughq.com", client="API"):
|
site="https://humbughq.com", client="API"):
|
||||||
|
@ -173,10 +173,10 @@ class HumbugAPI(object):
|
||||||
def _mk_subs(streams):
|
def _mk_subs(streams):
|
||||||
return {'subscriptions': streams}
|
return {'subscriptions': streams}
|
||||||
|
|
||||||
HumbugAPI._register('send_message', make_request=(lambda request: request))
|
Client._register('send_message', make_request=(lambda request: request))
|
||||||
HumbugAPI._register('get_messages', longpolling=True)
|
Client._register('get_messages', longpolling=True)
|
||||||
HumbugAPI._register('get_profile')
|
Client._register('get_profile')
|
||||||
HumbugAPI._register('get_public_streams')
|
Client._register('get_public_streams')
|
||||||
HumbugAPI._register('list_subscriptions', url='subscriptions/list')
|
Client._register('list_subscriptions', url='subscriptions/list')
|
||||||
HumbugAPI._register('add_subscriptions', url='subscriptions/add', make_request=_mk_subs)
|
Client._register('add_subscriptions', url='subscriptions/add', make_request=_mk_subs)
|
||||||
HumbugAPI._register('remove_subscriptions', url='subscriptions/remove', make_request=_mk_subs)
|
Client._register('remove_subscriptions', url='subscriptions/remove', make_request=_mk_subs)
|
||||||
|
|
Loading…
Reference in a new issue