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 PasswordAuth
7 can_update = lambda (field, value): field in ['description']
9 class AddAddressType(Method):
11 Adds a new address type. Fields specified in address_type_fields
14 Returns the new address_type_id (> 0) if successful, faults otherwise.
19 update_fields = dict(filter(can_update, AddressType.fields.items()))
23 AddressType.fields['name'],
27 returns = Parameter(int, 'New address_type_id (> 0) if successful')
30 object_type = 'AddressType'
33 def call(self, auth, name, address_type_fields = {}):
34 address_type_fields = dict(filter(can_update, address_type_fields.items()))
35 address_type = AddressType(self.api, address_type_fields)
36 address_type['name'] = name
38 self.object_ids = [address_type['address_type_id']]
40 return address_type['address_type_id']