Query node by name
query_params = {'name': '10.10.10.2'}
r_get = requests.get(f'http://{TOPOLOGRAPH_HOST}:{TOPOLOGRAPH_PORT}/api/diagram/{graph_time}/nodes', auth=(_USERNAME, _PASSWORD), params=query_params)
r_get.json()
[{'ha_role': 'primary', 'id': 1, 'label': '10.10.10.2', 'location': 'dc1', 'name': '10.10.10.2', 'size': 15}]
Query node by arbitrary tags. Get all nodes in location dc1
query_params = {'location': 'dc1'}
r_get = requests.get(f'http://{TOPOLOGRAPH_HOST}:{TOPOLOGRAPH_PORT}/api/diagram/{graph_time}/nodes', auth=(_USERNAME, _PASSWORD), params=query_params)
r_get.json()
[{'id': 0, 'label': '10.10.10.1', 'location': 'dc1', 'name': '10.10.10.1'},
{'ha_role': 'primary', 'id': 1, 'label': '10.10.10.2', 'location': 'dc1', 'name': '10.10.10.2', 'size': 15},
{'ha_role': 'secondary', 'id': 2, 'label': '10.10.10.3', 'location': 'dc1', 'name': '10.10.10.3'}]
Query node by arbitrary tags. Get all primary nodes in location dc1
query_params = {'location': 'dc1', 'ha_role': 'primary'}
r_get = requests.get(f'http://{TOPOLOGRAPH_HOST}:{TOPOLOGRAPH_PORT}/api/diagram/{graph_time}/nodes', auth=(_USERNAME, _PASSWORD), params=query_params)
r_get.json()
[{'ha_role': 'primary', 'id': 1, 'label': '10.10.10.2', 'location': 'dc1', 'name': '10.10.10.2', 'size': 15}]