unpoller / unifi

Go Library (w/ structures) to grab data from a Ubitquiti UniFi Controller
https://golift.io/discord
MIT License
114 stars 22 forks source link

Feature [set settings] - Firewall Rule updates #52

Open galaara98 opened 3 years ago

galaara98 commented 3 years ago

You mentioned in the readme that your not against maybe a few functions that set data.

So I have a WAN firewall rule designed to let a certain list of ip addresses in on a certain port. I'd like to be able to update the source IP addresses programically (if the API can do that) Technically in my case I use a Firewall ipv4 Group, so I'm looking for a way to actually update the group membership

davidnewhall commented 3 years ago

Howdy! Do you know what API paths these things live at by chance? If you can point me in a direction I can create the methods to access the stuff.

davidnewhall commented 3 years ago

I also need to verify you're asking for this Go library to be able to update firewall rules/data. You have the ability to write a Go app that uses this library to make the changes you're interested in?

galaara98 commented 3 years ago

$IdOfGroup = (((Invoke-WebRequest "$controller/api/s/default/rest/firewallgroup" -WebSession $session -Method Get).content | convertfrom-json).data | where-object { $_.name -like "*Player_Addresses"})._id

Invoke-WebRequest "$controller/api/s/default/rest/firewallgroup/$IdOfGroup" -WebSession $session -Method Put -body '{"group_members":["192.168.10.20","207.170.246.248"]}'

galaara98 commented 3 years ago

I also need to verify you're asking for this Go library to be able to update firewall rules/data. You have the ability to write a Go app that uses this library to make the changes you're interested in?

Sorry example was powershell, it is my native tongue :)

I know, I'm pondering how to tackle this... I already use your poller for better data/data visualization.. but I could just go separate on this.. i was just coincidentally checking in on your project and saw the readme mention.

davidnewhall commented 3 years ago

That's sorta why I asked. This repo is a Go library that makes it (slightly) easier for a Go application to interact with a UniFi Controller. Poller uses this library. If you don't program in Go, this library probably isn't very useful to you.

The examples you provided are "perfect" and I could certainly implement the Go methods to expose those API endpoints, but will you use it? I'm afraid if you're not a Go programmer it'll be difficult to get into. I don't want to discourage you though; if you're willing to learn I'm willing to help get you there. I could even provide some initial code to "create an application" and you may be able to get it going.

I don't have a ton of time, but I do enjoy helping folks learn things and this is something I'd put time into if you're up for it.

davidnewhall commented 3 years ago

And just so it's extra clear: this new code will be part of this library, but will not be part of (used in) poller.