Skip to content

Commit

Permalink
edit
Browse files Browse the repository at this point in the history
  • Loading branch information
jnussbaum committed Nov 12, 2024
1 parent 7441cb3 commit f66ffb6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion dsp_permissions_scripts/doap/doap_model.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
from __future__ import annotations

import re
from typing import Literal
from typing import Self

from pydantic import BaseModel
from pydantic import ConfigDict
from pydantic import Discriminator
from pydantic import Field
from pydantic import model_validator

from dsp_permissions_scripts.models.errors import EmptyDoapTargetError
Expand All @@ -21,7 +24,7 @@ class Doap(BaseModel):

model_config = ConfigDict(extra="forbid")

target: GroupDoapTarget | EntityDoapTarget
target: GroupDoapTarget | EntityDoapTarget = Field(discriminator=Discriminator("target"))
scope: PermissionScope
doap_iri: str

Expand All @@ -30,6 +33,7 @@ class GroupDoapTarget(BaseModel):
"""The group for which a DOAP is defined"""

model_config = ConfigDict(extra="forbid")
target: Literal["group"] = Field(init=False, default="group")

project_iri: str
group: Group
Expand All @@ -39,6 +43,7 @@ class EntityDoapTarget(BaseModel):
"""The resource class and/or property for which a DOAP is defined"""

model_config = ConfigDict(extra="forbid")
target: Literal["entity"] = Field(init=False, default="entity")

project_iri: str
resclass_iri: str | None = None
Expand Down

0 comments on commit f66ffb6

Please sign in to comment.