- remove object_ids as class variable declaration
[plcapi.git] / PLC / Methods / AddMessage.py
1 from PLC.Faults import *
2 from PLC.Method import Method
3 from PLC.Parameter import Parameter
4 from PLC.Messages import Message, Messages
5 from PLC.Auth import Auth
6
7 class AddMessage(Method):
8     """
9     Adds a new message template. Any values specified in
10     message_fields are used, otherwise defaults are used.
11
12     Returns 1 if successful, faults otherwise.
13     """
14
15     roles = ['admin']
16
17     accepts = [
18         Auth(),
19         Message.fields,
20         ]
21
22     returns = Parameter(int, '1 if successful')
23
24     event_type = 'Add'
25     object_type = 'Message'
26
27     def call(self, auth, message_fields):
28         message = Message(self.api, message_fields)
29         message.sync(insert = True)
30
31         return 1