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 PasswordAuth
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()))
21 for field in attribute_type_fields.values():
26 Mixed(SliceAttributeType.fields['attribute_type_id'],
27 SliceAttributeType.fields['name']),
31 returns = Parameter(int, '1 if successful')
33 def call(self, auth, attribute_type_id_or_name, attribute_type_fields):
34 attribute_type_fields = dict(filter(can_update, attribute_type_fields.items()))
36 attribute_types = SliceAttributeTypes(self.api, [attribute_type_id_or_name]).values()
37 if not attribute_types:
38 raise PLCInvalidArgument, "No such attribute"
39 attribute_type = attribute_types[0]
41 attribute_type.update(attribute_type_fields)