Skip to content

Commit

Permalink
UniFi API browser 2.0.17
Browse files Browse the repository at this point in the history
- updated PHP API client to 1.1.66
- restored json highlighting
- added menu options for new `list_device_name_mappings()` and `stat_full_status()` functions/methods
  • Loading branch information
malle-pietje committed Jan 24, 2021
1 parent c35123a commit 4d65348
Show file tree
Hide file tree
Showing 13 changed files with 483 additions and 381 deletions.
15 changes: 15 additions & 0 deletions collections.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@
'method' => 'list_self',
'params' => []
],
[
'type' => 'collection', // or divider
'label' => 'controller status',
'method' => 'stat_full_status',
'params' => []
],
[
'type' => 'divider', // or collection
],
Expand Down Expand Up @@ -269,6 +275,15 @@
'method' => 'list_tags',
'params' => []
],
[
'type' => 'divider', // or collection
],
[
'type' => 'collection', // or divider
'label' => 'list device name mappings', // supported from '5.5.0'
'method' => 'list_device_name_mappings',
'params' => []
],
],
],
[
Expand Down
2 changes: 1 addition & 1 deletion common.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* This file is subject to the MIT license that is bundled with this package in the file LICENSE.md
*/
define('TOOL_VERSION', '2.0.16');
define('TOOL_VERSION', '2.0.17');

/**
* gather some basic information for the About modal
Expand Down
27 changes: 21 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions js/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,7 @@ function fetchCollection() {
$('#output_pre').html('<code id="copy_container" class="json js-copy-target">' + output + '</code>');

if (selected_output_method === 'json_highlighted') {
$('#output_pre > code').each(function() {
hljs.highlightBlock(this);
});
hljs.highlightBlock(document.getElementById('output_pre'));
}
} else if (selected_output_method === 'kint' || selected_output_method === 'kint_plain') {
$('#output_pre').html('<div class="p-3">' + json.data + '</div>');
Expand Down
15 changes: 14 additions & 1 deletion vendor/art-of-wifi/unifi-api-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ A PHP class that provides access to Ubiquiti's [**UniFi Network Controller**](ht

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.


## Requirements

- a server with PHP, version 5.5.0 or higher, and the PHP cURL module installed (tested on Apache 2.4 with PHP Version 5.6.1 and cURL 7.42.1 and with PHP 7.2.24 and cURL 7.58.0)
Expand All @@ -17,10 +18,12 @@ Support for UniFi OS-based controllers (UniFi Dream Machine Pro or Cloud Key Gen

Please test all methods you plan on using thoroughly before using the API Client with UniFi OS devices in a production environment.


## Installation

Use [Composer](#composer), [Git](#git) or simply [Download the Release](#download-the-release) to install the API client class.


### Composer

The preferred installation method is through [composer](https://getcomposer.org). Follow these [installation instructions](https://getcomposer.org/doc/00-intro.md) if you do not already have composer installed.
Expand All @@ -47,6 +50,7 @@ Finally, be sure to include the autoloader in your code:
require_once 'vendor/autoload.php';
```


### Git

Execute the following `git` command from the shell in your project directory:
Expand All @@ -61,6 +65,7 @@ When git is done cloning, include the file containing the class like so in your
require_once 'path/to/src/Client.php';
```


### Download the Release

If you prefer not to use composer or git, simply [download the package](https://github.com/Art-of-WiFi/UniFi-API-client/archive/master.zip), uncompress the zip file, then include the file containing the class in your code like so:
Expand All @@ -69,6 +74,7 @@ If you prefer not to use composer or git, simply [download the package](https://
require_once 'path/to/src/Client.php';
```


## Example usage

A basic example how to use the class:
Expand All @@ -90,6 +96,7 @@ $results = $unifi_connection->list_alarms(); // returns a PHP array con

Please refer to the `examples/` directory for some more detailed examples which can be used as a starting point for your own PHP code.


#### 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 managing the site in the UniFi Network Controller. For example with this URL:
Expand All @@ -98,7 +105,8 @@ Please refer to the `examples/` directory for some more detailed examples which

`jl3z2shm` is the short site "name" and the value to assign to $site_id.

2. The last optional parameter that is passed to the constructor in the above example (`true`), enables validation of the controller's SSL certificate which is otherwise **disabled** by default. It is highly recommended to enable this feature in production environments where you have a valid SSL cert installed on the UniFi Controller that is associated with the FQDN in the `controller_url` parameter. This option was added with API client version 1.1.16.
2. The last optional parameter that is passed to the constructor in the above example (`true`), enables validation of the controller's SSL certificate which is otherwise **disabled** by default. It is **highly recommended** to enable this feature in production environments where you have a valid SSL cert installed on the UniFi Controller that is associated with the FQDN in the `controller_url` parameter. This option was added with API client version 1.1.16.


## Functions/methods supported

Expand Down Expand Up @@ -156,6 +164,7 @@ The class currently supports the following functions/methods to GET/POST/PUT/DEL
- list_current_channels()
- list_dashboard()
- list_devices()
- list_device_name_mappings()
- list_dpi_stats()
- list_dynamicdns()
- list_events()
Expand Down Expand Up @@ -247,6 +256,7 @@ The class currently supports the following functions/methods to GET/POST/PUT/DEL
- stat_speedtest_results()
- stat_sta_sessions_latest()
- stat_status()
- stat_full_status()
- stat_sysinfo()
- stat_voucher()
- stat_monthly_aps()
Expand Down Expand Up @@ -287,10 +297,12 @@ Other functions, getters/setters:

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 [issue list](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.


## Contribute

If you would like to contribute code (improvements), please open an issue and include your code there or else create a pull request.


## Credits

This class is based on the initial work by the following developers:
Expand All @@ -302,6 +314,7 @@ and the API as published by Ubiquiti:

- https://dl.ui.com/unifi/6.0.41/unifi_sh_api


## Important Disclaimer

Many of the functions in this API client class are not officially supported by UBNT and as such, may not be supported in future versions of the UniFi Controller API.
Loading

0 comments on commit 4d65348

Please sign in to comment.