from fastapi import APIRouter, Request from typing import Any, List, Dict, Union from app.services.tjnetwork import ( Any, ChangeSet, get_control, get_control_schema, get_rule, get_rule_schema, set_control, set_rule, ) router = APIRouter() @router.get("/getcontrolschema/") async def fastapi_get_control_schema(network: str) -> dict[str, dict[str, Any]]: return get_control_schema(network) @router.get("/getcontrolproperties/") async def fastapi_get_control_properties(network: str) -> dict[str, Any]: return get_control(network) @router.post("/setcontrolproperties/", response_model=None) async def fastapi_set_control_properties(network: str, req: Request) -> ChangeSet: props = await req.json() return set_control(network, ChangeSet(props)) @router.get("/getruleschema/") async def fastapi_get_rule_schema(network: str) -> dict[str, dict[str, Any]]: return get_rule_schema(network) @router.get("/getruleproperties/") async def fastapi_get_rule_properties(network: str) -> dict[str, Any]: return get_rule(network) @router.post("/setruleproperties/", response_model=None) async def fastapi_set_rule_properties(network: str, req: Request) -> ChangeSet: props = await req.json() return set_rule(network, ChangeSet(props))