Add get***schema

This commit is contained in:
DingZQ
2022-10-03 17:13:49 +08:00
parent 48e149b7b4
commit 6db9f03b19

21
main.py
View File

@@ -162,6 +162,9 @@ async def fastapi_is_curve(network: str, pattern: str) -> bool:
############################################################
# junction 2.[JUNCTIONS]
############################################################
@app.get('/getjunctionschema')
async def fast_get_junction_schema(network: str) -> dict[str, dict[str, Any]]:
return get_junction_schema(network)
@app.post("/addjunction/")
async def fastapi_add_junction(network: str, junction: str, x: float, y: float, z: float) -> ChangeSet:
@@ -226,6 +229,9 @@ async def fastapi_set_junction_properties(network: str, junction: str, props: di
############################################################
# reservoir 3.[RESERVOIRS]
############################################################
@app.get('/getreservoirschema')
async def fast_get_reservoir_schema(network: str) -> dict[str, dict[str, Any]]:
return get_reservoir_schema(network)
@app.post("/addreservoir/")
async def fastapi_add_reservoir(network: str, reservoir: str, x: float, y: float, head: float) -> ChangeSet:
@@ -280,6 +286,9 @@ async def fastapi_set_reservoir_properties(network: str, reservoir: str, props:
############################################################
# tank 4.[TANKS]
############################################################
@app.get('/gettankschema')
async def fast_get_tank_schema(network: str) -> dict[str, dict[str, Any]]:
return get_tank_schema(network)
@app.post("/addtank/")
async def fastapi_add_tank(network: str, tank: str, x: float, y: float, elevation: float, init_level: float = 0, min_level: float = 0, max_level: float = 0, diameter: float = 0, min_vol: float = 0) -> ChangeSet:
@@ -397,10 +406,12 @@ async def fastapi_set_tank_properties(network: str, tank: str, props: dict[str,
return set_tank(network, tank, props)
############################################################
# pipe 4.[PIPES]
############################################################
@app.get('/getpipeschema')
async def fast_get_pipe_schema(network: str) -> dict[str, dict[str, Any]]:
return get_pipe_schema(network)
@app.post("/addpipe/")
async def fastapi_add_pipe(network: str, pipe: str, node1: str, node2: str, length: float = 0, diameter: float = 0, roughness: float = 0, minorloss: float = 0, status: str = PIPE_STATUS_OPEN) -> ChangeSet:
@@ -494,10 +505,12 @@ async def fastapi_set_pipe_properties(network: str, pipe: str, props: dict[str,
return set_pipe(network, pipe, props)
############################################################
# pump 4.[PUMPS]
############################################################
@app.get('/getpumpschema')
async def fast_get_pump_schema(network: str) -> dict[str, dict[str, Any]]:
return get_pump_schema(network)
@app.post("/addpump/")
async def fastapi_add_pump(network: str, pump: str, node1: str, node2: str) -> ChangeSet:
@@ -538,10 +551,12 @@ async def fastapi_set_pump_properties(network: str, pump: str, props: dict[str,
return set_pump(network, pump, props)
############################################################
# valve 4.[VALVES]
############################################################
@app.get('/getvalveschema')
async def fast_get_valve_schema(network: str) -> dict[str, dict[str, Any]]:
return get_valve_schema(network)
@app.post("/addvalve/")
async def fastapi_add_valve(network: str, valve: str, node1: str, node2: str, diameter: float = 0, type: str = VALVES_TYPE_PRV, setting: float = 0, minor_loss: float = 0) -> ChangeSet: