From 22791a8d43df186f05c96bbeb3dfe950e2d2918e Mon Sep 17 00:00:00 2001 From: Sanjay Kumar Srikakulam Date: Thu, 25 Jul 2024 09:24:23 +0000 Subject: [PATCH] Add WebDAV as user file source Adds WebDAV example template, configuration and updates the docs, and the file source model along with the client API schema --- client/src/api/schema/schema.ts | 4 +- doc/source/admin/data.md | 21 ++++++++++ doc/source/admin/gen_diagrams.py | 4 ++ .../admin/search_for_new_screenshots.py | 1 + .../templates/examples/production_webdav.yml | 42 +++++++++++++++++++ lib/galaxy/files/templates/models.py | 28 ++++++++++++- 6 files changed, 97 insertions(+), 3 deletions(-) create mode 100644 lib/galaxy/files/templates/examples/production_webdav.yml diff --git a/client/src/api/schema/schema.ts b/client/src/api/schema/schema.ts index 51148bebc8d..be56f1ba7b3 100644 --- a/client/src/api/schema/schema.ts +++ b/client/src/api/schema/schema.ts @@ -9035,7 +9035,7 @@ export interface components { * Type * @enum {string} */ - type: "ftp" | "posix" | "s3fs" | "azure" | "onedata"; + type: "ftp" | "posix" | "s3fs" | "azure" | "onedata" | "webdav"; /** Variables */ variables?: | ( @@ -17366,7 +17366,7 @@ export interface components { * Type * @enum {string} */ - type: "ftp" | "posix" | "s3fs" | "azure" | "onedata"; + type: "ftp" | "posix" | "s3fs" | "azure" | "onedata" | "webdav"; /** Uri Root */ uri_root: string; /** diff --git a/doc/source/admin/data.md b/doc/source/admin/data.md index 1e9a3ea9095..0ec463c8f6e 100644 --- a/doc/source/admin/data.md +++ b/doc/source/admin/data.md @@ -350,6 +350,19 @@ configuration). ![](file_source_azure_configuration.png) +#### `webdav` + +The syntax for the `configuration` section of `webdav` templates looks like this. + +![](file_source_webdav_configuration_template.png) + +At runtime, after the `configuration` template is expanded, the resulting dictionary +passed to Galaxy's file source plugin infrastructure looks like this and should match a subset +of what you'd be able to add directly to `file_sources_conf.yml` (Galaxy's global file source +configuration). + +![](file_source_webdav_configuration.png) + ### YAML Syntax ![galaxy.files.templates.models](file_source_templates.png) @@ -398,6 +411,14 @@ and you are comfortable with it storing your user's secrets. :language: yaml ``` +#### Allow Users to Define WebDAV Servers as File Sources + +```{literalinclude} ../../../lib/galaxy/files/templates/examples/production_webdav.yml +:language: yaml +``` + +![Screenshot](user_file_source_form_full_webdav.png) + ## Playing Nicer with Ansible Many large instances of Galaxy are configured with Ansible and much of the existing administrator diff --git a/doc/source/admin/gen_diagrams.py b/doc/source/admin/gen_diagrams.py index 2627420177e..92d1bb15819 100644 --- a/doc/source/admin/gen_diagrams.py +++ b/doc/source/admin/gen_diagrams.py @@ -15,6 +15,8 @@ from galaxy.files.templates.models import ( PosixFileSourceTemplateConfiguration, S3FSFileSourceConfiguration, S3FSFileSourceTemplateConfiguration, + WebdavFileSourceTemplateConfiguration, + WebdavFileSourceConfiguration, ) from galaxy.objectstore.templates.models import ( AwsS3ObjectStoreConfiguration, @@ -53,6 +55,8 @@ class_to_diagram = { S3FSFileSourceConfiguration: "file_source_s3fs_configuration", FtpFileSourceTemplateConfiguration: "file_source_ftp_configuration_template", FtpFileSourceConfiguration: "file_source_ftp_configuration", + WebdavFileSourceTemplateConfiguration: "file_source_webdav_configuration_template", + WebdavFileSourceConfiguration: "file_source_webdav_configuration", } for clazz, diagram_name in class_to_diagram.items(): diff --git a/doc/source/admin/search_for_new_screenshots.py b/doc/source/admin/search_for_new_screenshots.py index 95f0ac2cbc6..c2d16a596e3 100644 --- a/doc/source/admin/search_for_new_screenshots.py +++ b/doc/source/admin/search_for_new_screenshots.py @@ -22,6 +22,7 @@ SEARCH_FOR = [ "user_file_source_form_full_aws_public.png", "user_file_source_form_full_azure.png", "user_file_source_form_full_ftp.png", + "user_file_source_form_full_webdav.png" ] diff --git a/lib/galaxy/files/templates/examples/production_webdav.yml b/lib/galaxy/files/templates/examples/production_webdav.yml new file mode 100644 index 00000000000..0767dc55086 --- /dev/null +++ b/lib/galaxy/files/templates/examples/production_webdav.yml @@ -0,0 +1,42 @@ +- id: webdav + version: 0 + name: WebDAV + description: | + The WebDAV protocol is a simple way to access files over the internet. This template + configuration allows you to connect to a WebDAV server. + variables: + url: + label: Server Domain (e.g. https://myowncloud.org) + type: string + help: | + The domain of the WebDAV server you are connecting to. This should be the full URL + including the protocol (http or https) and the domain name. + root: + label: WebDAV server Path (should end with /remote.php/webdav, e.g. /a/sub/path/remote.php/webdav) + type: string + help: | + The full server path to the WebDAV service. Ensure the path includes /remote.php/webdav. + login: + label: Username + type: string + help: | + The username to use to connect to the WebDAV server. This should be the username you use + to log in to the WebDAV server. + writable: + label: Writable? + type: boolean + default: false + help: Allow Galaxy to write data to this WebDAV server. + secrets: + password: + label: Password + help: | + The password to use to connect to the WebDAV server. This should be the password you use + to log in to the WebDAV server. + configuration: + type: webdav + url: '{{ variables.url }}' + root: '{{ variables.root }}' + login: '{{ variables.login }}' + writable: '{{ variables.writable }}' + password: '{{ secrets.password }}' diff --git a/lib/galaxy/files/templates/models.py b/lib/galaxy/files/templates/models.py index e4b7fcea49e..c69e5aeb9b2 100644 --- a/lib/galaxy/files/templates/models.py +++ b/lib/galaxy/files/templates/models.py @@ -25,7 +25,7 @@ from galaxy.util.config_templates import ( UserDetailsDict, ) -FileSourceTemplateType = Literal["ftp", "posix", "s3fs", "azure", "onedata"] +FileSourceTemplateType = Literal["ftp", "posix", "s3fs", "azure", "onedata", "webdav"] class PosixFileSourceTemplateConfiguration(StrictModel): @@ -121,6 +121,29 @@ class OnedataFileSourceConfiguration(StrictModel): disable_tls_certificate_validation: bool = False writable: bool = False +class WebdavFileSourceTemplateConfiguration(StrictModel): + type: Literal["webdav"] + url: Union[str, TemplateExpansion] + root: Union[str, TemplateExpansion] + login: Union[str, TemplateExpansion] + password: Union[str, TemplateExpansion] + writable: Union[bool, TemplateExpansion] = False + use_temp_files: Optional[Union[bool, TemplateExpansion]] = None + temp_path: Optional[Union[str, TemplateExpansion]] = None + template_start: Optional[str] = None + template_end: Optional[str] = None + + +class WebdavFileSourceConfiguration(StrictModel): + type: Literal["webdav"] + url: str + root: str + login: str + password: str + writable: bool = False + use_temp_files: Optional[bool] = None + temp_path: Optional[str] = None + FileSourceTemplateConfiguration = Union[ PosixFileSourceTemplateConfiguration, @@ -128,6 +151,7 @@ FileSourceTemplateConfiguration = Union[ FtpFileSourceTemplateConfiguration, AzureFileSourceTemplateConfiguration, OnedataFileSourceTemplateConfiguration, + WebdavFileSourceTemplateConfiguration, ] FileSourceConfiguration = Union[ PosixFileSourceConfiguration, @@ -135,6 +159,7 @@ FileSourceConfiguration = Union[ FtpFileSourceConfiguration, AzureFileSourceConfiguration, OnedataFileSourceConfiguration, + WebdavFileSourceConfiguration, ] @@ -196,6 +221,7 @@ TypesToConfigurationClasses: Dict[FileSourceTemplateType, Type[FileSourceConfigu "s3fs": S3FSFileSourceConfiguration, "azure": AzureFileSourceConfiguration, "onedata": OnedataFileSourceConfiguration, + "webdav": WebdavFileSourceConfiguration, }