From b02e537c12aa2db02e5c747c04a31ae00799f800 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Thu, 6 Jun 2024 10:27:54 -0400 Subject: [PATCH] wip: onedrive --- client/src/api/schema/schema.ts | 4 +-- .../FileSources/Instances/CreateInstance.vue | 2 +- .../examples/production_google_drive.yml | 4 +-- lib/galaxy/files/templates/models.py | 31 +++++++++++++++++-- 4 files changed, 33 insertions(+), 8 deletions(-) diff --git a/client/src/api/schema/schema.ts b/client/src/api/schema/schema.ts index cb843df428ea..717f8242f261 100644 --- a/client/src/api/schema/schema.ts +++ b/client/src/api/schema/schema.ts @@ -5188,7 +5188,7 @@ export interface components { * Type * @enum {string} */ - type: "ftp" | "posix" | "s3fs" | "azure" | "dropbox" | "googledrive"; + type: "ftp" | "posix" | "s3fs" | "azure" | "dropbox" | "googledrive" | "onedrive"; /** Variables */ variables?: | ( @@ -12790,7 +12790,7 @@ export interface components { * Type * @enum {string} */ - type: "ftp" | "posix" | "s3fs" | "azure" | "dropbox" | "googledrive"; + type: "ftp" | "posix" | "s3fs" | "azure" | "dropbox" | "googledrive" | "onedrive"; /** Uri Root */ uri_root: string; /** Uuid */ diff --git a/client/src/components/FileSources/Instances/CreateInstance.vue b/client/src/components/FileSources/Instances/CreateInstance.vue index cee1849cc30a..d4d5354f19bb 100644 --- a/client/src/components/FileSources/Instances/CreateInstance.vue +++ b/client/src/components/FileSources/Instances/CreateInstance.vue @@ -15,7 +15,7 @@ interface Props { uuid?: string; } -const OAUTH2_TYPES = ["dropbox", "googledrive"]; +const OAUTH2_TYPES = ["dropbox", "googledrive", "onedrive"]; const fileSourceTemplatesStore = useFileSourceTemplatesStore(); fileSourceTemplatesStore.fetchTemplates(); diff --git a/lib/galaxy/files/templates/examples/production_google_drive.yml b/lib/galaxy/files/templates/examples/production_google_drive.yml index 5f95420d944e..164b162ef386 100644 --- a/lib/galaxy/files/templates/examples/production_google_drive.yml +++ b/lib/galaxy/files/templates/examples/production_google_drive.yml @@ -1,6 +1,6 @@ - id: google_drive - name: Google Drive - description: Connect to a Galaxy specific folder on your Google Drive account. + name: Export to Google Drive + description: This file source allows export to your Google Drive but can only read files uploaded by this Galaxy instance. configuration: type: googledrive oauth2_client_id: "{{ environment.oauth2_client_id }}" diff --git a/lib/galaxy/files/templates/models.py b/lib/galaxy/files/templates/models.py index c43ffd4b0083..162979a5cb23 100644 --- a/lib/galaxy/files/templates/models.py +++ b/lib/galaxy/files/templates/models.py @@ -29,7 +29,7 @@ UserDetailsDict, ) -FileSourceTemplateType = Literal["ftp", "posix", "s3fs", "azure", "dropbox", "googledrive"] +FileSourceTemplateType = Literal["ftp", "posix", "s3fs", "azure", "dropbox", "googledrive", "onedrive"] class PosixFileSourceTemplateConfiguration(StrictModel): @@ -94,6 +94,21 @@ class GoogleDriveFileSourceConfiguration(OAuth2FileSourceConfiguration, StrictMo oauth2_access_token: str +class OneDriveFileSourceTemplateConfiguration(OAuth2TemplateConfiguration, StrictModel): + type: Literal["onedrive"] + writable: Union[bool, TemplateExpansion] = False + oauth2_client_id: Union[str, TemplateExpansion] + oauth2_client_secret: Union[str, TemplateExpansion] + template_start: Optional[str] = None + template_end: Optional[str] = None + + +class OneDriveFileSourceConfiguration(OAuth2FileSourceConfiguration, StrictModel): + type: Literal["onedrive"] + writable: bool = False + oauth2_access_token: str + + class S3FSFileSourceTemplateConfiguration(StrictModel): type: Literal["s3fs"] endpoint_url: Optional[Union[str, TemplateExpansion]] = None @@ -163,6 +178,7 @@ class AzureFileSourceConfiguration(StrictModel): AzureFileSourceTemplateConfiguration, DropboxFileSourceTemplateConfiguration, GoogleDriveFileSourceTemplateConfiguration, + OneDriveFileSourceTemplateConfiguration, ] FileSourceConfiguration = Union[ PosixFileSourceConfiguration, @@ -171,6 +187,7 @@ class AzureFileSourceConfiguration(StrictModel): AzureFileSourceConfiguration, DropboxFileSourceConfiguration, GoogleDriveFileSourceConfiguration, + OneDriveFileSourceConfiguration, ] @@ -226,8 +243,9 @@ def template_to_configuration( raw_config = expand_raw_config(configuration_template, variables, secrets, user_details, environment) if implicit: raw_config.update(implicit) - raw_config.pop("oauth2_client_id") - raw_config.pop("oauth2_client_secret") + raw_config.pop("oauth2_client_id", None) + raw_config.pop("oauth2_client_secret", None) + raw_config.pop("oauth2_scope", None) return to_configuration_object(raw_config) @@ -238,6 +256,7 @@ def template_to_configuration( "azure": AzureFileSourceConfiguration, "dropbox": DropboxFileSourceConfiguration, "googledrive": GoogleDriveFileSourceConfiguration, + "onedrive": OneDriveFileSourceConfiguration, } @@ -253,6 +272,12 @@ def template_to_configuration( token_url="https://oauth2.googleapis.com/token", scope=["https://www.googleapis.com/auth/drive.file"], ), + "onedrive": OAuth2Configuration( + authorize_url="https://login.live.com/oauth20_authorize.srf", + authorize_params={}, + token_url="https://login.live.com/oauth20_token.srf", + scope=["onedrive.readwrite offline_access"], + ) }