mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-05 14:51:13 +02:00
Pydantic v2 migration
This commit is contained in:
1 parent
11f51b3809
commit
9c456532d0
46 files changed
+221
-277
No files matched your search
@@ -15,7 +15,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from typing import Optional, List
|
||||
from pydantic import BaseModel, validator
|
||||
from pydantic import field_validator, ConfigDict, BaseModel
|
||||
from uuid import UUID
|
||||
from enum import Enum
|
||||
|
||||
@@ -53,11 +53,10 @@ class PermissionBase(BaseModel):
|
||||
path: str
|
||||
action: PermissionAction
|
||||
description: Optional[str] = None
|
||||
model_config = ConfigDict(use_enum_values=True)
|
||||
|
||||
class Config:
|
||||
use_enum_values = True
|
||||
|
||||
@validator("action", pre=True)
|
||||
@field_validator("action", mode="before")
|
||||
@classmethod
|
||||
def action_uppercase(cls, v):
|
||||
return v.upper()
|
||||
|
||||
@@ -81,9 +80,7 @@ class PermissionUpdate(PermissionBase):
|
||||
class Permission(DateTimeModelMixin, PermissionBase):
|
||||
|
||||
permission_id: UUID
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
|
||||
class RoleBase(BaseModel):
|
||||
@@ -116,6 +113,4 @@ class Role(DateTimeModelMixin, RoleBase):
|
||||
role_id: UUID
|
||||
is_builtin: bool
|
||||
permissions: List[Permission]
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
Reference in new issue
Block a user