Improve update user API payload schema

This commit is contained in:
davelopez
2024-07-26 16:53:52 +02:00
parent 2231152fdc
commit 3f26f693ff
3 changed files with 29 additions and 4 deletions
+19 -1
View File
@@ -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: {
+6
View File
@@ -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
+4 -3
View File
@@ -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(