3 from PLC.Faults import *
4 from PLC.Method import Method
5 from PLC.Parameter import Parameter, Mixed
6 from PLC.AddressTypes import AddressType, AddressTypes
7 from PLC.Auth import Auth
9 can_update = lambda (field, value): field in ['name', 'description']
11 class UpdateAddressType(Method):
13 Updates the parameters of an existing address type with the values
14 in address_type_fields.
16 Returns 1 if successful, faults otherwise.
21 address_type_fields = dict(filter(can_update, AddressType.fields.items()))
25 Mixed(AddressType.fields['address_type_id'],
26 AddressType.fields['name']),
30 returns = Parameter(int, '1 if successful')
32 def call(self, auth, address_type_id_or_name, address_type_fields):
33 address_type_fields = dict(filter(can_update, address_type_fields.items()))
35 address_types = AddressTypes(self.api, [address_type_id_or_name])
37 raise PLCInvalidArgument, "No such address type"
38 address_type = address_types[0]
40 address_type.update(address_type_fields)
42 self.event_objects = {'AddressType': [address_type['address_type_id']]}