This commit was manufactured by cvs2svn to create branch
[plcapi.git] / PLC / Methods / DeleteSliceAttributeType.py
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
6
7 class DeleteSliceAttributeType(Method):
8     """
9     Deletes the specified slice attribute.
10
11     Returns 1 if successful, faults otherwise.
12     """
13
14     roles = ['admin']
15
16     accepts = [
17         Auth(),
18         Mixed(SliceAttributeType.fields['attribute_type_id'],
19               SliceAttributeType.fields['name']),
20         ]
21
22     returns = Parameter(int, '1 if successful')
23
24
25     def call(self, auth, attribute_type_id_or_name):
26         attribute_types = SliceAttributeTypes(self.api, [attribute_type_id_or_name])
27         if not attribute_types:
28             raise PLCInvalidArgument, "No such slice attribute type"
29         attribute_type = attribute_types[0]
30
31         attribute_type.delete()
32         self.object_ids = [attribute_type['attribute_type_id']]
33
34         return 1