Merge from trunk
[plcapi.git] / trunk / PLC / Methods / GetSessions.py
diff --git a/trunk/PLC/Methods/GetSessions.py b/trunk/PLC/Methods/GetSessions.py
new file mode 100644 (file)
index 0000000..a72553c
--- /dev/null
@@ -0,0 +1,35 @@
+from PLC.Faults import *
+from PLC.Method import Method
+from PLC.Parameter import Parameter, Mixed
+from PLC.Filter import Filter
+from PLC.Sessions import Session, Sessions
+from PLC.Persons import Person, Persons
+from PLC.Auth import Auth
+
+class GetSessions(Method):
+    """
+    Returns an array of structs containing details about users sessions. If
+    session_filter is specified and is an array of user identifiers or
+    session_keys, or a struct of session attributes, only sessions matching the
+    filter will be returned. If return_fields is specified, only the
+    specified details will be returned.
+
+    
+    """
+
+    roles = ['admin']
+
+    accepts = [
+        Auth(),
+        Mixed([Mixed(Session.fields['person_id'],
+                     Session.fields['session_id'])],
+              Filter(Session.fields))
+        ]
+
+    returns = [Session.fields]
+    
+    def call(self, auth, session_filter = None):
+
+        sessions = Sessions(self.api, session_filter)
+       
+       return sessions