d6b40914c6693212f32d3bc524f3887041efdeee
[plcapi.git] / PLC / Methods / DeleteSliceInstantiation.py
1 from PLC.Faults import *
2 from PLC.Method import Method
3 from PLC.Parameter import Parameter, Mixed
4 from PLC.SliceInstantiations import SliceInstantiation, SliceInstantiations
5 from PLC.Auth import Auth
6
7 class DeleteSliceInstantiation(Method):
8     """
9     Deletes a slice instantiation state.
10
11     WARNING: This will cause the deletion of all slices of this instantiation.
12
13     Returns 1 if successful, faults otherwise.
14     """
15
16     roles = ['admin']
17
18     accepts = [
19         Auth(),
20         SliceInstantiation.fields['instantiation']
21         ]
22
23     returns = Parameter(int, '1 if successful')
24
25     event_type = 'Delete' 
26     object_type = 'SliceInstantiation'
27
28     def call(self, auth, instantiation):
29         slice_instantiations = SliceInstantiations(self.api, [instantiation])
30         if not slice_instantiations:
31             raise PLCInvalidArgument, "No such slice instantiation state"
32         slice_instantiation = slice_instantiations[0]
33
34         slice_instantiation.delete()
35
36         return 1