Add getProperties and setProperties

This commit is contained in:
DingZQ
2022-09-27 22:40:42 +08:00
parent 78573a32c5
commit 950875e4db

49
main.py
View File

@@ -219,7 +219,7 @@ async def fastapi_set_junction_pattern(network: str, junction: str, pattern: str
async def fastapi_get_junction_properties(network: str, junction: str) -> dict[str, Any]:
return get_junction(network, junction)
@app.get("/setjunctionproperties/")
@app.post("/setjunctionproperties/")
async def fastapi_set_junction_properties(network: str, junction: str, props: dict[str, Any]) -> ChangeSet:
return set_junction(network, junction, props)
@@ -268,6 +268,14 @@ async def fastapi_set_reservoir_coord(network: str, reservoir: str, x: float, y:
props['coord'] = {'x' : x, 'y' : y}
return set_reservoir(network, reservoir, props)
@app.get("/getreservoirproperties/")
async def fastapi_get_reservoir_properties(network: str, reservoir: str) -> dict[str, Any]:
return get_reservoir(network, reservoir)
@app.post("/setreservoirproperties/")
async def fastapi_set_reservoir_properties(network: str, reservoir: str, props: dict[str, Any]) -> ChangeSet:
return set_reservoir(network, reservoir, props)
############################################################
# tank 4.[TANKS]
@@ -380,6 +388,16 @@ async def fastapi_set_tank_coord(network: str, tank: str, x: float, y: float) ->
props['coord'] = {'x' : x, 'y' : y}
return set_tank(network, tank, props)
@app.get("/gettankproperties/")
async def fastapi_get_tank_properties(network: str, tank: str) -> dict[str, Any]:
return get_tank(network, tank)
@app.post("/settankproperties/")
async def fastapi_set_tank_properties(network: str, tank: str, props: dict[str, Any]) -> ChangeSet:
return set_tank(network, tank, props)
############################################################
# pipe 4.[PIPES]
############################################################
@@ -467,6 +485,15 @@ async def fastapi_set_pipe_status(network: str, pipe: str, status: float) -> Cha
props['status'] = status
return set_pipe(network, pipe, props)
@app.get("/getpipeproperties/")
async def fastapi_get_pipe_properties(network: str, pipe: str) -> dict[str, Any]:
return get_pipe(network, pipe)
@app.post("/setpipeproperties/")
async def fastapi_set_pipe_properties(network: str, pipe: str, props: dict[str, Any]) -> ChangeSet:
return set_pipe(network, pipe, props)
############################################################
# pump 4.[PUMPS]
@@ -502,6 +529,16 @@ async def fastapi_set_pump_node2(network: str, pump: str, node2: str) -> ChangeS
props['node2'] = node2
return set_pump(network, pump, props)
@app.get("/getpumpproperties/")
async def fastapi_get_pump_properties(network: str, pump: str) -> dict[str, Any]:
return get_pump(network, pump)
@app.post("/setpumpproperties/")
async def fastapi_set_pump_properties(network: str, pump: str, props: dict[str, Any]) -> ChangeSet:
return set_pump(network, pump, props)
############################################################
# valve 4.[VALVES]
############################################################
@@ -574,6 +611,16 @@ async def fastapi_set_valve_setting(network: str, valve: str, setting: float) ->
props['setting'] = setting
return set_valve(network, valve, props)
@app.get("/getvalveproperties/")
async def fastapi_get_valve_properties(network: str, valve: str) -> dict[str, Any]:
return get_valve(network, valve)
@app.post("/setvalveproperties/")
async def fastapi_set_valve_properties(network: str, valve: str, props: dict[str, Any]) -> ChangeSet:
return set_valve(network, valve, props)
# inp file
@app.post("/uploadinp/", status_code=status.HTTP_200_OK)
async def upload_inp(file: bytes = File(), name: str = None):