feat(api): add tag filtering to nodes and templates endpoints

- Add optional `tags` query parameter to `/nodes` and `/templates` endpoints
- Support filtering by tags in format "key:value" with multiple tags ANDed together
- Example: `?tags=vendor:cisco&tags=model:7200` filters nodes/templates with both tags
- Maintain backward compatibility for existing API usage without tags parameter
This commit is contained in:
YueGuobin committed 2026-02-22 22:52:28 +08:00
1 parent 56ece7ce88
commit a3616e6d33
6 files changed
+93 -16

No files matched your search

+13
View File
@@ -97,6 +97,7 @@ class Node:
self._y = 0
self._z = 1 # default z value is 1
self._locked = False
self._tags = {}
self._ports = None
self._symbol = None
self._custom_adapters = []
@@ -218,6 +219,17 @@ class Node:
def properties(self, val):
self._properties = val
@property
def tags(self):
return self._tags
@tags.setter
def tags(self, val):
if isinstance(val, dict):
self._tags = val
else:
self._tags = {}
def _base_config_file_content(self, path):
if not os.path.isabs(path):
path = os.path.join(self.project.controller.configs_path(), path)
@@ -823,6 +835,7 @@ class Node:
"port_segment_size": self._port_segment_size,
"first_port_name": self._first_port_name,
"custom_adapters": self._custom_adapters,
"tags": self._tags,
}
if topology_dump: