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.LinkTypes import LinkType, LinkTypes
10 from PLC.Auth import Auth
12 can_update = lambda (field, value): field in \
13 ['name', 'description', 'category', 'min_role_id']
15 class UpdateLinkType(Method):
17 Updates the parameters of an existing link type
18 with the values in link_type_fields.
20 Returns 1 if successful, faults otherwise.
25 link_type_fields = dict(filter(can_update, LinkType.fields.items()))
29 Mixed(LinkType.fields['link_type_id'],
30 LinkType.fields['name']),
34 returns = Parameter(int, '1 if successful')
36 def call(self, auth, link_type_id_or_name, link_type_fields):
37 link_type_fields = dict(filter(can_update, link_type_fields.items()))
39 link_types = LinkTypes(self.api, [link_type_id_or_name])
41 raise PLCInvalidArgument, "No such tag type"
42 link_type = link_types[0]
44 link_type.update(link_type_fields)
46 self.object_ids = [link_type['link_type_id']]