From 01c5cc1a88865e74211008d136cd196ed1bb9a08 Mon Sep 17 00:00:00 2001 From: Mateusz Kulas <60038363+m-qlas@users.noreply.github.com> Date: Thu, 7 Sep 2023 12:47:04 +0200 Subject: [PATCH] Generator for CKAN (#89) --- oddrn_generator/__init__.py | 2 ++ oddrn_generator/generators.py | 7 +++++++ oddrn_generator/path_models.py | 17 +++++++++++++++++ 3 files changed, 26 insertions(+) diff --git a/oddrn_generator/__init__.py b/oddrn_generator/__init__.py index 232e68b..723f8cb 100644 --- a/oddrn_generator/__init__.py +++ b/oddrn_generator/__init__.py @@ -57,6 +57,7 @@ GCSGenerator, AzureBlobStorageGenerator, BigQueryStorageGenerator, + CKANGenerator, ) __all__ = [ @@ -118,4 +119,5 @@ "GCSGenerator", "AzureBlobStorageGenerator", "BigQueryStorageGenerator", + "CKANGenerator", ] diff --git a/oddrn_generator/generators.py b/oddrn_generator/generators.py index 09e3941..4ebe57a 100644 --- a/oddrn_generator/generators.py +++ b/oddrn_generator/generators.py @@ -58,6 +58,7 @@ VerticaPathsModel, BlobPathsModel, BigQueryStoragePathsModel, + CKANPathsModel, ) from oddrn_generator.server_models import ( AbstractServerModel, @@ -533,3 +534,9 @@ class BigQueryStorageGenerator(Generator): source = "bigquery_storage" paths_model = BigQueryStoragePathsModel server_model = GCPCloudModel + + +class CKANGenerator(Generator): + source = "ckan" + paths_model = CKANPathsModel + server_model = HostnameModel diff --git a/oddrn_generator/path_models.py b/oddrn_generator/path_models.py index 9162b46..da50970 100644 --- a/oddrn_generator/path_models.py +++ b/oddrn_generator/path_models.py @@ -852,3 +852,20 @@ class Config: "tables": ("datasets", "tables"), "columns": ("datasets", "tables", "columns"), } + + +class CKANPathsModel(BasePathsModel): + organizations: Optional[str] + groups: Optional[str] + datasets: Optional[str] + resources: Optional[str] + fields: Optional[str] + + class Config: + dependencies_map = { + "organizations": ("organizations",), + "groups": ("groups",), + "datasets": ("organizations", "datasets"), + "resources": ("organizations", "datasets", "resources"), + "fields": ("organizations", "datasets", "resources", "fields"), + }