gams-pylican 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. gams_pylican-0.0.1/.gitignore +43 -0
  2. gams_pylican-0.0.1/.gitlab-ci.yml +48 -0
  3. gams_pylican-0.0.1/CHANGELOG.md +14 -0
  4. gams_pylican-0.0.1/LICENSE.md +21 -0
  5. gams_pylican-0.0.1/Make +19 -0
  6. gams_pylican-0.0.1/PKG-INFO +77 -0
  7. gams_pylican-0.0.1/README.md +67 -0
  8. gams_pylican-0.0.1/demo.py +31 -0
  9. gams_pylican-0.0.1/pyproject.toml +32 -0
  10. gams_pylican-0.0.1/src/gams_pylican/CurationApiFacade.py +142 -0
  11. gams_pylican-0.0.1/src/gams_pylican/IntegrationApiFacade.py +66 -0
  12. gams_pylican-0.0.1/src/gams_pylican/Pylican.py +87 -0
  13. gams_pylican-0.0.1/src/gams_pylican/PylicanStatics.py +20 -0
  14. gams_pylican-0.0.1/src/gams_pylican/__init__.py +4 -0
  15. gams_pylican-0.0.1/src/gams_pylican/api/DigitalObject/DigitalObject.py +27 -0
  16. gams_pylican-0.0.1/src/gams_pylican/api/DigitalObject/DigitalObjectService.py +93 -0
  17. gams_pylican-0.0.1/src/gams_pylican/api/DigitalObject/__init__.py +0 -0
  18. gams_pylican-0.0.1/src/gams_pylican/api/DigitalObject/exceptions.py +8 -0
  19. gams_pylican-0.0.1/src/gams_pylican/api/GamsApiClient.py +90 -0
  20. gams_pylican-0.0.1/src/gams_pylican/api/Project/Project.py +18 -0
  21. gams_pylican-0.0.1/src/gams_pylican/api/Project/ProjectService.py +47 -0
  22. gams_pylican-0.0.1/src/gams_pylican/api/Project/__init__.py +0 -0
  23. gams_pylican-0.0.1/src/gams_pylican/api/Project/exceptions.py +17 -0
  24. gams_pylican-0.0.1/src/gams_pylican/api/__init__.py +0 -0
  25. gams_pylican-0.0.1/src/gams_pylican/api/auth/AuthorizationService.py +114 -0
  26. gams_pylican-0.0.1/src/gams_pylican/api/auth/LoginFormParser.py +39 -0
  27. gams_pylican-0.0.1/src/gams_pylican/api/auth/__init__.py +0 -0
  28. gams_pylican-0.0.1/src/gams_pylican/app/IngestService.py +81 -0
  29. gams_pylican-0.0.1/src/gams_pylican/app/IntegrationService.py +67 -0
  30. gams_pylican-0.0.1/src/gams_pylican/app/__init__.py +0 -0
  31. gams_pylican-0.0.1/src/gams_pylican/exceptions.py +34 -0
  32. gams_pylican-0.0.1/src/gams_pylican/infrastructure/FileSystemService.py +50 -0
  33. gams_pylican-0.0.1/src/gams_pylican/infrastructure/__init__.py +0 -0
  34. gams_pylican-0.0.1/src/gams_pylican/main.py +54 -0
  35. gams_pylican-0.0.1/tests/__init__.py +0 -0
  36. gams_pylican-0.0.1/tests/conftest.py +70 -0
  37. gams_pylican-0.0.1/tests/integration/__init__.py +0 -0
  38. gams_pylican-0.0.1/tests/integration/test_ingest.py +25 -0
  39. gams_pylican-0.0.1/tests/integration/test_integration_api.py +37 -0
  40. gams_pylican-0.0.1/tests/integration/test_login.py +34 -0
  41. gams_pylican-0.0.1/tests/integration/test_project.py +76 -0
  42. gams_pylican-0.0.1/tests/pytest.ini +4 -0
  43. gams_pylican-0.0.1/tests/resources/bags/demo.person.1/bag-info.txt +4 -0
  44. gams_pylican-0.0.1/tests/resources/bags/demo.person.1/bagit.txt +2 -0
  45. gams_pylican-0.0.1/tests/resources/bags/demo.person.1/data/content/DC.xml +21 -0
  46. gams_pylican-0.0.1/tests/resources/bags/demo.person.1/data/content/EVENTS.json +133 -0
  47. gams_pylican-0.0.1/tests/resources/bags/demo.person.1/data/content/RDF.xml +55 -0
  48. gams_pylican-0.0.1/tests/resources/bags/demo.person.1/data/meta/sip.json +61 -0
  49. gams_pylican-0.0.1/tests/resources/bags/demo.person.1/manifest-md5.txt +4 -0
  50. gams_pylican-0.0.1/tests/resources/bags/demo.person.1/manifest-sha512.txt +4 -0
  51. gams_pylican-0.0.1/tests/unit/__init__.py +0 -0
  52. gams_pylican-0.0.1/tests/unit/test_filesystem_service.py +60 -0
  53. gams_pylican-0.0.1/tests/unit/test_gams_api_client.py +61 -0
  54. gams_pylican-0.0.1/tests/unit/test_login_form_parser.py +44 -0
  55. gams_pylican-0.0.1/tests/utils/TestPylicanProject.py +12 -0
  56. gams_pylican-0.0.1/tests/utils/__init__.py +0 -0
  57. gams_pylican-0.0.1/uv.lock +241 -0
