Skip to content

Commit

Permalink
rename fields
Browse files Browse the repository at this point in the history
  • Loading branch information
jnussbaum committed Nov 12, 2024
1 parent 215af9c commit 672345f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion dsp_permissions_scripts/doap/doap_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
14 changes: 7 additions & 7 deletions dsp_permissions_scripts/doap/doap_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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
4 changes: 2 additions & 2 deletions dsp_permissions_scripts/doap/doap_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 672345f

Please sign in to comment.