Skip to content

Commit

Permalink
WIP: file source templates
Browse files Browse the repository at this point in the history
  • Loading branch information
jmchilton committed Apr 29, 2024
1 parent 8f59082 commit 299f818
Show file tree
Hide file tree
Showing 98 changed files with 4,010 additions and 576 deletions.
21 changes: 21 additions & 0 deletions client/src/api/configTemplates.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import type { components } from "@/api/schema/schema";

export type Instance =
| components["schemas"]["UserFileSourceModel"]
| components["schemas"]["UserConcreteObjectStoreModel"];

export type TemplateVariable = components["schemas"]["TemplateVariable"];
export type TemplateSecret = components["schemas"]["TemplateSecret"];
export type VariableValueType = (string | boolean | number) | undefined;
export type VariableData = { [key: string]: VariableValueType };
export type SecretData = { [key: string]: string };

export interface TemplateSummary {
description: string | null;
hidden?: boolean;
id: string;
name: string | null;
secrets?: TemplateSecret[] | null;
variables?: TemplateVariable[] | null;
version?: number;
}
6 changes: 6 additions & 0 deletions client/src/api/fileSources.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { type components } from "@/api/schema";

export type FileSourceTemplateSummary = components["schemas"]["FileSourceTemplateSummary"];
export type FileSourceTemplateSummaries = FileSourceTemplateSummary[];

export type UserFileSourceModel = components["schemas"]["UserFileSourceModel"];
252 changes: 231 additions & 21 deletions client/src/api/schema/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,22 @@ export interface paths {
/** Download */
get: operations["download_api_drs_download__object_id__get"];
};
"/api/file_source_instances": {
/** Get a list of persisted file source instances defined by the requesting user. */
get: operations["file_sources__instances_index"];
/** Create a user-bound object store. */
post: operations["file_sources__create_instance"];
};
"/api/file_source_instances/{user_file_source_id}": {
/** Get a list of persisted file source instances defined by the requesting user. */
get: operations["file_sources__instances_get"];
/** Update or upgrade user file source instance. */
put: operations["file_sources__instances_update"];
};
"/api/file_source_templates": {
/** Get a list of file source templates available to build user defined file sources from */
get: operations["file_sources__templates_index"];
};
"/api/folders/{folder_id}/contents": {
/**
* Returns a list of a folder's contents (files and sub-folders) with additional metadata about the folder.
Expand Down Expand Up @@ -5234,6 +5250,36 @@ export interface components {
*/
update_time: string;
};
/** FileSourceTemplateSummaries */
FileSourceTemplateSummaries: components["schemas"]["FileSourceTemplateSummary"][];
/** FileSourceTemplateSummary */
FileSourceTemplateSummary: {
/** Description */
description: string | null;
/**
* Hidden
* @default false
*/
hidden?: boolean;
/** Id */
id: string;
/** Name */
name: string | null;
/** Secrets */
secrets?: components["schemas"]["TemplateSecret"][] | null;
/**
* Type
* @enum {string}
*/
type: "posix" | "s3fs";
/** Variables */
variables?: components["schemas"]["TemplateVariable"][] | null;
/**
* Version
* @default 0
*/
version?: number;
};
/** FilesSourcePlugin */
FilesSourcePlugin: {
/**
Expand Down Expand Up @@ -9915,13 +9961,6 @@ export interface components {
*/
up_to_date: boolean;
};
/** ObjectStoreTemplateSecret */
ObjectStoreTemplateSecret: {
/** Help */
help: string | null;
/** Name */
name: string;
};
/** ObjectStoreTemplateSummaries */
ObjectStoreTemplateSummaries: components["schemas"]["ObjectStoreTemplateSummary"][];
/** ObjectStoreTemplateSummary */
Expand All @@ -9940,32 +9979,20 @@ export interface components {
/** Name */
name: string | null;
/** Secrets */
secrets?: components["schemas"]["ObjectStoreTemplateSecret"][] | null;
secrets?: components["schemas"]["TemplateSecret"][] | null;
/**
* Type
* @enum {string}
*/
type: "s3" | "azure_blob" | "disk" | "generic_s3";
/** Variables */
variables?: components["schemas"]["ObjectStoreTemplateVariable"][] | null;
variables?: components["schemas"]["TemplateVariable"][] | null;
/**
* Version
* @default 0
*/
version?: number;
};
/** ObjectStoreTemplateVariable */
ObjectStoreTemplateVariable: {
/** Help */
help: string | null;
/** Name */
name: string;
/**
* Type
* @enum {string}
*/
type: "string" | "boolean" | "integer";
};
/** OutputReferenceByLabel */
OutputReferenceByLabel: {
/**
Expand Down Expand Up @@ -11842,6 +11869,25 @@ export interface components {
* @enum {string}
*/
TaskState: "PENDING" | "STARTED" | "RETRY" | "FAILURE" | "SUCCESS";
/** TemplateSecret */
TemplateSecret: {
/** Help */
help: string | null;
/** Name */
name: string;
};
/** TemplateVariable */
TemplateVariable: {
/** Help */
help: string | null;
/** Name */
name: string;
/**
* Type
* @enum {string}
*/
type: "string" | "boolean" | "integer";
};
/** ToolDataDetails */
ToolDataDetails: {
/**
Expand Down Expand Up @@ -12572,6 +12618,34 @@ export interface components {
*/
id: string;
};
/** UserFileSourceModel */
UserFileSourceModel: {
/** Description */
description: string | null;
/** Id */
id: string | number;
/** Name */
name: string;
/** Secrets */
secrets: string[];
/** Template Id */
template_id: string;
/** Template Version */
template_version: number;
/**
* Type
* @enum {string}
*/
type: "posix" | "s3fs";
/** Uri Root */
uri_root: string;
/** Uuid */
uuid: string;
/** Variables */
variables: {
[key: string]: (string | boolean | number) | undefined;
} | null;
};
/**
* UserModel
* @description User in a transaction context.
Expand Down Expand Up @@ -14761,6 +14835,142 @@ export interface operations {
};
};
};
file_sources__instances_index: {
/** Get a list of persisted file source instances defined by the requesting user. */
parameters?: {
/** @description The user ID that will be used to effectively make this API call. Only admins and designated users can make API calls on behalf of other users. */
header?: {
"run-as"?: string | null;
};
};
responses: {
/** @description Successful Response */
200: {
content: {
"application/json": components["schemas"]["UserFileSourceModel"][];
};
};
/** @description Validation Error */
422: {
content: {
"application/json": components["schemas"]["HTTPValidationError"];
};
};
};
};
file_sources__create_instance: {
/** Create a user-bound object store. */
parameters?: {
/** @description The user ID that will be used to effectively make this API call. Only admins and designated users can make API calls on behalf of other users. */
header?: {
"run-as"?: string | null;
};
};
requestBody: {
content: {
"application/json": components["schemas"]["CreateInstancePayload"];
};
};
responses: {
/** @description Successful Response */
200: {
content: {
"application/json": components["schemas"]["UserFileSourceModel"];
};
};
/** @description Validation Error */
422: {
content: {
"application/json": components["schemas"]["HTTPValidationError"];
};
};
};
};
file_sources__instances_get: {
/** Get a list of persisted file source instances defined by the requesting user. */
parameters: {
/** @description The user ID that will be used to effectively make this API call. Only admins and designated users can make API calls on behalf of other users. */
header?: {
"run-as"?: string | null;
};
/** @description The index for a persisted UserFileSourceStore object. */
path: {
user_file_source_id: string;
};
};
responses: {
/** @description Successful Response */
200: {
content: {
"application/json": components["schemas"]["UserFileSourceModel"];
};
};
/** @description Validation Error */
422: {
content: {
"application/json": components["schemas"]["HTTPValidationError"];
};
};
};
};
file_sources__instances_update: {
/** Update or upgrade user file source instance. */
parameters: {
/** @description The user ID that will be used to effectively make this API call. Only admins and designated users can make API calls on behalf of other users. */
header?: {
"run-as"?: string | null;
};
/** @description The index for a persisted UserFileSourceStore object. */
path: {
user_file_source_id: string;
};
};
requestBody: {
content: {
"application/json":
| components["schemas"]["UpdateInstanceSecretPayload"]
| components["schemas"]["UpgradeInstancePayload"]
| components["schemas"]["UpdateInstancePayload"];
};
};
responses: {
/** @description Successful Response */
200: {
content: {
"application/json": components["schemas"]["UserFileSourceModel"];
};
};
/** @description Validation Error */
422: {
content: {
"application/json": components["schemas"]["HTTPValidationError"];
};
};
};
};
file_sources__templates_index: {
/** Get a list of file source templates available to build user defined file sources from */
parameters?: {
/** @description The user ID that will be used to effectively make this API call. Only admins and designated users can make API calls on behalf of other users. */
header?: {
"run-as"?: string | null;
};
};
responses: {
/** @description A list of the configured file source templates. */
200: {
content: {
"application/json": components["schemas"]["FileSourceTemplateSummaries"];
};
};
/** @description Validation Error */
422: {
content: {
"application/json": components["schemas"]["HTTPValidationError"];
};
};
};
};
index_api_folders__folder_id__contents_get: {
/**
* Returns a list of a folder's contents (files and sub-folders) with additional metadata about the folder.
Expand Down
32 changes: 32 additions & 0 deletions client/src/components/ConfigTemplates/CreateInstance.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { shallowMount } from "@vue/test-utils";
import { getLocalVue } from "tests/jest/helpers";

import CreateInstance from "./CreateInstance.vue";

const localVue = getLocalVue(true);

describe("CreateInstance", () => {
it("should render a loading message during loading", async () => {
const wrapper = shallowMount(CreateInstance, {
propsData: {
loading: true,
loadingMessage: "component loading...",
},
localVue,
});
const loadingSpan = wrapper.findComponent({ name: "LoadingSpan" }).exists();
expect(loadingSpan).toBeTruthy();
});

it("should hide a loading message after loading", async () => {
const wrapper = shallowMount(CreateInstance, {
propsData: {
loading: false,
loadingMessage: "component loading...",
},
localVue,
});
const loadingSpan = wrapper.findComponent({ name: "LoadingSpan" }).exists();
expect(loadingSpan).toBeFalsy();
});
});
21 changes: 21 additions & 0 deletions client/src/components/ConfigTemplates/CreateInstance.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<script lang="ts" setup>
import { BContainer } from "bootstrap-vue";
import LoadingSpan from "@/components/LoadingSpan.vue";
interface Props {
loading: boolean;
loadingMessage: string;
}
defineProps<Props>();
</script>

<template>
<BContainer fluid class="p-0">
<LoadingSpan v-if="loading" :message="loadingMessage" />
<div v-else>
<slot />
</div>
</BContainer>
</template>
Loading

0 comments on commit 299f818

Please sign in to comment.