34 lines
1.1 KiB
Python
34 lines
1.1 KiB
Python
"""预算管理相关 Pydantic 模型"""
|
|
|
|
from typing import Optional
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class BudgetCreateRequest(BaseModel):
|
|
budget_type: str = Field(..., pattern="^(tenant|project)$")
|
|
project_id: Optional[int] = None
|
|
period: str = Field(default="monthly", pattern="^(monthly|quarterly|yearly)$")
|
|
budget_amount_usd: float = Field(..., gt=0)
|
|
alert_threshold_percent: float = Field(default=80.0, ge=1.0, le=100.0)
|
|
hard_limit_enabled: bool = True
|
|
|
|
|
|
class BudgetUpdateRequest(BaseModel):
|
|
period: Optional[str] = Field(default=None, pattern="^(monthly|quarterly|yearly)$")
|
|
budget_amount_usd: Optional[float] = Field(default=None, gt=0)
|
|
alert_threshold_percent: Optional[float] = Field(default=None, ge=1.0, le=100.0)
|
|
hard_limit_enabled: Optional[bool] = None
|
|
status: Optional[str] = Field(default=None, pattern="^(active|suspended|overridden)$")
|
|
|
|
|
|
class BudgetOverrideRequest(BaseModel):
|
|
note: str = ""
|
|
duration_hours: int = Field(default=24, ge=1, le=168)
|
|
|
|
|
|
class BudgetCheckRequest(BaseModel):
|
|
estimated_cost_usd: float = Field(..., ge=0)
|
|
project_id: Optional[int] = None
|
|
|