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