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