@@ -188,6 +188,14 @@ async def force_pw_principal(self, name: str, **dbargs) -> None:
188188 :param str name: principal
189189 """
190190
191+ @abstractmethod
192+ async def rename_princ (self , name : str , new_name : str ) -> None :
193+ """Rename principal.
194+
195+ :param str name: original name
196+ :param str new_name: new name
197+ """
198+
191199 @abstractmethod
192200 async def modify_principal (
193201 self ,
@@ -272,6 +280,19 @@ async def add_princ(
272280 partial (princ .modify , attributes = 128 ),
273281 )
274282
283+ async def rename_princ (self , name : str , new_name : str ) -> None :
284+ """Rename principal.
285+
286+ :param str name: original name
287+ :param str new_name: new name
288+ """
289+ await self .loop .run_in_executor (
290+ self .pool ,
291+ self .client .rename_principal ,
292+ name ,
293+ new_name ,
294+ )
295+
275296 async def _get_raw_principal (self , name : str ) -> PrincipalProtocol :
276297 principal = await self .loop .run_in_executor (
277298 self .pool ,
@@ -640,6 +661,25 @@ async def create_or_update_princ_password(
640661 await kadmin .create_or_update_princ_pw (name , password )
641662
642663
664+ @principal_router .put (
665+ "/rename" ,
666+ status_code = status .HTTP_202_ACCEPTED ,
667+ response_class = Response ,
668+ )
669+ async def rename_princ (
670+ kadmin : Annotated [AbstractKRBManager , Depends (get_kadmin )],
671+ name : Annotated [str , Body ()],
672+ new_name : Annotated [str , Body ()],
673+ ) -> None :
674+ """Rename principal.
675+
676+ :param Annotated[AbstractKRBManager, Depends kadmin: kadmin abstract
677+ :param Annotated[str, Body name: principal name
678+ :param Annotated[str, Body new_name: principal new name
679+ """
680+ await kadmin .rename_princ (name , new_name )
681+
682+
643683@principal_router .put (
644684 "/modify" ,
645685 status_code = status .HTTP_202_ACCEPTED ,
0 commit comments