Add method for control and rule

This commit is contained in:
DingZQ
2022-11-06 12:10:21 +08:00
parent 3cd0a88eba
commit 8c7b1f63d7

37
main.py
View File

@@ -938,6 +938,43 @@ async def fastapi_set_curve_properties(network: str, curve: str, req: Request) -
ps = { 'id' : curve } | props
return set_curve(network, ChangeSet(ps))
############################################################
# control 13.[CONTROLS]
############################################################
@app.get('/getcontrolschema')
async def fastapi_get_control_schema(network: str) -> dict[str, dict[str, Any]]:
return get_control_schema(network)
@app.get("/getcontrolproperties/")
async def fastapi_get_control_properties(control: str) -> dict[str, Any]:
return get_control(control)
# example: set_control(p, ChangeSet({'control': 'x'}))
@app.post("/setcontrolproperties/")
async def fastapi_set_control(control: str, req: Request) -> ChangeSet:
props = await req.json()
return set_control(control, ChangeSet(props))
############################################################
# rule 14.[RULES]
############################################################
@app.get("/getruleschema/")
async def fastapi_get_rule_schema(network: str) -> dict[str, dict[str, Any]]:
return get_rule_schema(network)
@app.get("/getruleproperties/")
async def fastapi_get_rule(rule: str) -> dict[str, Any]:
return get_rule(rule)
# example: set_rule(p, ChangeSet({'rule': 'x'}))
@app.post("/setruleproperties/")
async def fastapi_set_rule(rule: str, req: Request) -> ChangeSet:
props = await req.json()
return set_rule(rule, props)
############################################################
# emitter 16.[EMITTERS]
############################################################