mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-05 06:41:13 +02:00
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:
1 parent
56ece7ce88
commit
a3616e6d33
6 files changed
+93
-16
No files matched your search
@@ -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):
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from pydantic import ConfigDict, BaseModel, Field
|
||||
from typing import Optional, Union
|
||||
from typing import Optional, Union, Dict
|
||||
from enum import Enum
|
||||
from uuid import UUID
|
||||
|
||||
@@ -48,9 +48,10 @@ class TemplateBase(BaseModel):
|
||||
template_type: Optional[NodeType] = None
|
||||
compute_id: Optional[str] = None
|
||||
usage: Optional[str] = ""
|
||||
vendor: Optional[str] = Field(None, description="Device vendor (e.g., Cisco, Juniper, Huawei)")
|
||||
model: Optional[str] = Field(None, description="Device model (e.g., ISR4451-X, MX204, NE40E)")
|
||||
netmiko_device_type: Optional[str] = Field(None, description="Netmiko device type for automation (e.g., cisco_ios, juniper_junos, huawei)")
|
||||
tags: Optional[Dict[str, str]] = Field(
|
||||
default_factory=dict,
|
||||
description="User-defined metadata tags as key-value pairs (e.g., {'vendor': 'cisco', 'model': '7200', 'netmiko_device_type': 'cisco_ios'})"
|
||||
)
|
||||
|
||||
|
||||
class TemplateCreate(TemplateBase):
|
||||
|
||||
Reference in new issue
Block a user