das-cli 1.2.4__py3-none-any.whl → 1.2.5__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 +1234 -1234
- das/services/downloads.py +100 -100
- {das_cli-1.2.4.dist-info → das_cli-1.2.5.dist-info}/METADATA +1 -1
- {das_cli-1.2.4.dist-info → das_cli-1.2.5.dist-info}/RECORD +8 -8
- {das_cli-1.2.4.dist-info → das_cli-1.2.5.dist-info}/WHEEL +0 -0
- {das_cli-1.2.4.dist-info → das_cli-1.2.5.dist-info}/entry_points.txt +0 -0
- {das_cli-1.2.4.dist-info → das_cli-1.2.5.dist-info}/licenses/LICENSE +0 -0
- {das_cli-1.2.4.dist-info → das_cli-1.2.5.dist-info}/top_level.txt +0 -0
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,6 +1,6 @@
|
|
|
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=LBZMuI3xFuWT3uUK3zvevgJDHnG4QTm1UqOQAa2r_gM,49228
|
|
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
|
|
@@ -18,15 +18,15 @@ das/managers/search_manager.py,sha256=vXf0JmK5oW-xEGUdDnppfc1-6HdH1hfiZR7L2bCz9u
|
|
|
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=gauyQUhu4TmClLbnBf1N9k86c0PWm8ZlMIvxoE5cOB8,3609
|
|
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.5.dist-info/licenses/LICENSE,sha256=4EDhysVgQWBlzo0rdUl_k89s-iVfgCcSa1gUx1TM1vA,1124
|
|
28
|
+
das_cli-1.2.5.dist-info/METADATA,sha256=GbKacAx0MU0EmgHy-rSQTgvTrnunAoh0sFyM5yzLfRs,26209
|
|
29
|
+
das_cli-1.2.5.dist-info/WHEEL,sha256=qELbo2s1Yzl39ZmrAibXA2jjPLUYfnVhUNTlyF1rq0Y,92
|
|
30
|
+
das_cli-1.2.5.dist-info/entry_points.txt,sha256=ZrdMae7NcvogQhzM1zun8E8n_QwYq-LpZvoJCr2_I4g,36
|
|
31
|
+
das_cli-1.2.5.dist-info/top_level.txt,sha256=OJsPEeJyJ2rJlpEn2DTPgbMSvYG-6FeD13_m5qLpw3E,4
|
|
32
|
+
das_cli-1.2.5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|