Isaksson / node-red-contrib-unifi

MIT License
50 stars 19 forks source link

Best way to add feature to update port forwarding #112

Closed matthiasschoger closed 10 months ago

matthiasschoger commented 11 months ago

Hi,

I would like to contribute and add a new feature to modify the target host/port of a port forward.

Looking through the Unifi REST API, I would use the following approach:

  1. get port forwards (already implemented)
  2. find the relevant port forward by source port (todo)
  3. update port forward (todo)

As you can see, this would require two REST requests to accomplish.

  1. How could such a feature fit into the current architecture? Browsing through the code, all the functions I found map directly to one REST call.
  2. Should I extend an existing JS file or create a new one?

Thanks in advance Matt

matthiasschoger commented 11 months ago

Just came to my mind: Would it be better to use the existing getPortForwards function, handle the logic in a logic node and just add a new function to update a port forward? Might fit better into the current code base.

Isaksson commented 11 months ago

Hello. Great that you would like to contribute. I have already implemented functions that use multiple web requests in same function, for example setOutletPortState So I see no reason that you can't follow the same procedure. That will keep it simple for the users when they will call your new function.

matthiasschoger commented 11 months ago

Hi Chris, thanks for the reply.

Will have a look at setOutletPortState and will come back to you if I have any questions.

Best regards Matthias

Isaksson commented 11 months ago

Yeah sure, no problem 😀