interface to network_methods table
[plcapi.git] / PLC / Methods / DeleteNetworkMethod.py
1 from PLC.Faults import *
2 from PLC.Method import Method
3 from PLC.Parameter import Parameter, Mixed
4 from PLC.NetworkMethods import NetworkMethod, NetworkMethods
5 from PLC.Auth import PasswordAuth
6
7 class DeleteNetworkMethod(Method):
8     """
9     Deletes a network method.
10
11     Returns 1 if successful, faults otherwise.
12     """
13
14     roles = ['admin']
15
16     accepts = [
17         PasswordAuth(),
18         NetworkMethod.fields['method']
19         ]
20
21     returns = Parameter(int, '1 if successful')
22
23     def call(self, auth, name):
24         network_methods = NetworkMethods(self.api, [name])
25         if not network_methods:
26             raise PLCInvalidArgument, "No such network method"
27         network_method = network_methods.values()[0]
28
29         network_method.delete()
30
31         return 1