9e682b6dcce837765ab2f754409feec08b3c303e
[plcapi.git] / PLC / Methods / GetEvents.py
1 # $Id$
2 from PLC.Faults import *
3 from PLC.Method import Method
4 from PLC.Parameter import Parameter, Mixed
5 from PLC.Filter import Filter
6 from PLC.Events import Event, Events
7 from PLC.Auth import Auth
8
9 class GetEvents(Method):
10     """
11     Returns an array of structs containing details about events and
12     faults. If event_filter is specified and is an array of event
13     identifiers, or a struct of event attributes, only events matching
14     the filter will be returned. If return_fields is specified, only the
15     specified details will be returned.
16     """
17
18     roles = ['admin']
19
20     accepts = [
21         Auth(),
22         Mixed([Event.fields['event_id']],
23               Filter(Event.fields)),
24         Parameter([str], "List of fields to return", nullok = True)
25         ]
26
27     returns = [Event.fields]
28
29     def call(self, auth, event_filter = None, return_fields = None):
30         return Events(self.api, event_filter, return_fields)
31