mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
feat(api): add discriminators to link iface, appliance version and template settings schemas
This commit is contained in:
9 files changed
+202
-12
No files matched your search
@@ -19,7 +19,7 @@ API routes for appliances.
|
||||
"""
|
||||
|
||||
import logging
|
||||
from typing import List, Optional, Union
|
||||
from typing import List, Optional
|
||||
from uuid import UUID
|
||||
|
||||
from fastapi import APIRouter, Depends, status
|
||||
@@ -85,9 +85,7 @@ def get_appliance(appliance_id: UUID) -> schemas.Appliance:
|
||||
status_code=status.HTTP_201_CREATED,
|
||||
dependencies=[Depends(has_privilege("Appliance.Allocate"))],
|
||||
)
|
||||
def add_appliance_version(
|
||||
appliance_id: UUID, appliance_version: Union[schemas.ApplianceVersion, schemas.ApplianceVersionV8]
|
||||
) -> dict:
|
||||
def add_appliance_version(appliance_id: UUID, appliance_version: schemas.ApplianceVersionCreate) -> dict:
|
||||
"""
|
||||
Add a version to an appliance.
|
||||
|
||||
@@ -109,7 +107,7 @@ def add_appliance_version(
|
||||
if version.get("name") == appliance_version.name:
|
||||
raise ControllerError(message=f"Appliance '{appliance_id}' already has version '{appliance_version.name}'")
|
||||
|
||||
appliance.versions.append(appliance_version.model_dump(exclude_unset=True))
|
||||
appliance.versions.append(appliance_version.model_dump(exclude_unset=True, exclude={"registry_version"}))
|
||||
return appliance.asdict()
|
||||
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ API routes for links.
|
||||
|
||||
import logging
|
||||
import os
|
||||
from typing import Any, List, Union
|
||||
from typing import Any, List
|
||||
from uuid import UUID, uuid4
|
||||
|
||||
import aiohttp
|
||||
@@ -484,7 +484,7 @@ async def update_marker(marker_name: str, marker_data: schemas.MarkerUpdate, lin
|
||||
|
||||
@router.get(
|
||||
"/{link_id}/iface",
|
||||
response_model=Union[schemas.UDPPortInfo, schemas.EthernetPortInfo],
|
||||
response_model=schemas.LinkIfaceInfo,
|
||||
dependencies=[Depends(has_privilege("Link.Audit"))],
|
||||
)
|
||||
async def get_iface(link: Link = Depends(dep_link)) -> dict:
|
||||
@@ -515,6 +515,7 @@ async def get_iface(link: Link = Depends(dep_link)) -> dict:
|
||||
port_type = port.get("type", "")
|
||||
if "udp" in port_type.lower():
|
||||
ifaces_info = {
|
||||
"kind": "udp",
|
||||
"node_id": node.id,
|
||||
"type": f"{port_type}",
|
||||
"lport": port["lport"],
|
||||
@@ -523,6 +524,7 @@ async def get_iface(link: Link = Depends(dep_link)) -> dict:
|
||||
}
|
||||
else:
|
||||
ifaces_info = {
|
||||
"kind": "ethernet",
|
||||
"node_id": node.id,
|
||||
"type": f"{port_type}",
|
||||
"interface": port["interface"],
|
||||
|
||||
Reference in new issue
Block a user