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