svn kwds
[plcapi.git] / PLC / Methods / DeletePCUType.py
1 # $Id$
2 from PLC.Faults import *
3 from PLC.Method import Method
4 from PLC.Parameter import Parameter, Mixed
5 from PLC.PCUTypes import PCUType, PCUTypes
6 from PLC.Auth import Auth
7
8 class DeletePCUType(Method):
9     """
10     Deletes a PCU type.
11
12     Returns 1 if successful, faults otherwise.  
13     """
14
15     roles = ['admin']
16
17     accepts = [
18         Auth(),
19         PCUType.fields['pcu_type_id']
20         ]
21
22     returns = Parameter(int, '1 if successful')
23     
24
25     def call(self, auth, pcu_type_id):
26         pcu_types = PCUTypes(self.api, [pcu_type_id])
27         if not pcu_types:
28             raise PLCInvalidArgument, "No such pcu type"
29
30         pcu_type = pcu_types[0]
31         pcu_type.delete()
32         self.event_objects = {'PCUType': [pcu_type['pcu_type_id']]}
33
34         return 1