Add fastapi getelementproperties
This commit is contained in:
5
main.py
5
main.py
@@ -429,6 +429,11 @@ async def fast_get_node_properties(network: str, node: str) -> dict[str, Any]:
|
||||
async def fast_get_link_properties(network: str, link: str) -> dict[str, Any]:
|
||||
return get_link_properties(network, link)
|
||||
|
||||
# type can be 'node' or 'link'
|
||||
@app.get('/getelementproperties/')
|
||||
async def fast_get_element_properties(network: str, type: str, element: str) -> dict[str, Any]:
|
||||
return get_element_properties(network, type, element)
|
||||
|
||||
############################################################
|
||||
# title 1.[TITLE]
|
||||
############################################################
|
||||
|
||||
@@ -409,6 +409,15 @@ def get_link_properties(name: str, link_id: str) -> dict[str, Any]:
|
||||
elif api.is_valve(name, link_id):
|
||||
return api.get_valve(name, link_id)
|
||||
|
||||
# type can be 'node' or 'link'
|
||||
def get_element_properties(name: str, type: str, element_id: str) -> dict[str, Any]:
|
||||
if type == 'node':
|
||||
return get_node_properties(name, element_id)
|
||||
elif type == 'link':
|
||||
return get_link_properties(name, element_id)
|
||||
else:
|
||||
return {}
|
||||
|
||||
############################################################
|
||||
# title 1.[TITLE]
|
||||
############################################################
|
||||
|
||||
Reference in New Issue
Block a user