get rid of svn keywords once and for good
[plcapi.git] / PLC / Methods / NotifySupport.py
1 from PLC.Method import Method
2 from PLC.Parameter import Parameter, Mixed
3 from PLC.Auth import Auth
4 from PLC.sendmail import sendmail
5
6 class NotifySupport(Method):
7     """
8     Sends an e-mail message to the configured support address.
9
10     Returns 1 if successful.
11     """
12
13     roles = ['admin']
14
15     accepts = [
16         Auth(),
17         Parameter(str, "E-mail subject"),
18         Parameter(str, "E-mail body")
19         ]
20
21     returns = Parameter(int, '1 if successful')
22
23     def call(self, auth, subject, body):
24         to_name="%s Support"%self.api.config.PLC_NAME
25         to_address=self.api.config.PLC_MAIL_SUPPORT_ADDRESS
26
27         # Send email
28         sendmail(self.api, To=(to_name,to_address),
29                  Subject = subject,
30                  Body = body)
31
32         # Logging variables
33         #self.event_objects = {'Person': [person['person_id'] for person in persons]}
34         self.message = subject
35
36         return 1