|
16 | 16 | ProjectPath, |
17 | 17 | ) |
18 | 18 | from renku_data_services.data_connectors import apispec, models |
| 19 | +from renku_data_services.data_connectors.constants import ALLOWED_GLOBAL_DATA_CONNECTOR_PROVIDERS |
19 | 20 | from renku_data_services.data_connectors.doi import schema_org |
20 | 21 | from renku_data_services.data_connectors.doi.metadata import create_envidat_metadata_url, get_dataset_metadata |
21 | 22 | from renku_data_services.data_connectors.doi.models import DOI, SchemaOrgDataset |
@@ -94,11 +95,6 @@ async def validate_unsaved_storage_doi( |
94 | 95 | configuration: dict[str, Any] |
95 | 96 | source_path: str |
96 | 97 |
|
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 | | - |
102 | 98 | doi_str = storage.configuration.get("doi") |
103 | 99 | if not isinstance(doi_str, str): |
104 | 100 | raise errors.ValidationError(message="Cannot find the doi in the storage configuration") |
@@ -176,9 +172,11 @@ async def prevalidate_unsaved_global_data_connector( |
176 | 172 | ) -> models.PrevalidatedGlobalDataConnector: |
177 | 173 | """Pre-validate an unsaved data connector.""" |
178 | 174 | # 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.") |
181 | 177 | 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") |
182 | 180 | if not storage.readonly: |
183 | 181 | raise errors.ValidationError(message="Global data connectors must be read-only") |
184 | 182 |
|
|
0 commit comments