forked from VallariAg/teuthology-api
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add PresetCreate schema, update Presets cmd column type
Added a schema for /add endpoint request body for validating cmd attribute. Updated the cmd column datatype from string to JSON for the Presets model. Signed-off-by: Devansh Singh <[email protected]>
- Loading branch information
1 parent
bd3b11d
commit f0fa121
Showing
4 changed files
with
29 additions
and
9 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 |
---|---|---|
@@ -1,11 +1,14 @@ | ||
from sqlmodel import Field, SQLModel, UniqueConstraint | ||
from pydantic import ConfigDict | ||
from sqlmodel import Column, Field, JSON, SQLModel, UniqueConstraint | ||
|
||
|
||
class Presets(SQLModel, table=True): | ||
model_config = ConfigDict(arbitrary_types_allowed=True) | ||
|
||
id: int = Field(primary_key=True) | ||
username: str = Field(index=True) | ||
name: str | ||
suite: str | ||
cmd: str | ||
cmd: JSON = Field(sa_column=Column(JSON)) | ||
|
||
__table_args__ = (UniqueConstraint("username", "name"),) |
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,12 @@ | ||
from pydantic import BaseModel | ||
|
||
from teuthology_api.schemas.suite import SuiteArgs | ||
|
||
|
||
class PresetCreate(BaseModel): | ||
name: str | ||
suite: str | ||
cmd: SuiteArgs | ||
|
||
def model_post_init(self, __context): | ||
self.cmd = self.cmd.model_dump() |