Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve update user API payload schema #18602

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading