1616 ProjectPath ,
1717)
1818from renku_data_services .data_connectors import apispec , models
19+ from renku_data_services .data_connectors .constants import ALLOWED_GLOBAL_DATA_CONNECTOR_PROVIDERS
1920from renku_data_services .data_connectors .doi import schema_org
2021from renku_data_services .data_connectors .doi .metadata import create_envidat_metadata_url , get_dataset_metadata
2122from renku_data_services .data_connectors .doi .models import DOI , SchemaOrgDataset
@@ -94,11 +95,6 @@ async def validate_unsaved_storage_doi(
9495 configuration : dict [str , Any ]
9596 source_path : str
9697
97- if storage .storage_type != "doi" :
98- raise errors .ProgrammingError (
99- message = "Only doi-type storage can be validated by the validate_unsaved_storage_doi function."
100- )
101-
10298 doi_str = storage .configuration .get ("doi" )
10399 if not isinstance (doi_str , str ):
104100 raise errors .ValidationError (message = "Cannot find the doi in the storage configuration" )
@@ -116,7 +112,7 @@ async def validate_unsaved_storage_doi(
116112 # Most likely supported by rclone doi provider, you have to call validator.get_doi_metadata to confirm
117113 configuration = storage .configuration
118114 source_path = storage .source_path
119- storage_type = storage .storage_type
115+ storage_type = storage .storage_type or "doi"
120116
121117 validator .validate (configuration )
122118
@@ -176,9 +172,11 @@ async def prevalidate_unsaved_global_data_connector(
176172) -> models .PrevalidatedGlobalDataConnector :
177173 """Pre-validate an unsaved data connector."""
178174 # TODO: allow admins to create global data connectors, e.g. s3://giab
179- if isinstance (body .storage , apispec .CloudStorageUrlV2 ) or body . storage . storage_type != "doi" :
180- raise errors .ValidationError (message = "Only doi storage type is allowed for global data connectors " )
175+ if isinstance (body .storage , apispec .CloudStorageUrlV2 ):
176+ raise errors .ValidationError (message = "Global data connectors cannot be configured via a URL. " )
181177 storage , doi = await validate_unsaved_storage_doi (body .storage , validator = validator )
178+ if storage .storage_type not in ALLOWED_GLOBAL_DATA_CONNECTOR_PROVIDERS :
179+ raise errors .ValidationError (message = "Only doi storage type is allowed for global data connectors" )
182180 if not storage .readonly :
183181 raise errors .ValidationError (message = "Global data connectors must be read-only" )
184182
0 commit comments