2 from PLC.Faults import *
3 from PLC.Method import Method
4 from PLC.Parameter import Parameter, Mixed
5 from PLC.AddressTypes import AddressType, AddressTypes
6 from PLC.Auth import Auth
8 can_update = lambda (field, value): field in ['name', 'description']
10 class UpdateAddressType(Method):
12 Updates the parameters of an existing address type with the values
13 in address_type_fields.
15 Returns 1 if successful, faults otherwise.
20 address_type_fields = dict(filter(can_update, AddressType.fields.items()))
24 Mixed(AddressType.fields['address_type_id'],
25 AddressType.fields['name']),
29 returns = Parameter(int, '1 if successful')
31 def call(self, auth, address_type_id_or_name, address_type_fields):
32 address_type_fields = dict(filter(can_update, address_type_fields.items()))
34 address_types = AddressTypes(self.api, [address_type_id_or_name])
36 raise PLCInvalidArgument, "No such address type"
37 address_type = address_types[0]
39 address_type.update(address_type_fields)
41 self.event_objects = {'AddressType': [address_type['address_type_id']]}