906e21db113c2981b3b0c9589fe0651fedf3b8d2
[plcapi.git] / PLC / Methods / DeleteNetworkMethod.py
1 # $Id$
2 from PLC.Faults import *
3 from PLC.Method import Method
4 from PLC.Parameter import Parameter, Mixed
5 from PLC.NetworkMethods import NetworkMethod, NetworkMethods
6 from PLC.Auth import Auth
7
8 class DeleteNetworkMethod(Method):
9     """
10     Deletes a network method.
11
12     WARNING: This will cause the deletion of all network interfaces
13     that use this method.
14
15     Returns 1 if successful, faults otherwise.
16     """
17
18     roles = ['admin']
19
20     accepts = [
21         Auth(),
22         NetworkMethod.fields['method']
23         ]
24
25     returns = Parameter(int, '1 if successful')
26    
27
28     def call(self, auth, name):
29         network_methods = NetworkMethods(self.api, [name])
30         if not network_methods:
31             raise PLCInvalidArgument, "No such network method"
32         network_method = network_methods[0]
33
34         network_method.delete()
35
36         return 1