Refine control rule

This commit is contained in:
DingZQ
2022-11-06 12:23:09 +08:00
parent 8c7b1f63d7
commit 2d51c4494c

18
main.py
View File

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