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