diff --git a/dsp_permissions_scripts/models/permission.py b/dsp_permissions_scripts/models/doap.py similarity index 87% rename from dsp_permissions_scripts/models/permission.py rename to dsp_permissions_scripts/models/doap.py index aa639c45..1dfdfea5 100644 --- a/dsp_permissions_scripts/models/permission.py +++ b/dsp_permissions_scripts/models/doap.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from enum import Enum from typing import Self @@ -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 @@ -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 diff --git a/dsp_permissions_scripts/models/oap.py b/dsp_permissions_scripts/models/oap.py new file mode 100644 index 00000000..cc6200a4 --- /dev/null +++ b/dsp_permissions_scripts/models/oap.py @@ -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 diff --git a/dsp_permissions_scripts/template.py b/dsp_permissions_scripts/template.py index c0e9ee73..8156494b 100644 --- a/dsp_permissions_scripts/template.py +++ b/dsp_permissions_scripts/template.py @@ -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 ( diff --git a/dsp_permissions_scripts/utils/doap_get.py b/dsp_permissions_scripts/utils/doap_get.py index 8863c3fb..e34040e6 100644 --- a/dsp_permissions_scripts/utils/doap_get.py +++ b/dsp_permissions_scripts/utils/doap_get.py @@ -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 diff --git a/dsp_permissions_scripts/utils/doap_set.py b/dsp_permissions_scripts/utils/doap_set.py index fe298d0d..c946cc13 100644 --- a/dsp_permissions_scripts/utils/doap_set.py +++ b/dsp_permissions_scripts/utils/doap_set.py @@ -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 diff --git a/dsp_permissions_scripts/utils/oap.py b/dsp_permissions_scripts/utils/oap.py index a0df5673..070d6c9a 100644 --- a/dsp_permissions_scripts/utils/oap.py +++ b/dsp_permissions_scripts/utils/oap.py @@ -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 diff --git a/dsp_permissions_scripts/utils/project.py b/dsp_permissions_scripts/utils/project.py index 61a42a01..4c9b82ce 100644 --- a/dsp_permissions_scripts/utils/project.py +++ b/dsp_permissions_scripts/utils/project.py @@ -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