mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 22:11:14 +02:00
feat(api): add exact-match name filter to list endpoints
This commit is contained in:
11 files changed
+167
-6
No files matched your search
@@ -195,6 +195,7 @@ async def get_templates(
|
||||
templates_repo: TemplatesRepository = Depends(get_repository(TemplatesRepository)),
|
||||
current_user: schemas.User = Depends(get_current_active_user),
|
||||
tags: Optional[List[str]] = Query(None, description="Filter by tags (e.g. tags=vendor:cisco&tags=model:7200)"),
|
||||
name: Optional[str] = Query(None, description="Return only templates whose name exactly matches (case-sensitive)"),
|
||||
) -> List[dict]:
|
||||
"""
|
||||
Return all templates.
|
||||
@@ -204,10 +205,14 @@ async def get_templates(
|
||||
Query Parameters:
|
||||
- tags: Filter by tags. Multiple tags are ANDed together.
|
||||
Example: ?tags=vendor:cisco&tags=model:7200
|
||||
- name: Exact, case-sensitive match on the template name. Combined with other filters using AND.
|
||||
"""
|
||||
|
||||
templates = await TemplatesService(templates_repo).get_templates()
|
||||
|
||||
if name is not None:
|
||||
templates = [template for template in templates if template.get("name") == name]
|
||||
|
||||
# Filter by tags if provided (all filter tags have to match the node tags)
|
||||
if tags:
|
||||
filtered_templates = []
|
||||
|
||||
Reference in new issue
Block a user