Package Products :: Package Zuul :: Package routers :: Module modelQuery
[hide private]
[frames] | no frames]

Source Code for Module Products.Zuul.routers.modelQuery

 1  ############################################################################## 
 2  # 
 3  # Copyright (C) Zenoss, Inc. 2017, all rights reserved. 
 4  # 
 5  # This content is made available according to terms specified in 
 6  # License.zenoss under the directory where your Zenoss product is installed. 
 7  # 
 8  ############################################################################## 
 9   
10  from Products import Zuul 
11  from Products.Zuul.routers import TreeRouter 
12  from Products.ZenUtils.Ext import DirectResponse 
13   
14   
15 -class ModelQueryRouter(TreeRouter):
16 """ 17 A JSON/ExtDirect interface to retrieve model data from Solr 18 """ 19
20 - def __init__(self, context, request):
21 self.context = context 22 self.request = request 23 self.api = Zuul.getFacade('modelquery') 24 super(ModelQueryRouter, self).__init__(context, request)
25 26
27 - def _getFacade(self):
28 return self.api
29 30
31 - def getDevices(self, limit=200, params=None, fields=None):
32 """ 33 Retrieves a list of devices. 34 @type limit: integer 35 @param limit: (optional) Number of items to return 36 37 @type params: dictionary 38 @param params: (optional) Key-value pair of filters for this search 39 e.g. params={'name': 'localhost'} 40 41 @type fields: list of strings 42 @param fields: (optional) list of indexed fields to retrieve, if None 43 then attempts to retrive values for all indexes we have in SOLR. 44 e.g. fields=["name", "osModel", "productionState"] 45 """ 46 47 devices, totalCount = self.api.getDevices(limit=limit, params=params, fields=fields) 48 return DirectResponse(devices=devices, totalCount=totalCount)
49 50
51 - def getIndexes(self):
52 53 """ 54 Return list of dicts where each dict represents 55 list of indexes for a particular object 56 """ 57 58 indexes = self.api.getIndexInfo() 59 return DirectResponse(indexes=indexes)
60