Implement API endpoint for provisioning relays

This commit is contained in:
Mark Veidemanis 2022-08-13 20:51:31 +01:00
parent 28c1a33615
commit 92df4fb9a3
1 changed files with 14 additions and 0 deletions

View File

@ -395,6 +395,20 @@ class API(object):
main.saveConf("network")
return dumps({"success": True})
@app.route("/irc/network/<net>/<num>/provision/", methods=["POST"])
@login_required
def irc_network_relay_provision(self, request, net, num):
if net not in main.network.keys():
return dumps({"success": False, "reason": "no such net."})
if not num.isdigit():
return dumps({"success": False, "reason": "invalid num: not a number."})
num = int(num)
net_inst = main.network[net]
if num not in net_inst.relays:
return dumps({"success": False, "reason": "network does not have this relay."})
provision.provisionRelay(num, net)
return dumps({"success": True})
@app.route("/irc/network/<net>/channels/", methods=["POST"])
@login_required
def irc_network_channels(self, request, net):