From 443ff0a3bb230ba9af60950334c6f3028395d9d7 Mon Sep 17 00:00:00 2001 From: davelopez <46503462+davelopez@users.noreply.github.com> Date: Tue, 30 Jul 2024 10:40:03 +0200 Subject: [PATCH 1/2] Improve update history payload schema --- client/src/api/schema/schema.ts | 22 +++++++++++++++++++++- lib/galaxy/schema/schema.py | 17 +++++++++++++++++ lib/galaxy/webapps/galaxy/api/histories.py | 6 ++++-- 3 files changed, 42 insertions(+), 3 deletions(-) diff --git a/client/src/api/schema/schema.ts b/client/src/api/schema/schema.ts index 7e3cda1f61c4..c5efbb5b9de3 100644 --- a/client/src/api/schema/schema.ts +++ b/client/src/api/schema/schema.ts @@ -12397,6 +12397,26 @@ export interface components { visible?: boolean | null; [key: string]: unknown; }; + /** UpdateHistoryPayload */ + UpdateHistoryPayload: { + /** Annotation */ + annotation?: string | null; + /** Deleted */ + deleted?: boolean | null; + /** Genome Build */ + genome_build?: string | null; + /** Importable */ + importable?: boolean | null; + /** Name */ + name?: string | null; + /** Preferred Object Store Id */ + preferred_object_store_id?: string | null; + /** Published */ + published?: boolean | null; + /** Purged */ + purged?: boolean | null; + tags?: components["schemas"]["TagCollection"] | null; + }; /** UpdateInstancePayload */ UpdateInstancePayload: { /** Active */ @@ -17588,7 +17608,7 @@ export interface operations { }; requestBody: { content: { - "application/json": unknown; + "application/json": components["schemas"]["UpdateHistoryPayload"]; }; }; responses: { diff --git a/lib/galaxy/schema/schema.py b/lib/galaxy/schema/schema.py index e83c76edfef2..8a9af6552ff7 100644 --- a/lib/galaxy/schema/schema.py +++ b/lib/galaxy/schema/schema.py @@ -1445,6 +1445,23 @@ class CustomHistoryView(HistoryDetailed): ] +class UpdateHistoryPayload(Model): + name: Optional[str] = None + annotation: Optional[str] = None + tags: Optional[TagCollection] = None + published: Optional[bool] = None + importable: Optional[bool] = None + deleted: Optional[bool] = None + purged: Optional[bool] = None + genome_build: Optional[str] = None + preferred_object_store_id: Optional[str] = None + + # Potentially deprecated fields that are registered in the deserializer + # TODO: Expose or remove? + # user_rating: Optional[int] = None + # users_shared_with: Optional[List[DecodedDatabaseIdField]] = None + + class ExportHistoryArchivePayload(Model): gzip: Optional[bool] = Field( default=True, diff --git a/lib/galaxy/webapps/galaxy/api/histories.py b/lib/galaxy/webapps/galaxy/api/histories.py index 067dd425369a..de0a331ec70f 100644 --- a/lib/galaxy/webapps/galaxy/api/histories.py +++ b/lib/galaxy/webapps/galaxy/api/histories.py @@ -57,6 +57,7 @@ ShareWithPayload, SharingStatus, StoreExportPayload, + UpdateHistoryPayload, WriteStoreToPayload, ) from galaxy.schema.types import LatestLiteral @@ -457,13 +458,14 @@ def update( self, history_id: HistoryIDPathParam, trans: ProvidesHistoryContext = DependsOnTrans, - payload: Any = Body( + payload: UpdateHistoryPayload = Body( ..., description="Object containing any of the editable fields of the history.", ), serialization_params: SerializationParams = Depends(query_serialization_params), ) -> AnyHistoryView: - return self.service.update(trans, history_id, payload, serialization_params) + data = payload.model_dump(exclude_unset=True) + return self.service.update(trans, history_id, data, serialization_params) @router.post( "/api/histories/from_store", From 1bb3fdf4b2be09c04be825b0f59190a8cc3ce357 Mon Sep 17 00:00:00 2001 From: davelopez <46503462+davelopez@users.noreply.github.com> Date: Tue, 30 Jul 2024 17:24:42 +0200 Subject: [PATCH 2/2] Remove potentially deprecated properties to update histories --- lib/galaxy/schema/schema.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lib/galaxy/schema/schema.py b/lib/galaxy/schema/schema.py index 8a9af6552ff7..879d3158ad2f 100644 --- a/lib/galaxy/schema/schema.py +++ b/lib/galaxy/schema/schema.py @@ -1456,11 +1456,6 @@ class UpdateHistoryPayload(Model): genome_build: Optional[str] = None preferred_object_store_id: Optional[str] = None - # Potentially deprecated fields that are registered in the deserializer - # TODO: Expose or remove? - # user_rating: Optional[int] = None - # users_shared_with: Optional[List[DecodedDatabaseIdField]] = None - class ExportHistoryArchivePayload(Model): gzip: Optional[bool] = Field(