(self, request, tenant_id)
return json.dumps({'values': values, 'metadata': metadata})
All NotificationPlans a number of alarms pointing to them.
All NotificationPlans a number of alarms pointing to them.
All NotificationPlans a number of alarms pointing to them .
def alarm_counts_per_np(self, request, tenant_id):
        """
        All NotificationPlans a number of alarms pointing to them.
        """
        notification_plans = self._entity_cache_for_tenant(
            tenant_id).notification_plans
        entities = self._entity_cache_for_tenant(tenant_id).entities

        values = [{'notification_plan_id': np.id,
                   'alarm_count': len([alarm
                                       for entity in entities.values()
                                       for alarm in entity.alarms.values()
                                       if alarm.notification_plan_id == np.id])}
                  for np in notification_plans.values()]

        metadata = {'limit': 100,
                    'marker': None,
                    'next_marker': None,
                    'next_href': None,
                    'count': len(values)}
        request.setResponseCode(200)
        return json.dumps({'values': values, 'metadata': metadata})
def alarm_counts_per_np ( self , request , tenant_id ) : notification_plans = self . _entity_cache_for_tenant ( tenant_id ) . notification_plans entities = self . _entity_cache_for_tenant ( tenant_id ) . entities values = [ { 'notification_plan_id' : np . id , 'alarm_count' : len ( [ alarm for entity in entities . values ( ) for alarm in entity . alarms . values ( ) if alarm . notification_plan_id == np . id ] ) } for np in notification_plans . values ( ) ] metadata = { 'limit' : 100 , 'marker' : None , 'next_marker' : None , 'next_href' : None , 'count' : len ( values ) } request . setResponseCode ( 200 ) return json . dumps ( { 'values' : values , 'metadata' : metadata } )