das-cli 1.0.12__tar.gz → 1.0.14__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.0.12/das_cli.egg-info → das_cli-1.0.14}/PKG-INFO +1 -1
- {das_cli-1.0.12 → das_cli-1.0.14}/das/cli.py +41 -0
- das_cli-1.0.14/das/managers/digital_objects_manager.py +46 -0
- das_cli-1.0.14/das/services/digital_objects.py +44 -0
- {das_cli-1.0.12 → das_cli-1.0.14/das_cli.egg-info}/PKG-INFO +1 -1
- {das_cli-1.0.12 → das_cli-1.0.14}/das_cli.egg-info/SOURCES.txt +2 -0
- {das_cli-1.0.12 → das_cli-1.0.14}/pyproject.toml +1 -1
- {das_cli-1.0.12 → das_cli-1.0.14}/LICENSE +0 -0
- {das_cli-1.0.12 → das_cli-1.0.14}/MANIFEST.in +0 -0
- {das_cli-1.0.12 → das_cli-1.0.14}/README.md +0 -0
- {das_cli-1.0.12 → das_cli-1.0.14}/das/__init__.py +0 -0
- {das_cli-1.0.12 → das_cli-1.0.14}/das/ai/plugins/dasai.py +0 -0
- {das_cli-1.0.12 → das_cli-1.0.14}/das/ai/plugins/entries/entries_plugin.py +0 -0
- {das_cli-1.0.12 → das_cli-1.0.14}/das/app.py +0 -0
- {das_cli-1.0.12 → das_cli-1.0.14}/das/authentication/auth.py +0 -0
- {das_cli-1.0.12 → das_cli-1.0.14}/das/authentication/secure_input.py +0 -0
- {das_cli-1.0.12 → das_cli-1.0.14}/das/common/api.py +0 -0
- {das_cli-1.0.12 → das_cli-1.0.14}/das/common/config.py +0 -0
- {das_cli-1.0.12 → das_cli-1.0.14}/das/common/entry_fields_constants.py +0 -0
- {das_cli-1.0.12 → das_cli-1.0.14}/das/common/enums.py +0 -0
- {das_cli-1.0.12 → das_cli-1.0.14}/das/common/file_utils.py +0 -0
- {das_cli-1.0.12 → das_cli-1.0.14}/das/managers/__init__.py +0 -0
- {das_cli-1.0.12 → das_cli-1.0.14}/das/managers/download_manager.py +0 -0
- {das_cli-1.0.12 → das_cli-1.0.14}/das/managers/entries_manager.py +0 -0
- {das_cli-1.0.12 → das_cli-1.0.14}/das/managers/search_manager.py +0 -0
- {das_cli-1.0.12 → das_cli-1.0.14}/das/services/attributes.py +0 -0
- {das_cli-1.0.12 → das_cli-1.0.14}/das/services/cache.py +0 -0
- {das_cli-1.0.12 → das_cli-1.0.14}/das/services/downloads.py +0 -0
- {das_cli-1.0.12 → das_cli-1.0.14}/das/services/entries.py +0 -0
- {das_cli-1.0.12 → das_cli-1.0.14}/das/services/entry_fields.py +0 -0
- {das_cli-1.0.12 → das_cli-1.0.14}/das/services/hangfire.py +0 -0
- {das_cli-1.0.12 → das_cli-1.0.14}/das/services/search.py +0 -0
- {das_cli-1.0.12 → das_cli-1.0.14}/das/services/users.py +0 -0
- {das_cli-1.0.12 → das_cli-1.0.14}/das_cli.egg-info/dependency_links.txt +0 -0
- {das_cli-1.0.12 → das_cli-1.0.14}/das_cli.egg-info/entry_points.txt +0 -0
- {das_cli-1.0.12 → das_cli-1.0.14}/das_cli.egg-info/requires.txt +0 -0
- {das_cli-1.0.12 → das_cli-1.0.14}/das_cli.egg-info/top_level.txt +0 -0
- {das_cli-1.0.12 → das_cli-1.0.14}/setup.cfg +0 -0
|
@@ -14,6 +14,7 @@ from das.app import Das
|
|
|
14
14
|
from das.managers.download_manager import DownloadManager
|
|
15
15
|
from das.managers.entries_manager import EntryManager
|
|
16
16
|
from das.managers.search_manager import SearchManager
|
|
17
|
+
from das.managers.digital_objects_manager import DigitalObjectsManager
|
|
17
18
|
from das.common.file_utils import load_file_based_on_extension, parse_data_string
|
|
18
19
|
from das.ai.plugins.dasai import DasAI
|
|
19
20
|
|
|
@@ -51,6 +52,7 @@ class DasCLI:
|
|
|
51
52
|
self.entry_manager = None
|
|
52
53
|
self.search_manager = None
|
|
53
54
|
self.download_manager = None
|
|
55
|
+
self.digital_objects_manager = None
|
|
54
56
|
self.das_ai = None
|
|
55
57
|
|
|
56
58
|
def get_client(self):
|
|
@@ -65,6 +67,7 @@ class DasCLI:
|
|
|
65
67
|
self.entry_manager = EntryManager()
|
|
66
68
|
self.search_manager = SearchManager()
|
|
67
69
|
self.download_manager = DownloadManager()
|
|
70
|
+
self.digital_objects_manager = DigitalObjectsManager()
|
|
68
71
|
# Set SSL verification based on saved config
|
|
69
72
|
if not self.client:
|
|
70
73
|
self.client = Das(self.api_url)
|
|
@@ -409,6 +412,44 @@ def delete_entry(das_ctx, code):
|
|
|
409
412
|
except Exception as e:
|
|
410
413
|
click.secho(f"Error: {e}", fg="red")
|
|
411
414
|
|
|
415
|
+
@entry.command("link-digital-objects")
|
|
416
|
+
@click.option('--entry-code', required=True, help='Entry code to link/unlink digital objects to')
|
|
417
|
+
@click.option('--digital-object-code', '-d', multiple=True, required=True, help='Digital object code. Use multiple times for multiple objects.')
|
|
418
|
+
@click.option('--unlink', is_flag=True, help='Unlink specified digital objects from the entry instead of linking')
|
|
419
|
+
@pass_das_context
|
|
420
|
+
def link_digital_objects(das_ctx, entry_code, digital_object_code, unlink):
|
|
421
|
+
"""Link or unlink existing digital objects to an entry by their codes.
|
|
422
|
+
|
|
423
|
+
Examples:
|
|
424
|
+
|
|
425
|
+
\b
|
|
426
|
+
# Link two digital objects to an entry
|
|
427
|
+
das entry link-digital-objects --entry-code ENT001 -d DO001 -d DO002
|
|
428
|
+
|
|
429
|
+
\b
|
|
430
|
+
# Unlink a digital object from an entry
|
|
431
|
+
das entry link-digital-objects --entry-code ENT001 -d DO003 --unlink
|
|
432
|
+
"""
|
|
433
|
+
try:
|
|
434
|
+
das_ctx.get_client()
|
|
435
|
+
codes = list(digital_object_code)
|
|
436
|
+
if not codes:
|
|
437
|
+
raise click.UsageError("Please provide at least one --digital-object-code")
|
|
438
|
+
|
|
439
|
+
success = das_ctx.digital_objects_manager.link_existing_digital_objects(
|
|
440
|
+
entry_code=entry_code,
|
|
441
|
+
digital_object_code_list=codes,
|
|
442
|
+
is_unlink=unlink,
|
|
443
|
+
)
|
|
444
|
+
|
|
445
|
+
if success:
|
|
446
|
+
action = "unlinked" if unlink else "linked"
|
|
447
|
+
click.secho(f"✓ Successfully {action} {len(codes)} digital object(s) for entry '{entry_code}'", fg="green")
|
|
448
|
+
else:
|
|
449
|
+
click.secho("Operation did not report success.", fg="yellow")
|
|
450
|
+
except Exception as e:
|
|
451
|
+
click.secho(f"Error: {e}", fg="red")
|
|
452
|
+
|
|
412
453
|
@entry.command("create")
|
|
413
454
|
@click.option('--attribute', required=True, help='Attribute name')
|
|
414
455
|
@click.argument('file_path', required=False)
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
from das.common.config import load_api_url
|
|
2
|
+
from das.services.entries import EntriesService
|
|
3
|
+
from das.services.digital_objects import DigitalObjectsService
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class DigitalObjectsManager:
|
|
7
|
+
def __init__(self):
|
|
8
|
+
base_url = load_api_url()
|
|
9
|
+
if base_url is None or base_url == "":
|
|
10
|
+
raise ValueError(f"Base URL is required - {self.__class__.__name__}")
|
|
11
|
+
|
|
12
|
+
self.digital_objects_service = DigitalObjectsService(base_url)
|
|
13
|
+
self.entry_service = EntriesService(base_url)
|
|
14
|
+
|
|
15
|
+
def link_existing_digital_objects(
|
|
16
|
+
self, entry_code: str, digital_object_code_list: list[str], is_unlink: bool = False
|
|
17
|
+
) -> bool:
|
|
18
|
+
"""Attach or detach (unlink) digital objects to an entry using codes."""
|
|
19
|
+
entry_response = self.entry_service.get_entry(entry_code)
|
|
20
|
+
|
|
21
|
+
if entry_response is None:
|
|
22
|
+
raise ValueError(f"Entry with code '{entry_code}' not found")
|
|
23
|
+
|
|
24
|
+
entry_payload = entry_response.get("entry")
|
|
25
|
+
if entry_payload is None:
|
|
26
|
+
raise ValueError(f"Entry with code '{entry_code}' not found")
|
|
27
|
+
|
|
28
|
+
digital_object_id_list: list[str] = []
|
|
29
|
+
|
|
30
|
+
for code in digital_object_code_list:
|
|
31
|
+
do_response = self.entry_service.get_entry(code)
|
|
32
|
+
do_entry = do_response.get("entry") if do_response else None
|
|
33
|
+
if do_entry is None:
|
|
34
|
+
raise ValueError(f"Digital object with code '{code}' not found")
|
|
35
|
+
digital_object_id_list.append(do_entry.get("id"))
|
|
36
|
+
|
|
37
|
+
result = self.digital_objects_service.link_existing_digital_objects(
|
|
38
|
+
attribute_id=entry_response.get("attributeId"),
|
|
39
|
+
entry_id=entry_payload.get("id"),
|
|
40
|
+
digital_object_id_list=digital_object_id_list,
|
|
41
|
+
is_unlink=is_unlink,
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
return result
|
|
45
|
+
|
|
46
|
+
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
from das.common.api import post_data
|
|
2
|
+
from das.common.config import load_token
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class DigitalObjectsService:
|
|
6
|
+
def __init__(self, base_url):
|
|
7
|
+
self.base_url = f"{base_url}/api/services/app/DigitalObject"
|
|
8
|
+
|
|
9
|
+
def link_existing_digital_objects(self, attribute_id: int, entry_id: str, digital_object_id_list: list[str], is_unlink: bool = False):
|
|
10
|
+
"""Link existing digital objects to an entry."""
|
|
11
|
+
token = load_token()
|
|
12
|
+
|
|
13
|
+
if token is None or token == "":
|
|
14
|
+
raise ValueError("Authorization token is required")
|
|
15
|
+
|
|
16
|
+
headers = {
|
|
17
|
+
"Authorization": f"Bearer {token}",
|
|
18
|
+
"Content-Type": "application/json",
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
payload = {
|
|
22
|
+
"attributeId": attribute_id,
|
|
23
|
+
"attributeValueId": entry_id,
|
|
24
|
+
"digitalObjects": [],
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
for digital_object_id in digital_object_id_list:
|
|
28
|
+
payload["digitalObjects"].append(
|
|
29
|
+
{
|
|
30
|
+
"attributeId": attribute_id,
|
|
31
|
+
"attributeValueId": entry_id,
|
|
32
|
+
"digitalObjectId": digital_object_id,
|
|
33
|
+
"isDeleted": is_unlink,
|
|
34
|
+
}
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
response = post_data(
|
|
38
|
+
f"{self.base_url}/LinkExistingDigitalObject", data=payload, headers=headers
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
return response.get("success")
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
@@ -16,11 +16,13 @@ das/common/entry_fields_constants.py
|
|
|
16
16
|
das/common/enums.py
|
|
17
17
|
das/common/file_utils.py
|
|
18
18
|
das/managers/__init__.py
|
|
19
|
+
das/managers/digital_objects_manager.py
|
|
19
20
|
das/managers/download_manager.py
|
|
20
21
|
das/managers/entries_manager.py
|
|
21
22
|
das/managers/search_manager.py
|
|
22
23
|
das/services/attributes.py
|
|
23
24
|
das/services/cache.py
|
|
25
|
+
das/services/digital_objects.py
|
|
24
26
|
das/services/downloads.py
|
|
25
27
|
das/services/entries.py
|
|
26
28
|
das/services/entry_fields.py
|
|
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
|