Added permissions to the endpoints
This commit is contained in:
@@ -4,7 +4,7 @@ import websockets
|
||||
from quart import Blueprint, jsonify, request, abort, current_app
|
||||
from werkzeug.exceptions import HTTPException
|
||||
from enum import Enum
|
||||
from internal.types import ActiveClient, NodeCommands
|
||||
from internal.types import ActiveClient, NodeCommands, UserRoles
|
||||
import uuid # Import uuid for generating unique request IDs
|
||||
|
||||
nodes_bp = Blueprint('nodes', __name__)
|
||||
@@ -135,12 +135,16 @@ async def send_command_to_all_clients(command_name, *args):
|
||||
|
||||
|
||||
@nodes_bp.route("/", methods=['GET'])
|
||||
@jwt_required
|
||||
@role_required(UserRoles.USER)
|
||||
async def get_nodes():
|
||||
"""API endpoint to list currently connected client IDs."""
|
||||
return jsonify(list(current_app.active_clients.keys()))
|
||||
|
||||
|
||||
@nodes_bp.route("/online", methods=['GET'])
|
||||
@jwt_required
|
||||
@role_required(UserRoles.USER)
|
||||
async def get_online_bots():
|
||||
active_bots = []
|
||||
for client_id, active_client in current_app.active_clients.items():
|
||||
@@ -150,6 +154,8 @@ async def get_online_bots():
|
||||
|
||||
|
||||
@nodes_bp.route("/<client_id>/status", methods=["GET"])
|
||||
@jwt_required
|
||||
@role_required(UserRoles.USER)
|
||||
async def status(client_id):
|
||||
"""
|
||||
Get the status from a given client
|
||||
@@ -172,6 +178,8 @@ async def status(client_id):
|
||||
|
||||
|
||||
@nodes_bp.route("/<client_id>/join", methods=['POST'])
|
||||
@jwt_required
|
||||
@role_required(UserRoles.MOD)
|
||||
async def join(client_id):
|
||||
"""
|
||||
Send a join command to the specific system specified
|
||||
@@ -202,6 +210,8 @@ async def join(client_id):
|
||||
|
||||
|
||||
@nodes_bp.route("/<client_id>/leave", methods=['POST'])
|
||||
@jwt_required
|
||||
@role_required(UserRoles.MOD)
|
||||
async def leave(client_id):
|
||||
"""
|
||||
Send a leave command to the specific node
|
||||
@@ -230,6 +240,8 @@ async def leave(client_id):
|
||||
|
||||
|
||||
@nodes_bp.route("/<client_id>/op25_start", methods=['POST'])
|
||||
@jwt_required
|
||||
@role_required(UserRoles.MOD)
|
||||
async def op25_start(client_id):
|
||||
"""
|
||||
Send an OP25 start command to the specific node
|
||||
@@ -249,6 +261,8 @@ async def op25_start(client_id):
|
||||
|
||||
|
||||
@nodes_bp.route("/<client_id>/op25_stop", methods=['POST'])
|
||||
@jwt_required
|
||||
@role_required(UserRoles.MOD)
|
||||
async def op25_stop(client_id):
|
||||
"""
|
||||
Send an OP25 stop command to the specific node
|
||||
@@ -268,6 +282,8 @@ async def op25_stop(client_id):
|
||||
|
||||
|
||||
@nodes_bp.route("/<client_id>/op25_set", methods=['POST'])
|
||||
@jwt_required
|
||||
@role_required(UserRoles.MOD)
|
||||
async def op25_set(client_id):
|
||||
"""
|
||||
Send an OP25 set config command to the specific node
|
||||
|
||||
Reference in New Issue
Block a user