- define/modify logging variables
[plcapi.git] / PLC / Methods / DeleteSession.py
1 import time
2
3 from PLC.Method import Method
4 from PLC.Parameter import Parameter, Mixed
5 from PLC.Auth import SessionAuth
6 from PLC.Sessions import Session, Sessions
7
8 class DeleteSession(Method):
9     """
10     Invalidates the current session.
11
12     Returns 1 if successful.
13     """
14
15     roles = ['admin', 'pi', 'user', 'tech', 'node']
16     accepts = [SessionAuth()]
17     returns = Parameter(int, '1 if successful')
18
19     event_type = 'Delete'
20     object_type = 'Session'
21
22     def call(self, auth):
23         assert auth.has_key('session')
24
25         sessions = Sessions(self.api, [auth['session']])
26         if not sessions:
27             raise PLCAPIError, "No such session"
28         session = sessions[0]
29
30         session.delete()
31
32         return 1