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_value[0] not in ['address_type_id']
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 address_type_fields = dict(list(filter(can_update, list(AddressType.fields.items()))))
26 returns = Parameter(int, 'New address_type_id (> 0) if successful')
29 def call(self, auth, address_type_fields):
30 address_type_fields = dict(list(filter(can_update, list(address_type_fields.items()))))
31 address_type = AddressType(self.api, address_type_fields)
34 self.event_objects = {'AddressType' : [address_type['address_type_id']]}
36 return address_type['address_type_id']