3 from PLC.Faults import *
4 from PLC.Method import Method
5 from PLC.Parameter import Parameter, Mixed
6 from PLC.PCUs import PCU, PCUs
7 from PLC.Auth import Auth
9 class DeletePCU(Method):
13 Non-admins may only delete PCUs at their sites.
15 Returns 1 if successful, faults otherwise.
18 roles = ['admin', 'pi', 'tech']
25 returns = Parameter(int, '1 if successful')
28 def call(self, auth, pcu_id):
29 # Get associated PCU details
30 pcus = PCUs(self.api, [pcu_id])
32 raise PLCInvalidArgument, "No such PCU"
35 if 'admin' not in self.caller['roles']:
36 if pcu['site_id'] not in self.caller['site_ids']:
37 raise PLCPermissionDenied, "Not allowed to update that PCU"
42 self.event_objects = {'PCU': [pcu['pcu_id']]}
43 self.message = 'PCU %d deleted' % pcu['pcu_id']