@@ -627,14 +627,14 @@ async def delete_function(
627627 )
628628
629629
630- async def update_function_title (
630+ async def _update_function_attribute (
631631 app : web .Application ,
632- connection : AsyncConnection | None = None ,
632+ connection : AsyncConnection | None ,
633633 * ,
634634 user_id : UserID ,
635635 product_name : ProductName ,
636636 function_id : FunctionID ,
637- title : str ,
637+ ** update_kwargs ,
638638) -> RegisteredFunctionDB :
639639 async with transaction_context (get_asyncpg_engine (app ), connection ) as transaction :
640640 await check_user_api_access_rights (
@@ -661,7 +661,7 @@ async def update_function_title(
661661 result = await transaction .execute (
662662 functions_table .update ()
663663 .where (functions_table .c .uuid == function_id )
664- .values (title = title )
664+ .values (** update_kwargs )
665665 .returning (* _FUNCTIONS_TABLE_COLS )
666666 )
667667 row = result .one_or_none ()
@@ -672,48 +672,42 @@ async def update_function_title(
672672 return RegisteredFunctionDB .model_validate (row )
673673
674674
675- async def update_function_description (
675+ async def update_function_title (
676676 app : web .Application ,
677677 connection : AsyncConnection | None = None ,
678678 * ,
679679 user_id : UserID ,
680680 product_name : ProductName ,
681681 function_id : FunctionID ,
682- description : str ,
682+ title : str ,
683683) -> RegisteredFunctionDB :
684- async with transaction_context (get_asyncpg_engine (app ), connection ) as transaction :
685- await check_user_api_access_rights (
686- app ,
687- connection = transaction ,
688- user_id = user_id ,
689- product_name = product_name ,
690- api_access_rights = [
691- FunctionsApiAccessRights .READ_FUNCTIONS ,
692- FunctionsApiAccessRights .WRITE_FUNCTIONS ,
693- ],
694- )
695- await check_user_permissions (
696- app ,
697- transaction ,
698- user_id = user_id ,
699- product_name = product_name ,
700- object_id = function_id ,
701- object_type = "function" ,
702- permissions = ["write" ],
703- )
704-
705- result = await transaction .execute (
706- functions_table .update ()
707- .where (functions_table .c .uuid == function_id )
708- .values (description = description )
709- .returning (* _FUNCTIONS_TABLE_COLS )
710- )
711- row = result .one_or_none ()
684+ return await _update_function_attribute (
685+ app ,
686+ connection = connection ,
687+ user_id = user_id ,
688+ product_name = product_name ,
689+ function_id = function_id ,
690+ title = title ,
691+ )
712692
713- if row is None :
714- raise FunctionIDNotFoundError (function_id = function_id )
715693
716- return RegisteredFunctionDB .model_validate (row )
694+ async def update_function_description (
695+ app : web .Application ,
696+ connection : AsyncConnection | None = None ,
697+ * ,
698+ user_id : UserID ,
699+ product_name : ProductName ,
700+ function_id : FunctionID ,
701+ description : str ,
702+ ) -> RegisteredFunctionDB :
703+ return await _update_function_attribute (
704+ app ,
705+ connection = connection ,
706+ user_id = user_id ,
707+ product_name = product_name ,
708+ function_id = function_id ,
709+ description = description ,
710+ )
717711
718712
719713async def get_function_job (
0 commit comments