donaldzou / WGDashboard

Simple dashboard for WireGuard VPN written in Python & Vue.js
https://donaldzou.github.io/WGDashboard-Documentation/
Apache License 2.0
1.59k stars 236 forks source link

Does the delete API call exist in v4.x? #367

Open mzs114 opened 2 months ago

mzs114 commented 2 months ago

Is your feature request related to a problem? Please describe. Hi, I checked the API documentation and could not find the delete call, we are testing WGD out and wanted to bulk delete all the created peers. Currently we cannot automate testing due to lack of this.

Describe the solution you'd like Please share a way to delete peers in bulk or get a list and then delete. If no API, can we delete from the wgX.conf file and delete from the backend DB(Sqlite) ?

donaldzou commented 2 months ago

Hi! Yes it does I'm just too busy to finish the doc. Here is how to use it in JS, for example my configuration name is wg0:

const headers = new Headers();
headers.append("Content-Type", "application/json");

const requestOptions = {
    method: "POST",
    headers: myHeaders,
    body: JSON.stringify({
        "peers": [
            "public_key_1",
            "public_key_2",
            "public_key_3"
        ]
    }),
};

fetch("/api/deletePeers/wg0", requestOptions)
    .then((response) => response.json())
    .then((result) => console.log(result));

Hope this helps :)

mzs114 commented 2 months ago

Just a side note, would it be easier to use something like Django for this? Though it is heavy compared to flask, perhaps the unwanted modules can be disabled or removed and it may suffice. I mean it comes with user management and web UI included, just a thought.

donaldzou commented 2 months ago

Well yes Django should be a better solution. The reason I used Flask is it is easy to configure, code and maintain and is minimal to endusers :)