3 # Thierry Parmentelat - INRIA
7 from PLC.Faults import *
8 from PLC.Method import Method
9 from PLC.Parameter import Parameter, Mixed
10 from PLC.TagTypes import TagType, TagTypes
11 from PLC.Auth import Auth
13 can_update = lambda (field, value): field in \
14 ['tagname', 'description', 'category', 'min_role_id']
16 class UpdateTagType(Method):
18 Updates the parameters of an existing tag type
19 with the values in tag_type_fields.
21 Returns 1 if successful, faults otherwise.
26 tag_type_fields = dict(filter(can_update, TagType.fields.items()))
30 Mixed(TagType.fields['tag_type_id'],
31 TagType.fields['tagname']),
35 returns = Parameter(int, '1 if successful')
37 def call(self, auth, tag_type_id_or_name, tag_type_fields):
38 tag_type_fields = dict(filter(can_update, tag_type_fields.items()))
40 tag_types = TagTypes(self.api, [tag_type_id_or_name])
42 raise PLCInvalidArgument, "No such tag type"
43 tag_type = tag_types[0]
45 tag_type.update(tag_type_fields)
47 self.object_ids = [tag_type['tag_type_id']]