(self, request, tenant_id)
return json.dumps({'values': values, 'metadata': metadata})
Gets entities grouped with their latest alarm states.
Gets entities grouped with their latest alarm states.
Gets entities grouped with their latest alarm states .
def latest_alarm_states(self, request, tenant_id):
        """
        Gets entities grouped with their latest alarm states.
        """
        entities = self._entity_cache_for_tenant(tenant_id).entities
        maas_store = self._entity_cache_for_tenant(tenant_id).maas_store

        values = [{'entity_id': entity.id,
                   'entity_uri': entity.uri,
                   'entity_label': entity.label,
                   'latest_alarm_states': [
                       state.detail_json()
                       for state in maas_store.latest_alarm_states_for_entity(entity.id)]}
                  for entity in entities.values()]

        metadata = {'count': len(values),
                    'marker': None,
                    'next_marker': None,
                    'limit': 1000,
                    'next_href': None}

        request.setResponseCode(200)
        return json.dumps({'values': values, 'metadata': metadata})
def latest_alarm_states ( self , request , tenant_id ) : entities = self . _entity_cache_for_tenant ( tenant_id ) . entities maas_store = self . _entity_cache_for_tenant ( tenant_id ) . maas_store values = [ { 'entity_id' : entity . id , 'entity_uri' : entity . uri , 'entity_label' : entity . label , 'latest_alarm_states' : [ state . detail_json ( ) for state in maas_store . latest_alarm_states_for_entity ( entity . id ) ] } for entity in entities . values ( ) ] metadata = { 'count' : len ( values ) , 'marker' : None , 'next_marker' : None , 'limit' : 1000 , 'next_href' : None } request . setResponseCode ( 200 ) return json . dumps ( { 'values' : values , 'metadata' : metadata } )