das-cli 1.5.9__tar.gz → 1.5.11__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.
- {das_cli-1.5.9/das_cli.egg-info → das_cli-1.5.11}/PKG-INFO +1 -1
- {das_cli-1.5.9 → das_cli-1.5.11}/das/managers/digital_objects_manager.py +37 -15
- {das_cli-1.5.9 → das_cli-1.5.11}/das/services/digital_objects.py +9 -1
- {das_cli-1.5.9 → das_cli-1.5.11/das_cli.egg-info}/PKG-INFO +1 -1
- {das_cli-1.5.9 → das_cli-1.5.11}/pyproject.toml +1 -1
- {das_cli-1.5.9 → das_cli-1.5.11}/LICENSE +0 -0
- {das_cli-1.5.9 → das_cli-1.5.11}/MANIFEST.in +0 -0
- {das_cli-1.5.9 → das_cli-1.5.11}/README.md +0 -0
- {das_cli-1.5.9 → das_cli-1.5.11}/das/__init__.py +0 -0
- {das_cli-1.5.9 → das_cli-1.5.11}/das/ai/plugins/dasai.py +0 -0
- {das_cli-1.5.9 → das_cli-1.5.11}/das/ai/plugins/entries/entries_plugin.py +0 -0
- {das_cli-1.5.9 → das_cli-1.5.11}/das/app.py +0 -0
- {das_cli-1.5.9 → das_cli-1.5.11}/das/authentication/auth.py +0 -0
- {das_cli-1.5.9 → das_cli-1.5.11}/das/authentication/oauth.py +0 -0
- {das_cli-1.5.9 → das_cli-1.5.11}/das/authentication/secure_input.py +0 -0
- {das_cli-1.5.9 → das_cli-1.5.11}/das/cli.py +0 -0
- {das_cli-1.5.9 → das_cli-1.5.11}/das/common/api.py +0 -0
- {das_cli-1.5.9 → das_cli-1.5.11}/das/common/config.py +0 -0
- {das_cli-1.5.9 → das_cli-1.5.11}/das/common/entry_fields_constants.py +0 -0
- {das_cli-1.5.9 → das_cli-1.5.11}/das/common/enums.py +0 -0
- {das_cli-1.5.9 → das_cli-1.5.11}/das/common/file_utils.py +0 -0
- {das_cli-1.5.9 → das_cli-1.5.11}/das/managers/__init__.py +0 -0
- {das_cli-1.5.9 → das_cli-1.5.11}/das/managers/download_manager.py +0 -0
- {das_cli-1.5.9 → das_cli-1.5.11}/das/managers/entries_manager.py +0 -0
- {das_cli-1.5.9 → das_cli-1.5.11}/das/managers/search_manager.py +0 -0
- {das_cli-1.5.9 → das_cli-1.5.11}/das/services/attributes.py +0 -0
- {das_cli-1.5.9 → das_cli-1.5.11}/das/services/cache.py +0 -0
- {das_cli-1.5.9 → das_cli-1.5.11}/das/services/das_elastic_search.py +0 -0
- {das_cli-1.5.9 → das_cli-1.5.11}/das/services/downloads.py +0 -0
- {das_cli-1.5.9 → das_cli-1.5.11}/das/services/entries.py +0 -0
- {das_cli-1.5.9 → das_cli-1.5.11}/das/services/entry_fields.py +0 -0
- {das_cli-1.5.9 → das_cli-1.5.11}/das/services/hangfire.py +0 -0
- {das_cli-1.5.9 → das_cli-1.5.11}/das/services/search.py +0 -0
- {das_cli-1.5.9 → das_cli-1.5.11}/das/services/service_base.py +0 -0
- {das_cli-1.5.9 → das_cli-1.5.11}/das/services/users.py +0 -0
- {das_cli-1.5.9 → das_cli-1.5.11}/das_cli.egg-info/SOURCES.txt +0 -0
- {das_cli-1.5.9 → das_cli-1.5.11}/das_cli.egg-info/dependency_links.txt +0 -0
- {das_cli-1.5.9 → das_cli-1.5.11}/das_cli.egg-info/entry_points.txt +0 -0
- {das_cli-1.5.9 → das_cli-1.5.11}/das_cli.egg-info/requires.txt +0 -0
- {das_cli-1.5.9 → das_cli-1.5.11}/das_cli.egg-info/top_level.txt +0 -0
- {das_cli-1.5.9 → das_cli-1.5.11}/setup.cfg +0 -0
- {das_cli-1.5.9 → das_cli-1.5.11}/tests/__init__.py +0 -0
- {das_cli-1.5.9 → das_cli-1.5.11}/tests/attributes_test.py +0 -0
- {das_cli-1.5.9 → das_cli-1.5.11}/tests/download_manager_test.py +0 -0
- {das_cli-1.5.9 → das_cli-1.5.11}/tests/entries_manager_test.py +0 -0
- {das_cli-1.5.9 → das_cli-1.5.11}/tests/entries_service_test.py +0 -0
- {das_cli-1.5.9 → das_cli-1.5.11}/tests/entries_test.py +0 -0
- {das_cli-1.5.9 → das_cli-1.5.11}/tests/file_utils_test.py +0 -0
- {das_cli-1.5.9 → das_cli-1.5.11}/tests/run_tests.py +0 -0
- {das_cli-1.5.9 → das_cli-1.5.11}/tests/search_manager_test.py +0 -0
|
@@ -51,34 +51,56 @@ class DigitalObjectsManager:
|
|
|
51
51
|
|
|
52
52
|
return result
|
|
53
53
|
|
|
54
|
-
def
|
|
55
|
-
"""Upload a digital object to the digital object service."""
|
|
54
|
+
def _resolve_digital_object_type_id(self, digital_object_type: str) -> str:
|
|
56
55
|
response = self.search_service.search_entries(
|
|
57
56
|
queryString=f"displayname({digital_object_type})",
|
|
58
57
|
attributeId=self.__attribute_id_digital_object_type,
|
|
59
58
|
maxResultCount=1,
|
|
60
|
-
skipCount=0
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
entry_response = self.entry_service.get_entry(entry_code)
|
|
64
|
-
if entry_response is None:
|
|
65
|
-
raise ValueError(f"Entry with code '{entry_code}' not found")
|
|
59
|
+
skipCount=0,
|
|
60
|
+
)
|
|
66
61
|
|
|
67
|
-
if response.get(
|
|
62
|
+
if response.get("totalCount", 0) == 0:
|
|
68
63
|
raise ValueError(f"Digital object type '{digital_object_type}' not found")
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
64
|
+
|
|
65
|
+
return response.get("items", [])[0].get("entry").get("id")
|
|
66
|
+
|
|
67
|
+
def upload_file(
|
|
68
|
+
self, file_description: str, digital_object_type: str, file_path: str
|
|
69
|
+
) -> str:
|
|
70
|
+
"""Upload a file as a digital object without linking it to an entry."""
|
|
71
|
+
digital_object_type_id = self._resolve_digital_object_type_id(digital_object_type)
|
|
72
|
+
digital_object_id = self.digital_objects_service.upload_digital_object(
|
|
73
|
+
file_description, digital_object_type_id, file_path
|
|
74
|
+
)
|
|
72
75
|
|
|
73
76
|
if not digital_object_id:
|
|
74
77
|
raise ValueError(f"Upload did not return a digital object id for '{file_path}'")
|
|
75
78
|
|
|
79
|
+
return digital_object_id
|
|
80
|
+
|
|
81
|
+
def link_to_entry(self, entry_code: str, digital_object_ids: list[str]) -> None:
|
|
82
|
+
"""Link one or more uploaded digital objects to an entry."""
|
|
83
|
+
if not digital_object_ids:
|
|
84
|
+
raise ValueError("At least one digital object id is required")
|
|
85
|
+
|
|
86
|
+
entry_response = self.entry_service.get_entry(entry_code)
|
|
87
|
+
if entry_response is None:
|
|
88
|
+
raise ValueError(f"Entry with code '{entry_code}' not found")
|
|
89
|
+
|
|
90
|
+
entry_payload = entry_response.get("entry")
|
|
91
|
+
if entry_payload is None:
|
|
92
|
+
raise ValueError(f"Entry with code '{entry_code}' not found")
|
|
93
|
+
|
|
76
94
|
self.digital_objects_service.link_existing_digital_objects(
|
|
77
|
-
attribute_id=entry_response.get(
|
|
78
|
-
entry_id=
|
|
79
|
-
digital_object_id_list=
|
|
95
|
+
attribute_id=entry_response.get("attributeId"),
|
|
96
|
+
entry_id=entry_payload.get("id"),
|
|
97
|
+
digital_object_id_list=digital_object_ids,
|
|
80
98
|
)
|
|
81
99
|
|
|
100
|
+
def upload_digital_object(self, entry_code: str, file_description: str, digital_object_type: str, file_path: str):
|
|
101
|
+
"""Upload a digital object and link it to an entry."""
|
|
102
|
+
digital_object_id = self.upload_file(file_description, digital_object_type, file_path)
|
|
103
|
+
self.link_to_entry(entry_code, [digital_object_id])
|
|
82
104
|
return digital_object_id
|
|
83
105
|
|
|
84
106
|
def download_digital_object(self, output_path: str, digital_object_id: str = None, digital_object_code: str = None):
|
|
@@ -41,7 +41,15 @@ class DigitalObjectsService(ServiceBase):
|
|
|
41
41
|
f"{self.base_url}/LinkExistingDigitalObject", data=payload, headers=headers
|
|
42
42
|
)
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
if response.get("success") is not True:
|
|
45
|
+
error = response.get("error") or {}
|
|
46
|
+
if isinstance(error, dict):
|
|
47
|
+
message = (error.get("message") or "Failed to link digital objects").strip()
|
|
48
|
+
else:
|
|
49
|
+
message = str(error).strip() or "Failed to link digital objects"
|
|
50
|
+
raise ValueError(message)
|
|
51
|
+
|
|
52
|
+
return True
|
|
45
53
|
|
|
46
54
|
# This is our chunk reader. This is what gets the next chunk of data ready to send.
|
|
47
55
|
def __read_in_chunks(self, file_object, chunk_size):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|