43 lines
1.4 KiB
Python
43 lines
1.4 KiB
Python
from fastapi import APIRouter, Request
|
|
from typing import Any, List, Dict, Union
|
|
from app.services.tjnetwork import *
|
|
|
|
router = APIRouter()
|
|
|
|
@router.get("/getcurveschema")
|
|
async def fastapi_get_curve_schema(network: str) -> dict[str, dict[str, Any]]:
|
|
return get_curve_schema(network)
|
|
|
|
@router.post("/addcurve/", response_model=None)
|
|
async def fastapi_add_curve(network: str, curve: str, req: Request) -> "ChangeSet":
|
|
props = await req.json()
|
|
ps = {
|
|
"id": curve,
|
|
} | props
|
|
return add_curve(network, ChangeSet(ps))
|
|
|
|
@router.post("/deletecurve/", response_model=None)
|
|
async def fastapi_delete_curve(network: str, curve: str) -> "ChangeSet":
|
|
ps = {"id": curve}
|
|
return delete_curve(network, ChangeSet(ps))
|
|
|
|
@router.get("/getcurveproperties/")
|
|
async def fastapi_get_curve_properties(network: str, curve: str) -> dict[str, Any]:
|
|
return get_curve(network, curve)
|
|
|
|
@router.post("/setcurveproperties/", response_model=None)
|
|
async def fastapi_set_curve_properties(
|
|
network: str, curve: str, req: Request
|
|
) -> "ChangeSet":
|
|
props = await req.json()
|
|
ps = {"id": curve} | props
|
|
return set_curve(network, ChangeSet(ps))
|
|
|
|
@router.get("/getcurves/")
|
|
async def fastapi_get_curves(network: str) -> list[str]:
|
|
return get_curves(network)
|
|
|
|
@router.get("/iscurve/")
|
|
async def fastapi_is_curve(network: str, curve: str) -> bool:
|
|
return is_curve(network, curve)
|