mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Improve update user API payload schema
This commit is contained in:
@@ -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 */
|
||||
@@ -24966,7 +24984,7 @@ export interface operations {
|
||||
};
|
||||
requestBody: {
|
||||
content: {
|
||||
"application/json": Record<string, never>;
|
||||
"application/json": components["schemas"]["UserUpdatePayload"];
|
||||
};
|
||||
};
|
||||
responses: {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -8,7 +8,6 @@ import logging
|
||||
import re
|
||||
from typing import (
|
||||
Any,
|
||||
Dict,
|
||||
List,
|
||||
Optional,
|
||||
Union,
|
||||
@@ -61,6 +60,7 @@ from galaxy.schema.schema import (
|
||||
UserBeaconSetting,
|
||||
UserCreationPayload,
|
||||
UserDeletionPayload,
|
||||
UserUpdatePayload,
|
||||
)
|
||||
from galaxy.security.validate_user_input import (
|
||||
validate_email,
|
||||
@@ -674,13 +674,14 @@ class FastAPIUsers:
|
||||
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(
|
||||
|
||||
Reference in New Issue
Block a user