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
7 can_update = lambda (field, value): field in ['name', 'description']
9 class UpdateAddressType(Method):
11 Updates the parameters of an existing address type with the values
12 in address_type_fields.
14 Returns 1 if successful, faults otherwise.
19 address_type_fields = dict(filter(can_update, AddressType.fields.items()))
23 Mixed(AddressType.fields['address_type_id'],
24 AddressType.fields['name']),
28 returns = Parameter(int, '1 if successful')
30 def call(self, auth, address_type_id_or_name, address_type_fields):
31 address_type_fields = dict(filter(can_update, address_type_fields.items()))
33 address_types = AddressTypes(self.api, [address_type_id_or_name])
35 raise PLCInvalidArgument, "No such address type"
36 address_type = address_types[0]
38 address_type.update(address_type_fields)