Skip to content

Commit

Permalink
added list_usergroups to API class and to API browser
Browse files Browse the repository at this point in the history
version 1.0.1
  • Loading branch information
malle-pietje committed Mar 23, 2016
1 parent bdf4d69 commit 09607db
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
7 changes: 6 additions & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
Ubiquiti Community forums for this:
https://community.ubnt.com/t5/UniFi-Wireless/Unifi-API-browser-tool-released/m-p/1392651
VERSION: 1.0
VERSION: 1.0.1
------------------------------------------------------------------------------------
Expand Down Expand Up @@ -228,6 +228,10 @@
$selection = 'list guests';
$data = $unifidata->list_guests();
break;
case 'list_usergroups':
$selection = 'list usergroups';
$data = $unifidata->list_usergroups();
break;
case 'stat_hourly_site':
$selection = 'hourly site stats';
$data = $unifidata->stat_hourly_site();
Expand Down Expand Up @@ -477,6 +481,7 @@ function to print the output
<li id="list_clients"><a href="?action=list_clients">list online clients</a></li>
<li id="list_guests"><a href="?action=list_guests">list guests</a></li>
<li id="list_users"><a href="?action=list_users">list users</a></li>
<li id="list_usergroups"><a href="?action=list_usergroups">list user groups</a></li>
<li role="separator" class="divider"></li>
<li id="stat_allusers"><a href="?action=stat_allusers">stat all users</a></li>
<li id="stat_auths"><a href="?action=stat_auths">stat authorisations</a></li>
Expand Down
23 changes: 22 additions & 1 deletion phpapi/class.unifi.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
and the API as published by Ubiquiti:
https://dl.ubnt.com/unifi/4.7.6/unifi_sh_api
VERSION: 1.0
VERSION: 1.0.1
NOTE:
this Class will only work with Unifi Controller versions 4.x. There are no checks to prevent you from
Expand Down Expand Up @@ -435,6 +435,27 @@ public function list_clients() {
return $return;
}

/*
list user groups
returns an array of user group objects
*/
public function list_usergroups() {
if (!$this->is_loggedin) return false;
$return = array();
$json = json_encode(array());
$content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/list/usergroup','json='.$json));
if (isset($content_decoded->meta->rc)) {
if ($content_decoded->meta->rc == 'ok') {
if (is_array($content_decoded->data)) {
foreach ($content_decoded->data as $usergroup) {
$return[]= $usergroup;
}
}
}
}
return $return;
}

/*
list health metrics
returns an array of health metric objects
Expand Down

0 comments on commit 09607db

Please sign in to comment.