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