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