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