Skip to content

Commit 1c7505b

Browse files
committed
fix(schema): resolve TasksQueryReq (de)serde issue
1 parent da8c040 commit 1c7505b

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

src/pynetmito/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
ArtifactContentType,
99
AttachmentContentType,
1010
TaskExecState,
11+
UserState,
12+
GroupState,
13+
WorkerState,
14+
UserGroupRole,
15+
GroupWorkerRole,
1116
TaskResultMessage,
1217
RemoteResource,
1318
RemoteResourceDownload,
@@ -63,6 +68,11 @@
6368
"ArtifactContentType",
6469
"AttachmentContentType",
6570
"TaskExecState",
71+
"UserState",
72+
"GroupState",
73+
"WorkerState",
74+
"UserGroupRole",
75+
"GroupWorkerRole",
6676
"TaskResultMessage",
6777
"RemoteResource",
6878
"RemoteResourceDownload",

src/pynetmito/schemas.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,42 @@ class TasksQueryReq(BaseAPIModel):
376376
offset: Optional[NonNegativeInt] = Field(default=None)
377377
count: bool = Field(default=False)
378378

379+
@field_serializer("creator_usernames")
380+
def serialize_creator_usernames(self, creator_usernames: Optional[Set[str]]):
381+
return list(creator_usernames) if creator_usernames else None
382+
383+
@field_validator("creator_usernames", mode="before")
384+
@classmethod
385+
def deserialize_creator_usernames(cls, creator_usernames: Optional[list[str]]):
386+
return set(creator_usernames) if creator_usernames else None
387+
388+
@field_serializer("tags")
389+
def serialize_tags(self, tags: Optional[Set[str]]):
390+
return list(tags) if tags else None
391+
392+
@field_validator("tags", mode="before")
393+
@classmethod
394+
def deserialize_tags(cls, tags: Optional[list[str]]):
395+
return set(tags) if tags else None
396+
397+
@field_serializer("labels")
398+
def serialize_labels(self, labels: Optional[Set[str]]):
399+
return list(labels) if labels else None
400+
401+
@field_validator("labels", mode="before")
402+
@classmethod
403+
def deserialize_labels(cls, labels: Optional[list[str]]):
404+
return set(labels) if labels else None
405+
406+
@field_serializer("states")
407+
def serialize_states(self, states: Optional[Set[TaskState]]):
408+
return list(states) if states else None
409+
410+
@field_validator("states", mode="before")
411+
@classmethod
412+
def deserialize_states(cls, states: Optional[list[TaskState]]):
413+
return set(states) if states else None
414+
379415

380416
class TaskQueryInfo(BaseAPIModel):
381417
model_config = ConfigDict(

0 commit comments

Comments
 (0)