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