b49135fcce20b8d61ccd0686275b561ea97e022e
[plcapi.git] / PLC / Methods / AddNodeType.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 AddNodeType(Method):
9     """
10     Adds a new node node type.
11
12     Returns 1 if successful, faults otherwise.
13     """
14
15     roles = ['admin']
16
17     accepts = [
18         Auth(),
19         NodeType.fields['node_type']
20         ]
21
22     returns = Parameter(int, '1 if successful')
23
24     
25     def call(self, auth, name):
26         node_type = NodeType(self.api)
27         node_type['node_type'] = name
28         node_type.sync(insert = True)
29
30         return 1