Skip to content

Commit

Permalink
wip: onedrive
Browse files Browse the repository at this point in the history
  • Loading branch information
jmchilton committed Jun 12, 2024
1 parent 675f2d2 commit b02e537
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 8 deletions.
4 changes: 2 additions & 2 deletions client/src/api/schema/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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?:
| (
Expand Down Expand Up @@ -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 */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ interface Props {
uuid?: string;
}
const OAUTH2_TYPES = ["dropbox", "googledrive"];
const OAUTH2_TYPES = ["dropbox", "googledrive", "onedrive"];
const fileSourceTemplatesStore = useFileSourceTemplatesStore();
fileSourceTemplatesStore.fetchTemplates();
Expand Down
Original file line number Diff line number Diff line change
@@ -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 }}"
Expand Down
31 changes: 28 additions & 3 deletions lib/galaxy/files/templates/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -163,6 +178,7 @@ class AzureFileSourceConfiguration(StrictModel):
AzureFileSourceTemplateConfiguration,
DropboxFileSourceTemplateConfiguration,
GoogleDriveFileSourceTemplateConfiguration,
OneDriveFileSourceTemplateConfiguration,
]
FileSourceConfiguration = Union[
PosixFileSourceConfiguration,
Expand All @@ -171,6 +187,7 @@ class AzureFileSourceConfiguration(StrictModel):
AzureFileSourceConfiguration,
DropboxFileSourceConfiguration,
GoogleDriveFileSourceConfiguration,
OneDriveFileSourceConfiguration,
]


Expand Down Expand Up @@ -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)


Expand All @@ -238,6 +256,7 @@ def template_to_configuration(
"azure": AzureFileSourceConfiguration,
"dropbox": DropboxFileSourceConfiguration,
"googledrive": GoogleDriveFileSourceConfiguration,
"onedrive": OneDriveFileSourceConfiguration,
}


Expand All @@ -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"],
)
}


Expand Down

0 comments on commit b02e537

Please sign in to comment.