From b2033a47dfb1ce17df8c0064a1246a8cc11b5e1d Mon Sep 17 00:00:00 2001 From: John Chilton Date: Thu, 26 Sep 2024 11:51:35 -0400 Subject: [PATCH] Rework user file/object store for changes to client fetch arch. --- client/src/api/configTemplates.ts | 1 - client/src/api/objectStores.ts | 4 +- client/src/api/schema/schema.ts | 28 +-- .../useConfigurationTesting.ts | 182 ++++++++++++------ .../FileSources/Instances/CreateForm.vue | 7 +- .../FileSources/Instances/CreateInstance.vue | 26 ++- .../FileSources/Instances/EditInstance.vue | 14 +- .../FileSources/Instances/EditSecrets.vue | 4 +- .../Instances/InstanceDropdown.vue | 4 +- .../FileSources/Instances/ManageIndex.vue | 11 +- .../FileSources/Instances/UpgradeForm.vue | 9 +- .../FileSources/Instances/services.ts | 23 +-- .../ObjectStore/Instances/CreateForm.test.ts | 2 +- .../ObjectStore/Instances/CreateForm.vue | 7 +- .../ObjectStore/Instances/EditInstance.vue | 14 +- .../ObjectStore/Instances/EditSecrets.vue | 4 +- .../Instances/InstanceDropdown.vue | 4 +- .../ObjectStore/Instances/ManageIndex.vue | 12 +- .../ObjectStore/Instances/UpgradeForm.test.ts | 8 +- .../ObjectStore/Instances/UpgradeForm.vue | 9 +- .../ObjectStore/Instances/services.ts | 22 +-- lib/galaxy/webapps/galaxy/api/file_sources.py | 30 +-- lib/galaxy/webapps/galaxy/api/object_store.py | 26 +-- 23 files changed, 252 insertions(+), 199 deletions(-) diff --git a/client/src/api/configTemplates.ts b/client/src/api/configTemplates.ts index 09b6348739e9..ec987c7eb3a7 100644 --- a/client/src/api/configTemplates.ts +++ b/client/src/api/configTemplates.ts @@ -19,7 +19,6 @@ export type SecretData = CreateInstancePayload["secrets"]; export type PluginAspectStatus = components["schemas"]["PluginAspectStatus"]; export type PluginStatus = components["schemas"]["PluginStatus"]; -export type CreateInstancePayload = components["schemas"]["CreateInstancePayload"]; export type UpgradeInstancePayload = components["schemas"]["UpgradeInstancePayload"]; export type TestUpgradeInstancePayload = components["schemas"]["TestUpgradeInstancePayload"]; export type UpdateInstancePayload = components["schemas"]["UpdateInstancePayload"]; diff --git a/client/src/api/objectStores.ts b/client/src/api/objectStores.ts index 55b9a30d39a2..376d75d8e54a 100644 --- a/client/src/api/objectStores.ts +++ b/client/src/api/objectStores.ts @@ -23,8 +23,8 @@ export async function getObjectStoreDetails(id: string) { if (id.startsWith("user_objects://")) { const userObjectStoreId = id.substring("user_objects://".length); - const { data, error } = await GalaxyApi().GET("/api/object_store_instances/{user_object_store_id}", { - params: { path: { user_object_store_id: userObjectStoreId } }, + const { data, error } = await GalaxyApi().GET("/api/object_store_instances/{uuid}", { + params: { path: { uuid: userObjectStoreId } }, }); if (error) { diff --git a/client/src/api/schema/schema.ts b/client/src/api/schema/schema.ts index b1c70fab2d91..7c9c44a6958b 100644 --- a/client/src/api/schema/schema.ts +++ b/client/src/api/schema/schema.ts @@ -906,7 +906,7 @@ export interface paths { patch?: never; trace?: never; }; - "/api/file_source_instances/{user_file_source_id}": { + "/api/file_source_instances/{uuid}": { parameters: { query?: never; header?: never; @@ -925,7 +925,7 @@ export interface paths { patch?: never; trace?: never; }; - "/api/file_source_instances/{user_file_source_id}/test": { + "/api/file_source_instances/{uuid}/test": { parameters: { query?: never; header?: never; @@ -3322,7 +3322,7 @@ export interface paths { patch?: never; trace?: never; }; - "/api/object_store_instances/{user_object_store_id}": { + "/api/object_store_instances/{uuid}": { parameters: { query?: never; header?: never; @@ -3341,7 +3341,7 @@ export interface paths { patch?: never; trace?: never; }; - "/api/object_store_instances/{user_object_store_id}/test": { + "/api/object_store_instances/{uuid}/test": { parameters: { query?: never; header?: never; @@ -20070,7 +20070,7 @@ export interface operations { }; path: { /** @description The UUID index for a persisted UserFileSourceStore object. */ - user_file_source_id: string; + uuid: string; }; cookie?: never; }; @@ -20114,7 +20114,7 @@ export interface operations { }; path: { /** @description The UUID index for a persisted UserFileSourceStore object. */ - user_file_source_id: string; + uuid: string; }; cookie?: never; }; @@ -20165,7 +20165,7 @@ export interface operations { }; path: { /** @description The UUID index for a persisted UserFileSourceStore object. */ - user_file_source_id: string; + uuid: string; }; cookie?: never; }; @@ -20207,7 +20207,7 @@ export interface operations { }; path: { /** @description The UUID index for a persisted UserFileSourceStore object. */ - user_file_source_id: string; + uuid: string; }; cookie?: never; }; @@ -20251,7 +20251,7 @@ export interface operations { }; path: { /** @description The UUID index for a persisted UserFileSourceStore object. */ - user_file_source_id: string; + uuid: string; }; cookie?: never; }; @@ -28541,7 +28541,7 @@ export interface operations { }; path: { /** @description The UUID used to identify a persisted UserObjectStore object. */ - user_object_store_id: string; + uuid: string; }; cookie?: never; }; @@ -28585,7 +28585,7 @@ export interface operations { }; path: { /** @description The UUID used to identify a persisted UserObjectStore object. */ - user_object_store_id: string; + uuid: string; }; cookie?: never; }; @@ -28636,7 +28636,7 @@ export interface operations { }; path: { /** @description The UUID used to identify a persisted UserObjectStore object. */ - user_object_store_id: string; + uuid: string; }; cookie?: never; }; @@ -28678,7 +28678,7 @@ export interface operations { }; path: { /** @description The UUID used to identify a persisted UserObjectStore object. */ - user_object_store_id: string; + uuid: string; }; cookie?: never; }; @@ -28722,7 +28722,7 @@ export interface operations { }; path: { /** @description The UUID used to identify a persisted UserObjectStore object. */ - user_object_store_id: string; + uuid: string; }; cookie?: never; }; diff --git a/client/src/components/ConfigTemplates/useConfigurationTesting.ts b/client/src/components/ConfigTemplates/useConfigurationTesting.ts index b32876668db4..26ec1389cf8e 100644 --- a/client/src/components/ConfigTemplates/useConfigurationTesting.ts +++ b/client/src/components/ConfigTemplates/useConfigurationTesting.ts @@ -1,15 +1,7 @@ import { computed, type Ref, ref } from "vue"; -import type { - CreateInstancePayload, - Instance, - PluginStatus, - TemplateSummary, - TestUpdateInstancePayload, - TestUpgradeInstancePayload, - UpdateInstancePayload, - UpgradeInstancePayload, -} from "@/api/configTemplates"; +import { GalaxyApi } from "@/api"; +import { type Instance, type PluginStatus, type TemplateSummary } from "@/api/configTemplates"; import { type buildInstanceRoutingComposable } from "@/components/ConfigTemplates/routing"; import { errorMessageAsString } from "@/utils/simple-error"; @@ -40,12 +32,15 @@ export function useConfigurationTesting() { }; } +type CreateTestUrl = "/api/object_store_instances/test" | "/api/file_source_instances/test"; +type CreateUrl = "/api/object_store_instances" | "/api/file_source_instances"; + export function useConfigurationTemplateCreation( what: string, template: Ref, uuid: Ref, - test: (payload: CreateInstancePayload) => Promise<{ data: PluginStatus }>, - create: (payload: CreateInstancePayload) => Promise<{ data: R }>, + testUrl: CreateTestUrl, + createUrl: CreateUrl, onCreate: (result: R) => unknown ) { const error = ref(null); @@ -56,26 +51,41 @@ export function useConfigurationTemplateCreation( if (uuid.value) { payload.uuid = uuid.value; } - let pluginStatus; + let pluginStatus: PluginStatus; try { testRunning.value = true; - const response = await test(payload); - pluginStatus = response["data"]; - testResults.value = pluginStatus; + const { data, error: testRequestError } = await GalaxyApi().POST(testUrl, { + body: payload, + }); + if (testRequestError) { + error.value = "Failed to verify configuration: " + errorMessageAsString(testRequestError); + return; + } else { + pluginStatus = data; + testResults.value = pluginStatus; + } } catch (e) { error.value = "Failed to verify configuration: " + errorMessageAsString(e); return; } finally { testRunning.value = false; } - const testError = pluginStatusToErrorMessage(pluginStatus); - if (testError) { - error.value = testError; - return; + if (pluginStatus) { + const testError = pluginStatusToErrorMessage(pluginStatus); + if (testError) { + error.value = testError; + return; + } } try { - const { data: userObject } = await create(payload); - onCreate(userObject); + const { data: userObject, error: createRequestError } = await GalaxyApi().POST(createUrl, { + body: payload, + }); + if (createRequestError) { + error.value = errorMessageAsString(createRequestError); + } else { + onCreate(userObject as R); + } } catch (e) { error.value = errorMessageAsString(e); return; @@ -102,7 +112,9 @@ export function useConfigurationTemplateCreation( }; } -export function useInstanceTesting(testInstance: (id: string) => Promise<{ data: PluginStatus }>) { +type TestInstanceUrl = "/api/file_source_instances/{uuid}/test" | "/api/object_store_instances/{uuid}/test"; + +export function useInstanceTesting(testUrl: TestInstanceUrl) { const showTestResults = ref(false); const testResults = ref(undefined); const testingError = ref(undefined); @@ -112,8 +124,16 @@ export function useInstanceTesting(testInstance: (id: string testingError.value = undefined; showTestResults.value = true; try { - const { data } = await testInstance(instance.uuid); - testResults.value = data; + const { data, error } = await GalaxyApi().GET(testUrl, { + params: { path: { uuid: instance.uuid } }, + }); + const pluginStatus = data; + const testRequestError = error; + if (testRequestError) { + testingError.value = errorMessageAsString(testRequestError); + } else { + testResults.value = pluginStatus; + } } catch (e) { testingError.value = errorMessageAsString(e); } @@ -128,12 +148,15 @@ export function useInstanceTesting(testInstance: (id: string }; } +type TestUpdateUrl = "/api/object_store_instances/{uuid}/test" | "/api/file_source_instances/{uuid}/test"; +type UpdateUrl = "/api/object_store_instances/{uuid}" | "/api/file_source_instances/{uuid}"; + export function useConfigurationTemplateEdit( what: string, instance: Ref, template: Ref, - testUpdate: (payload: TestUpdateInstancePayload) => Promise<{ data: PluginStatus }>, - update: (payload: UpdateInstancePayload) => Promise<{ data: R }>, + testUpdateUrl: TestUpdateUrl, + updateUrl: UpdateUrl, useRouting: InstanceRoutingComposableType ) { const { testRunning, testResults } = useConfigurationTesting(); @@ -161,15 +184,21 @@ export function useConfigurationTemplateEdit, template: Ref, - testUpdate: (payload: TestUpgradeInstancePayload) => Promise<{ data: PluginStatus }>, - update: (payload: UpgradeInstancePayload) => Promise<{ data: R }>, + testUpdateUrl: TestUpdateUrl, + updateUrl: UpdateUrl, useRouting: InstanceRoutingComposableType ) { const { goToIndex } = useRouting(); @@ -257,14 +302,26 @@ export function useConfigurationTemplateUpgrade emit("created", fileSource) ); diff --git a/client/src/components/FileSources/Instances/CreateInstance.vue b/client/src/components/FileSources/Instances/CreateInstance.vue index cee1849cc30a..4daae81903ed 100644 --- a/client/src/components/FileSources/Instances/CreateInstance.vue +++ b/client/src/components/FileSources/Instances/CreateInstance.vue @@ -1,11 +1,11 @@