node's name is mandatory. Should be in IP-address format. To change it to any other value - use label.
visualization' options: full option list
nodes:
10.10.10.2: # Name of node. Mandatory
# Tags of node. Any key (type string): value (str, int, float, dictionary, list) pairs. Optional
vendor: Juniper
role: router
ha_role: primary
location: dc1
# visualization' options
label: 10.10.10.2-R2
size: 15
color: red
10.10.10.3:
ha_role: secondary
location: dc1
10.10.10.6:
src, dst is mandatory
cost is optional. Default is 1. Equal to OSPF/IS-IS cost.
color is optional, ie '#007bff'
dashes is optional. Input value: true/false. Default is false.
directed is optional. Default is false.
edges:
# use directed: true, otherwise all edges will be treated as undirected
- dst: 10.10.10.2
src: 10.10.10.3
cost: 1 # default value
- dst: 10.10.10.3
src: 10.10.10.6
# Tags of edge. Any key (type string): value (str, int, float, dictionary, list) pairs. Optional
bw: 1000
isp: verizon
media: fiber
Copy/paste this test topology to the input window above
nodes:
10.10.10.1:
10.10.10.2:
10.10.10.3:
10.10.10.4:
10.10.10.5:
10.10.10.6:
edges:
- src: 10.10.10.1
dst: 10.10.10.2
- src: 10.10.10.1
dst: 10.10.10.3
- src: 10.10.10.2
dst: 10.10.10.4
- src: 10.10.10.2
dst: 10.10.10.4
- src: 10.10.10.2
dst: 10.10.10.3
- src: 10.10.10.3
dst: 10.10.10.5
- src: 10.10.10.5
dst: 10.10.10.4
- src: 10.10.10.4
dst: 10.10.10.6
- src: 10.10.10.5
dst: 10.10.10.6
Copy/paste this test topology to the input window above
nodes:
10.10.10.1:
label: 10.10.10.1
location: dc1
10.10.10.2:
ha_role: primary
label: 10.10.10.2
location: dc1
size: 15
10.10.10.3:
ha_role: secondary
label: 10.10.10.3
location: dc1
10.10.10.4:
ha_role: primary
label: 10.10.10.4
location: dc2
size: 15
10.10.10.5:
ha_role: secondary
label: 10.10.10.5label
location: dc2
10.10.10.6:
label: 10.10.10.6
location: dc2
edges:
- src: 10.10.10.1
dst: 10.10.10.2
bw: 1000
directed: true
media: copper
- src: 10.10.10.2
dst: 10.10.10.1
bw: 1000
directed: true
media: copper
- src: 10.10.10.1
dst: 10.10.10.3
bw: 1000
directed: true
media: copper
- src: 10.10.10.3
dst: 10.10.10.1
bw: 1000
directed: true
media: copper
- src: 10.10.10.2
dst: 10.10.10.4
bw: 100
cost: 100
directed: true
isp: att
media: copper
- src: 10.10.10.4
dst: 10.10.10.2
bw: 100
directed: true
isp: att
media: copper
- src: 10.10.10.4
dst: 10.10.10.2
bw: 1000
directed: true
isp: verizon
media: fiber
- src: 10.10.10.2
dst: 10.10.10.4
bw: 1000
directed: true
isp: verizon
media: fiber
- src: 10.10.10.3
dst: 10.10.10.2
bw: 1000
directed: true
media: copper
- src: 10.10.10.2
dst: 10.10.10.3
bw: 1000
directed: true
media: copper
- src: 10.10.10.3
dst: 10.10.10.5
bw: 100
directed: true
isp: virgin
media: fiber
- src: 10.10.10.5
dst: 10.10.10.3
bw: 100
directed: true
isp: virgin
media: fiber
- src: 10.10.10.5
dst: 10.10.10.4
bw: 1000
directed: true
media: copper
- src: 10.10.10.4
dst: 10.10.10.5
bw: 1000
directed: true
media: copper
- src: 10.10.10.4
dst: 10.10.10.6
bw: 1000
directed: true
media: fiber
- src: 10.10.10.6
dst: 10.10.10.4
bw: 1000
directed: true
media: fiber
- src: 10.10.10.5
dst: 10.10.10.6
bw: 1000
directed: true
media: fiber
- src: 10.10.10.6
dst: 10.10.10.5
bw: 1000
directed: true
media: fiber
Query node by name (REST API)
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 name (Topolograph Python SDK)
from topolograph import Topolograph
# Initialize client
topo = Topolograph(url=f'http://{TOPOLOGRAPH_HOST}:{TOPOLOGRAPH_PORT}', token='your-token')
# Or use: topo = Topolograph(url=f'http://{TOPOLOGRAPH_HOST}:{TOPOLOGRAPH_PORT}', username=_USERNAME, password=_PASSWORD)
# Get graph
graph = topo.graphs.get_by_time(graph_time)
# Query node by name
nodes = graph.nodes.get(name='10.10.10.2')
for node in nodes:
print(f"Node: {node.name}, ID: {node.id}, Attributes: {node.attributes}")
# Output: Node: 10.10.10.2, ID: 1, Attributes: {'ha_role': 'primary', 'label': '10.10.10.2', 'location': 'dc1', 'size': 15}
Query node by arbitrary tags. Get all nodes in location dc1 (REST API)
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 nodes in location dc1 (Topolograph Python SDK)
from topolograph import Topolograph
# Initialize client
topo = Topolograph(url=f'http://{TOPOLOGRAPH_HOST}:{TOPOLOGRAPH_PORT}', token='your-token')
# Get graph
graph = topo.graphs.get_by_time(graph_time)
# Query nodes by location tag
nodes = graph.nodes.get(location='dc1')
for node in nodes:
print(f"Node: {node.name}, Location: {node.attributes.get('location')}")
# Output:
# Node: 10.10.10.1, Location: dc1
# Node: 10.10.10.2, Location: dc1
# Node: 10.10.10.3, Location: dc1
Query node by arbitrary tags. Get all primary nodes in location dc1 (REST API)
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}]
Query node by arbitrary tags. Get all primary nodes in location dc1 (Topolograph Python SDK)
from topolograph import Topolograph
# Initialize client
topo = Topolograph(url=f'http://{TOPOLOGRAPH_HOST}:{TOPOLOGRAPH_PORT}', token='your-token')
# Get graph
graph = topo.graphs.get_by_time(graph_time)
# Query nodes by multiple tags
nodes = graph.nodes.get(location='dc1', ha_role='primary')
for node in nodes:
print(f"Node: {node.name}, Role: {node.attributes.get('ha_role')}, Location: {node.attributes.get('location')}")
# Output: Node: 10.10.10.2, Role: primary, Location: dc1
Query all edges between two nodes (REST API)
query_params = {'src_node': '10.10.10.2', 'dst_node': '10.10.10.4'}
r_get = requests.get(f'http://{TOPOLOGRAPH_HOST}:{TOPOLOGRAPH_PORT}/api/diagram/{graph_time}/edges', auth=(_USERNAME, _PASSWORD), params=query_params)
r_get.json()
[{'bw': 100, 'dst': '10.10.10.4', 'id': 4, 'isp': 'att', 'media': 'copper', 'src': '10.10.10.2', 'cost': 100},
{'bw': 1000, 'dst': '10.10.10.4', 'id': 7, 'isp': 'verizon', 'media': 'fiber', 'src': '10.10.10.2', 'cost': 1}]
Query all edges between two nodes (Topolograph Python SDK)
from topolograph import Topolograph
# Initialize client
topo = Topolograph(url=f'http://{TOPOLOGRAPH_HOST}:{TOPOLOGRAPH_PORT}', token='your-token')
# Get graph
graph = topo.graphs.get_by_time(graph_time)
# Query edges using client directly (edges API not yet in SDK)
edges = topo.get(f'/diagram/{graph_time}/edges', params={'src_node': '10.10.10.2', 'dst_node': '10.10.10.4'})
edges_data = edges.json()
print(edges_data)
# Output:
# [{'bw': 100, 'dst': '10.10.10.4', 'id': 4, 'isp': 'att', 'media': 'copper', 'src': '10.10.10.2', 'cost': 100},
# {'bw': 1000, 'dst': '10.10.10.4', 'id': 7, 'isp': 'verizon', 'media': 'fiber', 'src': '10.10.10.2', 'cost': 1}]
Query edge by arbitrary tags. Get all links between '10.10.10.2' and '10.10.10.4' from Verizon ISP (REST API)
query_params = {'src_node': '10.10.10.2', 'dst_node': '10.10.10.4', 'isp': 'verizon'}
r_get = requests.get(f'http://{TOPOLOGRAPH_HOST}:{TOPOLOGRAPH_PORT}/api/diagram/{graph_time}/edges', auth=(_USERNAME, _PASSWORD), params=query_params)
r_get.json()
[{'bw': 1000, 'dst': '10.10.10.4', 'id': 7, 'isp': 'verizon', 'media': 'fiber', 'src': '10.10.10.2', 'cost': 1}]
Query edge by arbitrary tags. Get all links between '10.10.10.2' and '10.10.10.4' from Verizon ISP (Topolograph Python SDK)
from topolograph import Topolograph
# Initialize client
topo = Topolograph(url=f'http://{TOPOLOGRAPH_HOST}:{TOPOLOGRAPH_PORT}', token='your-token')
# Get graph
graph = topo.graphs.get_by_time(graph_time)
# Query edges with additional filters using client directly
edges = topo.get(f'/diagram/{graph_time}/edges', params={
'src_node': '10.10.10.2',
'dst_node': '10.10.10.4',
'isp': 'verizon'
})
edges_data = edges.json()
print(edges_data)
# Output: [{'bw': 1000, 'dst': '10.10.10.4', 'id': 7, 'isp': 'verizon', 'media': 'fiber', 'src': '10.10.10.2', 'cost': 1}]