3 # Thierry Parmentelat - INRIA
9 from PLC.Faults import *
10 from PLC.Method import Method
11 from PLC.Parameter import Parameter, Mixed
12 from PLC.TagTypes import TagType, TagTypes
13 from PLC.Auth import Auth
15 can_update = lambda (field, value): field in \
16 ['tagname', 'description', 'category', 'min_role_id']
18 class AddTagType(Method):
20 Adds a new type of node tag.
21 Any fields specified are used, otherwise defaults are used.
23 Returns the new node_tag_id (> 0) if successful,
29 tag_type_fields = dict(filter(can_update, TagType.fields.items()))
36 returns = Parameter(int, 'New node_tag_id (> 0) if successful')
39 def call(self, auth, tag_type_fields):
40 tag_type_fields = dict(filter(can_update, tag_type_fields.items()))
41 tag_type = TagType(self.api, tag_type_fields)
44 self.object_ids = [tag_type['tag_type_id']]
46 return tag_type['tag_type_id']