diff --git a/client/src/api/schema/schema.ts b/client/src/api/schema/schema.ts index 7b032f8caa49..7e3cda1f61c4 100644 --- a/client/src/api/schema/schema.ts +++ b/client/src/api/schema/schema.ts @@ -13020,6 +13020,24 @@ export interface components { /** Total Disk Usage */ total_disk_usage: number; }; + /** UserUpdatePayload */ + UserUpdatePayload: { + /** + * Active + * @description User is active + */ + active?: boolean | null; + /** + * Preferred Object Store ID + * @description The ID of the object store that should be used to store new datasets in this history. + */ + preferred_object_store_id?: string | null; + /** + * Username + * @description The name of the user. + */ + username?: string | null; + }; /** Visualization */ Visualization: Record; /** VisualizationSummary */ @@ -24966,7 +24984,7 @@ export interface operations { }; requestBody: { content: { - "application/json": Record; + "application/json": components["schemas"]["UserUpdatePayload"]; }; }; responses: { diff --git a/lib/galaxy/schema/schema.py b/lib/galaxy/schema/schema.py index 9cdf22507164..e83c76edfef2 100644 --- a/lib/galaxy/schema/schema.py +++ b/lib/galaxy/schema/schema.py @@ -375,6 +375,12 @@ class DetailedUserModel(BaseUserModel, AnonUserModel): tags_used: List[str] = Field(default=..., title="Tags used", description="Tags used by the user") +class UserUpdatePayload(Model): + active: Annotated[Optional[bool], Field(None, title="Active", description="User is active")] + username: Annotated[Optional[str], Field(None, title="Username", description="The name of the user.")] + preferred_object_store_id: Annotated[Optional[str], PreferredObjectStoreIdField] + + class UserCreationPayload(Model): password: str = Field(default=..., title="user_password", description="The password of the user.") email: str = UserEmailField diff --git a/lib/galaxy/webapps/galaxy/api/users.py b/lib/galaxy/webapps/galaxy/api/users.py index eb051f63ed97..d3d4ea4dcda4 100644 --- a/lib/galaxy/webapps/galaxy/api/users.py +++ b/lib/galaxy/webapps/galaxy/api/users.py @@ -8,7 +8,6 @@ import re from typing import ( Any, - Dict, List, Optional, Union, @@ -61,6 +60,7 @@ UserBeaconSetting, UserCreationPayload, UserDeletionPayload, + UserUpdatePayload, ) from galaxy.security.validate_user_input import ( validate_email, @@ -674,13 +674,14 @@ def update( self, trans: ProvidesUserContext = DependsOnTrans, user_id: FlexibleUserIdType = FlexibleUserIdPathParam, - payload: Dict[Any, Any] = UserUpdateBody, + payload: UserUpdatePayload = UserUpdateBody, deleted: Optional[bool] = UserDeletedQueryParam, ) -> DetailedUserModel: deleted = deleted or False current_user = trans.user user_to_update = self.service.get_non_anonymous_user_full(trans, user_id, deleted=deleted) - self.service.user_deserializer.deserialize(user_to_update, payload, user=current_user, trans=trans) + data = payload.model_dump(exclude_unset=True) + self.service.user_deserializer.deserialize(user_to_update, data, user=current_user, trans=trans) return self.service.user_to_detailed_model(user_to_update) @router.delete(