@@ -0,0 +1,43 @@
1
+ # python generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ wheels/
7
+ *.egg-info
8
+
9
+ # venv
10
+ .venv
11
+
12
+ # exclude rye local dependency files
13
+ .python-version
14
+ requirements.lock
15
+ requirements-dev.lock
16
+
17
+
18
+ Thumbs.db
19
+ .DS_Store
20
+ .gradle
21
+ build/
22
+ target/
23
+ out/
24
+ .idea
25
+ *.iml
26
+ *.ipr
27
+ *.iws
28
+ .project
29
+ .settings
30
+ .classpath
31
+ .factorypath
32
+
33
+ # custom
34
+ venv/
35
+ .venv/
36
+ bock.egg*
37
+ dist
38
+ .pypirc
39
+ __pycache__
40
+ logs
41
+ project/bags
42
+ models
43
+ .vscode/
@@ -0,0 +1,48 @@
1
+ stages:
2
+ - test
3
+ - lint
4
+ - build
5
+ - publish
6
+
7
+ # A hidden job template that can be used by different Python versions
8
+ .test-template:
9
+ stage: test
10
+ script:
11
+ - echo "uv environment version"
12
+ - uv --version
13
+ - echo "Pinning ${PYTHON_VERSION}"
14
+ - uv python pin ${PYTHON_VERSION}
15
+ - uv sync
16
+ - echo "Using python version:"
17
+ - python --version
18
+ - echo "Running tests with uv"
19
+ - uv run pytest tests
20
+
21
+ # Specific jobs for Python versions
22
+ test-py_3.12:
23
+ extends: .test-template
24
+ variables:
25
+ PYTHON_VERSION: "3.12"
26
+
27
+ lint:
28
+ stage: lint
29
+ script:
30
+ - echo "uv environment version"
31
+ - uv --version
32
+ - echo "Using python version:"
33
+ - python --version
34
+ - echo "Running uv check with ruff"
35
+ - uv run ruff check src
36
+
37
+ build:
38
+ stage: build
39
+ script:
40
+ uv build
41
+
42
+ publish-pypi:
43
+ stage: publish
44
+ script:
45
+ - uv build
46
+ - uv publish --token $PYPI_TOKEN
47
+ rules:
48
+ - if: $CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+$/
@@ -0,0 +1,14 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+
9
+ ## [0.0.1]
10
+
11
+ ### Added
12
+
13
+ - initial release
14
+ - core features as python facade for
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Sebastian David Schiller-Stoff
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,19 @@
1
+ # make test, coverage, documentation, etc
2
+ SHELL := /bin/bash
3
+
4
+ .PHONY: all test clean build
5
+
6
+ all: init test lint build
7
+
8
+ init:
9
+ @uv sync
10
+
11
+ test:
12
+ @uv run pytest tests
13
+
14
+ lint:
15
+ @uv run ruff check src
16
+
17
+ build:
18
+ @uv build
19
+
@@ -0,0 +1,77 @@
1
+ Metadata-Version: 2.4
2
+ Name: gams-pylican
3
+ Version: 0.0.1
4
+ Summary: Python based gams5 client / api facade - installabe via pip, uv etc. Pelicans use their massive pouches to scoop up and transport large catches. Similarily gams-pylican transports gams5 data for your personal usage.
5
+ Author-email: Sebastian David Schiller-Stoff <sebastian.stoff@uni-graz.at>
6
+ License-File: LICENSE.md
7
+ Requires-Python: >=3.12
8
+ Requires-Dist: requests>=2.32.4
9
+ Description-Content-Type: text/markdown
10
+
11
+ # gams-pylican
12
+
13
+ Lightweight python based gams5 client / api facade - installable via pip, uv etc. Pelicans use their massive pouches to scoop up and transport large catches. Similarly, gams-pylican transports gams5 data for your personal usage.
14
+
15
+
16
+ # Installation
17
+
18
+ ```sh
19
+ # e.g.
20
+ pip install gams-pylican
21
+
22
+
23
+ ```
24
+
25
+ # Quickstart
26
+
27
+ ```py
28
+ import gams_pylican
29
+
30
+ # instantiate client
31
+ gams_client = gams_pylican.bootstrap_client("https://gams.uni-graz.at")
32
+
33
+ # use api facade operations (public get)
34
+ objects = gams_client.curation.list_objects("memor")
35
+
36
+
37
+ ```
38
+
39
+
40
+ # State changing operations
41
+
42
+ - e.g. CRUD on digital objects, datastreams, projects or ingest operations.
43
+
44
+ ```py
45
+ import gams_pylican
46
+
47
+ # instantiate client
48
+ gams_client = gams_pylican.bootstrap_client("https://gams.uni-graz.at")
49
+
50
+ # either supply username and password
51
+ gams_client.login(username="foo", password="bar")
52
+ # or overwrite values from env variables (PYLICAN_USER, PYLICAN_PASSWORD)
53
+ gams_client.login() # in this case method can be empty
54
+
55
+ # perform state changing operations
56
+ gams_client.curation.update_project("foo", "bar")
57
+ gams_client.curation.ingest("foo")
58
+ # ...
59
+
60
+ # logout as last step
61
+ gams_client.logout()
62
+
63
+
64
+ ```
65
+
66
+
67
+ ## Development
68
+
69
+ ### Release
70
+
71
+ 1. Increment version in pyproject.toml in feature branch (merging into develop):
72
+ - make sure version follow vd.d.d pattern
73
+ 2. Merge changes to develop -> main
74
+ 3. Create release on the gitlab webclient (from main branch) with new git tag that must be the same as in the pyproject.toml!
75
+ - e.g. v0.1.1
76
+ - create the release from the main branch!
77
+ - gitlab will autodeploy the new version to pypi
@@ -0,0 +1,67 @@
1
+ # gams-pylican
2
+
3
+ Lightweight python based gams5 client / api facade - installable via pip, uv etc. Pelicans use their massive pouches to scoop up and transport large catches. Similarly, gams-pylican transports gams5 data for your personal usage.
4
+
5
+
6
+ # Installation
7
+
8
+ ```sh
9
+ # e.g.
10
+ pip install gams-pylican
11
+
12
+
13
+ ```
14
+
15
+ # Quickstart
16
+
17
+ ```py
18
+ import gams_pylican
19
+
20
+ # instantiate client
21
+ gams_client = gams_pylican.bootstrap_client("https://gams.uni-graz.at")
22
+
23
+ # use api facade operations (public get)
24
+ objects = gams_client.curation.list_objects("memor")
25
+
26
+
27
+ ```
28
+
29
+
30
+ # State changing operations
31
+
32
+ - e.g. CRUD on digital objects, datastreams, projects or ingest operations.
33
+
34
+ ```py
35
+ import gams_pylican
36
+
37
+ # instantiate client
38
+ gams_client = gams_pylican.bootstrap_client("https://gams.uni-graz.at")
39
+
40
+ # either supply username and password
41
+ gams_client.login(username="foo", password="bar")
42
+ # or overwrite values from env variables (PYLICAN_USER, PYLICAN_PASSWORD)
43
+ gams_client.login() # in this case method can be empty
44
+
45
+ # perform state changing operations
46
+ gams_client.curation.update_project("foo", "bar")
47
+ gams_client.curation.ingest("foo")
48
+ # ...
49
+
50
+ # logout as last step
51
+ gams_client.logout()
52
+
53
+
54
+ ```
55
+
56
+
57
+ ## Development
58
+
59
+ ### Release
60
+
61
+ 1. Increment version in pyproject.toml in feature branch (merging into develop):
62
+ - make sure version follow vd.d.d pattern
63
+ 2. Merge changes to develop -> main
64
+ 3. Create release on the gitlab webclient (from main branch) with new git tag that must be the same as in the pyproject.toml!
65
+ - e.g. v0.1.1
66
+ - create the release from the main branch!
67
+ - gitlab will autodeploy the new version to pypi
@@ -0,0 +1,31 @@
1
+ import gams_pylican
2
+
3
+ # demo calls for pylican
4
+
5
+ gams_client = gams_pylican.bootstrap_client("https://it030021.uni-graz.at")
6
+ # gams_client = gams_pylican.bootstrap_client("https://it030021.uni-graz.at", str(Path.cwd() / "bags"))
7
+
8
+ objects = gams_client.curation.list_objects("memor")
9
+
10
+ gams_client.login(username="foo", password="bar")
11
+ gams_client.login()
12
+
13
+ # gams_client.curation.update_project("memo", "MEMOR | Digitales Memorbuch der Stadt Graz")
14
+
15
+ gams_client.logout()
16
+
17
+ # gams_client.curation.update_project("memo", "MEMOR | Digitales Memorbuch der Stadt Graz")
18
+
19
+ # gams_client.curation.update_project("memo", "MEMOR | Digitales Memorbuch der Stadt Graz")
20
+
21
+ #gams_client.curation.update_project()
22
+
23
+ print(objects)
24
+
25
+
26
+ # this should fail with 403
27
+ # gams_client.delete_object("htx.durham.1", "htx")
28
+
29
+
30
+
31
+
@@ -0,0 +1,32 @@
1
+ [project]
2
+ name = "gams-pylican"
3
+ version = "v0.0.1"
4
+ description = "Python based gams5 client / api facade - installabe via pip, uv etc. Pelicans use their massive pouches to scoop up and transport large catches. Similarily gams-pylican transports gams5 data for your personal usage."
5
+ authors = [
6
+ { name = "Sebastian David Schiller-Stoff", email = "sebastian.stoff@uni-graz.at" }
7
+ ]
8
+ dependencies = [
9
+ "requests>=2.32.4"
10
+ ]
11
+ readme = "README.md"
12
+ requires-python = ">= 3.12"
13
+
14
+ [build-system]
15
+ requires = ["hatchling"]
16
+ build-backend = "hatchling.build"
17
+
18
+ [tool.hatch.metadata]
19
+ allow-direct-references = true
20
+
21
+ [tool.hatch.build.targets.wheel]
22
+ packages = ["src/gams_pylican"]
23
+
24
+ [dependency-groups]
25
+ dev = [
26
+ "pytest>=8.3.5",
27
+ "requests-mock>=1.12.1",
28
+ "ruff>=0.14.14",
29
+ ]
30
+
31
+ [project.scripts]
32
+ pylican = "gams_pylican.cli:cli"
@@ -0,0 +1,142 @@
1
+ import logging
2
+ import os
3
+ from typing import Optional, List
4
+
5
+ from gams_pylican.api.DigitalObject.DigitalObjectService import DigitalObjectService
6
+ from gams_pylican.api.Project.ProjectService import ProjectService
7
+ from gams_pylican.api.auth.AuthorizationService import AuthorizationService
8
+ from gams_pylican.app.IngestService import IngestService
9
+
10
+
11
+ class CurationApiFacade:
12
+ """
13
+ Facade class for the curation part of the gams-api under /api/curation/v1 etc.
14
+ """
15
+
16
+ # Services
17
+ _digital_object_service: DigitalObjectService
18
+ _ingest_service: IngestService
19
+ _authorization_service: AuthorizationService
20
+ _project_service: ProjectService
21
+
22
+ _local_bagit_files_path: Optional[str]
23
+
24
+ def __init__(self,
25
+ local_bagit_files_path: Optional[str],
26
+ authorization_service: AuthorizationService,
27
+ ingest_service: IngestService,
28
+ project_service: ProjectService,
29
+ digital_object_service: DigitalObjectService
30
+ ) -> None:
31
+
32
+ self._local_bagit_files_path = local_bagit_files_path
33
+
34
+ self._authorization_service = authorization_service
35
+ self._digital_object_service = digital_object_service
36
+ self._ingest_service = ingest_service
37
+ self._project_service = project_service
38
+
39
+ def list_objects(self, project_abbr: str) -> List[str]:
40
+ """
41
+ Lists all objects of defined project
42
+ """
43
+
44
+ return self._digital_object_service.list_objects(project_abbr)
45
+
46
+ def save_object(self, object_id: str, project_abbr: str):
47
+ """
48
+ Creates a digital object
49
+ """
50
+ return self._digital_object_service.save_object(object_id, project_abbr)
51
+
52
+ def assign_child_objects(self, parent_id: str, children_ids: List[str], project_abbr: str):
53
+ """
54
+ Assigns a child object to a parent object
55
+ """
56
+ return self._digital_object_service.assign_child_objects(parent_id, children_ids, project_abbr)
57
+
58
+ def delete_object(self, object_id: str, project_abbr: str):
59
+ """
60
+ Deletes a digital object
61
+ """
62
+
63
+ return self._digital_object_service.delete_object(object_id, project_abbr)
64
+
65
+ def delete_objects(self, project_abbr: str):
66
+ """
67
+ Deletes all digital objects of a project
68
+ """
69
+ project_objects = self.list_objects(project_abbr)
70
+ logging.info(f"Deleting now {len(project_objects)} objects for project {project_abbr}")
71
+ for obj in project_objects:
72
+ self.delete_object(obj, project_abbr)
73
+
74
+ def create_project(self, project_abbr: str, description: str):
75
+ """
76
+ Creates a new project with given abbreviation and description.
77
+ """
78
+ self._project_service.save_project(project_abbr, description)
79
+
80
+ def update_project(self, project_abbr: str, description: str):
81
+ """
82
+ Updates a project.
83
+ """
84
+ self._project_service.update_project(project_abbr, description)
85
+
86
+ def delete_project(self, project_abbr: str):
87
+ """
88
+ Deletes a project.
89
+ """
90
+ self._project_service.delete_project(project_abbr)
91
+
92
+ def ingest_bag(self, project_abbr: str, sip_folder_name: str):
93
+ """
94
+ Ingests defined folder from the local SIP structure.
95
+ """
96
+ if self._digital_object_service.object_exists(sip_folder_name, project_abbr):
97
+ self.delete_object(sip_folder_name, project_abbr)
98
+ logging.info(f"Successfully deleted existing object: {sip_folder_name} for ingest")
99
+
100
+
101
+ self._ingest_service.ingest_bag(project_abbr, sip_folder_name)
102
+
103
+ def ingest_bags(self, project_abbr: str):
104
+ """
105
+ Ingests all bags from the local bag structure.
106
+ """
107
+
108
+ if not self._local_bagit_files_path:
109
+ raise ValueError("Local bag path is not configured.")
110
+
111
+ failures = []
112
+
113
+ for folder_name in os.listdir(self._local_bagit_files_path):
114
+ # Basic filter (you might want to improve this)
115
+ if not folder_name.startswith(project_abbr):
116
+ continue
117
+
118
+ try:
119
+ logging.info(f"Starting ingest for: {folder_name}")
120
+ self.ingest_bag(project_abbr, folder_name)
121
+ logging.info(f"Successfully ingested: {folder_name}")
122
+ except Exception as e:
123
+ logging.error(f"FAILED to ingest {folder_name}: {e}")
124
+ failures.append(folder_name)
125
+
126
+ # Critical: If there were failures, we should probably let the caller know
127
+ if failures:
128
+ raise RuntimeError(f"Batch ingest completed with {len(failures)} errors: {failures}")
129
+
130
+ def ingest(self, project_abbr: str):
131
+ """
132
+ Performs a complete ingest operation based on the defined SIP folders.
133
+ """
134
+
135
+ # optionally delete all objects first
136
+ # self.curation.delete_objects(project_abbr)
137
+
138
+ # delete all indices from dependent services
139
+ # self.disintegrate_project_objects(project_abbr)
140
+
141
+ # ingesting all bags from the local bag structure admin
142
+ self.ingest_bags(project_abbr)
@@ -0,0 +1,66 @@
1
+ from gams_pylican.app.IntegrationService import IntegrationService
2
+
3
+
4
+ class IntegrationApiFacade:
5
+ """
6
+ Facade class for the integration part of the gams-api under /api/integration/v1 etc.
7
+ """
8
+
9
+ # Services
10
+ _integration_service: IntegrationService
11
+
12
+
13
+ def __init__(self, integration_service: IntegrationService):
14
+ """
15
+
16
+ """
17
+ self._integration_service = integration_service
18
+
19
+ def integrate_project_objects(self, project_abbr: str):
20
+ """
21
+ Integrates all objects of a project
22
+ """
23
+ return self._integration_service.integrate_all(project_abbr)
24
+
25
+ def disintegrate_project_objects(self, project_abbr: str):
26
+ """
27
+ Disintegrates all objects of a project
28
+ """
29
+ return self._integration_service.disintegrate_all(project_abbr)
30
+
31
+ def integrate_project_object(self, project_abbr: str, object_id: str):
32
+ """
33
+ Integrates a single object of a project in gams-integration services.
34
+ """
35
+ return self._integration_service.integrate(project_abbr, object_id)
36
+
37
+ def disintegrate_project_object(self, project_abbr: str, object_id: str):
38
+ """
39
+ Disintegrates a single object of a project in gams-integration services.
40
+ """
41
+ return self._integration_service.disintegrate(project_abbr, object_id)
42
+
43
+ def integrate_project_objects_custom_search(self, project_abbr: str):
44
+ """
45
+ Integrates all objects of a project to custom search service.
46
+ """
47
+ return self._integration_service.integrate_all_custom_search(project_abbr)
48
+
49
+ def disintegrate_project_objects_custom_search(self, project_abbr: str):
50
+ """
51
+ Disintegrates all objects of a project from custom search service.
52
+ """
53
+ return self._integration_service.disintegrate_all_custom_search(project_abbr)
54
+
55
+ def integrate_project_objects_plexus_search(self, project_abbr: str):
56
+ """
57
+ Integrates all objects of a project to plexus search service.
58
+ """
59
+ return self._integration_service.integrate_all_plexus_search(project_abbr)
60
+
61
+ def disintegrate_project_objects_plexus_search(self, project_abbr: str):
62
+ """
63
+ Disintegrates all objects of a project from plexus search service.
64
+ """
65
+ return self._integration_service.disintegrate_all_plexus_search(project_abbr)
66
+
@@ -0,0 +1,87 @@
1
+ import os
2
+ from typing import Optional
3
+
4
+ from gams_pylican.CurationApiFacade import CurationApiFacade
5
+ from gams_pylican.IntegrationApiFacade import IntegrationApiFacade
6
+ from gams_pylican.PylicanStatics import PylicanStatics
7
+ from gams_pylican.api.DigitalObject.DigitalObjectService import DigitalObjectService
8
+ from gams_pylican.api.GamsApiClient import GamsApiClient
9
+ from gams_pylican.api.Project.ProjectService import ProjectService
10
+ from gams_pylican.api.auth.AuthorizationService import AuthorizationService
11
+ from gams_pylican.app.IngestService import IngestService
12
+ from gams_pylican.app.IntegrationService import IntegrationService
13
+
14
+
15
+ class Pylican:
16
+ """
17
+ Provides abstractions for the usage of GAMS5 REST-API, like:
18
+ - ingesting bags as digital objects and datastreams
19
+ - creation of projects etc.
20
+ """
21
+
22
+ # Core components
23
+ _client: GamsApiClient
24
+ _host: str
25
+ _local_bagit_files_path: Optional[str]
26
+
27
+ # Services
28
+ _digital_object_service: DigitalObjectService
29
+ _ingest_service: IngestService
30
+ _integration_service: IntegrationService
31
+ _authorization_service: AuthorizationService
32
+ _project_service: ProjectService
33
+
34
+ curation: CurationApiFacade
35
+ integration: IntegrationApiFacade
36
+
37
+ def __init__(self,
38
+ local_bagit_files_path: str,
39
+ authorization_service: AuthorizationService,
40
+ digital_object_service: DigitalObjectService,
41
+ ingest_service: IngestService,
42
+ integration_service: IntegrationService,
43
+ project_service: ProjectService
44
+ ) -> None:
45
+
46
+ self._local_bagit_files_path = local_bagit_files_path
47
+
48
+ self._authorization_service = authorization_service
49
+ self._digital_object_service = digital_object_service
50
+ self._ingest_service = ingest_service
51
+ self._integration_service = integration_service
52
+ self._project_service = project_service
53
+
54
+ self.curation = CurationApiFacade(
55
+ local_bagit_files_path=local_bagit_files_path,
56
+ authorization_service=self._authorization_service,
57
+ digital_object_service=self._digital_object_service,
58
+ ingest_service=self._ingest_service,
59
+ project_service=self._project_service
60
+ )
61
+
62
+ self.integration = IntegrationApiFacade(
63
+ integration_service=self._integration_service,
64
+ )
65
+
66
+ def login(self, username: str = None, password: str = None):
67
+ """
68
+ Logs in to the GAMS5 instance.
69
+ """
70
+
71
+ env_username = os.environ.get(PylicanStatics.PYLICAN_USERNAME_ENV_VARIABLE)
72
+ env_password = os.environ.get(PylicanStatics.PYLICAN_PASSWORD_ENV_VARIABLE)
73
+
74
+ # overwrite any given username and password with environment variables if defined.
75
+ if env_username:
76
+ username = env_username
77
+ if env_password:
78
+ password = env_password
79
+
80
+ self._authorization_service.login(username, password)
81
+
82
+ def logout(self):
83
+ """
84
+ Logs out from the GAMS5 instance.
85
+ """
86
+ self._authorization_service.logout()
87
+
@@ -0,0 +1,20 @@
1
+ class PylicanStatics:
2
+ """
3
+ This class contains all statics for the GAMS5 API, like the API root path, the demo project abbreviation, the demo user name, etc.
4
+ all paths are relative to the current working directory.
5
+ """
6
+
7
+ API_ROOT = "/api"
8
+ AUTH_ENDPOINT = API_ROOT + "/auth"
9
+
10
+ CURATION_API_RELATIVE = "/curation/v1"
11
+ INTEGRATION_API_RELATIVE = "/integration/v1"
12
+
13
+ CURATION_API_ROOT = API_ROOT + CURATION_API_RELATIVE
14
+ INTEGRATION_API_ROOT = API_ROOT + INTEGRATION_API_RELATIVE
15
+
16
+ PYLICAN_USERNAME_ENV_VARIABLE = "PYLICAN_USER"
17
+ PYLICAN_PASSWORD_ENV_VARIABLE = "PYLICAN_PASSWORD"
18
+
19
+ def __init__(self) -> None:
20
+ pass
@@ -0,0 +1,4 @@
1
+ from gams_pylican.main import bootstrap_client
2
+
3
+ __all__ = ["bootstrap_client"]
4
+