mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-08-14 02:26:58 -07:00
Add newsletter commands to API docs
This commit is contained in:
parent
d3e53cb97f
commit
14b6df8c25
3 changed files with 252 additions and 18 deletions
|
@ -37,6 +37,8 @@ import logger
|
|||
import mobile_app
|
||||
import notification_handler
|
||||
import notifiers
|
||||
import newsletter_handler
|
||||
import newsletters
|
||||
import users
|
||||
|
||||
|
||||
|
@ -443,6 +445,51 @@ class API2:
|
|||
|
||||
return
|
||||
|
||||
def notify_newsletter(self, newsletter_id='', subject='', body='', message='', **kwargs):
|
||||
""" Send a newsletter using Tautulli.
|
||||
|
||||
```
|
||||
Required parameters:
|
||||
newsletter_id (int): The ID number of the newsletter agent
|
||||
|
||||
Optional parameters:
|
||||
subject (str): The subject of the newsletter
|
||||
body (str): The body of the newsletter
|
||||
message (str): The message of the newsletter
|
||||
|
||||
Returns:
|
||||
None
|
||||
```
|
||||
"""
|
||||
if not newsletter_id:
|
||||
self._api_msg = 'Newsletter failed: no newsletter id provided.'
|
||||
self._api_result_type = 'error'
|
||||
return
|
||||
|
||||
newsletter = newsletters.get_newsletter_config(newsletter_id=newsletter_id)
|
||||
|
||||
if not newsletter:
|
||||
self._api_msg = 'Newsletter failed: invalid newsletter_id provided %s.' % newsletter_id
|
||||
self._api_result_type = 'error'
|
||||
return
|
||||
|
||||
logger.api_debug(u'Tautulli APIv2 :: Sending newsletter.')
|
||||
success = newsletter_handler.notify(newsletter_id=newsletter_id,
|
||||
notify_action='api',
|
||||
subject=subject,
|
||||
body=body,
|
||||
message=message,
|
||||
**kwargs)
|
||||
|
||||
if success:
|
||||
self._api_msg = 'Newsletter sent.'
|
||||
self._api_result_type = 'success'
|
||||
else:
|
||||
self._api_msg = 'Newsletter failed.'
|
||||
self._api_result_type = 'error'
|
||||
|
||||
return
|
||||
|
||||
def _api_make_md(self):
|
||||
""" Tries to make a API.md to simplify the api docs. """
|
||||
|
||||
|
|
|
@ -5552,7 +5552,7 @@ class WebInterface(object):
|
|||
Returns:
|
||||
json:
|
||||
[{"id": 1,
|
||||
"agent_id": 13,
|
||||
"agent_id": 0,
|
||||
"agent_name": "recently_added",
|
||||
"agent_label": "Recently Added",
|
||||
"friendly_name": "",
|
||||
|
@ -5612,15 +5612,24 @@ class WebInterface(object):
|
|||
Returns:
|
||||
json:
|
||||
{"id": 1,
|
||||
"agent_id": 13,
|
||||
"agent_id": 0,
|
||||
"agent_name": "recently_added",
|
||||
"agent_label": "Recently Added",
|
||||
"friendly_name": "",
|
||||
"id_name": "",
|
||||
"cron": "0 0 * * 1",
|
||||
"active": 1
|
||||
"config": {"time_frame": 7,
|
||||
"time_frame_units": "days",
|
||||
"incl_libraries": [1, 2]
|
||||
"active": 1,
|
||||
"subject": "Recently Added to {server_name}! ({end_date})",
|
||||
"body": "View the newsletter here: {newsletter_url}",
|
||||
"message": "",
|
||||
"config": {"custom_cron": 0,
|
||||
"filename": "newsletter_{newsletter_uuid}.html",
|
||||
"formatted": 1,
|
||||
"incl_libraries": ["1", "2"],
|
||||
"notifier_id": 1,
|
||||
"save_only": 0,
|
||||
"time_frame": 7,
|
||||
"time_frame_units": "days"
|
||||
},
|
||||
"email_config": {...},
|
||||
"config_options": [{...}, ...],
|
||||
|
@ -5667,19 +5676,15 @@ class WebInterface(object):
|
|||
@requireAuth(member_of("admin"))
|
||||
@addtoapi()
|
||||
def set_newsletter_config(self, newsletter_id=None, agent_id=None, **kwargs):
|
||||
""" Configure an exisitng notificaiton agent.
|
||||
""" Configure an exisitng newsletter agent.
|
||||
|
||||
```
|
||||
Required parameters:
|
||||
newsletter_id (int): The newsletter config to update
|
||||
agent_id (int): The newsletter type of the newsletter
|
||||
newsletter_id (int): The newsletter config to update
|
||||
agent_id (int): The newsletter type of the newsletter
|
||||
|
||||
Optional parameters:
|
||||
Pass all the config options for the agent with the agent prefix:
|
||||
e.g. For Recently Added: recently_added_last_days
|
||||
recently_added_incl_movies
|
||||
recently_added_incl_shows
|
||||
recently_added_incl_artists
|
||||
Pass all the config options for the agent with the 'newsletter_config_' and 'newsletter_email_' prefix.
|
||||
|
||||
Returns:
|
||||
None
|
||||
|
@ -5697,7 +5702,6 @@ class WebInterface(object):
|
|||
@cherrypy.expose
|
||||
@cherrypy.tools.json_out()
|
||||
@requireAuth(member_of("admin"))
|
||||
@addtoapi("notify_newsletter")
|
||||
def send_newsletter(self, newsletter_id=None, subject='', body='', message='', notify_action='', **kwargs):
|
||||
""" Send a newsletter using Tautulli.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue