|
15 | 15 | from fastapi.middleware.cors import CORSMiddleware |
16 | 16 | from fastapi.openapi.docs import get_swagger_ui_html |
17 | 17 | from fastapi.openapi.utils import get_openapi |
18 | | -from pydantic import BaseModel, IPvAnyAddress, Field, validator |
| 18 | +from pydantic import BaseModel, IPvAnyAddress, Field, field_validator |
19 | 19 |
|
20 | 20 | from cloudproxy.providers import settings |
21 | 21 | from cloudproxy.providers.settings import delete_queue, restart_queue |
@@ -129,8 +129,10 @@ class ProxyAddress(BaseModel): |
129 | 129 | auth_enabled: bool = True |
130 | 130 | url: Optional[str] = None |
131 | 131 |
|
132 | | - @validator('url', always=True) |
133 | | - def set_url(cls, v, values): |
| 132 | + @field_validator('url', mode='before') |
| 133 | + @classmethod |
| 134 | + def set_url(cls, v, info): |
| 135 | + values = info.data |
134 | 136 | ip = str(values.get('ip')) |
135 | 137 | port = values.get('port', 8899) |
136 | 138 | if values.get('auth_enabled'): |
@@ -368,8 +370,10 @@ class ProviderUpdateRequest(BaseModel): |
368 | 370 | min_scaling: int = Field(ge=0, description="Minimum number of proxy instances") |
369 | 371 | max_scaling: int = Field(ge=0, description="Maximum number of proxy instances") |
370 | 372 |
|
371 | | - @validator('max_scaling') |
372 | | - def max_scaling_must_be_greater_than_min(cls, v, values): |
| 373 | + @field_validator('max_scaling') |
| 374 | + @classmethod |
| 375 | + def max_scaling_must_be_greater_than_min(cls, v, info): |
| 376 | + values = info.data |
373 | 377 | if 'min_scaling' in values and v < values['min_scaling']: |
374 | 378 | raise ValueError('max_scaling must be greater than or equal to min_scaling') |
375 | 379 | return v |
|
0 commit comments