Add 'php/phpxmlrpc/' from commit 'cd5dbb4a511e7a616a61187a5de1a611a9748cbd'
[plcapi.git] / PLC / Methods / AddNodeType.py
1 from PLC.Faults import *
2 from PLC.Method import Method
3 from PLC.Parameter import Parameter, Mixed
4 from PLC.NodeTypes import NodeType, NodeTypes
5 from PLC.Auth import Auth
6
7 class AddNodeType(Method):
8     """
9     Adds a new node node type.
10
11     Returns 1 if successful, faults otherwise.
12     """
13
14     roles = ['admin']
15
16     accepts = [
17         Auth(),
18         NodeType.fields['node_type']
19         ]
20
21     returns = Parameter(int, '1 if successful')
22
23
24     def call(self, auth, name):
25         node_type = NodeType(self.api)
26         node_type['node_type'] = name
27         node_type.sync(insert = True)
28
29         return 1