1 from PLC.Faults import *
2 from PLC.Method import Method
3 from PLC.Parameter import Parameter, Mixed
4 from PLC.SliceAttributeTypes import SliceAttributeType, SliceAttributeTypes
5 from PLC.Auth import Auth
7 can_update = lambda (field, value): field in \
8 ['name', 'description', 'min_role_id']
10 class UpdateSliceAttributeType(Method):
12 Updates the parameters of an existing attribute with the values in
13 attribute_type_fields.
15 Returns 1 if successful, faults otherwise.
20 attribute_type_fields = dict(filter(can_update, SliceAttributeType.fields.items()))
24 Mixed(SliceAttributeType.fields['attribute_type_id'],
25 SliceAttributeType.fields['name']),
29 returns = Parameter(int, '1 if successful')
31 def call(self, auth, attribute_type_id_or_name, attribute_type_fields):
32 attribute_type_fields = dict(filter(can_update, attribute_type_fields.items()))
34 attribute_types = SliceAttributeTypes(self.api, [attribute_type_id_or_name])
35 if not attribute_types:
36 raise PLCInvalidArgument, "No such attribute"
37 attribute_type = attribute_types[0]
39 attribute_type.update(attribute_type_fields)
41 self.event_objects = {'AttributeType': [attribute_type['attribute_type_id']]}