5e84017a7cf888b0e448493faed8cee186a83975
[plcapi.git] / PLC / Methods / GetSessions.py
1 # $Id$
2 # $URL$
3 from PLC.Faults import *
4 from PLC.Method import Method
5 from PLC.Parameter import Parameter, Mixed
6 from PLC.Filter import Filter
7 from PLC.Sessions import Session, Sessions
8 from PLC.Persons import Person, Persons
9 from PLC.Auth import Auth
10
11 class GetSessions(Method):
12     """
13     Returns an array of structs containing details about users sessions. If
14     session_filter is specified and is an array of user identifiers or
15     session_keys, or a struct of session attributes, only sessions matching the
16     filter will be returned. If return_fields is specified, only the
17     specified details will be returned.
18
19
20     """
21
22     roles = ['admin']
23
24     accepts = [
25         Auth(),
26         Mixed([Mixed(Session.fields['person_id'],
27                      Session.fields['session_id'])],
28               Filter(Session.fields))
29         ]
30
31     returns = [Session.fields]
32
33     def call(self, auth, session_filter = None):
34
35         sessions = Sessions(self.api, session_filter)
36
37         return sessions