Coverage for microservice_websocket/app/blueprints/api/command.py: 85%
13 statements
« prev ^ index » next coverage.py v7.0.0, created at 2022-12-20 14:31 +0000
« prev ^ index » next coverage.py v7.0.0, created at 2022-12-20 14:31 +0000
1from fastapi import APIRouter, Depends
2from pydantic import BaseModel
4from ...services.jwt import jwt_required
5from ...utils.command import handle_command
6from ...utils.enums import CommandType
8command_router = APIRouter(prefix="/command")
11class MqttCommandPayload(BaseModel):
12 nodeID: int
13 applicationID: str
16@command_router.post("/{command_type}", dependencies=[Depends(jwt_required)])
17async def send_mqtt_command_route(
18 command_type: CommandType, payload: MqttCommandPayload
19):
20 await handle_command(command_type, payload.applicationID, payload.nodeID)
22 return {"message": "Sent"}