@@ -19,7 +19,7 @@ class Config:
19
19
use_enum_values = True
20
20
21
21
22
- class OperationTypeEnum (Enum ):
22
+ class OperationType (Enum ):
23
23
"""
24
24
Supported search entity types
25
25
Each type corresponds to a different filter class
@@ -35,8 +35,14 @@ class OperationTypeEnum(Enum):
35
35
TaskRemainingCount = 'task_remaining_count'
36
36
37
37
38
- OperationType = Annotated [OperationTypeEnum ,
39
- PlainSerializer (lambda x : x .value , return_type = str )]
38
+ def convert_enum_to_str (enum_or_str : Union [Enum , str ]) -> str :
39
+ if isinstance (enum_or_str , Enum ):
40
+ return enum_or_str .value
41
+ return enum_or_str
42
+
43
+
44
+ OperationType = Annotated [OperationType ,
45
+ PlainSerializer (convert_enum_to_str , return_type = str )]
40
46
41
47
IsoDatetimeType = Annotated [datetime .datetime ,
42
48
PlainSerializer (format_iso_datetime )]
@@ -77,7 +83,7 @@ class OrganizationFilter(BaseSearchFilter):
77
83
"""
78
84
Filter for organization to which projects belong
79
85
"""
80
- operation : OperationType = Field (default = OperationTypeEnum .Organization ,
86
+ operation : OperationType = Field (default = OperationType .Organization ,
81
87
serialization_alias = 'type' )
82
88
operator : IdOperator
83
89
values : List [str ]
@@ -89,7 +95,7 @@ class SharedWithOrganizationFilter(BaseSearchFilter):
89
95
"""
90
96
91
97
operation : OperationType = Field (
92
- default = OperationTypeEnum .SharedWithOrganization ,
98
+ default = OperationType .SharedWithOrganization ,
93
99
serialization_alias = 'type' )
94
100
operator : IdOperator
95
101
values : List [str ]
@@ -99,7 +105,7 @@ class WorkspaceFilter(BaseSearchFilter):
99
105
"""
100
106
Filter for workspace
101
107
"""
102
- operation : OperationType = Field (default = OperationTypeEnum .Workspace ,
108
+ operation : OperationType = Field (default = OperationType .Workspace ,
103
109
serialization_alias = 'type' )
104
110
operator : IdOperator
105
111
values : List [str ]
@@ -110,7 +116,7 @@ class TagFilter(BaseSearchFilter):
110
116
Filter for project tags
111
117
values are tag ids
112
118
"""
113
- operation : OperationType = Field (default = OperationTypeEnum .Tag ,
119
+ operation : OperationType = Field (default = OperationType .Tag ,
114
120
serialization_alias = 'type' )
115
121
operator : IdOperator
116
122
values : List [str ]
@@ -121,7 +127,7 @@ class ProjectStageFilter(BaseSearchFilter):
121
127
Filter labelbox service / aka project stages
122
128
Stages are: requested, in_progress, completed etc. as described by LabelingServiceStatus
123
129
"""
124
- operation : OperationType = Field (default = OperationTypeEnum .Stage ,
130
+ operation : OperationType = Field (default = OperationType .Stage ,
125
131
serialization_alias = 'type' )
126
132
operator : IdOperator
127
133
values : List [LabelingServiceStatus ]
@@ -163,7 +169,7 @@ class WorkforceStageUpdatedFilter(BaseSearchFilter):
163
169
Filter for workforce stage updated date
164
170
"""
165
171
operation : OperationType = Field (
166
- default = OperationTypeEnum .WorkforceStageUpdatedDate ,
172
+ default = OperationType .WorkforceStageUpdatedDate ,
167
173
serialization_alias = 'type' )
168
174
value : DateValue
169
175
@@ -173,8 +179,7 @@ class WorkforceRequestedDateFilter(BaseSearchFilter):
173
179
Filter for workforce requested date
174
180
"""
175
181
operation : OperationType = Field (
176
- default = OperationTypeEnum .WorforceRequestedDate ,
177
- serialization_alias = 'type' )
182
+ default = OperationType .WorforceRequestedDate , serialization_alias = 'type' )
178
183
value : DateValue
179
184
180
185
@@ -199,8 +204,7 @@ class WorkforceRequestedDateRangeFilter(BaseSearchFilter):
199
204
Filter for workforce requested date range
200
205
"""
201
206
operation : OperationType = Field (
202
- default = OperationTypeEnum .WorforceRequestedDate ,
203
- serialization_alias = 'type' )
207
+ default = OperationType .WorforceRequestedDate , serialization_alias = 'type' )
204
208
value : DateRangeValue
205
209
206
210
@@ -209,7 +213,7 @@ class WorkforceStageUpdatedRangeFilter(BaseSearchFilter):
209
213
Filter for workforce stage updated date range
210
214
"""
211
215
operation : OperationType = Field (
212
- default = OperationTypeEnum .WorkforceStageUpdatedDate ,
216
+ default = OperationType .WorkforceStageUpdatedDate ,
213
217
serialization_alias = 'type' )
214
218
value : DateRangeValue
215
219
@@ -219,19 +223,17 @@ class TaskCompletedCountFilter(BaseSearchFilter):
219
223
Filter for completed tasks count
220
224
A task maps to a data row. Task completed should map to a data row in a labeling queue DONE
221
225
"""
222
- operation : OperationType = Field (
223
- default = OperationTypeEnum .TaskCompletedCount ,
224
- serialization_alias = 'type' )
226
+ operation : OperationType = Field (default = OperationType .TaskCompletedCount ,
227
+ serialization_alias = 'type' )
225
228
value : IntegerValue
226
229
227
230
228
231
class TaskRemainingCountFilter (BaseSearchFilter ):
229
232
"""
230
233
Filter for remaining tasks count. Reverse of TaskCompletedCountFilter
231
234
"""
232
- operation : OperationType = Field (
233
- default = OperationTypeEnum .TaskRemainingCount ,
234
- serialization_alias = 'type' )
235
+ operation : OperationType = Field (default = OperationType .TaskRemainingCount ,
236
+ serialization_alias = 'type' )
235
237
value : IntegerValue
236
238
237
239
0 commit comments