From 1e6d5da0a20fe4397171671ea9ff29dd2f2f6e27 Mon Sep 17 00:00:00 2001 From: Mark Huang Date: Wed, 8 Nov 2006 23:06:08 +0000 Subject: [PATCH] - no need for os - use Filter to select rows - should be admin-only --- PLC/Methods/GetEvents.py | 62 +++++++--------------------------------- 1 file changed, 10 insertions(+), 52 deletions(-) diff --git a/PLC/Methods/GetEvents.py b/PLC/Methods/GetEvents.py index 4d293112..30f246ec 100644 --- a/PLC/Methods/GetEvents.py +++ b/PLC/Methods/GetEvents.py @@ -1,69 +1,27 @@ -import os - from PLC.Faults import * from PLC.Method import Method from PLC.Parameter import Parameter, Mixed +from PLC.Filter import Filter from PLC.Events import Event, Events from PLC.Auth import Auth class GetEvents(Method): """ - Return an array of dictionaries containing details about the - specified events. - - if object_ids is specified, and object_types must be specified - with only 1 object type + Returns an array of structs containing details about events and + faults. If event_filter is specified and is an array of event + identifiers, or a struct of event attributes, only events matching + the filter will be returned. """ - roles = ['admin', 'pi', 'user', 'tech'] + roles = ['admin'] accepts = [ Auth(), - [Event.fields['event_id']], - [Event.fields['person_id']], - Event.fields['object_ids'], - [Event.fields['event_type']], - [Event.fields['object_type']], - [Event.fields['fault_code']] + Mixed([Event.fields['event_id']], + Filter(Event.fields)) ] returns = [Event.fields] - def __init__(self, *args, **kwds): - Method.__init__(self, *args, **kwds) - # Update documentation with list of default fields returned - self.__doc__ += os.linesep.join(Event.fields.keys()) - - def call(self, auth, event_id_list = None, person_id_list = None, event_type_list = None, object_type_list = None, object_id_list = None, fault_code_list = None): - - # Authenticated function - assert self.caller is not None - - # filter out invalid event types - if event_type_list: - valid_event_types = ['Add', 'AddTo', 'Get', 'Update', 'Delete', \ - 'DeleteFrom', 'Unknown'] - if filter(lambda field: field not in valid_event_types, event_type_list): - raise PLCInvalidArgument, "Invalid event type. Must be in %s" % \ - valid_event_types - - # filter out invalid object types - if object_type_list: - valid_object_types = ['AddreessType', 'Address', 'BootState', 'ConfFile', \ - 'KeyType', 'Key', 'NetworkType', 'NodeGroup',\ - 'NodeNetwork', 'Node', 'PCU', 'Perons', 'Site', \ - 'SliceAttributeType', 'SliceAttribute', 'Slice', 'Unknown'] - if filter(lambda field: field not in valid_object_types, object_type_list): - raise PLCInvalidArgument, "Invalid object type. Must be in %s" % \ - valid_object_types - - # if object ids are specified only 1 object type can be specified - if object_id_list: - if not object_type_list: - raise PLCInvalidArgument, "Object type must be specified" - elif len(object_type_list) > 1: - raise PLCInvalidArgument, "Cannot specify multiple object types when object_ids are specified" - - # Get node information - return Events(self.api, event_id_list, person_id_list, event_type_list, \ - object_type_list, object_id_list, fault_code_list).values() + def call(self, auth, event_filter = None): + return Events(self.api, event_filter).values() -- 2.47.0