- added class variables: event_type, object_type, object_ids (used by event logger)
[plcapi.git] / PLC / Methods / AddNetworkType.py
1 from PLC.Faults import *
2 from PLC.Method import Method
3 from PLC.Parameter import Parameter, Mixed
4 from PLC.NetworkTypes import NetworkType, NetworkTypes
5 from PLC.Auth import PasswordAuth
6
7 class AddNetworkType(Method):
8     """
9     Adds a new network type.
10
11     Returns 1 if successful, faults otherwise.
12     """
13
14     roles = ['admin']
15
16     accepts = [
17         PasswordAuth(),
18         NetworkType.fields['type']
19         ]
20
21     returns = Parameter(int, '1 if successful')
22
23     event_type = 'Add'
24     object_type = 'NetworkType'
25
26     def call(self, auth, name):
27         network_type = NetworkType(self.api)
28         network_type['type'] = name
29         network_type.sync()
30
31         return 1