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 not in ['address_type_id']
10 class AddAddressType(Method):
12 Adds a new address type. Fields specified in address_type_fields
15 Returns the new address_type_id (> 0) if successful, faults otherwise.
20 address_type_fields = dict(filter(can_update, AddressType.fields.items()))
27 returns = Parameter(int, 'New address_type_id (> 0) if successful')
30 def call(self, auth, address_type_fields):
31 address_type_fields = dict(filter(can_update, address_type_fields.items()))
32 address_type = AddressType(self.api, address_type_fields)
35 self.event_objects = {'AddressType' : [address_type['address_type_id']]}
37 return address_type['address_type_id']