2323from doccano_client .models .role import Role
2424from doccano_client .models .task_status import TaskStatus
2525from doccano_client .models .user import User
26+ from doccano_client .models .user_details import PasswordUpdated , UserDetails
2627from doccano_client .repositories .base import BaseRepository
2728from doccano_client .repositories .comment import CommentRepository
2829from doccano_client .repositories .data_download import DataDownloadRepository
4748from doccano_client .repositories .role import RoleRepository
4849from doccano_client .repositories .task_status import TaskStatusRepository
4950from doccano_client .repositories .user import UserRepository
51+ from doccano_client .repositories .user_details import UserDetailsRepository
5052from doccano_client .services .label_type import LabelTypeService
5153from doccano_client .usecase .comment import CommentUseCase
5254from doccano_client .usecase .data_download import DataDownloadUseCase
6365from doccano_client .usecase .label_type import LabelTypeUseCase
6466from doccano_client .usecase .member import MemberUseCase
6567from doccano_client .usecase .project import ProjectType , ProjectUseCase
68+ from doccano_client .usecase .user_details import UserDetailsUseCase
6669
6770
6871class DoccanoClient :
@@ -82,6 +85,7 @@ def __init__(self, base_url: str, verify: Optional[str | bool] = None):
8285 """
8386 self ._base_repository = BaseRepository (base_url , verify = verify )
8487 self ._user_repository = UserRepository (self ._base_repository )
88+ self ._user_details_repository = UserDetailsRepository (self ._base_repository )
8589 self ._role_repository = RoleRepository (self ._base_repository )
8690 self ._project_repository = ProjectRepository (self ._base_repository )
8791 self ._metrics_repository = MetricsRepository (self ._base_repository )
@@ -182,6 +186,10 @@ def bounding_box(self) -> BoundingBoxUseCase:
182186 def text (self ) -> TextUseCase :
183187 return TextUseCase (self ._text_repository )
184188
189+ @property
190+ def user_details (self ) -> UserDetailsUseCase :
191+ return UserDetailsUseCase (self ._user_details_repository )
192+
185193 def _get_label_type_usecase (self , type : Literal ["category" , "span" , "relation" ]) -> LabelTypeUseCase :
186194 if type == "category" :
187195 return self .category_type
@@ -208,6 +216,36 @@ def get_profile(self) -> User:
208216 """
209217 return self ._user_repository .get_profile ()
210218
219+ def change_current_user_password (self , password : str , confirm_password : str ) -> PasswordUpdated :
220+ """Change the current user's password
221+
222+ Args:
223+ password (str): the new password to set for the current user
224+ confirm_password(str): confirm the new password to set for the current user
225+
226+ Returns:
227+ PasswordUpdated: Message confirming password change.
228+ """
229+ return self .user_details .change_current_user_password (password = password , confirm_password = confirm_password )
230+
231+ def update_current_user_details (
232+ self , username : str = None , first_name : str = None , last_name : str = None
233+ ) -> UserDetails :
234+ """Update either username, first name or last name of the current user.
235+ If any args are left as None the current info will be kept
236+
237+ Args:
238+ username (str): The username to change the current user to.
239+ first_name (str): The first name to change the current user to.
240+ last_name (str): The last name to change the current user to
241+
242+ Returns:
243+ UserDetails: the updated user login info
244+ """
245+ return self .user_details .update_current_user_details (
246+ username = username , first_name = first_name , last_name = last_name
247+ )
248+
211249 def search_users (self , name : str = "" ) -> List [User ]:
212250 """Search users by name.
213251
0 commit comments