- added stat_speedtest_results() method/function to collect results from scheduled speed tests

- added list_backups() method/function to list auto backups
This commit is contained in:
malle-pietje 2018-08-28 14:44:49 +02:00
parent de407e6ac0
commit 2c035878ed
2 changed files with 37 additions and 0 deletions

View File

@ -1,4 +1,5 @@
## API client class usage examples
This directory contains some PHP code examples which demonstrate usage of the PHP API client class and can be used as a good starting point for your own custom code.
### Usage

View File

@ -665,6 +665,28 @@ class Client
return $this->process_response($response);
}
/**
* Method to fetch speed test results
* ----------------------------------
* returns an array of speed test result objects
* optional parameter <start> = Unix timestamp in milliseconds
* optional parameter <end> = Unix timestamp in milliseconds
*
* NOTES:
* - defaults to the past 24 hours
* - requires a USG
*/
public function stat_speedtest_results($start = null, $end = null)
{
if (!$this->is_loggedin) return false;
$end = is_null($end) ? ((time())*1000) : intval($end);
$start = is_null($start) ? $end-(24*3600*1000) : intval($start);
$json = ['attrs' => ['xput_download','xput_upload','latency','time'], 'start' => $start, 'end' => $end];
$json = json_encode($json);
$response = $this->exec_curl('/api/s/'.$this->site.'/stat/report/archive.speedtest', 'json='.$json);
return $this->process_response($response);
}
/**
* Show all login sessions
* -----------------------
@ -1047,6 +1069,20 @@ class Client
return $this->process_response($response);
}
/**
* List auto backups
* ---------------------------
* return an array containing objects with backup details on success
*/
public function list_backups()
{
if (!$this->is_loggedin) return false;
$mac = strtolower($mac);
$json = json_encode(['cmd' => 'list-backups']);
$response = $this->exec_curl('/api/s/'.$this->site.'/cmd/backup', 'json='.$json);
return $this->process_response($response);
}
/**
* List sites
* ----------