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