das-cli 1.2.10__py3-none-any.whl → 1.2.16__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/cli.py +1245 -1245
- das/common/entry_fields_constants.py +2 -1
- das/managers/entries_manager.py +34 -12
- das/services/downloads.py +100 -100
- {das_cli-1.2.10.dist-info → das_cli-1.2.16.dist-info}/METADATA +1 -1
- {das_cli-1.2.10.dist-info → das_cli-1.2.16.dist-info}/RECORD +10 -10
- {das_cli-1.2.10.dist-info → das_cli-1.2.16.dist-info}/WHEEL +1 -1
- {das_cli-1.2.10.dist-info → das_cli-1.2.16.dist-info}/entry_points.txt +0 -0
- {das_cli-1.2.10.dist-info → das_cli-1.2.16.dist-info}/licenses/LICENSE +0 -0
- {das_cli-1.2.10.dist-info → das_cli-1.2.16.dist-info}/top_level.txt +0 -0
das/managers/entries_manager.py
CHANGED
|
@@ -4,7 +4,7 @@ from das.managers.search_manager import SearchManager
|
|
|
4
4
|
from das.services.attributes import AttributesService
|
|
5
5
|
from das.services.entry_fields import EntryFieldsService
|
|
6
6
|
from das.services.entries import EntriesService
|
|
7
|
-
from das.common.entry_fields_constants import DIGITAL_OBJECT_INPUT, SELECT_COMBO_INPUT
|
|
7
|
+
from das.common.entry_fields_constants import DIGITAL_OBJECT_INPUT, SELECT_COMBO_INPUT, GROUP_BOX_INPUT
|
|
8
8
|
from das.services.search import SearchService
|
|
9
9
|
from das.services.users import UsersService
|
|
10
10
|
|
|
@@ -168,12 +168,13 @@ class EntryManager:
|
|
|
168
168
|
field_name = field.get("displayName").lower()
|
|
169
169
|
column_name = field.get("column").lower()
|
|
170
170
|
|
|
171
|
-
if
|
|
172
|
-
new_entry
|
|
173
|
-
elif column_name in entry:
|
|
174
|
-
new_entry[column_name] = self.__get_value(field, entry[column_name])
|
|
171
|
+
if field.get('inputType') == GROUP_BOX_INPUT:
|
|
172
|
+
new_entry = self.__set_group_box_field_value(new_entry, field, entry)
|
|
175
173
|
else:
|
|
176
|
-
|
|
174
|
+
if field_name in entry:
|
|
175
|
+
new_entry[column_name] = self.__get_value(field, entry[field_name])
|
|
176
|
+
elif column_name in entry:
|
|
177
|
+
new_entry[column_name] = self.__get_value(field, entry[column_name])
|
|
177
178
|
|
|
178
179
|
return self.entry_service.create(attribute_id=attribute_id, entry=new_entry)
|
|
179
180
|
|
|
@@ -270,24 +271,45 @@ class EntryManager:
|
|
|
270
271
|
updated_entry = existing_entry_response.get('entry', {})
|
|
271
272
|
|
|
272
273
|
for field in fields:
|
|
274
|
+
|
|
273
275
|
field_name = field.get("displayName").lower()
|
|
274
|
-
column_name = field.get("column").lower()
|
|
276
|
+
column_name = field.get("column").lower()
|
|
275
277
|
|
|
276
|
-
if
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
updated_entry[column_name] = self.__get_value(field, entry[column_name])
|
|
278
|
+
if field.get('inputType') == GROUP_BOX_INPUT:
|
|
279
|
+
# remove the column from the entry
|
|
280
|
+
updated_entry = self.__set_group_box_field_value(updated_entry, field, entry)
|
|
280
281
|
else:
|
|
281
|
-
|
|
282
|
+
if field_name in entry:
|
|
283
|
+
updated_entry[column_name] = self.__get_value(field, entry[field_name])
|
|
284
|
+
elif column_name in entry:
|
|
285
|
+
updated_entry[column_name] = self.__get_value(field, entry[column_name])
|
|
282
286
|
|
|
283
287
|
return self.entry_service.update(attribute_id=attribute_id, entry=updated_entry)
|
|
284
288
|
|
|
289
|
+
def __set_group_box_field_value(self, current_entry: dict, field, entry: dict) -> dict:
|
|
290
|
+
"""Helper method to set group box field value."""
|
|
291
|
+
custom_data = field.get('customData', None)
|
|
292
|
+
if custom_data is not None:
|
|
293
|
+
custom_data = json.loads(custom_data)
|
|
294
|
+
if custom_data.get('fields') is not None:
|
|
295
|
+
for field in custom_data.get('fields'):
|
|
296
|
+
field_name = field.get("displayName").lower()
|
|
297
|
+
column_name = field.get("column").lower()
|
|
298
|
+
if field_name in entry:
|
|
299
|
+
current_entry[column_name] = self.__get_value(field, entry[field_name])
|
|
300
|
+
elif column_name in entry:
|
|
301
|
+
current_entry[column_name] = self.__get_value(field, entry[column_name])
|
|
302
|
+
|
|
303
|
+
return current_entry
|
|
285
304
|
|
|
286
305
|
def __get_value(self, field, source: str):
|
|
287
306
|
"""Helper method to get field value based on its type."""
|
|
288
307
|
if field.get('inputType') == SELECT_COMBO_INPUT: # SELECT_COMBO_INPUT
|
|
289
308
|
select_value = self.__get_select_combobox_field_value(field, source)
|
|
290
309
|
return select_value
|
|
310
|
+
elif field.get('inputType') == GROUP_BOX_INPUT:
|
|
311
|
+
# group_box_value = self.__get_group_box_field_value(entry_raw, field)
|
|
312
|
+
return None
|
|
291
313
|
else:
|
|
292
314
|
return source
|
|
293
315
|
|
das/services/downloads.py
CHANGED
|
@@ -1,101 +1,101 @@
|
|
|
1
|
-
from das.common.api import post_data, get_data, get_binary_response
|
|
2
|
-
from das.common.config import load_token
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class DownloadRequestService:
|
|
6
|
-
def __init__(self, base_url):
|
|
7
|
-
self.base_url = f"{base_url}/api/services/app/DownloadRequest"
|
|
8
|
-
self.download_files_url = f"{base_url}/File/DownloadRequestSet"
|
|
9
|
-
|
|
10
|
-
def create(self, request_data: list[dict]):
|
|
11
|
-
"""Create a new download request."""
|
|
12
|
-
token = load_token()
|
|
13
|
-
|
|
14
|
-
if (token is None or token == ""):
|
|
15
|
-
raise ValueError("Authorization token is required")
|
|
16
|
-
|
|
17
|
-
headers = {
|
|
18
|
-
"Authorization": f"Bearer {token}",
|
|
19
|
-
"Content-Type": "application/json"
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
url = f"{self.base_url}/Create"
|
|
23
|
-
|
|
24
|
-
response = post_data(url, data=request_data, headers=headers)
|
|
25
|
-
|
|
26
|
-
if response.get('success') == True:
|
|
27
|
-
return response.get('result')
|
|
28
|
-
else:
|
|
29
|
-
raise ValueError(response.get('error'))
|
|
30
|
-
|
|
31
|
-
def delete(self, request_id: str):
|
|
32
|
-
"""Delete a download request by ID."""
|
|
33
|
-
|
|
34
|
-
#check if request_id is valid uuid
|
|
35
|
-
if not isinstance(request_id, str) or len(request_id) != 36:
|
|
36
|
-
raise ValueError("Invalid request ID")
|
|
37
|
-
|
|
38
|
-
token = load_token()
|
|
39
|
-
|
|
40
|
-
if (token is None or token == ""):
|
|
41
|
-
raise ValueError("Authorization token is required")
|
|
42
|
-
|
|
43
|
-
headers = {
|
|
44
|
-
"Authorization": f"Bearer {token}",
|
|
45
|
-
"Content-Type": "application/json"
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
url = f"{self.base_url}/Delete?downloadRequestId={request_id}"
|
|
49
|
-
|
|
50
|
-
response = post_data(url, data={}, headers=headers)
|
|
51
|
-
|
|
52
|
-
if response.get('success') == True:
|
|
53
|
-
return response.get('result')
|
|
54
|
-
else:
|
|
55
|
-
raise ValueError(response.get('error'))
|
|
56
|
-
|
|
57
|
-
def get_my_requests(self):
|
|
58
|
-
"""Get all download requests for the current user."""
|
|
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
|
-
url = f"{self.base_url}/GetMyRequests"
|
|
69
|
-
response = get_data(url, headers=headers)
|
|
70
|
-
|
|
71
|
-
# Expected API response shape:
|
|
72
|
-
# { success: true, result: { totalCount: number, items: [...] }, ... }
|
|
73
|
-
if isinstance(response, dict) and response.get('success') is True:
|
|
74
|
-
return response.get('result')
|
|
75
|
-
# Some backends might already return the result without 'success'
|
|
76
|
-
if isinstance(response, dict) and 'result' in response and 'success' not in response:
|
|
77
|
-
return response.get('result')
|
|
78
|
-
# If the API directly returns the payload (result), pass it through
|
|
79
|
-
if isinstance(response, dict) and 'items' in response and 'totalCount' in response:
|
|
80
|
-
return response
|
|
81
|
-
# Otherwise raise a meaningful error
|
|
82
|
-
error_msg = None
|
|
83
|
-
if isinstance(response, dict):
|
|
84
|
-
error_msg = response.get('error') or response.get('message')
|
|
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)
|
|
1
|
+
from das.common.api import post_data, get_data, get_binary_response
|
|
2
|
+
from das.common.config import load_token
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class DownloadRequestService:
|
|
6
|
+
def __init__(self, base_url):
|
|
7
|
+
self.base_url = f"{base_url}/api/services/app/DownloadRequest"
|
|
8
|
+
self.download_files_url = f"{base_url}/File/DownloadRequestSet"
|
|
9
|
+
|
|
10
|
+
def create(self, request_data: list[dict]):
|
|
11
|
+
"""Create a new download request."""
|
|
12
|
+
token = load_token()
|
|
13
|
+
|
|
14
|
+
if (token is None or token == ""):
|
|
15
|
+
raise ValueError("Authorization token is required")
|
|
16
|
+
|
|
17
|
+
headers = {
|
|
18
|
+
"Authorization": f"Bearer {token}",
|
|
19
|
+
"Content-Type": "application/json"
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
url = f"{self.base_url}/Create"
|
|
23
|
+
|
|
24
|
+
response = post_data(url, data=request_data, headers=headers)
|
|
25
|
+
|
|
26
|
+
if response.get('success') == True:
|
|
27
|
+
return response.get('result')
|
|
28
|
+
else:
|
|
29
|
+
raise ValueError(response.get('error'))
|
|
30
|
+
|
|
31
|
+
def delete(self, request_id: str):
|
|
32
|
+
"""Delete a download request by ID."""
|
|
33
|
+
|
|
34
|
+
#check if request_id is valid uuid
|
|
35
|
+
if not isinstance(request_id, str) or len(request_id) != 36:
|
|
36
|
+
raise ValueError("Invalid request ID")
|
|
37
|
+
|
|
38
|
+
token = load_token()
|
|
39
|
+
|
|
40
|
+
if (token is None or token == ""):
|
|
41
|
+
raise ValueError("Authorization token is required")
|
|
42
|
+
|
|
43
|
+
headers = {
|
|
44
|
+
"Authorization": f"Bearer {token}",
|
|
45
|
+
"Content-Type": "application/json"
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
url = f"{self.base_url}/Delete?downloadRequestId={request_id}"
|
|
49
|
+
|
|
50
|
+
response = post_data(url, data={}, headers=headers)
|
|
51
|
+
|
|
52
|
+
if response.get('success') == True:
|
|
53
|
+
return response.get('result')
|
|
54
|
+
else:
|
|
55
|
+
raise ValueError(response.get('error'))
|
|
56
|
+
|
|
57
|
+
def get_my_requests(self):
|
|
58
|
+
"""Get all download requests for the current user."""
|
|
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
|
+
url = f"{self.base_url}/GetMyRequests"
|
|
69
|
+
response = get_data(url, headers=headers)
|
|
70
|
+
|
|
71
|
+
# Expected API response shape:
|
|
72
|
+
# { success: true, result: { totalCount: number, items: [...] }, ... }
|
|
73
|
+
if isinstance(response, dict) and response.get('success') is True:
|
|
74
|
+
return response.get('result')
|
|
75
|
+
# Some backends might already return the result without 'success'
|
|
76
|
+
if isinstance(response, dict) and 'result' in response and 'success' not in response:
|
|
77
|
+
return response.get('result')
|
|
78
|
+
# If the API directly returns the payload (result), pass it through
|
|
79
|
+
if isinstance(response, dict) and 'items' in response and 'totalCount' in response:
|
|
80
|
+
return response
|
|
81
|
+
# Otherwise raise a meaningful error
|
|
82
|
+
error_msg = None
|
|
83
|
+
if isinstance(response, dict):
|
|
84
|
+
error_msg = response.get('error') or response.get('message')
|
|
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
101
|
return response
|
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
das/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
2
|
das/app.py,sha256=kKxN4Vn84SA5Ph3zY13avMG2vrUp-ffpdDkhwYR9Bho,1475
|
|
3
|
-
das/cli.py,sha256=
|
|
3
|
+
das/cli.py,sha256=lh6RGqxACR4OOS7wrkhfD2yXli-Z7dsrch1_HNF05LM,51264
|
|
4
4
|
das/ai/plugins/dasai.py,sha256=1P-0q4ReAnmJxliGAPMxR1aij9RWKxyTIHJzWTwLZLo,2459
|
|
5
5
|
das/ai/plugins/entries/entries_plugin.py,sha256=Dhv6PrguQj5mzxBW6DlCzkmwucszazLQfzwlp9EhIGk,608
|
|
6
6
|
das/authentication/auth.py,sha256=DTtH66Ft6nuuMe7EYvrr3GqGVEGGxE7GmD2fO7vRv4s,1501
|
|
7
7
|
das/authentication/secure_input.py,sha256=P-NpbFeHrp2uIOMqip55cGn_NqqpswhnknAF1t7c2_U,1911
|
|
8
8
|
das/common/api.py,sha256=GNY1nF5B8JgFDAGifC2jR2ZTtKt4GLd7W20ARky4wcY,4501
|
|
9
9
|
das/common/config.py,sha256=VQi_tJ7hvIa--gvx9VCBkfVI9p0ptOvifIu08tc8kEs,6127
|
|
10
|
-
das/common/entry_fields_constants.py,sha256=
|
|
10
|
+
das/common/entry_fields_constants.py,sha256=719tx8ZINbmb-qrrRM-O9AKcyy-vrPiW8tKGqom_MqY,117
|
|
11
11
|
das/common/enums.py,sha256=jS0frv6717duG_wZNockXMTZ-VfsGu_f8_-lgYGnrcY,1745
|
|
12
12
|
das/common/file_utils.py,sha256=Mb1uV9OAHle4zPSQFrythsU_8fzYV5grjgc1p9cmeA4,7129
|
|
13
13
|
das/managers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
14
|
das/managers/digital_objects_manager.py,sha256=v7VAYfKoDpmWJGVgpVoSyk6hqGMiQJeOX5rgm65xE5U,3677
|
|
15
15
|
das/managers/download_manager.py,sha256=bZuRX5yoKC_n00Tbjn_aRHgHLeq6SjI0TqDqgjttOQU,5431
|
|
16
|
-
das/managers/entries_manager.py,sha256=
|
|
16
|
+
das/managers/entries_manager.py,sha256=VzFU8CPoybU8VwOQ4maHoT0qS-_cBdQXzNDIJEHAiQk,22524
|
|
17
17
|
das/managers/search_manager.py,sha256=vXf0JmK5oW-xEGUdDnppfc1-6HdH1hfiZR7L2bCz9u0,4263
|
|
18
18
|
das/services/attributes.py,sha256=78E9f1wNZYxG9Hg5HfX_h1CFmACaMjwD2Y6Ilb7PJGY,2616
|
|
19
19
|
das/services/cache.py,sha256=g-vY51gqGV_1Vpza476PkMqGpuDNo1NbTwQWIIsvO0s,1932
|
|
20
20
|
das/services/digital_objects.py,sha256=ww1KHVLNmm_ffzgqP4Jt4wCbHMVfhD2FJWahlSPFaes,4935
|
|
21
|
-
das/services/downloads.py,sha256=
|
|
21
|
+
das/services/downloads.py,sha256=cn2eoiKEDRcINlzoLgw6mpN3VVLBBiccdFyuCO7TB2I,3709
|
|
22
22
|
das/services/entries.py,sha256=Dzvzx4wOljfumjBBg4sboXmgDTQf3FNbTQp-sl9hAn0,5755
|
|
23
23
|
das/services/entry_fields.py,sha256=x2wUDkKNduj9pf4s56hRo0UW-eBhipkU9gFMEjFw5DA,1290
|
|
24
24
|
das/services/hangfire.py,sha256=hidmVP9yb4znzBaJJRyKawYx7oYaBv5OVL-t0BhvN_A,818
|
|
25
25
|
das/services/search.py,sha256=3X_KPb9fs024FhxoTr4j-xY5ymm5rvvzlekxuh8tLdg,1374
|
|
26
26
|
das/services/users.py,sha256=iNijO2UPIEtcpPy8Tkemdxxym9rYLCUyckQHIQj68W0,795
|
|
27
|
-
das_cli-1.2.
|
|
28
|
-
das_cli-1.2.
|
|
29
|
-
das_cli-1.2.
|
|
30
|
-
das_cli-1.2.
|
|
31
|
-
das_cli-1.2.
|
|
32
|
-
das_cli-1.2.
|
|
27
|
+
das_cli-1.2.16.dist-info/licenses/LICENSE,sha256=4EDhysVgQWBlzo0rdUl_k89s-iVfgCcSa1gUx1TM1vA,1124
|
|
28
|
+
das_cli-1.2.16.dist-info/METADATA,sha256=phODkhz41Byo1Y7TZUN15GFmZNgSDGQ_w3CcwPvFBMc,26210
|
|
29
|
+
das_cli-1.2.16.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
30
|
+
das_cli-1.2.16.dist-info/entry_points.txt,sha256=ZrdMae7NcvogQhzM1zun8E8n_QwYq-LpZvoJCr2_I4g,36
|
|
31
|
+
das_cli-1.2.16.dist-info/top_level.txt,sha256=OJsPEeJyJ2rJlpEn2DTPgbMSvYG-6FeD13_m5qLpw3E,4
|
|
32
|
+
das_cli-1.2.16.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|