Skip to content

Commit

Permalink
- bumped version to class v1.1.80
Browse files Browse the repository at this point in the history
- added generate_backup_site() method, contributed by @labo-jad
  • Loading branch information
malle-pietje committed Mar 28, 2023
1 parent cbe89d9 commit 67d318c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 12 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

A PHP class that provides access to Ubiquiti's [**UniFi Network Controller**](https://unifi-network.ui.com/) API.

UniFi Network Controller software versions 4.X.X, 5.X.X, 6.X.X, and 7.X.X (version 7.0.23 has been confirmed to work)
UniFi Network Controller software versions 4.X.X, 5.X.X, 6.X.X, and 7.X.X (version 7.2.93 has been confirmed to work)
are supported as well as UniFi OS-based controllers. This class is used by our API browser tool which can be found
[here](https://github.com/Art-of-WiFi/UniFi-API-browser).

Expand All @@ -27,8 +27,9 @@ Support for UniFi OS-based controllers has been added as of version 1.1.47:
- UniFi Dream Router (UDR)
- UniFi Dream Machine (UDM)
- UniFi Dream Machine Pro (UDM PRO)
- Cloud Key Gen2 (UCK G2), firmware version 2.0.24 or higher
- Cloud Key Gen2 Plus (UCK G2 Plus), firmware version 2.0.24 or higher
- UniFi Cloud Key Gen2 (UCK G2), firmware version 2.0.24 or higher
- UniFi Cloud Key Gen2 Plus (UCK G2 Plus), firmware version 2.0.24 or higher
- UniFi Cloud Console, details [here](https://help.ui.com/hc/en-us/articles/4415364143511)

The class automatically detects UniFi OS-based controllers and adjusts URLs and several functions/methods accordingly.
If your own code implements strict validation of the URL that is passed to the constructor, please adapt your
Expand Down Expand Up @@ -183,6 +184,8 @@ more details on each of the functions/methods and their respective parameters.
- edit_usergroup()
- extend_guest_validity()
- forget_sta() (supported on controller version 5.9.X and higher)
- generate_backup()
- generate_backup_site()
- invite_admin()
- led_override()
- list_admins()
Expand Down Expand Up @@ -352,7 +355,7 @@ This class is based on the initial work by the following developers:

and the API as published by Ubiquiti:

- https://dl.ui.com/unifi/7.0.23/unifi_sh_api
- https://dl.ui.com/unifi/7.0.25/unifi_sh_api

## Important Disclaimer

Expand Down
5 changes: 4 additions & 1 deletion examples/update_switch_poe-mode.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
* usage: If the file is called via a web URL, it should be called like: update_switch_poe-mode.php?poe_mode=off
* If the file is called via the command line, it should be called like: php update_switch_poe-mode.php off
* The values can be "off" or "auto"
*
* IMPORTANT INFORMATION:
* This example no longer works with controller versions 7.1.X and higher. You now need to work with port profiles to enable POE on a switch port.
*/

/**
Expand Down Expand Up @@ -91,4 +94,4 @@ function update_ports($running_config, $ports, $poe_mode){
echo json_encode($error, JSON_PRETTY_PRINT);
}

echo json_encode($update_device, JSON_PRETTY_PRINT);
echo json_encode($update_device, JSON_PRETTY_PRINT);
26 changes: 19 additions & 7 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
* @package UniFi_Controller_API_Client_Class
* @author Art of WiFi <info@artofwifi.net>
* @version Release: 1.1.79
* @version Release: 1.1.80
* @license This class is subject to the MIT license that is bundled with this package in the file LICENSE.md
* @example This directory in the package repository contains a collection of examples:
* https://github.com/Art-of-WiFi/UniFi-API-client/tree/master/examples
Expand All @@ -26,7 +26,7 @@ class Client
* NOTE:
* do not modify the values here, instead use the constructor or the getter and setter functions/methods
*/
const CLASS_VERSION = '1.1.79';
const CLASS_VERSION = '1.1.80';
protected $baseurl = 'https://127.0.0.1:8443';
protected $user = '';
protected $password = '';
Expand Down Expand Up @@ -424,8 +424,7 @@ public function create_user($mac, $user_group_id, $name = null, $note = null, $i
* Add/modify/remove a client-device note
*
* @param string $user_id id of the client-device to be modified
* @param string $note optional, note to be applied to the client-device, when empty or not set,
* the existing note for the client-device is removed and "noted" attribute set to false
* @param string $note optional, note to be applied to the client-device
* @return bool returns true upon success
*/
public function set_sta_note($user_id, $note = '')
Expand Down Expand Up @@ -1448,10 +1447,9 @@ public function list_known_rogueaps()
}

/**
* Generate backup
* Generate a backup
*
* NOTES:
* this is an experimental function, please do not use unless you know exactly what you're doing
* NOTES: this is an experimental function, please do not use unless you know exactly what you're doing
*
* @return array|bool URL from where the backup file can be downloaded once generated, false upon failure
*/
Expand All @@ -1472,6 +1470,20 @@ public function list_backups()
return $this->fetch_results('/api/s/' . $this->site . '/cmd/backup', $payload);
}

/**
* Generate a backup/export of the current site
*
* NOTES: this is an experimental function, please do not use unless you know exactly what you're doing
*
* @return array|bool URL from where the backup/export file can be downloaded once generated, false upon failure
*/
public function generate_backup_site()
{
$payload = ['cmd' => 'export-site'];

return $this->fetch_results('/api/s/' . $this->site . '/cmd/backup', $payload);
}

/**
* Fetch sites
*
Expand Down

0 comments on commit 67d318c

Please sign in to comment.