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 not in ['address_type_id']
11 class AddAddressType(Method):
13 Adds a new address type. Fields specified in address_type_fields
16 Returns the new address_type_id (> 0) if successful, faults otherwise.
21 address_type_fields = dict(filter(can_update, AddressType.fields.items()))
28 returns = Parameter(int, 'New address_type_id (> 0) if successful')
31 def call(self, auth, address_type_fields):
32 address_type_fields = dict(filter(can_update, address_type_fields.items()))
33 address_type = AddressType(self.api, address_type_fields)
36 self.event_objects = {'AddressType' : [address_type['address_type_id']]}
38 return address_type['address_type_id']