Skip to content

Commit

Permalink
chore: split up models.permissions.py (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
jnussbaum authored Oct 5, 2023
1 parent 02fbf22 commit b88a5ae
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from enum import Enum
from typing import Self

Expand All @@ -6,6 +8,16 @@
from dsp_permissions_scripts.models.scope import PermissionScope


class Doap(BaseModel):
"""
Model representing a DOAP, containing the target, the scope and the IRI of the DOAP.
"""

target: DoapTarget
scope: PermissionScope
doap_iri: str


class DoapTarget(BaseModel):
project: str
group: str | None
Expand All @@ -26,25 +38,8 @@ def assert_correct_combination(self) -> Self:
return self


class Doap(BaseModel):
"""
Model representing a DOAP, containing the target, the scope and the IRI of the DOAP.
"""

target: DoapTarget
scope: PermissionScope
doap_iri: str


class DoapTargetType(Enum):
ALL = "all"
GROUP = "group"
RESOURCE_CLASS = "resource_class"
PROPERTY = "property"


class Oap(BaseModel):
"""Model representing an object access permission, containing a scope and the IRI of the resource/value"""

scope: PermissionScope
object_iri: str
10 changes: 10 additions & 0 deletions dsp_permissions_scripts/models/oap.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from pydantic import BaseModel

from dsp_permissions_scripts.models.scope import PermissionScope


class Oap(BaseModel):
"""Model representing an object access permission, containing a scope and the IRI of the resource/value"""

scope: PermissionScope
object_iri: str
3 changes: 2 additions & 1 deletion dsp_permissions_scripts/template.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from dotenv import load_dotenv

from dsp_permissions_scripts.models.doap import Doap
from dsp_permissions_scripts.models.groups import BuiltinGroup
from dsp_permissions_scripts.models.host import Hosts
from dsp_permissions_scripts.models.permission import Doap, Oap
from dsp_permissions_scripts.models.oap import Oap
from dsp_permissions_scripts.models.scope import PUBLIC
from dsp_permissions_scripts.utils.authentication import login
from dsp_permissions_scripts.utils.doap_get import (
Expand Down
2 changes: 1 addition & 1 deletion dsp_permissions_scripts/utils/doap_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import requests

from dsp_permissions_scripts.models.permission import Doap, DoapTarget, DoapTargetType
from dsp_permissions_scripts.models.doap import Doap, DoapTarget, DoapTargetType
from dsp_permissions_scripts.utils.authentication import get_protocol
from dsp_permissions_scripts.utils.get_logger import get_logger, get_timestamp
from dsp_permissions_scripts.utils.project import get_project_iri_by_shortcode
Expand Down
2 changes: 1 addition & 1 deletion dsp_permissions_scripts/utils/doap_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import requests

from dsp_permissions_scripts.models.permission import Doap
from dsp_permissions_scripts.models.doap import Doap
from dsp_permissions_scripts.models.scope import PermissionScope
from dsp_permissions_scripts.utils.authentication import get_protocol
from dsp_permissions_scripts.utils.doap_get import create_doap_from_admin_route_response
Expand Down
2 changes: 1 addition & 1 deletion dsp_permissions_scripts/utils/oap.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import requests

from dsp_permissions_scripts.models.permission import Oap
from dsp_permissions_scripts.models.oap import Oap
from dsp_permissions_scripts.models.scope import PermissionScope
from dsp_permissions_scripts.models.value import ValueUpdate
from dsp_permissions_scripts.utils.authentication import get_protocol
Expand Down
2 changes: 1 addition & 1 deletion dsp_permissions_scripts/utils/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import requests

from dsp_permissions_scripts.models.permission import Oap
from dsp_permissions_scripts.models.oap import Oap
from dsp_permissions_scripts.utils.authentication import get_protocol
from dsp_permissions_scripts.utils.get_logger import get_logger, get_timestamp
from dsp_permissions_scripts.utils.scope_serialization import create_scope_from_string
Expand Down

0 comments on commit b88a5ae

Please sign in to comment.