Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
acc783520f | ||
|
|
e95961834b | ||
|
|
6f8d90b4f0 | ||
|
|
1a9de7cb47 | ||
|
|
c1e398118d | ||
|
|
766eac5944 | ||
|
|
d0df4db012 | ||
|
|
0981857a39 | ||
|
|
f2050c1e00 | ||
|
|
02c0953294 | ||
|
|
e9bdb783c9 | ||
|
|
d240294cee | ||
|
|
ba7e10f1c0 | ||
|
|
465c223c15 | ||
|
|
6995d10419 | ||
|
|
fe4c18c53e | ||
|
|
05cb58b9f1 |
8
.gitignore
vendored
8
.gitignore
vendored
@@ -13,4 +13,10 @@
|
||||
*.xml
|
||||
|
||||
# ignore PHPStorm files
|
||||
.idea/*
|
||||
.idea/*
|
||||
|
||||
# ignore the TODO list
|
||||
TODO.md
|
||||
|
||||
# ignore Claude Code files
|
||||
CLAUDE*.md
|
||||
1284
API_REFERENCE.md
1284
API_REFERENCE.md
File diff suppressed because it is too large
Load Diff
94
README.md
94
README.md
@@ -14,33 +14,45 @@ The package can be installed manually or by using
|
||||
composer/[packagist](https://packagist.org/packages/art-of-wifi/unifi-api-client) for
|
||||
easy inclusion in your projects. See the [installation instructions](#Installation) below for more details.
|
||||
|
||||
|
||||
## Why use this API client?
|
||||
|
||||
- Easy to use: clear docs, comprehensive method coverage, and helpful examples.
|
||||
- Broad coverage: exposes many UniFi endpoints not (yet) available in the official APIs.
|
||||
- Composer-friendly: installable via [Composer](https://getcomposer.org) and works with modern PHP projects.
|
||||
- Lightweight and dependency-free: no external libraries required; uses cURL.
|
||||
- Secure: communicates over TLS and supports optional SSL certificate validation.
|
||||
- Flexible and extensible: includes `custom_api_request()` for calling any API endpoint.
|
||||
- Robust error handling: throws named Exceptions for precise try/catch handling.
|
||||
- Actively maintained: regular updates and compatibility with recent UniFi versions.
|
||||
|
||||
|
||||
## Supported Versions
|
||||
|
||||
| Software | Versions |
|
||||
|--------------------------------------|-----------------------------------------------------------|
|
||||
| UniFi Network Application/controller | 5.x, 6.x, 7.x, 8.x, 9.x, 10.x (**10.0.140 is confirmed**) |
|
||||
| UniFi OS | 3.x, 4.x, 5.x (**5.0.4 is confirmed**) |
|
||||
| UniFi Network Application/controller | 5.x, 6.x, 7.x, 8.x, 9.x, 10.x (**10.0.154 is confirmed**) |
|
||||
| UniFi OS | 3.x, 4.x, 5.x (**5.0.5 is confirmed**) |
|
||||
|
||||
|
||||
## Requirements
|
||||
|
||||
- a server with:
|
||||
- a server or desktop with:
|
||||
- PHP **7.4.0** or higher (use version [1.1.83](https://github.com/Art-of-WiFi/UniFi-API-client/releases/tag/v1.1.83)
|
||||
for PHP 7.3.x and lower)
|
||||
- PHP json and PHP cURL modules enabled
|
||||
- direct network connectivity between this server and the host and port (usually TCP port 8443, port 11443 for UniFi OS
|
||||
Server, or port 443 for UniFi OS consoles) where the UniFi Network Application is running
|
||||
- PHP cURL (`php-curl`) module enabled
|
||||
- direct network connectivity between this server/desktop and the host and port where the UniFi Network Application is
|
||||
running (usually TCP port 8443, port 11443 for UniFi OS Server, or port 443 for UniFi OS consoles)
|
||||
- you **must** use an admin **account with local access permissions** to access the API through this class as explained
|
||||
here: https://artofwifi.net/blog/use-local-admin-account-unifi-api-captive-portal
|
||||
here:
|
||||
https://artofwifi.net/blog/use-local-admin-account-unifi-api-captive-portal
|
||||
- do **not** use UniFi Cloud accounts and do not enable MFA/2FA for the accounts that you use with this class
|
||||
|
||||
|
||||
## UniFi OS Support
|
||||
|
||||
Besides the classic "software-based" UniFi Network Application, this class also supports UniFi OS-based
|
||||
controllers starting from version **1.1.47**.
|
||||
|
||||
These applications/devices/services have been verified to work:
|
||||
Starting from version **1.1.47**, this API client also supports UniFi OS-based controllers. These
|
||||
applications/devices/services have been verified to work:
|
||||
- UniFi OS Server, announcement [here](https://blog.ui.com/article/introducing-unifi-os-server)
|
||||
- UniFi Dream Router (UDR)
|
||||
- UniFi Dream Machine (UDM)
|
||||
@@ -55,22 +67,21 @@ These applications/devices/services have been verified to work:
|
||||
- Official UniFi Hosting, details [here](https://help.ui.com/hc/en-us/articles/4415364143511)
|
||||
- HostiFi UniFi Cloud Hosting, details [here](https://hostifi.com/unifi)
|
||||
|
||||
The class automatically detects UniFi OS consoles/servers and adjusts the URLs and several functions/methods
|
||||
accordingly.
|
||||
The class automatically detects UniFi OS consoles/servers and adjusts URLs and several functions/methods accordingly.
|
||||
|
||||
UniFi OS-based consoles require you to connect using port **443** instead of **8443** which is used for
|
||||
the classic "software-based" controllers. When using **UniFi OS Server**, you are required to use port **11443**.
|
||||
|
||||
If your own code implements strict validation of the URL that is passed to the constructor, please adapt your logic to
|
||||
allow URLs without a port suffix, with port 443 or port 11443 when working with a UniFi OS-based controller.
|
||||
UniFi OS-based consoles require you to connect using port **443** while **8443** which is used for
|
||||
the self-hosted/software-based controllers. When connecting to **UniFi OS Server**, you are required to use port
|
||||
**11443**.
|
||||
|
||||
|
||||
### Remote API access to UniFi OS-based controllers
|
||||
### Remote API access to UniFi OS-based gateways
|
||||
When connecting to a UniFi OS-based gateway through the WAN interface, you need to create a specific firewall rule to
|
||||
allow this. See this blog post on the Art of WiFi website for more details:
|
||||
allow this. See this blog post on the Art of WiFi website for detailed instructions when using the **"Classic"**
|
||||
firewall:
|
||||
https://artofwifi.net/blog/how-to-access-the-unifi-controller-by-wan-ip-or-hostname-on-a-udm-pro
|
||||
|
||||
The "custom firewall rule" approach described there is the recommended method.
|
||||
See this blog post when using the **Zone-Based firewall** (ZBF):
|
||||
https://artofwifi.net/blog/how-to-access-the-unifi-controller-by-wan-ip-or-hostname-on-a-udm-pro-using-zbf
|
||||
|
||||
|
||||
## Upgrading from previous versions
|
||||
@@ -116,7 +127,7 @@ require_once 'vendor/autoload.php';
|
||||
|
||||
## Example usage
|
||||
|
||||
A basic example of how to use the class:
|
||||
A quick and basic example of how to use the class:
|
||||
|
||||
```php
|
||||
/**
|
||||
@@ -133,6 +144,7 @@ $login = $unifi_connection->login();
|
||||
$results = $unifi_connection->list_alarms(); // returns a PHP array containing alarm objects
|
||||
```
|
||||
|
||||
|
||||
#### IMPORTANT NOTES:
|
||||
|
||||
1. In the above example, `$site_id` is the short site "name" (usually 8 characters long) that is visible in the URL when
|
||||
@@ -153,6 +165,9 @@ $results = $unifi_connection->list_alarms(); // returns a PHP array con
|
||||
[issue](https://github.com/Art-of-WiFi/UniFi-API-browser/issues/94) for an example where the WPA2 password isn't
|
||||
visible for **read-only** administrator accounts.
|
||||
|
||||
### Code Examples:
|
||||
|
||||
More code examples are available in the [`examples/`](examples/) directory.
|
||||
|
||||
## Exception handling
|
||||
|
||||
@@ -218,7 +233,7 @@ try {
|
||||
```
|
||||
|
||||
Although the PHP DocBlocks for most public methods/functions contain `@throws Exception`, it is recommended to catch
|
||||
other specific Exceptions that can be thrown by the API Client class to provide more detailed error messages to your
|
||||
specific Exceptions that can be thrown by the API Client class to provide more detailed error messages to your
|
||||
application code.
|
||||
|
||||
In most cases, the class will let Exceptions bubble up to the calling code, but in some cases it will catch them and
|
||||
@@ -237,16 +252,30 @@ their purpose, and their respective parameters.
|
||||
If you are using an advanced IDE such as PHPStorm or VS Code, you can use its code completion and other
|
||||
features to explore the available functions/methods thanks to the extensive PHP DocBlocks throughout the code.
|
||||
|
||||
For a quick overview of the available functions/methods, you can also check the API Reference here:
|
||||
|
||||
For a quick overview of the available functions/methods, you can also check the API Reference here:
|
||||
[API Reference](API_REFERENCE.md)
|
||||
|
||||
|
||||
## Need help or have suggestions?
|
||||
|
||||
There is still work to be done to add functionality and further improve the usability of
|
||||
this class, so all suggestions/comments are welcome. Please use the GitHub
|
||||
[Issues section](https://github.com/Art-of-WiFi/UniFi-API-client/issues) or the Ubiquiti
|
||||
Community forums (https://community.ui.com/questions/PHP-client-class-to-access-the-UniFi-controller-API-updates-and-discussion-part-2/a793904e-6023-4a7f-bcae-340db2a03fc1)
|
||||
to share your suggestions and questions.
|
||||
|
||||
|
||||
#### IMPORTANT NOTE:
|
||||
When encountering issues with the UniFi API using other libraries, cURL or Postman, please do **not** open an Issue.
|
||||
Such issues will be closed immediately. Please use the [Discussions](https://github.com/Art-of-WiFi/UniFi-API-client/discussions) section instead.
|
||||
|
||||
|
||||
## Looking for version 1.x.x?
|
||||
|
||||
With versions 1.x.x of the API client, the entire client was contained within a single file which can be useful in
|
||||
specific cases.
|
||||
This has changed with version 2.0.0 where the code is now split across multiple files and is managed using composer.
|
||||
This has changed with version 2.0.0 where the code is now split across multiple files and inclusion in your project is
|
||||
managed using composer.
|
||||
|
||||
If you are looking for the version 1.x.x code, you can tell composer to install that version by using the following
|
||||
syntax in your `composer.json` file:
|
||||
@@ -263,19 +292,6 @@ Alternatively, you can download the latest 1.x.x code from the [releases page](h
|
||||
|
||||
Whenever necessary, we will make sure to update the **version_1** branch with the latest 1.x.x code.
|
||||
|
||||
## Need help or have suggestions?
|
||||
|
||||
There is still work to be done to add functionality and further improve the usability of
|
||||
this class, so all suggestions/comments are welcome. Please use the GitHub
|
||||
[Issues section](https://github.com/Art-of-WiFi/UniFi-API-client/issues) or the Ubiquiti
|
||||
Community forums (https://community.ubnt.com/t5/UniFi-Wireless/PHP-class-to-access-the-UniFi-controller-API-updates-and/td-p/1512870)
|
||||
to share your suggestions and questions.
|
||||
|
||||
|
||||
#### IMPORTANT NOTE:
|
||||
When encountering issues with the UniFi API using other libraries, cURL or Postman, please do **not** open an Issue. Such issues will be closed immediately.
|
||||
Please use the [Discussions](https://github.com/Art-of-WiFi/UniFi-API-client/discussions) section instead.
|
||||
|
||||
|
||||
## Credits
|
||||
|
||||
|
||||
289
src/Client.php
289
src/Client.php
@@ -36,7 +36,7 @@ use UniFi_API\Exceptions\NotAUnifiOsConsoleException;
|
||||
class Client
|
||||
{
|
||||
/** Constants. */
|
||||
const CLASS_VERSION = '2.0.8';
|
||||
const CLASS_VERSION = '2.0.11';
|
||||
const CURL_METHODS_ALLOWED = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH'];
|
||||
const DEFAULT_CURL_METHOD = 'GET';
|
||||
|
||||
@@ -233,7 +233,10 @@ class Client
|
||||
|
||||
/** If the HTTP response code is 200, we are logged in. */
|
||||
if ($http_code === 200) {
|
||||
curl_close($ch);
|
||||
if(PHP_VERSION_ID < 80500) {
|
||||
curl_close($ch);
|
||||
}
|
||||
|
||||
return $this->is_logged_in = true;
|
||||
}
|
||||
|
||||
@@ -283,7 +286,9 @@ class Client
|
||||
throw new CurlGeneralErrorException(curl_error($ch), curl_getinfo($ch, CURLINFO_RESPONSE_CODE), curl_getinfo($ch));
|
||||
}
|
||||
|
||||
curl_close($ch);
|
||||
if(PHP_VERSION_ID < 80500) {
|
||||
curl_close($ch);
|
||||
}
|
||||
|
||||
$this->is_logged_in = false;
|
||||
$this->cookies = '';
|
||||
@@ -402,8 +407,7 @@ class Client
|
||||
/**
|
||||
* Forget one or more client devices.
|
||||
*
|
||||
* @note only supported with controller versions 5.9.X and higher, can be
|
||||
* slow (up to 5 minutes) on larger controllers
|
||||
* @note can be slow (up to 5 minutes) on larger controllers
|
||||
* @param array|string $mac array of client MAC addresses (strings) or a single MAC address string
|
||||
* @return bool true upon success
|
||||
* @throws Exception|MacAddressEmptyException|MacAddressInvalidException
|
||||
@@ -505,7 +509,6 @@ class Client
|
||||
* Fetch 5-minute site stats.
|
||||
*
|
||||
* @note - defaults to the past 12 hours
|
||||
* - this function/method is only supported on controller versions 5.5.* and later
|
||||
* - make sure that the retention policy for 5 minutes stats is set to the correct value in
|
||||
* the controller settings
|
||||
* @param int|null $start optional, Unix timestamp in milliseconds
|
||||
@@ -531,11 +534,8 @@ class Client
|
||||
/**
|
||||
* Fetch hourly site stats.
|
||||
*
|
||||
* TODO: add support for optional attrib parameter
|
||||
* airtime_avg
|
||||
*
|
||||
* @todo add support for optional attrib parameter: airtime_avg
|
||||
* @note - defaults to the past 7*24 hours
|
||||
* - "bytes" are no longer returned with controller version 4.9.1 and later
|
||||
* @param int|null $start optional, Unix timestamp in milliseconds
|
||||
* @param int|null $end optional, Unix timestamp in milliseconds
|
||||
* @param array|null $attribs optional, array of attributes to collect.
|
||||
@@ -557,7 +557,6 @@ class Client
|
||||
* Fetch daily site stats.
|
||||
*
|
||||
* @note - defaults to the past 52*7*24 hours
|
||||
* - "bytes" are no longer returned with controller version 4.9.1 and later
|
||||
* @param int|null $start optional, Unix timestamp in milliseconds
|
||||
* @param int|null $end optional, Unix timestamp in milliseconds
|
||||
* @param array|null $attribs optional, array of attributes to collect.
|
||||
@@ -579,7 +578,6 @@ class Client
|
||||
* Fetch monthly site stats.
|
||||
*
|
||||
* @note - defaults to the past 52 weeks (52*7*24 hours)
|
||||
* - "bytes" are no longer returned with controller version 4.9.1 and later
|
||||
* @param int|null $start optional, Unix timestamp in milliseconds
|
||||
* @param int|null $end optional, Unix timestamp in milliseconds
|
||||
* @param array|null $attribs optional, array of attributes to collect.
|
||||
@@ -601,37 +599,18 @@ class Client
|
||||
* Fetch 5-minutes stats for a single access point or all access points.
|
||||
*
|
||||
* @note - defaults to the past 12 hours
|
||||
* - this function/method is only supported on controller versions 5.5.* and later
|
||||
* - make sure that the retention policy for 5 minutes stats is set to the correct value in
|
||||
* the controller settings
|
||||
* @param int|null $start optional, Unix timestamp in milliseconds
|
||||
* @param int|null $end optional, Unix timestamp in milliseconds
|
||||
* @param string|null $mac optional, AP MAC address to return stats for, when empty,
|
||||
* stats for all APs are returned
|
||||
* @param array|null $attribs optional, array of attributes to collect, default: (bytes, num_sta, time). Example values:
|
||||
* 'bytes',
|
||||
* 'num_sta',
|
||||
* 'time',
|
||||
* 'wifi_tx_attempts',
|
||||
* 'tx_retries',
|
||||
* 'wifi_tx_dropped',
|
||||
* 'mac_filter_rejections',
|
||||
* 'user-wlan-num_sta_connected',
|
||||
* 'user-wlan-num_sta_disconnected',
|
||||
* 'na-wifi_tx_attempts',
|
||||
* 'ng-wifi_tx_attempts',
|
||||
* 'na-wifi_tx_dropped',
|
||||
* 'ng-wifi_tx_dropped',
|
||||
* 'na-tx_retries',
|
||||
* 'ng-tx_retries',
|
||||
* 'na-tx_packets',
|
||||
* 'ng-tx_packets',
|
||||
* 'na-tx_bytes',
|
||||
* 'ng-tx_bytes',
|
||||
* 'na-rx_packets',
|
||||
* 'ng-rx_packets',
|
||||
* 'na-rx_bytes',
|
||||
* 'ng-rx_bytes',
|
||||
* @param array|null $attribs optional, array of attributes to collect, default: (bytes, num_sta, time). Valid values:
|
||||
* bytes, num_sta, time, wifi_tx_attempts, tx_retries, wifi_tx_dropped,
|
||||
* mac_filter_rejections, user-wlan-num_sta_connected, user-wlan-num_sta_disconnected,
|
||||
* na-wifi_tx_attempts, ng-wifi_tx_attempts, na-wifi_tx_dropped, ng-wifi_tx_dropped,
|
||||
* na-tx_retries, ng-tx_retries, na-tx_packets, ng-tx_packets, na-tx_bytes,
|
||||
* ng-tx_bytes, na-rx_packets, ng-rx_packets, na-rx_bytes, ng-rx_bytes
|
||||
* @return array|bool returns an array of 5-minute stats objects
|
||||
* @throws Exception
|
||||
*/
|
||||
@@ -658,7 +637,7 @@ class Client
|
||||
* @param int|null $start optional, Unix timestamp in milliseconds
|
||||
* @param int|null $end optional, Unix timestamp in milliseconds
|
||||
* @param string|null $mac optional, AP MAC address to return stats for, when empty,
|
||||
* stats for all APs are returned
|
||||
* stats for all APs are returned
|
||||
* @param array|null $attribs optional, array of attributes to collect, default: (bytes, num_sta, time).
|
||||
* @return array|bool returns an array of hourly stats objects
|
||||
* @throws Exception
|
||||
@@ -740,7 +719,6 @@ class Client
|
||||
* Fetch 5-minutes stats for a single user/client device or all user/client devices.
|
||||
*
|
||||
* @note - defaults to the past 12 hours
|
||||
* - only supported with UniFi controller versions 5.8.X and higher
|
||||
* - make sure that the retention policy for 5-minute stats is set to the correct value in
|
||||
* the controller settings
|
||||
* - make sure that the "Clients Historical Data" option has been enabled in the UniFi controller settings in
|
||||
@@ -769,7 +747,6 @@ class Client
|
||||
* Fetch hourly stats for a single user/client device or all user/client devices.
|
||||
*
|
||||
* @note - defaults to the past 7*24 hours
|
||||
* - only supported with UniFi controller versions 5.8.X and higher
|
||||
* - make sure that the retention policy for hourly stats is set to the correct value in
|
||||
* the controller settings
|
||||
* - make sure that "Clients Historical Data" has been enabled in the UniFi controller settings in the Maintenance
|
||||
@@ -800,7 +777,6 @@ class Client
|
||||
* Fetch daily stats for a single user/client device or all user/client devices.
|
||||
*
|
||||
* @note - defaults to the past 7*24 hours
|
||||
* - only supported with UniFi controller versions 5.8.X and higher
|
||||
* - make sure that the retention policy for daily stats is set to the correct value in
|
||||
* the controller settings
|
||||
* - make sure that "Clients Historical Data" has been enabled in the UniFi controller settings in the Maintenance
|
||||
@@ -831,7 +807,6 @@ class Client
|
||||
* Fetch monthly stats for a single user/client device or all user/client devices.
|
||||
*
|
||||
* @note - defaults to the past 13 weeks (52*7*24 hours)
|
||||
* - only supported with UniFi controller versions 5.8.X and higher
|
||||
* - make sure that the retention policy for monthly stats is set to the correct value in
|
||||
* the controller settings
|
||||
* - make sure that "Clients Historical Data" has been enabled in the UniFi controller settings in the Maintenance
|
||||
@@ -862,7 +837,6 @@ class Client
|
||||
* Fetch 5-minute gateway stats.
|
||||
*
|
||||
* @note - defaults to the past 12 hours
|
||||
* - this function/method is only supported on controller versions 5.5.* and later
|
||||
* - make sure that the retention policy for 5 minutes stats is set to the correct value in
|
||||
* the controller settings
|
||||
* - requires a UniFi gateway
|
||||
@@ -975,7 +949,6 @@ class Client
|
||||
*
|
||||
* @note - defaults to the past 24 hours
|
||||
* - requires a UniFi gateway
|
||||
* - supported in UniFi controller versions 5.9.X and higher
|
||||
* @param int|null $start optional, Unix timestamp in milliseconds
|
||||
* @param int|null $end optional, Unix timestamp in milliseconds
|
||||
* @param int|null $limit optional, maximum number of events to return, defaults to 10000
|
||||
@@ -1080,8 +1053,7 @@ class Client
|
||||
* Fetch guest devices
|
||||
*
|
||||
* @note defaults to the past 7*24 hours
|
||||
* @param int $within optional, time frame in hours to go back to list guests with valid access (default = 24*365
|
||||
* hours)
|
||||
* @param int $within optional, time frame in hours to go back to list guests with valid access (default = 24*365 hours)
|
||||
* @return array|bool returns an array of guest device objects with valid access
|
||||
* @throws Exception
|
||||
*/
|
||||
@@ -1095,8 +1067,7 @@ class Client
|
||||
/**
|
||||
* Fetch online client device(s)
|
||||
*
|
||||
* @param string|null $mac optional, the MAC address of a single online client device for which the call must be
|
||||
* made
|
||||
* @param string|null $mac optional, the MAC address of a single online client device for which the call must be made
|
||||
* @return array|bool returns an array of online client device objects, or in case of a single device request, returns a
|
||||
* single client device object, false upon error
|
||||
* @throws Exception|MacAddressEmptyException|MacAddressInvalidException
|
||||
@@ -1506,8 +1477,8 @@ class Client
|
||||
* Fetch dashboard metrics.
|
||||
*
|
||||
* @param boolean $five_minutes when true, return stats based on 5 minute intervals,
|
||||
* returns hourly stats by default (supported on controller versions 5.5.* and higher)
|
||||
* @return array|bool containing dashboard metric objects (available since controller version 4.9.1.alpha)
|
||||
* returns hourly stats by default
|
||||
* @return array|bool containing dashboard metric objects
|
||||
* @throws Exception
|
||||
*/
|
||||
public function list_dashboard(bool $five_minutes = false)
|
||||
@@ -1566,7 +1537,6 @@ class Client
|
||||
/**
|
||||
* Fetch (device) tags (using REST).
|
||||
*
|
||||
* @note this endpoint was introduced with controller versions 5.5.X
|
||||
* @return array|bool containing known device tag objects
|
||||
* @throws Exception
|
||||
*/
|
||||
@@ -1578,7 +1548,6 @@ class Client
|
||||
/**
|
||||
* Create a (device) tag (using REST).
|
||||
*
|
||||
* @note this endpoint was introduced with controller versions 5.5.X
|
||||
* @param string $name required, the tag name to add
|
||||
* @param array|null $macs optional, an array of the MAC address(es) for the device(s) to tag with the new tag
|
||||
* @return bool return true on success
|
||||
@@ -1598,7 +1567,6 @@ class Client
|
||||
/**
|
||||
* Set tagged devices (using REST).
|
||||
*
|
||||
* @note this endpoint was introduced with controller versions 5.5.X
|
||||
* @param array $macs required, an array of the MAC address(es) for the device(s) to tag
|
||||
* @param string $tag_id required, the _id value of the tag to set
|
||||
* @return bool return true on success
|
||||
@@ -1616,7 +1584,6 @@ class Client
|
||||
/**
|
||||
* Get a (device) tag (using REST).
|
||||
*
|
||||
* @note this endpoint was introduced with controller versions 5.5.X
|
||||
* @param string $tag_id required, the _id value of the tag to retrieve
|
||||
* @return array|bool containing matching tag objects
|
||||
* @throws Exception
|
||||
@@ -1631,7 +1598,6 @@ class Client
|
||||
/**
|
||||
* Delete a (device) tag (using REST).
|
||||
*
|
||||
* @note this endpoint was introduced with controller versions 5.5.X
|
||||
* @param string $tag_id required, the _id value of the tag to set
|
||||
* @return bool return true on success
|
||||
* @throws Exception
|
||||
@@ -1738,7 +1704,6 @@ class Client
|
||||
/**
|
||||
* Fetch sites stats.
|
||||
*
|
||||
* @note this endpoint was introduced with controller version 5.2.9
|
||||
* @return array|bool statistics for all sites hosted on this controller
|
||||
* @throws Exception
|
||||
*/
|
||||
@@ -1806,8 +1771,10 @@ class Client
|
||||
{
|
||||
$this->curl_method = 'PUT';
|
||||
|
||||
return $this->fetch_results_boolean('/api/s/' . $this->site . '/rest/setting/country/' . trim($country_id),
|
||||
$payload);
|
||||
return $this->fetch_results_boolean(
|
||||
'/api/s/' . $this->site . '/rest/setting/country/' . trim($country_id),
|
||||
$payload
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1827,8 +1794,10 @@ class Client
|
||||
{
|
||||
$this->curl_method = 'PUT';
|
||||
|
||||
return $this->fetch_results_boolean('/api/s/' . $this->site . '/rest/setting/locale/' . trim($locale_id),
|
||||
$payload);
|
||||
return $this->fetch_results_boolean(
|
||||
'/api/s/' . $this->site . '/rest/setting/locale/' . trim($locale_id),
|
||||
$payload
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1845,7 +1814,10 @@ class Client
|
||||
{
|
||||
$this->curl_method = 'PUT';
|
||||
|
||||
return $this->fetch_results_boolean('/api/s/' . $this->site . '/rest/setting/snmp/' . trim($snmp_id), $payload);
|
||||
return $this->fetch_results_boolean(
|
||||
'/api/s/' . $this->site . '/rest/setting/snmp/' . trim($snmp_id),
|
||||
$payload
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1862,7 +1834,10 @@ class Client
|
||||
{
|
||||
$this->curl_method = 'PUT';
|
||||
|
||||
return $this->fetch_results_boolean('/api/s/' . $this->site . '/rest/setting/mgmt/' . trim($mgmt_id), $payload);
|
||||
return $this->fetch_results_boolean(
|
||||
'/api/s/' . $this->site . '/rest/setting/mgmt/' . trim($mgmt_id),
|
||||
$payload
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1879,8 +1854,10 @@ class Client
|
||||
{
|
||||
$this->curl_method = 'PUT';
|
||||
|
||||
return $this->fetch_results_boolean('/api/s/' . $this->site . '/rest/setting/guest_access/' . trim($guest_access_id),
|
||||
$payload);
|
||||
return $this->fetch_results_boolean(
|
||||
'/api/s/' . $this->site . '/rest/setting/guest_access/' . trim($guest_access_id),
|
||||
$payload
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1897,7 +1874,10 @@ class Client
|
||||
{
|
||||
$this->curl_method = 'PUT';
|
||||
|
||||
return $this->fetch_results_boolean('/api/s/' . $this->site . '/rest/setting/ntp/' . trim($ntp_id), $payload);
|
||||
return $this->fetch_results_boolean(
|
||||
'/api/s/' . $this->site . '/rest/setting/ntp/' . trim($ntp_id),
|
||||
$payload
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1914,8 +1894,10 @@ class Client
|
||||
{
|
||||
$this->curl_method = 'PUT';
|
||||
|
||||
return $this->fetch_results_boolean('/api/s/' . $this->site . '/rest/setting/connectivity/' . trim($connectivity_id),
|
||||
$payload);
|
||||
return $this->fetch_results_boolean(
|
||||
'/api/s/' . $this->site . '/rest/setting/connectivity/' . trim($connectivity_id),
|
||||
$payload
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1955,11 +1937,9 @@ class Client
|
||||
* permissions, default value is false which gives the new admin
|
||||
* Administrator permissions
|
||||
* @param bool $device_adopt optional, whether the new admin has permissions to
|
||||
* adopt devices, default value is false. With versions < 5.9.X this only applies
|
||||
* when readonly is true.
|
||||
* adopt devices, default value is false.
|
||||
* @param bool $device_restart optional, whether the new admin has permissions to
|
||||
* restart devices, default value is false. With versions < 5.9.X this only applies
|
||||
* when readonly is true.
|
||||
* restart devices, default value is false.
|
||||
* @return bool true on success
|
||||
* @throws EmailInvalidException|Exception
|
||||
*/
|
||||
@@ -2006,16 +1986,13 @@ class Client
|
||||
* Assign an existing admin to the current site.
|
||||
*
|
||||
* @param string $admin_id _id value of the admin user to assign, can be obtained using the
|
||||
* list_all_admins() method/function
|
||||
* list_all_admins() method/function
|
||||
* @param bool $readonly optional, whether the new admin has readonly
|
||||
* permissions, default value is false which gives the new admin
|
||||
* Administrator permissions
|
||||
* permissions, default value is false which gives the new admin Administrator permissions
|
||||
* @param bool $device_adopt optional, whether the new admin has permissions to
|
||||
* adopt devices, default value is false. With versions < 5.9.X this only applies
|
||||
* when readonly is true.
|
||||
* adopt devices, default value is false.
|
||||
* @param bool $device_restart optional, whether the new admin has permissions to
|
||||
* restart devices, default value is false. With versions < 5.9.X this only applies
|
||||
* when readonly is true.
|
||||
* restart devices, default value is false.
|
||||
* @return bool true on success
|
||||
* @throws Exception
|
||||
*/
|
||||
@@ -2060,11 +2037,9 @@ class Client
|
||||
* permissions, default value is false which gives the new admin
|
||||
* Administrator permissions
|
||||
* @param bool $device_adopt optional, whether the new admin has permissions to
|
||||
* adopt devices, default value is false. With versions < 5.9.X this only applies
|
||||
* when readonly is true.
|
||||
* adopt devices, default value is false.
|
||||
* @param bool $device_restart optional, whether the new admin has permissions to
|
||||
* restart devices, default value is false. With versions < 5.9.X this only applies
|
||||
* when readonly is true.
|
||||
* restart devices, default value is false.
|
||||
* @return bool true on success
|
||||
* @throws EmailInvalidException|Exception
|
||||
*/
|
||||
@@ -2076,7 +2051,7 @@ class Client
|
||||
bool $readonly = false,
|
||||
bool $device_adopt = false,
|
||||
bool $device_restart = false,
|
||||
bool $is_super = null
|
||||
?bool $is_super = null
|
||||
): bool
|
||||
{
|
||||
$email = trim($email);
|
||||
@@ -2107,7 +2082,7 @@ class Client
|
||||
$payload['permissions'][] = 'API_DEVICE_RESTART';
|
||||
}
|
||||
|
||||
if ($is_super) {
|
||||
if (!is_null($is_super)) {
|
||||
$payload['is_super'] = $is_super;
|
||||
}
|
||||
|
||||
@@ -2299,7 +2274,7 @@ class Client
|
||||
* @param int $minutes minutes the voucher is valid after activation (expiration time)
|
||||
* @param int $count number of vouchers to create, default value is 1
|
||||
* @param int $quota single-use or multi-use vouchers, value '0' is for multi-use, '1' is for single-use,
|
||||
* 'n' is for multi-use n times
|
||||
* 'n' is for multi-use n times
|
||||
* @param string $note note text to add to voucher when printing
|
||||
* @param int|null $up upload speed limit in kbps
|
||||
* @param int|null $down download speed limit in kbps
|
||||
@@ -2674,8 +2649,6 @@ class Client
|
||||
*
|
||||
* @note - a disabled device is excluded from the dashboard status and device count and its LED and WLAN are turned off
|
||||
* - appears to only be supported for access points
|
||||
* - available since controller versions 5.2.X
|
||||
*
|
||||
* @param string $ap_id value of _id for the access point which can be obtained from the device list
|
||||
* @param bool $disable true disables the device, false enables the device
|
||||
* @return bool true on success
|
||||
@@ -2693,7 +2666,6 @@ class Client
|
||||
/**
|
||||
* Override LED mode for a device (using REST).
|
||||
*
|
||||
* @note available since controller versions 5.2.X
|
||||
* @param string $device_id value of _id for the device which can be obtained from the device list
|
||||
* @param string $override_mode off/on/default; "off" disables the LED of the device,
|
||||
* "on" enables the LED of the device,
|
||||
@@ -2711,7 +2683,10 @@ class Client
|
||||
|
||||
$payload = ['led_override' => $override_mode];
|
||||
|
||||
return $this->fetch_results_boolean('/api/s/' . $this->site . '/rest/device/' . trim($device_id), $payload);
|
||||
return $this->fetch_results_boolean(
|
||||
'/api/s/' . $this->site . '/rest/device/' . trim($device_id),
|
||||
$payload
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2777,7 +2752,7 @@ class Client
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign access point to another WLAN group.
|
||||
* Assign an access point to another WLAN group.
|
||||
*
|
||||
* @param string $type_id WLAN type, can be either 'ng' (for WLANs 2G (11n/b/g)) or 'na' (WLANs 5G (11n/a/ac))
|
||||
* @param string $device_id _id value of the access point to be modified
|
||||
@@ -2857,7 +2832,10 @@ class Client
|
||||
$section_id = '/' . $section_id;
|
||||
}
|
||||
|
||||
return $this->fetch_results_boolean('/api/s/' . $this->site . '/set/setting/guest_access' . $section_id, $payload);
|
||||
return $this->fetch_results_boolean(
|
||||
'/api/s/' . $this->site . '/set/setting/guest_access' . $section_id,
|
||||
$payload
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2887,7 +2865,10 @@ class Client
|
||||
*/
|
||||
public function set_super_mgmt_settings_base(string $settings_id, $payload): bool
|
||||
{
|
||||
return $this->fetch_results_boolean('/api/s/' . $this->site . '/set/setting/super_mgmt/' . trim($settings_id), $payload);
|
||||
return $this->fetch_results_boolean(
|
||||
'/api/s/' . $this->site . '/set/setting/super_mgmt/' . trim($settings_id),
|
||||
$payload
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2903,7 +2884,10 @@ class Client
|
||||
*/
|
||||
public function set_super_smtp_settings_base(string $settings_id, $payload): bool
|
||||
{
|
||||
return $this->fetch_results_boolean('/api/s/' . $this->site . '/set/setting/super_smtp/' . trim($settings_id), $payload);
|
||||
return $this->fetch_results_boolean(
|
||||
'/api/s/' . $this->site . '/set/setting/super_smtp/' . trim($settings_id),
|
||||
$payload
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2919,7 +2903,10 @@ class Client
|
||||
*/
|
||||
public function set_super_identity_settings_base(string $settings_id, $payload): bool
|
||||
{
|
||||
return $this->fetch_results_boolean('/api/s/' . $this->site . '/set/setting/super_identity/' . trim($settings_id), $payload);
|
||||
return $this->fetch_results_boolean(
|
||||
'/api/s/' . $this->site . '/set/setting/super_identity/' . trim($settings_id),
|
||||
$payload
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3349,10 +3336,10 @@ class Client
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the recent firmware update for an UniFi-OS console
|
||||
* Get the recent firmware update for an UniFi-OS console.
|
||||
*
|
||||
* @return array|bool returns an array with a single object containing details of the current known latest
|
||||
* UniFi OS version info on success, else returns false
|
||||
* UniFi OS version info on success, else returns false
|
||||
* @throws Exception
|
||||
*/
|
||||
public function get_update_os_console()
|
||||
@@ -3365,7 +3352,7 @@ class Client
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the OS for an UniFi-OS console
|
||||
* Update the OS for an UniFi-OS console.
|
||||
*
|
||||
* @note triggers an UniFi OS Update in Control Plane > Updates > UniFi OS
|
||||
* @return bool true upon success
|
||||
@@ -3382,6 +3369,23 @@ class Client
|
||||
return $this->fetch_results_boolean('/api/firmware/update', $payload, true, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reboot an UniFi-OS console.
|
||||
*
|
||||
* @return bool true upon success
|
||||
* @throws Exception
|
||||
*/
|
||||
public function reboot_os_console(): bool
|
||||
{
|
||||
if (!$this->is_unifi_os) {
|
||||
throw new NotAUnifiOsConsoleException();
|
||||
}
|
||||
|
||||
$this->curl_method = 'POST';
|
||||
|
||||
return $this->fetch_results_boolean('/api/system/reboot', null, true, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check firmware update.
|
||||
*
|
||||
@@ -3430,7 +3434,7 @@ class Client
|
||||
* Upgrade a device to a specific firmware file.
|
||||
*
|
||||
* @note - updates the device to the firmware file at the given URL
|
||||
* - please take great care to select a valid firmware file for the device!
|
||||
* - take great care to select a valid firmware file for the device!
|
||||
* @param string $firmware_url URL for the firmware file to upgrade the device to
|
||||
* @param string|array $macs MAC address of the device to upgrade or an array of MAC addresses
|
||||
* @return bool true upon success
|
||||
@@ -3559,7 +3563,6 @@ class Client
|
||||
/**
|
||||
* Fetch Radius profiles (using REST).
|
||||
*
|
||||
* @note this function/method is only supported on controller versions 5.5.19 and later
|
||||
* @return array|bool objects containing all Radius profiles for the current site
|
||||
* @throws Exception
|
||||
*/
|
||||
@@ -3571,7 +3574,6 @@ class Client
|
||||
/**
|
||||
* Fetch Radius user accounts (using REST).
|
||||
*
|
||||
* @note this function/method is only supported on controller versions 5.5.19 and later
|
||||
* @return array|bool objects containing all Radius accounts for the current site
|
||||
* @throws Exception
|
||||
*/
|
||||
@@ -3583,41 +3585,40 @@ class Client
|
||||
/**
|
||||
* Create a Radius user account (using REST).
|
||||
*
|
||||
* @note this function/method is only supported on controller versions 5.5.19 and later
|
||||
* @param string $name name for the new account
|
||||
* @param string $x_password password for the new account
|
||||
* @param int|null $tunnel_type optional, must be one of the following values:
|
||||
* 1 Point-to-Point Tunneling Protocol (PPTP)
|
||||
* 2 Layer Two Forwarding (L2F)
|
||||
* 3 Layer Two Tunneling Protocol (L2TP)
|
||||
* 4 Ascend Tunnel Management Protocol (ATMP)
|
||||
* 5 Virtual Tunneling Protocol (VTP)
|
||||
* 6 IP Authentication Header in the Tunnel-mode (AH)
|
||||
* 7 IP-in-IP Encapsulation (IP-IP)
|
||||
* 8 Minimal IP-in-IP Encapsulation (MIN-IP-IP)
|
||||
* 9 IP Encapsulating Security Payload in the Tunnel-mode (ESP)
|
||||
* 10 Generic Route Encapsulation (GRE)
|
||||
* 11 Bay Dial Virtual Services (DVS)
|
||||
* 12 IP-in-IP Tunneling
|
||||
* 13 Virtual LANs (VLAN)
|
||||
* 1 Point-to-Point Tunneling Protocol (PPTP)
|
||||
* 2 Layer Two Forwarding (L2F)
|
||||
* 3 Layer Two Tunneling Protocol (L2TP)
|
||||
* 4 Ascend Tunnel Management Protocol (ATMP)
|
||||
* 5 Virtual Tunneling Protocol (VTP)
|
||||
* 6 IP Authentication Header in the Tunnel-mode (AH)
|
||||
* 7 IP-in-IP Encapsulation (IP-IP)
|
||||
* 8 Minimal IP-in-IP Encapsulation (MIN-IP-IP)
|
||||
* 9 IP Encapsulating Security Payload in the Tunnel-mode (ESP)
|
||||
* 10 Generic Route Encapsulation (GRE)
|
||||
* 11 Bay Dial Virtual Services (DVS)
|
||||
* 12 IP-in-IP Tunneling
|
||||
* 13 Virtual LANs (VLAN)
|
||||
* @param int|null $tunnel_medium_type optional, must be one of the following values:
|
||||
* 1 IPv4 (IP version 4)
|
||||
* 2 IPv6 (IP version 6)
|
||||
* 3 NSAP
|
||||
* 4 HDLC (8-bit multidrop)
|
||||
* 5 BBN 1822
|
||||
* 6 802 (includes all 802 media plus Ethernet "canonical format")
|
||||
* 7 E.163 (POTS)
|
||||
* 8 E.164 (SMDS, Frame Relay, ATM)
|
||||
* 9 F.69 (Telex)
|
||||
* 10 X.121 (X.25, Frame Relay)
|
||||
* 11 IPX
|
||||
* 12 Appletalk
|
||||
* 13 Decnet IV
|
||||
* 14 Banyan Vines
|
||||
* 15 E.164 with NSAP format subaddress
|
||||
* 1 IPv4 (IP version 4)
|
||||
* 2 IPv6 (IP version 6)
|
||||
* 3 NSAP
|
||||
* 4 HDLC (8-bit multidrop)
|
||||
* 5 BBN 1822
|
||||
* 6 802 (includes all 802 media plus Ethernet "canonical format")
|
||||
* 7 E.163 (POTS)
|
||||
* 8 E.164 (SMDS, Frame Relay, ATM)
|
||||
* 9 F.69 (Telex)
|
||||
* 10 X.121 (X.25, Frame Relay)
|
||||
* 11 IPX
|
||||
* 12 Appletalk
|
||||
* 13 Decnet IV
|
||||
* 14 Banyan Vines
|
||||
* 15 E.164 with NSAP format subaddress
|
||||
* @param string|null $vlan optional, VLAN to assign to the account
|
||||
* @return bool|array containing a single object for the newly created account upon success, else returns false
|
||||
* @return bool|array containing a single object for the newly created account upon success, else returns false
|
||||
* @throws Exception
|
||||
*/
|
||||
public function create_radius_account(
|
||||
@@ -3662,7 +3663,6 @@ class Client
|
||||
/**
|
||||
* Update a Radius account, base (using REST).
|
||||
*
|
||||
* @note this function/method is only supported on controller versions 5.5.19 and later
|
||||
* @param string $account_id _id of the account which can be found with the list_radius_accounts() function
|
||||
* @param object|array $payload stdClass object or associative array containing the new profile to apply to the
|
||||
* account, must be a (partial) object/array structured in the same manner as is
|
||||
@@ -3680,7 +3680,6 @@ class Client
|
||||
/**
|
||||
* Delete a Radius account (using REST).
|
||||
*
|
||||
* @note this function/method is only supported on controller versions 5.5.19 and later
|
||||
* @param string $account_id _id of the account which can be found with the list_radius_accounts() function
|
||||
* @return bool true on success
|
||||
* @throws Exception
|
||||
@@ -3843,7 +3842,7 @@ class Client
|
||||
* Get a list of all UniFi device models present in the current site.
|
||||
*
|
||||
* @note This endpoint is available in Network Application/Controller version 9.2.x onwards.
|
||||
* @return object|null An object, or null on failure. The `model_list` property of the results object contains an
|
||||
* @return object|null An object, or null on failure. The `model_list` property of the `results` object contains an
|
||||
* array of device models.
|
||||
* @throws Exception
|
||||
*/
|
||||
@@ -3886,10 +3885,11 @@ class Client
|
||||
* @param object|array|null $payload optional, stdClass object or associative array containing the payload to pass
|
||||
* @param string $return optional, string; determines how to return results, when "boolean" the method must
|
||||
* return a boolean result or "array" when the method must return an array (default)
|
||||
* @param bool $prefix_path optional, determines if the path should be prefixed for UniFi OS consoles
|
||||
* @return bool|array returns results as requested, returns false on incorrect parameters
|
||||
* @throws Exception
|
||||
*/
|
||||
public function custom_api_request(string $path, string $method = 'GET', $payload = null, string $return = 'array')
|
||||
public function custom_api_request(string $path, string $method = 'GET', $payload = null, string $return = 'array', bool $prefix_path = true)
|
||||
{
|
||||
if (!in_array($method, self::CURL_METHODS_ALLOWED)) {
|
||||
return false;
|
||||
@@ -3902,11 +3902,11 @@ class Client
|
||||
$this->curl_method = $method;
|
||||
|
||||
if ($return === 'array') {
|
||||
return $this->fetch_results($path, $payload);
|
||||
return $this->fetch_results($path, $payload, false, true, $prefix_path);
|
||||
}
|
||||
|
||||
if ($return === 'boolean') {
|
||||
return $this->fetch_results_boolean($path, $payload);
|
||||
return $this->fetch_results_boolean($path, $payload, true, $prefix_path);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -3917,6 +3917,7 @@ class Client
|
||||
****************************************************************/
|
||||
|
||||
/**
|
||||
* @deprecated Use list_devices() instead
|
||||
* @throws MethodDeprecatedException
|
||||
*/
|
||||
public function list_aps()
|
||||
@@ -3925,6 +3926,7 @@ class Client
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use locate_ap() instead
|
||||
* @throws MethodDeprecatedException
|
||||
*/
|
||||
public function set_locate_ap()
|
||||
@@ -3933,6 +3935,7 @@ class Client
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use locate_ap() instead
|
||||
* @throws MethodDeprecatedException
|
||||
*/
|
||||
public function unset_locate_ap(): bool
|
||||
@@ -3941,6 +3944,7 @@ class Client
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use site_leds() instead
|
||||
* @throws MethodDeprecatedException
|
||||
*/
|
||||
public function site_ledson(): bool
|
||||
@@ -3949,6 +3953,7 @@ class Client
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use site_leds() instead
|
||||
* @throws MethodDeprecatedException
|
||||
*/
|
||||
public function site_ledsoff(): bool
|
||||
@@ -3957,6 +3962,7 @@ class Client
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use restart_device() instead
|
||||
* @throws MethodDeprecatedException
|
||||
*/
|
||||
public function restart_ap(): bool
|
||||
@@ -4309,6 +4315,7 @@ class Client
|
||||
* @param boolean $boolean optional, whether the method should return a boolean result, else return
|
||||
* the "data" array
|
||||
* @param boolean $login_required optional, whether the method requires to be logged in or not
|
||||
* @param bool $prefix_path optional, determines if the path should be prefixed for UniFi OS consoles
|
||||
* @return bool|array|object returns an array with the "data" array on success, returns boolean if $boolean is true
|
||||
* @throws Exception
|
||||
*/
|
||||
@@ -4402,6 +4409,7 @@ class Client
|
||||
* @param object|array|null $payload optional, PHP associative array or stdClass Object, payload to pass with the
|
||||
* request
|
||||
* @param bool $login_required optional, whether the method requires to be logged in or not
|
||||
* @param bool $prefix_path optional, determines if the path should be prefixed for UniFi OS consoles
|
||||
* @return bool [description]
|
||||
* @throws Exception
|
||||
*/
|
||||
@@ -4633,6 +4641,7 @@ class Client
|
||||
*
|
||||
* @param string $path path for the request
|
||||
* @param object|array|null $payload optional, payload to pass with the request
|
||||
* @param bool $prefix_path optional, determines if the path should be prefixed for UniFi OS consoles
|
||||
* @return bool|string response returned by the controller API
|
||||
* @throws CurlGeneralErrorException|CurlTimeoutException|InvalidCurlMethodException|LoginFailedException
|
||||
*/
|
||||
@@ -4730,7 +4739,9 @@ class Client
|
||||
$this->cookies_created_at = 0;
|
||||
$this->exec_retries++;
|
||||
|
||||
curl_close($ch);
|
||||
if(PHP_VERSION_ID < 80500) {
|
||||
curl_close($ch);
|
||||
}
|
||||
|
||||
/** Re-login, and if successful, execute the same cURL request again. */
|
||||
if ($this->login()) {
|
||||
@@ -4765,7 +4776,9 @@ class Client
|
||||
print '</pre>' . PHP_EOL;
|
||||
}
|
||||
|
||||
curl_close($ch);
|
||||
if(PHP_VERSION_ID < 80500) {
|
||||
curl_close($ch);
|
||||
}
|
||||
|
||||
/** Set the method back to the default value, just in case. */
|
||||
$this->curl_method = self::DEFAULT_CURL_METHOD;
|
||||
|
||||
@@ -5,8 +5,8 @@ namespace UniFi_API\Exceptions;
|
||||
/**
|
||||
* Thrown when the required PHP cURL extension is not loaded in the runtime.
|
||||
*
|
||||
* Consumers can catch this to provide an installation hint or to disable any
|
||||
* functionality that requires cURL.
|
||||
* @note Consumers can catch this to provide an installation hint or to disable any
|
||||
* functionality that requires cURL.
|
||||
*
|
||||
* @package UniFi_Controller_API_Client_Class
|
||||
*/
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace UniFi_API\Exceptions;
|
||||
/**
|
||||
* Thrown when an invalid email address is provided to the client.
|
||||
*
|
||||
* This is used for input validation where a properly formatted email is required.
|
||||
* @note This Exception is used for input validation where a properly formatted email is required.
|
||||
*
|
||||
* @package UniFi_Controller_API_Client_Class
|
||||
*/
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
namespace UniFi_API\Exceptions;
|
||||
|
||||
/**
|
||||
* Thrown when a provided site name is invalid or cannot be used by the client.
|
||||
* Thrown when a provided short site name is invalid or cannot be used by the client.
|
||||
*
|
||||
* This can be raised when the site name contains illegal characters or when
|
||||
* the name does not correspond to any known site on the controller.
|
||||
* @note This Exception is thrown when the short site name contains illegal characters or when
|
||||
* the name does not correspond to any known site on the controller.
|
||||
*
|
||||
* @package UniFi_Controller_API_Client_Class
|
||||
*/
|
||||
|
||||
@@ -5,8 +5,8 @@ namespace UniFi_API\Exceptions;
|
||||
/**
|
||||
* Thrown when the client fails to authenticate with the UniFi controller.
|
||||
*
|
||||
* This can indicate invalid credentials, connectivity problems, or a change
|
||||
* in the controller's authentication mechanism (e.g., MFA).
|
||||
* @note This can indicate invalid credentials, connectivity problems, or a change
|
||||
* in the controller's authentication mechanism (e.g., MFA).
|
||||
*
|
||||
* @property-read mixed $httpResponseCode HTTP response code if available
|
||||
*
|
||||
|
||||
@@ -4,8 +4,9 @@ namespace UniFi_API\Exceptions;
|
||||
|
||||
/**
|
||||
* Thrown when a library method or API endpoint has been deprecated and should
|
||||
* no longer be used. Consumers can catch this to provide migration guidance
|
||||
* or suppress warnings for legacy callers.
|
||||
* no longer be used.
|
||||
*
|
||||
* @note Consumers can catch this to provide migration guidance or suppress warnings for legacy callers.
|
||||
*
|
||||
* @package UniFi_Controller_API_Client_Class
|
||||
*/
|
||||
|
||||
@@ -8,9 +8,9 @@ use Throwable;
|
||||
/**
|
||||
* Base exception for the UniFi API client.
|
||||
*
|
||||
* All custom exceptions in this library extend this class so consumers can
|
||||
* catch a single type (\UniFi_API\Exceptions\UnifiApiException) when they
|
||||
* want to handle all client errors uniformly.
|
||||
* @note All custom exceptions in this library extend this class so consumers can
|
||||
* catch a single type (\UniFi_API\Exceptions\UnifiApiException) when they
|
||||
* want to handle all client errors uniformly.
|
||||
*
|
||||
* @package UniFi_Controller_API_Client_Class
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user