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

+5 -1
View File
@@ -15,7 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from pydantic import BaseModel, Field, model_validator
from typing import List, Optional, Union, Any
from typing import List, Optional, Union, Any, Dict
from enum import Enum
from uuid import UUID, uuid4
@@ -133,6 +133,10 @@ class NodeBase(BaseModel):
port_segment_size: Optional[int] = Field(None, description="Size of the port segment")
first_port_name: Optional[str] = Field(None, description="Name of the first port")
custom_adapters: Optional[List[CustomAdapter]] = None
tags: Optional[Dict[str, str]] = Field(
default_factory=dict,
description="User-defined metadata tags inherited from template or custom"
)
class NodeCreate(NodeBase):