1 from PLC.Faults import *
2 from PLC.Method import Method
3 from PLC.Parameter import Parameter, Mixed
4 from PLC.Attributes import Attribute, Attributes
5 from PLC.Auth import PasswordAuth
7 can_update = lambda (field, value): field in \
8 ['description', 'min_role_id']
10 class AddAttribute(Method):
12 Adds a new type of attribute. Any fields specified in
13 attribute_fields are used, otherwise defaults are used.
15 Returns the new attribute_id (> 0) if successful, faults otherwise.
20 update_fields = dict(filter(can_update, Attribute.fields.items()))
24 Attribute.fields['name'],
28 returns = Parameter(int, 'New attribute_id (> 0) if successful')
30 def call(self, auth, name, attribute_fields = {}):
31 attribute_fields = dict(filter(can_update, attribute_fields.items()))
32 attribute = Attribute(self.api, attribute_fields)
33 attribute['name'] = name
36 return attribute['attribute_id']