29 lines
676 B
Python
29 lines
676 B
Python
|
from typing import List, Optional
|
||
|
import uuid
|
||
|
from pydantic import UUID4, BaseModel, ConfigDict, Field
|
||
|
|
||
|
class VM(BaseModel):
|
||
|
model_config = ConfigDict(from_attributes=True)
|
||
|
|
||
|
id:UUID4
|
||
|
name:str
|
||
|
state:str
|
||
|
|
||
|
class Datacenter(BaseModel):
|
||
|
model_config = ConfigDict(from_attributes=True)
|
||
|
|
||
|
company_id:UUID4
|
||
|
id:UUID4
|
||
|
name:str
|
||
|
cluster_id:UUID4
|
||
|
storage_pool_id:UUID4
|
||
|
vm:List[VM] = Field(default=[])
|
||
|
|
||
|
class DatacenterCreate(BaseModel):
|
||
|
model_config = ConfigDict(from_attributes=True)
|
||
|
|
||
|
company_id:UUID4
|
||
|
id:Optional[UUID4] = Field(default_factory=lambda:uuid.uuid4())
|
||
|
name:str
|
||
|
cluster_id:UUID4
|
||
|
storage_pool_id:UUID4
|