mirror of
https://github.com/Art-of-WiFi/UniFi-API-client.git
synced 2024-11-21 17:49:59 +01:00
- 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:
parent
de407e6ac0
commit
2c035878ed
@ -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
|
||||
|
@ -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
|
||||
* ----------
|
||||
|
Loading…
Reference in New Issue
Block a user