Skip to content

Commit

Permalink
Merge pull request #18602 from davelopez/improve_update_user_api_schema
Browse files Browse the repository at this point in the history
Improve update user API payload schema
  • Loading branch information
bgruening authored Jul 26, 2024
2 parents 65838ae + 3f26f69 commit 543ad8b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
20 changes: 19 additions & 1 deletion client/src/api/schema/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, never>;
/** VisualizationSummary */
Expand Down Expand Up @@ -24966,7 +24984,7 @@ export interface operations {
};
requestBody: {
content: {
"application/json": Record<string, never>;
"application/json": components["schemas"]["UserUpdatePayload"];
};
};
responses: {
Expand Down
6 changes: 6 additions & 0 deletions lib/galaxy/schema/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions lib/galaxy/webapps/galaxy/api/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import re
from typing import (
Any,
Dict,
List,
Optional,
Union,
Expand Down Expand Up @@ -61,6 +60,7 @@
UserBeaconSetting,
UserCreationPayload,
UserDeletionPayload,
UserUpdatePayload,
)
from galaxy.security.validate_user_input import (
validate_email,
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 543ad8b

Please sign in to comment.