-
Notifications
You must be signed in to change notification settings - Fork 492
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NAS-132736 / 25.04 / Convert pool.scrub to new api style (#15045)
* pause * test * fix CRUDService.query call * don't fail in @job if args are not provided (fail in @api_method instead) * exclude pool_name from pool.scrub.update args
- Loading branch information
1 parent
feca45d
commit 90d1f68
Showing
3 changed files
with
98 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
from typing import Annotated, Literal | ||
|
||
from pydantic import Field, PositiveInt | ||
|
||
from middlewared.api.base import BaseModel, Excluded, excluded_field, ForUpdateMetaclass | ||
from .common import CronModel | ||
|
||
|
||
__all__ = [ | ||
"PoolScrubEntry", "PoolScrubCreateArgs", "PoolScrubCreateResult", "PoolScrubUpdateArgs", "PoolScrubUpdateResult", | ||
"PoolScrubDeleteArgs", "PoolScrubDeleteResult", "PoolScrubScrubArgs", "PoolScrubScrubResult", "PoolScrubRunArgs", | ||
"PoolScrubRunResult" | ||
] | ||
|
||
|
||
class PoolScrubCron(CronModel): | ||
minute: str = "00" | ||
hour: str = "00" | ||
dow: str = "7" | ||
|
||
|
||
class PoolScrubEntry(BaseModel): | ||
pool: PositiveInt | ||
threshold: Annotated[int, Field(ge=0)] | ||
description: str | ||
schedule: PoolScrubCron | ||
enabled: bool = True | ||
id: int | ||
pool_name: str | ||
|
||
|
||
class PoolScrubCreate(PoolScrubEntry): | ||
id: Excluded = excluded_field() | ||
pool_name: Excluded = excluded_field() | ||
|
||
|
||
class PoolScrubUpdate(PoolScrubCreate, metaclass=ForUpdateMetaclass): | ||
pass | ||
|
||
|
||
class PoolScrubCreateArgs(BaseModel): | ||
data: PoolScrubCreate | ||
|
||
|
||
class PoolScrubCreateResult(BaseModel): | ||
result: PoolScrubEntry | ||
|
||
|
||
class PoolScrubUpdateArgs(BaseModel): | ||
id_: int | ||
data: PoolScrubUpdate | ||
|
||
|
||
class PoolScrubUpdateResult(BaseModel): | ||
result: PoolScrubEntry | ||
|
||
|
||
class PoolScrubDeleteArgs(BaseModel): | ||
id_: int | ||
|
||
|
||
class PoolScrubDeleteResult(BaseModel): | ||
result: Literal[True] | ||
|
||
|
||
class PoolScrubScrubArgs(BaseModel): | ||
name: str | ||
action: Literal["START", "STOP", "PAUSE"] = "START" | ||
|
||
|
||
class PoolScrubScrubResult(BaseModel): | ||
result: None | ||
|
||
|
||
class PoolScrubRunArgs(BaseModel): | ||
name: str | ||
threshold: int = 35 | ||
|
||
|
||
class PoolScrubRunResult(BaseModel): | ||
result: None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters