monasca-vagrant/tests/notification.py
Craig Bryant 0da507c473 Added test to alarm_crud.py of changing state via API and then having it change back to original state via the incoming metrics.
Added more output explaining what alarm_crud.py is doing

Enhanced check of Alarm history in utils.py

Moved find_notifications to utils.py
2014-06-11 09:36:57 -06:00

33 lines
869 B
Python

from __future__ import print_function
"""
Utility methods for notifications
"""
def create(mon_client, name, email):
kwargs = {'name': name, 'address': email, 'type': 'EMAIL'}
result = mon_client.notifications.create(**kwargs)
return result['id']
def update(mon_client, notification_id, name, email):
kwargs = {'id': notification_id, 'name': name, 'address': email,
'type': 'EMAIL'}
result = mon_client.notifications.update(**kwargs)
return result['id']
def get(mon_client, notification_id):
kwargs = {'notification_id': notification_id}
result = mon_client.notifications.get(**kwargs)
return result
def find_by_name(mon_client, name):
result = mon_client.notifications.list(**{})
for notification in result:
if notification['name'] == name:
return notification
return None