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