2 # Thierry Parmentelat - INRIA
6 from PLC.Faults import *
7 from PLC.Method import Method
8 from PLC.Parameter import Parameter, Mixed
9 from PLC.TagTypes import TagType, TagTypes
10 from PLC.Auth import Auth
12 can_update = lambda (field, value): field in \
13 ['tagname', 'description', 'category', 'min_role_id']
15 class UpdateTagType(Method):
17 Updates the parameters of an existing tag type
18 with the values in tag_type_fields.
20 Returns 1 if successful, faults otherwise.
25 tag_type_fields = dict(filter(can_update, TagType.fields.items()))
29 Mixed(TagType.fields['tag_type_id'],
30 TagType.fields['tagname']),
34 returns = Parameter(int, '1 if successful')
36 def call(self, auth, tag_type_id_or_name, tag_type_fields):
37 tag_type_fields = dict(filter(can_update, tag_type_fields.items()))
39 tag_types = TagTypes(self.api, [tag_type_id_or_name])
41 raise PLCInvalidArgument, "No such tag type"
42 tag_type = tag_types[0]
44 tag_type.update(tag_type_fields)
46 self.object_ids = [tag_type['tag_type_id']]