diff --git a/main.py b/main.py index 134b55f..838e455 100644 --- a/main.py +++ b/main.py @@ -959,7 +959,6 @@ async def fastapi_set_control(network: str, req: Request) -> ChangeSet: ############################################################ # rule 14.[RULES] ############################################################ - @app.get("/getruleschema/") async def fastapi_get_rule_schema(network: str) -> dict[str, dict[str, Any]]: return get_rule_schema(network) @@ -978,7 +977,6 @@ async def fastapi_set_rule(network: str, req: Request) -> ChangeSet: ############################################################ # energy 15.[ENERGY] ############################################################ - @app.get("/getglobalenergyschema/") async def fastapi_get_global_energy_schema(network: str) -> dict[str, dict[str, Any]]: return get_global_energy_schema() @@ -1024,6 +1022,26 @@ async def fastapi_set_emitter_properties(network: str, junction: str, req: Reque ps = { 'id' : junction } | props return set_emitter(network, ChangeSet(ps)) + +############################################################ +# quality 17.[QUALITY] +############################################################ +@app.get('/getqualityschema/') +async def fastapi_get_quality_schema(network: str) -> dict[str, dict[str, Any]]: + return get_quality_schema(network) + +@app.get('/getqualityproperties/') +async def fastapi_get_quality(network: str, node: str) -> dict[str, Any]: + return get_quality(network, node) + +# example: set_quality(p, ChangeSet({'node': 'j1', 'quality': 10.0})) +@app.post("/setqualityproperties/") +async def fastapi_set_quality_properties(network: str, req: Request) -> ChangeSet: + props = await req.json() + ps = { 'id' : network} | props + return set_quality(network, ChangeSet(ps)) + + ############################################################ # time 21.[TIME] ############################################################ @@ -1043,7 +1061,7 @@ async def fastapi_set_time_properties(network: str, time: str, req: Request) -> ############################################################ # option 23.[OPTIONS] ############################################################ -@app.get('/getoptionschema') +@app.get('/getoptionschema/') async def fast_get_option_schema(network: str) -> dict[str, dict[str, Any]]: return get_option_schema(network) @@ -1056,6 +1074,68 @@ async def fastapi_set_option_properties(network: str, req: Request) -> ChangeSet props = await req.json() return set_option(network, ChangeSet(props)) + +############################################################ +# vertex 25.[VERTICES] +############################################################ +@app.get('/getvertexschema/') +async def fastapi_get_vertex_schema(network: str) -> dict[str, dict[str, Any]]: + return get_vertex_schema(network) + +@app.get('/getvertexproperties/') +async def fastapi_get_vertex(network: str, link: str) -> dict[str, Any]: + return get_vertex(network, link) + +# set_vertex(p, ChangeSet({'link' : 'p0', 'coords': [{'x': 1.0, 'y': 2.0}, {'x': 2.0, 'y': 1.0}]})) +@app.post('/setvertexproperties/') +async def set_vertex(network: str, req: Request) -> ChangeSet: + props = await req.json() + return set_vertex(network, ChangeSet(props)) + +@app.post('/addvertex/') +async def fastapi_add_vertex(network: str, req: Request) -> ChangeSet: + props = await req.json() + return add_vertex(network, ChangeSet(props)) + +@app.post('/deletevertex/') +async def fastapi_delete_vertex(network: str, req: Request) -> ChangeSet: + props = await req.json() + return api.delete_vertex(network, ChangeSet(props)) + + +############################################################ +# label 26.[LABELS] +############################################################ +def get_label_schema(name: str) -> dict[str, dict[str, Any]]: + return api.get_label_schema(name) + +def get_label(name: str, x: float, y: float) -> dict[str, Any]: + return api.get_label(name, x, y) + +def set_label(name: str, cs: ChangeSet) -> ChangeSet: + return api.set_label(name, cs) + +def add_label(name: str, cs: ChangeSet) -> ChangeSet: + return api.add_label(name, cs) + +def delete_label(name: str, cs: ChangeSet) -> ChangeSet: + return api.delete_label(name, cs) + + +############################################################ +# backdrop 27.[BACKDROP] +############################################################ + +def get_backdrop_schema(name: str) -> dict[str, dict[str, Any]]: + return api.get_backdrop_schema(name) + +def get_backdrop(name: str) -> dict[str, Any]: + return api.get_backdrop(name) + +def set_backdrop(name: str, cs: ChangeSet) -> ChangeSet: + return api.set_backdrop(name, cs) + + # inp file @app.post("/uploadinp/", status_code=status.HTTP_200_OK) async def upload_inp(file: bytes = File(), name: str = None):