3131from models_library .rest_ordering import OrderBy
3232from models_library .rest_pagination import PageMetaInfoLimitOffset
3333from models_library .users import UserID
34+ from pydantic import TypeAdapter
3435
3536from ._base import BaseRpcApi
3637
@@ -48,8 +49,7 @@ async def register_function(
4849 function : Function ,
4950 ) -> RegisteredFunction :
5051 """Register a function."""
51- return cast (
52- RegisteredFunction ,
52+ return TypeAdapter (RegisteredFunction ).validate_python (
5353 await self ._request (
5454 "register_function" ,
5555 product_name = product_name ,
@@ -66,8 +66,7 @@ async def get_function(
6666 function_id : FunctionID ,
6767 ) -> RegisteredFunction :
6868 """Get a function by ID."""
69- return cast (
70- RegisteredFunction ,
69+ return TypeAdapter (RegisteredFunction ).validate_python (
7170 await self ._request (
7271 "get_function" ,
7372 product_name = product_name ,
@@ -84,8 +83,7 @@ async def get_function_input_schema(
8483 function_id : FunctionID ,
8584 ) -> FunctionInputSchema :
8685 """Get function input schema."""
87- return cast (
88- FunctionInputSchema ,
86+ return TypeAdapter (FunctionInputSchema ).validate_python (
8987 await self ._request (
9088 "get_function_input_schema" ,
9189 product_name = product_name ,
@@ -102,8 +100,7 @@ async def get_function_output_schema(
102100 function_id : FunctionID ,
103101 ) -> FunctionOutputSchema :
104102 """Get function output schema."""
105- return cast (
106- FunctionOutputSchema ,
103+ return TypeAdapter (FunctionOutputSchema ).validate_python (
107104 await self ._request (
108105 "get_function_output_schema" ,
109106 product_name = product_name ,
@@ -140,8 +137,9 @@ async def list_functions(
140137 search_by_multi_columns : str | None = None ,
141138 ) -> tuple [list [RegisteredFunction ], PageMetaInfoLimitOffset ]:
142139 """List available functions."""
143- return cast (
144- tuple [list [RegisteredFunction ], PageMetaInfoLimitOffset ],
140+ return TypeAdapter (
141+ tuple [list [RegisteredFunction ], PageMetaInfoLimitOffset ]
142+ ).validate_python (
145143 await self ._request (
146144 "list_functions" ,
147145 product_name = product_name ,
@@ -167,8 +165,9 @@ async def list_function_jobs(
167165 filter_by_function_job_collection_id : FunctionJobCollectionID | None = None ,
168166 ) -> tuple [list [RegisteredFunctionJob ], PageMetaInfoLimitOffset ]:
169167 """List function jobs."""
170- return cast (
171- tuple [list [RegisteredFunctionJob ], PageMetaInfoLimitOffset ],
168+ return TypeAdapter (
169+ tuple [list [RegisteredFunctionJob ], PageMetaInfoLimitOffset ]
170+ ).validate_python (
172171 await self ._request (
173172 "list_function_jobs" ,
174173 product_name = product_name ,
@@ -193,8 +192,9 @@ async def list_function_jobs_with_status(
193192 filter_by_function_job_collection_id : FunctionJobCollectionID | None = None ,
194193 ) -> tuple [list [RegisteredFunctionJobWithStatus ], PageMetaInfoLimitOffset ]:
195194 """List function jobs with status."""
196- return cast (
197- tuple [list [RegisteredFunctionJobWithStatus ], PageMetaInfoLimitOffset ],
195+ return TypeAdapter (
196+ tuple [list [RegisteredFunctionJobWithStatus ], PageMetaInfoLimitOffset ]
197+ ).validate_python (
198198 await self ._request (
199199 "list_function_jobs_with_status" ,
200200 product_name = product_name ,
@@ -217,8 +217,9 @@ async def list_function_job_collections(
217217 filters : FunctionJobCollectionsListFilters | None = None ,
218218 ) -> tuple [list [RegisteredFunctionJobCollection ], PageMetaInfoLimitOffset ]:
219219 """List function job collections."""
220- return cast (
221- tuple [list [RegisteredFunctionJobCollection ], PageMetaInfoLimitOffset ],
220+ return TypeAdapter (
221+ tuple [list [RegisteredFunctionJobCollection ], PageMetaInfoLimitOffset ]
222+ ).validate_python (
222223 await self ._request (
223224 "list_function_job_collections" ,
224225 product_name = product_name ,
@@ -238,8 +239,7 @@ async def update_function_title(
238239 title : str ,
239240 ) -> RegisteredFunction :
240241 """Update function title."""
241- return cast (
242- RegisteredFunction ,
242+ return TypeAdapter (RegisteredFunction ).validate_python (
243243 await self ._request (
244244 "update_function_title" ,
245245 product_name = product_name ,
@@ -258,8 +258,7 @@ async def update_function_description(
258258 description : str ,
259259 ) -> RegisteredFunction :
260260 """Update function description."""
261- return cast (
262- RegisteredFunction ,
261+ return TypeAdapter (RegisteredFunction ).validate_python (
263262 await self ._request (
264263 "update_function_description" ,
265264 product_name = product_name ,
@@ -278,8 +277,7 @@ async def run_function(
278277 inputs : FunctionInputs ,
279278 ) -> RegisteredFunctionJob :
280279 """Run a function."""
281- return cast (
282- RegisteredFunctionJob ,
280+ return TypeAdapter (RegisteredFunctionJob ).validate_python (
283281 await self ._request (
284282 "run_function" ,
285283 product_name = product_name ,
@@ -297,8 +295,7 @@ async def register_function_job(
297295 function_job : FunctionJob ,
298296 ) -> RegisteredFunctionJob :
299297 """Register a function job."""
300- return cast (
301- RegisteredFunctionJob ,
298+ return TypeAdapter (RegisteredFunctionJob ).validate_python (
302299 await self ._request (
303300 "register_function_job" ,
304301 product_name = product_name ,
@@ -316,8 +313,7 @@ async def patch_registered_function_job(
316313 registered_function_job_patch : RegisteredFunctionJobPatch ,
317314 ) -> RegisteredFunctionJob :
318315 """Patch a registered function job."""
319- return cast (
320- RegisteredFunctionJob ,
316+ return TypeAdapter (RegisteredFunctionJob ).validate_python (
321317 await self ._request (
322318 "patch_registered_function_job" ,
323319 product_name = product_name ,
@@ -335,8 +331,7 @@ async def get_function_job(
335331 function_job_id : FunctionJobID ,
336332 ) -> RegisteredFunctionJob :
337333 """Get a function job."""
338- return cast (
339- RegisteredFunctionJob ,
334+ return TypeAdapter (RegisteredFunctionJob ).validate_python (
340335 await self ._request (
341336 "get_function_job" ,
342337 product_name = product_name ,
@@ -353,8 +348,7 @@ async def get_function_job_status(
353348 function_job_id : FunctionJobID ,
354349 ) -> FunctionJobStatus :
355350 """Get function job status."""
356- return cast (
357- FunctionJobStatus ,
351+ return TypeAdapter (FunctionJobStatus ).validate_python (
358352 await self ._request (
359353 "get_function_job_status" ,
360354 product_name = product_name ,
@@ -371,8 +365,7 @@ async def get_function_job_outputs(
371365 function_job_id : FunctionJobID ,
372366 ) -> FunctionOutputs :
373367 """Get function job outputs."""
374- return cast (
375- FunctionOutputs ,
368+ return TypeAdapter (FunctionOutputs ).validate_python (
376369 await self ._request (
377370 "get_function_job_outputs" ,
378371 product_name = product_name ,
@@ -391,8 +384,7 @@ async def update_function_job_status(
391384 check_write_permissions : bool = True ,
392385 ) -> FunctionJobStatus :
393386 """Update function job status."""
394- return cast (
395- FunctionJobStatus ,
387+ return TypeAdapter (FunctionJobStatus ).validate_python (
396388 await self ._request (
397389 "update_function_job_status" ,
398390 product_name = product_name ,
@@ -413,8 +405,7 @@ async def update_function_job_outputs(
413405 check_write_permissions : bool = True ,
414406 ) -> FunctionOutputs :
415407 """Update function job outputs."""
416- return cast (
417- FunctionOutputs ,
408+ return TypeAdapter (FunctionOutputs ).validate_python (
418409 await self ._request (
419410 "update_function_job_outputs" ,
420411 product_name = product_name ,
@@ -449,8 +440,7 @@ async def find_cached_function_jobs(
449440 inputs : FunctionInputs ,
450441 ) -> list [RegisteredFunctionJob ] | None :
451442 """Find cached function jobs."""
452- return cast (
453- list [RegisteredFunctionJob ] | None ,
443+ return TypeAdapter (list [RegisteredFunctionJob ] | None ).validate_python (
454444 await self ._request (
455445 "find_cached_function_jobs" ,
456446 product_name = product_name ,
@@ -468,8 +458,7 @@ async def register_function_job_collection(
468458 function_job_collection : FunctionJobCollection ,
469459 ) -> RegisteredFunctionJobCollection :
470460 """Register a function job collection."""
471- return cast (
472- RegisteredFunctionJobCollection ,
461+ return TypeAdapter (RegisteredFunctionJobCollection ).validate_python (
473462 await self ._request (
474463 "register_function_job_collection" ,
475464 product_name = product_name ,
@@ -486,8 +475,7 @@ async def get_function_job_collection(
486475 function_job_collection_id : FunctionJobCollectionID ,
487476 ) -> RegisteredFunctionJobCollection :
488477 """Get a function job collection."""
489- return cast (
490- RegisteredFunctionJobCollection ,
478+ return TypeAdapter (RegisteredFunctionJobCollection ).validate_python (
491479 await self ._request (
492480 "get_function_job_collection" ,
493481 product_name = product_name ,
@@ -519,8 +507,7 @@ async def get_function_user_permissions(
519507 function_id : FunctionID ,
520508 ) -> FunctionUserAccessRights :
521509 """Get function user permissions."""
522- return cast (
523- FunctionUserAccessRights ,
510+ return TypeAdapter (FunctionUserAccessRights ).validate_python (
524511 await self ._request (
525512 "get_function_user_permissions" ,
526513 product_name = product_name ,
@@ -536,8 +523,7 @@ async def get_functions_user_api_access_rights(
536523 user_id : UserID ,
537524 ) -> FunctionUserApiAccessRights :
538525 """Get functions user API access rights."""
539- return cast (
540- FunctionUserApiAccessRights ,
526+ return TypeAdapter (FunctionUserApiAccessRights ).validate_python (
541527 await self ._request (
542528 "get_functions_user_api_access_rights" ,
543529 product_name = product_name ,
0 commit comments