32 lines
962 B
Python
32 lines
962 B
Python
import logging
|
|
|
|
from fastapi import APIRouter, Request
|
|
|
|
from control_backend.schemas.program import Program
|
|
|
|
logger = logging.getLogger(__name__)
|
|
router = APIRouter()
|
|
|
|
|
|
@router.post("/program", status_code=202)
|
|
async def receive_message(program: Program, request: Request):
|
|
"""
|
|
Endpoint to upload a new Behavior Program.
|
|
|
|
Validates the program structure (phases, norms, goals) and publishes it to the internal
|
|
'program' topic. The :class:`~control_backend.agents.bdi.bdi_program_manager.BDIProgramManager`
|
|
will pick this up and update the BDI agent.
|
|
|
|
:param program: The parsed Program object.
|
|
:param request: The FastAPI request object.
|
|
"""
|
|
logger.debug("Received raw program: %s", program)
|
|
|
|
# send away
|
|
topic = b"program"
|
|
body = program.model_dump_json().encode()
|
|
pub_socket = request.app.state.endpoints_pub_socket
|
|
await pub_socket.send_multipart([topic, body])
|
|
|
|
return {"status": "Program parsed"}
|