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