N4S4 / synology-api

A Python wrapper around Synology API
MIT License
368 stars 138 forks source link

Enhancement suggestion for Backup Tasks #77

Closed therealj4nd3rs0n closed 2 years ago

therealj4nd3rs0n commented 2 years ago

I have been trying to get backup task status via API calls for years with no success. I found a reference to user 'leirn' and their project to monitor Syno things with nagios. In there was the key, undocumented extended attributes to pass to the 'status' method of SYNO.Backup.Task. I have no idea how 'leirn' found this, credit to him or her. I am sorry I do not have time to properly contribute the code changes, so I offer the extended attributes to someone who does. The normal 'status' method will only return the job's config status, is it a job that is configured correctly. If what you really want is the result from the last time the job ran, get the task_id with a call to backup_task_list, then use this new function:

def backup_task_result(self, taskid):
    api_name = 'SYNO.Backup.Task'
    info = self.gen_list[api_name]
    api_path = info['path']
    req_param = {'version': info['minVersion'], 'method': 'status', 'blOnline': 'false', 'additional': '["last_bkp_time","next_bkp_time","last_bkp_result","is_modified","last_bkp_progress"]', 'task_id': taskid}

I tested it against DSM6, I have not upgraded to DSM7 yet so no idea how it works there.

N4S4 commented 2 years ago

Oh ok grat I will work on that :+1:

N4S4 commented 2 years ago

Closed with PR #78 #79