Add return ID for async API calls

* export_id, notification_id, and newsletter_notification_d
This commit is contained in:
JonnyWong16 2023-05-05 15:56:32 -07:00
parent fe4fba353e
commit 3a1d6322ae
No known key found for this signature in database
GPG key ID: B1F1F9807184697A
4 changed files with 15 additions and 15 deletions

View file

@ -505,7 +505,8 @@ class API2(object):
script_args (str): The arguments for script notifications script_args (str): The arguments for script notifications
Returns: Returns:
None json:
{"notification_id": 1}
``` ```
""" """
if not notifier_id: if not notifier_id:
@ -527,14 +528,14 @@ class API2(object):
body=body, body=body,
**kwargs) **kwargs)
if success: if isinstance(success, int):
self._api_msg = 'Notification sent.' self._api_msg = 'Notification sent.'
self._api_result_type = 'success' self._api_result_type = 'success'
return {'notification_id': success}
else: else:
self._api_msg = 'Notification failed.' self._api_msg = 'Notification failed.'
self._api_result_type = 'error' self._api_result_type = 'error'
return
return
def notify_newsletter(self, newsletter_id='', subject='', body='', message='', **kwargs): def notify_newsletter(self, newsletter_id='', subject='', body='', message='', **kwargs):
""" Send a newsletter using Tautulli. """ Send a newsletter using Tautulli.
@ -549,7 +550,8 @@ class API2(object):
message (str): The message of the newsletter message (str): The message of the newsletter
Returns: Returns:
None json:
{"newsletter_notification_id": 1}
``` ```
""" """
if not newsletter_id: if not newsletter_id:
@ -572,14 +574,14 @@ class API2(object):
message=message, message=message,
**kwargs) **kwargs)
if success: if isinstance(success, int):
self._api_msg = 'Newsletter sent.' self._api_msg = 'Newsletter sent.'
self._api_result_type = 'success' self._api_result_type = 'success'
return {'newsletter_notification_id': success}
else: else:
self._api_msg = 'Newsletter failed.' self._api_msg = 'Newsletter failed.'
self._api_result_type = 'error' self._api_result_type = 'error'
return
return
def _api_make_md(self): def _api_make_md(self):
""" Tries to make a API.md to simplify the api docs. """ """ Tries to make a API.md to simplify the api docs. """

View file

@ -1837,7 +1837,7 @@ class Export(object):
threading.Thread(target=self._real_export).start() threading.Thread(target=self._real_export).start()
return True return self.export_id
def add_export(self): def add_export(self):
keys = { keys = {

View file

@ -438,7 +438,7 @@ def notify(notifier_id=None, notify_action=None, stream_data=None, timeline_data
if success: if success:
set_notify_success(notification_id) set_notify_success(notification_id)
return True return notification_id
def get_notify_state(session): def get_notify_state(session):

View file

@ -7057,9 +7057,7 @@ class WebInterface(object):
Returns: Returns:
json: json:
{"result": "success", {"export_id": 1}
"message": "Metadata export has started."
}
``` ```
""" """
individual_files = helpers.bool_true(individual_files) individual_files = helpers.bool_true(individual_files)
@ -7075,8 +7073,8 @@ class WebInterface(object):
export_type=export_type, export_type=export_type,
individual_files=individual_files).export() individual_files=individual_files).export()
if result is True: if isinstance(result, int):
return {'result': 'success', 'message': 'Metadata export has started.'} return {'result': 'success', 'message': 'Metadata export has started.', 'export_id': result}
else: else:
return {'result': 'error', 'message': result} return {'result': 'error', 'message': result}