def isTransformEnabled(self, uid): """ Returns True if transform is enabled, False if disabled. """ facade = self._getFacade() data = facade.isTransformEnabled(uid) return DirectResponse(data=Zuul.marshal(data))
def addClass(self, contextUid, id, posQuery=None): """ Add a new service class. @type contextUid: string @param contextUid: Unique ID of the service ogranizer to add new class to @type id: string @param id: ID of the new service @type posQuery: dictionary @param posQuery: Object defining a query where the returned position will lie @rtype: DirectResponse @return: B{Properties}: - newIndex: (integer) Index of the newly added class in the query defined by posQuery """ newUid = self.api.addClass(contextUid, id) if isinstance(posQuery.get('params'), basestring): posQuery['params'] = unjson(posQuery['params']) result = self.api.getList(**posQuery) for count, serviceInfo in enumerate(result['serviceInfos']): if serviceInfo.uid == newUid: newIndex = count break else: raise Exception('The new service was added, but the system was ' 'unable to add it to the list.') audit('UI.Service.Add', contextUid + '/' + id) return DirectResponse(newIndex=newIndex)
def setTransformEnabled(self, uid, enabled): """ Enables or disables transforms on the given event class. When disabled transforms are enabled again, bad_transform events are cleared. """ facade = self._getFacade() data = facade.setTransformEnabled(uid, enabled) return DirectResponse(data=Zuul.marshal(data))
def query(self, limit=None, start=None, sort=None, dir=None, params=None, page=None, history=False, uid=None, criteria=()): """ Retrieve a list of services based on a set of parameters. @type limit: integer @param limit: (optional) Number of items to return; used in pagination (default: None) @type start: integer @param start: (optional) Offset to return the results from; used in pagination (default: None) @type sort: string @param sort: (optional) Key on which to sort the return results (default: None) @type dir: string @param dir: (optional) Sort order; can be either 'ASC' or 'DESC' (default: None) @type params: dictionary @param params: (optional) Key-value pair of filters for this search. @type history: boolean @param history: not used @type uid: string @param uid: Service class UID to query @type criteria: list @param criteria: not used @rtype: DirectResponse @return: B{Properties}: - services: ([dictionary]) List of objects representing services - totalCount: (integer) Total number of services - hash: (string) Hashcheck of the current services state - disabled: (boolean) True if current user cannot manage services """ if uid is None: uid = "/".join(self.context.getPhysicalPath()) if isinstance(params, basestring): params = unjson(params) services = self.api.getList(limit, start, sort, dir, params, uid, criteria) disabled = not Zuul.checkPermission('Manage DMD') data = Zuul.marshal(services['serviceInfos'], keys=('name', 'description', 'count', 'uid', 'port')) return DirectResponse(services=data, totalCount=services['total'], hash=services['hash'], disabled=disabled)
def getIndexes(self): """ Return list of dicts where each dict represents list of indexes for a particular object """ indexes = self.api.getIndexInfo() return DirectResponse(indexes=indexes)
def query(self, limit=None, start=None, sort=None, dir=None, params=None, page=None, history=False, uid=None, criteria=()): """ Retrieve a list of processes based on a set of parameters. @type limit: integer @param limit: (optional) Number of items to return; used in pagination (default: None) @type start: integer @param start: (optional) Offset to return the results from; used in pagination (default: None) @type sort: string @param sort: (optional) Key on which to sort the return results (default: None) @type dir: string @param dir: (optional) Sort order; can be either 'ASC' or 'DESC' (default: None) @type params: dictionary @param params: (optional) Key-value pair of filters for this search. @type history: boolean @param history: not used @type uid: string @param uid: Service class UID to query @type criteria: list @param criteria: not used @rtype: DirectResponse @return: B{Properties}: - processes: ([dictionary]) List of objects representing processes - totalCount: (integer) Total number of processes - hash: (string) Hashcheck of the current processes state - disabled: (boolean) True if current user cannot manage processes """ facade = self._getFacade() if uid is None: uid = self.context if isinstance(params, basestring): params = unjson(params) processes = facade.getList(limit, start, sort, dir, params, uid, criteria) disabled = not Zuul.checkPermission('Manage DMD') data = Zuul.marshal(processes) return DirectResponse(processes=data, totalCount=processes.total, hash=processes.hash_, disabled=disabled)
def editMaintWindow(self, params): """ Edits the values of of a maintenance window for this context and window id @type params: dict @param params: """ facade = self._getFacade() data = facade.editMaintWindow(params) return DirectResponse(data=Zuul.marshal(data))
def getAdminRoles(self, uid, params=None): """ Returns the admin roles associated with the device for this context @type uid: string @param uid: unique identifier of an object """ facade = self._getFacade() data = facade.getAdminRoles(uid) return DirectResponse(data=Zuul.marshal(data))
def getJobs(self, start, limit, page, sort, dir, uid=None): # if user isn't global only show them the jobs they created user = self.context.dmd.ZenUsers.getUserSettings() createdBy = user.id if user.hasNoGlobalRoles() else None results, total = self.api.getJobs(start=start, limit=limit, sort=sort, dir=dir, createdBy=createdBy) jobs = Zuul.marshal(results, keys=JOBKEYS) for job in jobs: job['description'] = cgi.escape(job.get('description') or '') return DirectResponse(jobs=jobs, totalCount=total)
def getUserCommands(self, uid, params=None): """ Get a list of user commands for a device uid. @type uid: string @param uid: Device to use to get user commands @rtype: [dictionary] @return: List of objects representing user commands """ facade = self._getFacade() data = facade.getUserCommands(uid) return DirectResponse(data=Zuul.marshal(data))
def getMaintWindows(self, uid, params=None): """ Returns the definition and values of all the maintenance windows for this context @type uid: string @param uid: unique identifier of an object @type params: none @param params: none for page reloads and error avoidance """ facade = self._getFacade() data = facade.getMaintWindows(uid) return DirectResponse(data=Zuul.marshal(data))
def getCustomProperties( self, uid, start=0, params="{}", limit=None, sort=None, page=None, dir='ASC'): """ Returns the definition and values of all the zen properties for this context @type uid: string @param uid: unique identifier of an object """ facade = self._getFacade() data = facade.getCustomProperties(uid) data = _filterData(params, data) if sort: data = _sortData(sort, data, dir) return DirectResponse(data=Zuul.marshal(data), totalCount=len(data))