class iris_messenger(object): supports = frozenset([EMAIL_SUPPORT, SMS_SUPPORT, CALL_SUPPORT, SLACK_SUPPORT]) def __init__(self, config): self.iris_client = IrisClient(config['application'], config['iris_api_key'], config['api_host']) def send(self, message): try: self.iris_client.notification(role='user', target=message['user'], priority=message.get('priority'), mode=message.get('mode'), subject=message['subject'], body=message['body']) except ValueError as e: if 'INVALID role:target' not in e.args[0]: raise e except Exception as e: raise e
class iris_messenger(object): supports = frozenset( [EMAIL_SUPPORT, SMS_SUPPORT, CALL_SUPPORT, SLACK_SUPPORT]) def __init__(self, config): self.iris_client = IrisClient(config['application'], config['iris_api_key'], config['api_host']) def send(self, message): self.iris_client.notification(role='user', target=message['user'], priority=message.get('priority'), mode=message.get('mode'), subject=message['subject'], body=message['body'])
def test_encoding_in_hmac(mocker): mocker.patch('irisclient.time').time.return_value = 1000 IrisClient(app='SERVICE_FOO', key='IRIS_API_KEY', api_host='http://iris.foo.bar') client = IrisClient(app=b'SERVICE_FOO', key=b'IRIS_API_KEY', api_host='http://iris.foo.bar') @all_requests def check_auth_header(url, request): header_bytes = bytes(request.headers['Authorization']) assert header_bytes.startswith('hmac SERVICE_FOO:'.encode('utf-8')) return {'status_code': 200} with HTTMock(check_auth_header): client.notification(role='user', target='foo', priority='high', subject='test')
def __init__(self, config): self.iris_client = IrisClient(config['application'], config['iris_api_key'], config['api_host'])
def iris_client(): return IrisClient(app='SERVICE_FOO', key='IRIS_API_KEY', api_host='http://iris.foo.bar')
def init(config): global client global settings settings = {key: config[key] for key in config if key != 'api_key'} client = IrisClient(config['app'], config['api_key'], config['api_host'])