Example #1
0
 def list(self, r):
     result = []
     for monitor in sorted(r.user.monitors.values(), key=lambda m: m.name.lower()):
         r = dict(name=monitor.name, 
              url=monitor.config,
              state=encode_enum(Monitor, monitor.state),
              kind=encode_enum(Monitor, monitor.kind, name='kind'),
              user_state=encode_enum(Monitor, monitor.user_state, name='user_state'))
         result.append(r)
     return result
Example #2
0
 def list_notifications(self, r, name):
     monitor = r.user.monitors[name]
     target_tz = pytz.timezone(r.user.timezone)
     result = []
     for ad in monitor.alert_destinations:
         result.append(
             dict(name=ad.destination.destination_name,
                  destination_type=encode_enum(Destination, ad.destination.destination_type),
                  notify_down_on=encode_enum(AlertDestinationNotifyOn, ad.notify_down_on),
                  notify_up=ad.notify_up,
                  qp_start=localtimefromtime(ad.qp_start, target_tz),
                  qp_end=localtimefromtime(ad.qp_end, target_tz),
             )
         )
     return result