Skip to content

Commit

Permalink
write script
Browse files Browse the repository at this point in the history
  • Loading branch information
jnussbaum committed Oct 23, 2024
1 parent 5d7c1f4 commit 393af01
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 106 deletions.
106 changes: 0 additions & 106 deletions 084C_kirchen_rom.http

This file was deleted.

71 changes: 71 additions & 0 deletions dsp_permissions_scripts/084C_kirchen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
from dsp_permissions_scripts.doap.doap_delete import _delete_doap_on_server
from dsp_permissions_scripts.doap.doap_get import get_doaps_of_project
from dsp_permissions_scripts.doap.doap_model import NewEntityDoapTarget
from dsp_permissions_scripts.doap.doap_model import NewGroupDoapTarget
from dsp_permissions_scripts.doap.doap_serialize import serialize_doaps_of_project
from dsp_permissions_scripts.doap.doap_set import create_new_doap_on_server
from dsp_permissions_scripts.models.group import PROJECT_MEMBER
from dsp_permissions_scripts.models.host import Hosts
from dsp_permissions_scripts.models.scope import OPEN
from dsp_permissions_scripts.utils.authentication import login
from dsp_permissions_scripts.utils.dsp_client import DspClient
from dsp_permissions_scripts.utils.get_logger import get_logger
from dsp_permissions_scripts.utils.get_logger import log_start_of_script

logger = get_logger(__name__)


def update_doaps(shortcode: str, dsp_client: DspClient) -> None:
"""Sample function to modify the Default Object Access Permissions of a project."""
project_doaps = get_doaps_of_project(shortcode, dsp_client)
serialize_doaps_of_project(
project_doaps=project_doaps,
shortcode=shortcode,
mode="original",
server=dsp_client.server,
)
for doap in project_doaps:
_delete_doap_on_server(doap, dsp_client)
logger.info(f"Deleted DOAP {doap.doap_iri}")
_ = create_new_doap_on_server(
target=NewGroupDoapTarget(group=PROJECT_MEMBER),
shortcode=shortcode,
scope=OPEN,
dsp_client=dsp_client,
)
_ = create_new_doap_on_server(
target=NewEntityDoapTarget(resource_class=f"{dsp_client.server}/ontology/084C/church/v2#RestrictedAccessImage"),
shortcode=shortcode,
scope=OPEN,
dsp_client=dsp_client,
)
project_doaps_updated = get_doaps_of_project(shortcode, dsp_client)
serialize_doaps_of_project(
project_doaps=project_doaps_updated,
shortcode=shortcode,
mode="modified",
server=dsp_client.server,
)


def main() -> None:
"""
The main function provides you with 3 sample functions:
One to update the Administrative Permissions of a project,
one to update the Default Object Access Permissions of a project,
and one to update the Object Access Permissions of a project.
All must first be adapted to your needs.
"""
host = Hosts.get_host("rdu")
shortcode = "084C"
log_start_of_script(host, shortcode)
dsp_client = login(host)

update_doaps(
shortcode=shortcode,
dsp_client=dsp_client,
)


if __name__ == "__main__":
main()

0 comments on commit 393af01

Please sign in to comment.