From 672345f8fd0d3b6a27aef230f97c6605e4019be6 Mon Sep 17 00:00:00 2001 From: Johannes Nussbaum Date: Tue, 12 Nov 2024 14:37:42 +0100 Subject: [PATCH] rename fields --- dsp_permissions_scripts/doap/doap_get.py | 2 +- dsp_permissions_scripts/doap/doap_model.py | 14 +++++++------- dsp_permissions_scripts/doap/doap_set.py | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/dsp_permissions_scripts/doap/doap_get.py b/dsp_permissions_scripts/doap/doap_get.py index 934f8077..db5aad7b 100644 --- a/dsp_permissions_scripts/doap/doap_get.py +++ b/dsp_permissions_scripts/doap/doap_get.py @@ -37,7 +37,7 @@ def create_doap_from_admin_route_response(permission: dict[str, Any], dsp_client target = GroupDoapTarget(project_iri=project_iri, group=group_builder(prefixed_group_iri)) case {"forProject": project_iri, **p}: target = EntityDoapTarget( - project_iri=project_iri, resource_class=p.get("forResourceClass"), property=p.get("forProperty") + project_iri=project_iri, resclass_iri=p.get("forResourceClass"), property_iri=p.get("forProperty") ) return Doap( target=target, diff --git a/dsp_permissions_scripts/doap/doap_model.py b/dsp_permissions_scripts/doap/doap_model.py index 97e6bd39..488653ef 100644 --- a/dsp_permissions_scripts/doap/doap_model.py +++ b/dsp_permissions_scripts/doap/doap_model.py @@ -35,13 +35,13 @@ class EntityDoapTarget(BaseModel): model_config = ConfigDict(extra="forbid") project_iri: str - resource_class: str | None = None - property: str | None = None + resclass_iri: str | None = None + property_iri: str | None = None @model_validator(mode="after") def _validate(self) -> Self: - if self.resource_class is None and self.property is None: - raise ValueError("At least one of resource_class or property must be set") + if self.resclass_iri is None and self.property_iri is None: + raise ValueError("At least one of resclass_iri or property_iri must be set") return self @@ -65,11 +65,11 @@ class NewEntityDoapTarget(BaseModel): model_config = ConfigDict(extra="forbid") - resource_class: str | None = None - property: str | None = None + prefixed_class: str | None = None + prefixed_prop: str | None = None @model_validator(mode="after") def _validate(self) -> Self: - if self.resource_class is None and self.property is None: + if self.prefixed_class is None and self.prefixed_prop is None: raise ValueError("At least one of resource_class or property must be set") return self diff --git a/dsp_permissions_scripts/doap/doap_set.py b/dsp_permissions_scripts/doap/doap_set.py index b7029b0b..6e85e0e8 100644 --- a/dsp_permissions_scripts/doap/doap_set.py +++ b/dsp_permissions_scripts/doap/doap_set.py @@ -54,8 +54,8 @@ def create_new_doap_on_server( payload = { "forGroup": forGroup, "forProject": proj_iri, - "forProperty": target.property if isinstance(target, NewEntityDoapTarget) else None, - "forResourceClass": target.resource_class if isinstance(target, NewEntityDoapTarget) else None, + "forProperty": target.prefixed_prop if isinstance(target, NewEntityDoapTarget) else None, + "forResourceClass": target.prefixed_class if isinstance(target, NewEntityDoapTarget) else None, "hasPermissions": create_admin_route_object_from_scope(scope, dsp_client), } try: