das-cli 1.0.4__py3-none-any.whl → 1.2.4__py3-none-any.whl
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/ai/plugins/dasai.py +11 -2
- das/cli.py +130 -6
- das/common/api.py +20 -0
- das/common/config.py +14 -0
- das/managers/digital_objects_manager.py +84 -0
- das/managers/download_manager.py +43 -1
- das/managers/entries_manager.py +37 -1
- das/managers/search_manager.py +17 -2
- das/services/digital_objects.py +142 -0
- das/services/downloads.py +19 -2
- das/services/entries.py +29 -3
- das_cli-1.2.4.dist-info/METADATA +1076 -0
- das_cli-1.2.4.dist-info/RECORD +32 -0
- {das_cli-1.0.4.dist-info → das_cli-1.2.4.dist-info}/WHEEL +1 -1
- das_cli-1.0.4.dist-info/METADATA +0 -408
- das_cli-1.0.4.dist-info/RECORD +0 -30
- {das_cli-1.0.4.dist-info → das_cli-1.2.4.dist-info}/entry_points.txt +0 -0
- {das_cli-1.0.4.dist-info → das_cli-1.2.4.dist-info}/licenses/LICENSE +0 -0
- {das_cli-1.0.4.dist-info → das_cli-1.2.4.dist-info}/top_level.txt +0 -0
das/services/downloads.py
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
from das.common.api import post_data, get_data
|
|
1
|
+
from das.common.api import post_data, get_data, get_binary_response
|
|
2
2
|
from das.common.config import load_token
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
class DownloadRequestService:
|
|
6
6
|
def __init__(self, base_url):
|
|
7
7
|
self.base_url = f"{base_url}/api/services/app/DownloadRequest"
|
|
8
|
+
self.download_files_url = f"{base_url}/File/DownloadRequestSet"
|
|
8
9
|
|
|
9
10
|
def create(self, request_data: list[dict]):
|
|
10
11
|
"""Create a new download request."""
|
|
@@ -81,4 +82,20 @@ class DownloadRequestService:
|
|
|
81
82
|
error_msg = None
|
|
82
83
|
if isinstance(response, dict):
|
|
83
84
|
error_msg = response.get('error') or response.get('message')
|
|
84
|
-
raise ValueError(error_msg or 'Failed to fetch download requests')
|
|
85
|
+
raise ValueError(error_msg or 'Failed to fetch download requests')
|
|
86
|
+
|
|
87
|
+
def download_files(self, request_id: str):
|
|
88
|
+
"""Return a streaming HTTP response for the download bundle of a request."""
|
|
89
|
+
token = load_token()
|
|
90
|
+
|
|
91
|
+
if (token is None or token == ""):
|
|
92
|
+
raise ValueError("Authorization token is required")
|
|
93
|
+
|
|
94
|
+
headers = {
|
|
95
|
+
"Authorization": f"Bearer {token}"
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
url = f"{self.download_files_url}?requestId={request_id}"
|
|
99
|
+
|
|
100
|
+
response = get_binary_response(url, headers=headers, params=None, stream=True)
|
|
101
|
+
return response
|
das/services/entries.py
CHANGED
|
@@ -52,8 +52,34 @@ class EntriesService():
|
|
|
52
52
|
raise ValueError(f"API returned invalid JSON: {response.get('error')}\nResponse content: {raw_content}")
|
|
53
53
|
else:
|
|
54
54
|
raise ValueError(response.get('error') or "Unknown error occurred")
|
|
55
|
-
|
|
56
|
-
def
|
|
55
|
+
|
|
56
|
+
def delete_by_id(self, id: str) -> bool:
|
|
57
|
+
"""Delete an entry by its id."""
|
|
58
|
+
|
|
59
|
+
token = load_token()
|
|
60
|
+
|
|
61
|
+
if (token is None or token == ""):
|
|
62
|
+
raise ValueError("Authorization token is required")
|
|
63
|
+
|
|
64
|
+
headers = {
|
|
65
|
+
"Authorization": f"Bearer {token}"
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
response_entry = self.get(id=id)
|
|
69
|
+
|
|
70
|
+
if response_entry is None:
|
|
71
|
+
raise ValueError(f"Entry with id {id} not found")
|
|
72
|
+
|
|
73
|
+
url = f"{self.base_url}/Delete?Id={response_entry.get('entry',{}).get('id')}&AttributeId={response_entry.get('attributeId')}"
|
|
74
|
+
|
|
75
|
+
response = delete_data(url, headers=headers)
|
|
76
|
+
|
|
77
|
+
if response.get('success') == True:
|
|
78
|
+
return True
|
|
79
|
+
else:
|
|
80
|
+
raise ValueError(response.get('error'))
|
|
81
|
+
|
|
82
|
+
def delete(self, code: str) -> bool:
|
|
57
83
|
"""Delete an entry by its code."""
|
|
58
84
|
token = load_token()
|
|
59
85
|
|
|
@@ -74,7 +100,7 @@ class EntriesService():
|
|
|
74
100
|
response = delete_data(url, headers=headers)
|
|
75
101
|
|
|
76
102
|
if response.get('success') == True:
|
|
77
|
-
return
|
|
103
|
+
return True
|
|
78
104
|
else:
|
|
79
105
|
raise ValueError(response.get('error'))
|
|
80
106
|
|