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