mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-06 07:11:13 +02:00
Merge branch '3.1' into mypy-schemas-plus
This commit is contained in:
84 files changed
+503
-506
No files matched your search
@@ -782,7 +782,7 @@ Appliance = ApplianceUnion
|
||||
# Create a validator wrapper for convenience
|
||||
from pydantic import TypeAdapter
|
||||
|
||||
_appliance_validator = TypeAdapter(ApplianceUnion)
|
||||
_appliance_validator: TypeAdapter[Union[ApplianceV1_6, ApplianceV8]] = TypeAdapter(ApplianceUnion)
|
||||
|
||||
|
||||
class ApplianceModel:
|
||||
|
||||
@@ -114,9 +114,9 @@ class NodeBase(BaseModel):
|
||||
Node data.
|
||||
"""
|
||||
|
||||
compute_id: Union[UUID, str]
|
||||
name: str
|
||||
node_type: NodeType
|
||||
compute_id: Optional[Union[UUID, str]] = None
|
||||
name: Optional[str] = None
|
||||
node_type: Optional[NodeType] = None
|
||||
|
||||
node_id: Optional[UUID] = None
|
||||
|
||||
@@ -162,6 +162,9 @@ class NodeBase(BaseModel):
|
||||
|
||||
|
||||
class NodeCreate(NodeBase):
|
||||
compute_id: Union[UUID, str]
|
||||
name: str
|
||||
node_type: NodeType
|
||||
node_id: UUID = Field(default_factory=uuid4)
|
||||
|
||||
|
||||
@@ -170,12 +173,13 @@ class NodeUpdate(NodeBase):
|
||||
Data to update a node.
|
||||
"""
|
||||
|
||||
compute_id: Optional[Union[UUID, str]] = None
|
||||
name: Optional[str] = None
|
||||
node_type: Optional[NodeType] = None
|
||||
pass
|
||||
|
||||
|
||||
class Node(NodeBase):
|
||||
compute_id: Union[UUID, str]
|
||||
name: str
|
||||
node_type: NodeType
|
||||
template_id: Optional[UUID] = Field(
|
||||
None, description="Template UUID from which the node has been created. Read only"
|
||||
)
|
||||
|
||||
@@ -45,7 +45,7 @@ class ProjectBase(BaseModel):
|
||||
Common properties for projects.
|
||||
"""
|
||||
|
||||
name: str
|
||||
name: Optional[str] = None
|
||||
project_id: Optional[UUID] = None
|
||||
path: Optional[str] = Field(None, description="Project directory")
|
||||
auto_close: Optional[bool] = Field(None, description="Close project when last client leaves")
|
||||
@@ -69,7 +69,7 @@ class ProjectCreate(ProjectBase):
|
||||
Properties for project creation.
|
||||
"""
|
||||
|
||||
pass
|
||||
name: str
|
||||
|
||||
|
||||
class ProjectDuplicate(ProjectBase):
|
||||
@@ -77,6 +77,7 @@ class ProjectDuplicate(ProjectBase):
|
||||
Properties for project duplication.
|
||||
"""
|
||||
|
||||
name: str
|
||||
reset_mac_addresses: Optional[bool] = Field(False, description="Reset MAC addresses for this project")
|
||||
|
||||
|
||||
@@ -85,12 +86,11 @@ class ProjectUpdate(ProjectBase):
|
||||
Properties for project update.
|
||||
"""
|
||||
|
||||
name: Optional[str] = None
|
||||
pass
|
||||
|
||||
|
||||
class Project(ProjectBase):
|
||||
project_id: UUID
|
||||
name: Optional[str] = None
|
||||
status: Optional[ProjectStatus] = None
|
||||
filename: Optional[str] = None
|
||||
created_by: Optional[str] = Field(None, description="Username of the user who created the project")
|
||||
|
||||
@@ -25,6 +25,7 @@ says, so exposing or writing it via the API would be useless at best and
|
||||
a secret leak at worst.
|
||||
"""
|
||||
|
||||
from pathlib import Path
|
||||
from typing import List, Optional
|
||||
|
||||
from pydantic import ConfigDict, BaseModel, Field
|
||||
@@ -49,9 +50,11 @@ SECRET_MASK = "**********"
|
||||
class ServerSettingsResponse(ServerSettings):
|
||||
# plain strings instead of FilePath/DirectoryPath: paths are validated when
|
||||
# the settings are loaded or updated, not when echoed back to the client
|
||||
secrets_dir: Optional[str] = Field(None, description="Directory where secrets are stored (e.g. the JWT secret key)")
|
||||
certfile: Optional[str] = Field(None, description="SSL certificate file, requires enable_ssl")
|
||||
certkey: Optional[str] = Field(None, description="SSL key file, requires enable_ssl")
|
||||
secrets_dir: Optional[Path] = Field(
|
||||
None, description="Directory where secrets are stored (e.g. the JWT secret key)"
|
||||
)
|
||||
certfile: Optional[Path] = Field(None, description="SSL certificate file, requires enable_ssl")
|
||||
certkey: Optional[Path] = Field(None, description="SSL key file, requires enable_ssl")
|
||||
# Optional overrides: typed as plain "str = None" in the config schema,
|
||||
# which fails re-validation when the value actually is None
|
||||
resources_path: Optional[str] = Field(
|
||||
|
||||
@@ -22,11 +22,11 @@ from pydantic import Field
|
||||
from typing import Optional, List
|
||||
|
||||
|
||||
class DockerTemplate(TemplateBase):
|
||||
class DockerTemplateBase(TemplateBase):
|
||||
category: Optional[Category] = Category.guest
|
||||
default_name_format: Optional[str] = "{name}-{0}"
|
||||
symbol: Optional[str] = "docker_guest"
|
||||
image: str = Field(..., description="Docker image name")
|
||||
image: Optional[str] = Field(None, description="Docker image name")
|
||||
adapters: Optional[int] = Field(1, ge=0, le=100, description="Number of adapters")
|
||||
mac_address: Optional[str] = Field(
|
||||
"", description="Base MAC address", pattern="^([0-9a-fA-F]{2}[:]){5}([0-9a-fA-F]{2})$|^$"
|
||||
@@ -58,5 +58,9 @@ class DockerTemplate(TemplateBase):
|
||||
custom_adapters: Optional[List[CustomAdapter]] = Field(default_factory=list, description="Custom adapters")
|
||||
|
||||
|
||||
class DockerTemplateUpdate(DockerTemplate):
|
||||
image: Optional[str] = Field(None, description="Docker image name")
|
||||
class DockerTemplate(DockerTemplateBase):
|
||||
image: str = Field(..., description="Docker image name")
|
||||
|
||||
|
||||
class DockerTemplateUpdate(DockerTemplateBase):
|
||||
pass
|
||||
@@ -80,7 +80,7 @@ class UserGroupCreate(UserGroupBase):
|
||||
Properties to create a user group.
|
||||
"""
|
||||
|
||||
name: Optional[str] = Field(..., min_length=3, pattern="[a-zA-Z0-9_-]+$")
|
||||
name: str = Field(..., min_length=3, pattern="[a-zA-Z0-9_-]+$")
|
||||
|
||||
|
||||
class UserGroupUpdate(UserGroupBase):
|
||||
|
||||
Reference in new issue
Block a user