diff --git a/dsp_permissions_scripts/main.py b/dsp_permissions_scripts/main.py index 37c50f21..ebd8d56e 100644 --- a/dsp_permissions_scripts/main.py +++ b/dsp_permissions_scripts/main.py @@ -2,13 +2,14 @@ from dsp_permissions_scripts.models.groups import BuiltinGroup from dsp_permissions_scripts.models.host import Hosts +from dsp_permissions_scripts.models.permission import Oap from dsp_permissions_scripts.models.scope import PUBLIC from dsp_permissions_scripts.utils.authentication import login from dsp_permissions_scripts.utils.permissions import ( + apply_updated_oaps_on_server, get_doaps_of_project, print_doaps_of_project, set_doaps_of_groups, - update_permissions_for_resources_and_values, ) from dsp_permissions_scripts.utils.project import ( get_all_resource_oaps_of_project, @@ -16,6 +17,12 @@ ) +def modify_oaps(oaps: list[Oap]) -> list[Oap]: + for oap in oaps: + oap.scope.D.append(BuiltinGroup.PROJECT_MEMBER) + return oaps + + def main() -> None: """ The main method assembles a sample call of all available high-level functions. @@ -54,9 +61,9 @@ def main() -> None: host=host, token=token, ) - update_permissions_for_resources_and_values( - resource_iris=resource_oaps_updated, - scope=new_scope, + resource_oaps_updated = modify_oaps(oaps=resource_oaps) + apply_updated_oaps_on_server( + resource_oaps=resource_oaps_updated, host=host, token=token, ) diff --git a/dsp_permissions_scripts/utils/permissions.py b/dsp_permissions_scripts/utils/permissions.py index d811536f..2059a9af 100644 --- a/dsp_permissions_scripts/utils/permissions.py +++ b/dsp_permissions_scripts/utils/permissions.py @@ -9,6 +9,7 @@ Doap, DoapTarget, DoapTargetType, + Oap, PermissionScope, ) from dsp_permissions_scripts.models.value import ValueUpdate @@ -233,6 +234,21 @@ def update_doap_scope( return new_doap +def apply_updated_oaps_on_server( + resource_oaps: list[Oap], + host: str, + token: str, +) -> None: + """Applies object access permissions on a DSP server.""" + for resource_oap in resource_oaps: + update_permissions_for_resources_and_values( + resource_iris=[resource_oap.object_iri], + scope=resource_oap.scope, + host=host, + token=token, + ) + + def update_permissions_for_resources_and_values( resource_iris: list[str], scope: PermissionScope,