-
Notifications
You must be signed in to change notification settings - Fork 229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
change create_wlan function #169
base: main
Are you sure you want to change the base?
Conversation
No longer requires wlangroup_id and API endpoint updated
Could you share how you use the create_wlan function? After implementing the proposed changes, I am getting an invalid payload message. |
Thanks for sharing this. I need to think about how to make this backwards compatible, e.g. by checking against the (controller) version property. Do we know with which controller version this behavior changed? Also, we currently don't yet use the (controller) version property so need to implement this in a smart and re-usable manner. |
Am I correct in thinking the switchover when the In that case the |
@karpiatek $name = 'APIWiFi';
$password = 'APIWiFiPassword';
$usergroup_id = 'xxxxxxxxxxxxxxxxxx';
$result = $unifi_connection->create_wlan($name, $password, $usergroup_id, ...); |
@malle-pietje I'm not sure which version this changed in. Do you have a way to check that other than pulling different versions of the controller and snooping on the API call? This seems like a major version sort of change so 6.X or 7.X would be the likely candidates. 6.X would seem to make sense since (according to the As for handling different endpoints, a utility function for checking greater/less than for the version number string will be helpful $endpoint = ($this->version_greater_than('6.0')) ? 'rest/wlanconf' : 'add/wlanconf';
return $this->fetch_results_boolean('/api/s/' . $this->site . $endpoint, $payload); |
@OrionTheGiant Yes, I do. I don't know, maybe I missed something.
I'm running UniFi version 6.x and I'm pretty sure, that if the changes you made work in version 7.x, it should also work in version 6.x. Apparently, I made some kind of mistake here. The code in Client.php is exactly the same as yours. I'm sorry for spamming here, it's just an engineer's curiosity. Trying to figure out what's wrong ;) |
@karpiatek I don't know if this is your only problem but the UniFi API needs $ap_group_ids = ['62fexxxxxxxxxxxxxxxx9790']; I ran into the same thing the first time trying |
I had similar observations while working on #191. In addition to the changes specifically to the |
I see what you mean but this cannot be handled through versioning of the API client class. For example, most of our software packages are multi-site, multi-controller meaning that a single software instance must be able to talk with large number of controller versions. One of our instances actually supports almost each controller version between 5.11.50 and 7.3.83… It makes more sense IMHO to have the API client deal with such changes which is why we still have the $controller_version property. It is still not used but I’m open to suggestions on how to implement this. One of the next challenges will be to document this in a clear manner. |
Fair enough. I was not aware of such use cases. Then I suggest to start by introducing unit tests and integration tests (in combination with a PHP version matrix). I can work on this. |
No longer requires wlangroup_id and API endpoint updated.
I don't know how you'd like to handle having two different API endpoints based on the controller version so I just updated the existing line to point to the new endpoint. Happy to add some additional logic to check controller version if there's already a standard way of checking that.