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