das-cli 1.0.1__py3-none-any.whl → 1.0.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/cli.py +1110 -1102
- das/common/api.py +5 -5
- das/managers/search_manager.py +1 -1
- das/services/downloads.py +83 -83
- {das_cli-1.0.1.dist-info → das_cli-1.0.4.dist-info}/METADATA +1 -1
- {das_cli-1.0.1.dist-info → das_cli-1.0.4.dist-info}/RECORD +10 -10
- {das_cli-1.0.1.dist-info → das_cli-1.0.4.dist-info}/WHEEL +0 -0
- {das_cli-1.0.1.dist-info → das_cli-1.0.4.dist-info}/entry_points.txt +0 -0
- {das_cli-1.0.1.dist-info → das_cli-1.0.4.dist-info}/licenses/LICENSE +0 -0
- {das_cli-1.0.1.dist-info → das_cli-1.0.4.dist-info}/top_level.txt +0 -0
das/common/api.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import json
|
|
2
2
|
import requests
|
|
3
|
-
from das.common.config import
|
|
3
|
+
from das.common.config import load_verify_ssl
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
def get_data(url, headers=None, params=None):
|
|
@@ -16,7 +16,7 @@ def get_data(url, headers=None, params=None):
|
|
|
16
16
|
dict: The JSON response from the API or an error message.
|
|
17
17
|
"""
|
|
18
18
|
try:
|
|
19
|
-
response = requests.get(url, headers=headers, params=params, verify=
|
|
19
|
+
response = requests.get(url, headers=headers, params=params, verify=load_verify_ssl())
|
|
20
20
|
response.raise_for_status() # Raise an error for HTTP errors
|
|
21
21
|
try:
|
|
22
22
|
return response.json()
|
|
@@ -40,7 +40,7 @@ def post_data(url, headers=None, data=None):
|
|
|
40
40
|
dict: The JSON response from the API or an error message.
|
|
41
41
|
"""
|
|
42
42
|
try:
|
|
43
|
-
response = requests.post(url, headers=headers, json=data, verify=
|
|
43
|
+
response = requests.post(url, headers=headers, json=data, verify=load_verify_ssl())
|
|
44
44
|
response.raise_for_status() # Raise an error for HTTP errors
|
|
45
45
|
try:
|
|
46
46
|
return response.json()
|
|
@@ -64,7 +64,7 @@ def put_data(url, headers=None, data=None):
|
|
|
64
64
|
dict: The JSON response from the API or an error message.
|
|
65
65
|
"""
|
|
66
66
|
try:
|
|
67
|
-
response = requests.put(url, headers=headers, json=data, verify=
|
|
67
|
+
response = requests.put(url, headers=headers, json=data, verify=load_verify_ssl())
|
|
68
68
|
response.raise_for_status() # Raise an error for HTTP errors
|
|
69
69
|
try:
|
|
70
70
|
return response.json()
|
|
@@ -88,7 +88,7 @@ def delete_data(url, headers=None, data=None):
|
|
|
88
88
|
dict: The JSON response from the API or an error message.
|
|
89
89
|
"""
|
|
90
90
|
try:
|
|
91
|
-
response = requests.delete(url, headers=headers, json=data, verify=
|
|
91
|
+
response = requests.delete(url, headers=headers, json=data, verify=load_verify_ssl())
|
|
92
92
|
response.raise_for_status() # Raise an error for HTTP errors
|
|
93
93
|
try:
|
|
94
94
|
return response.json()
|
das/managers/search_manager.py
CHANGED
|
@@ -55,7 +55,7 @@ class SearchManager:
|
|
|
55
55
|
"attributeId": attribute_id,
|
|
56
56
|
"queryString": self.__convert_filter(entry_fields, query),
|
|
57
57
|
"maxResultCount": max_results,
|
|
58
|
-
"skipCount": (max_results * (page - 1)),
|
|
58
|
+
"skipCount": 0 if page <= 0 else (max_results * (page - 1)),
|
|
59
59
|
"sorting": self.__convert_sorting(entry_fields, sort_by, sort_order)
|
|
60
60
|
}
|
|
61
61
|
results = self.search_service.search_entries(**search_params)
|
das/services/downloads.py
CHANGED
|
@@ -1,84 +1,84 @@
|
|
|
1
|
-
from das.common.api import post_data, get_data
|
|
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
|
-
|
|
9
|
-
def create(self, request_data: list[dict]):
|
|
10
|
-
"""Create a new download request."""
|
|
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
|
-
url = f"{self.base_url}/Create"
|
|
22
|
-
|
|
23
|
-
response = post_data(url, data=request_data, headers=headers)
|
|
24
|
-
|
|
25
|
-
if response.get('success') == True:
|
|
26
|
-
return response.get('result')
|
|
27
|
-
else:
|
|
28
|
-
raise ValueError(response.get('error'))
|
|
29
|
-
|
|
30
|
-
def delete(self, request_id: str):
|
|
31
|
-
"""Delete a download request by ID."""
|
|
32
|
-
|
|
33
|
-
#check if request_id is valid uuid
|
|
34
|
-
if not isinstance(request_id, str) or len(request_id) != 36:
|
|
35
|
-
raise ValueError("Invalid request ID")
|
|
36
|
-
|
|
37
|
-
token = load_token()
|
|
38
|
-
|
|
39
|
-
if (token is None or token == ""):
|
|
40
|
-
raise ValueError("Authorization token is required")
|
|
41
|
-
|
|
42
|
-
headers = {
|
|
43
|
-
"Authorization": f"Bearer {token}",
|
|
44
|
-
"Content-Type": "application/json"
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
url = f"{self.base_url}/Delete?downloadRequestId={request_id}"
|
|
48
|
-
|
|
49
|
-
response = post_data(url, data={}, headers=headers)
|
|
50
|
-
|
|
51
|
-
if response.get('success') == True:
|
|
52
|
-
return response.get('result')
|
|
53
|
-
else:
|
|
54
|
-
raise ValueError(response.get('error'))
|
|
55
|
-
|
|
56
|
-
def get_my_requests(self):
|
|
57
|
-
"""Get all download requests for the current user."""
|
|
58
|
-
token = load_token()
|
|
59
|
-
|
|
60
|
-
if (token is None or token == ""):
|
|
61
|
-
raise ValueError("Authorization token is required")
|
|
62
|
-
|
|
63
|
-
headers = {
|
|
64
|
-
"Authorization": f"Bearer {token}"
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
url = f"{self.base_url}/GetMyRequests"
|
|
68
|
-
response = get_data(url, headers=headers)
|
|
69
|
-
|
|
70
|
-
# Expected API response shape:
|
|
71
|
-
# { success: true, result: { totalCount: number, items: [...] }, ... }
|
|
72
|
-
if isinstance(response, dict) and response.get('success') is True:
|
|
73
|
-
return response.get('result')
|
|
74
|
-
# Some backends might already return the result without 'success'
|
|
75
|
-
if isinstance(response, dict) and 'result' in response and 'success' not in response:
|
|
76
|
-
return response.get('result')
|
|
77
|
-
# If the API directly returns the payload (result), pass it through
|
|
78
|
-
if isinstance(response, dict) and 'items' in response and 'totalCount' in response:
|
|
79
|
-
return response
|
|
80
|
-
# Otherwise raise a meaningful error
|
|
81
|
-
error_msg = None
|
|
82
|
-
if isinstance(response, dict):
|
|
83
|
-
error_msg = response.get('error') or response.get('message')
|
|
1
|
+
from das.common.api import post_data, get_data
|
|
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
|
+
|
|
9
|
+
def create(self, request_data: list[dict]):
|
|
10
|
+
"""Create a new download request."""
|
|
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
|
+
url = f"{self.base_url}/Create"
|
|
22
|
+
|
|
23
|
+
response = post_data(url, data=request_data, headers=headers)
|
|
24
|
+
|
|
25
|
+
if response.get('success') == True:
|
|
26
|
+
return response.get('result')
|
|
27
|
+
else:
|
|
28
|
+
raise ValueError(response.get('error'))
|
|
29
|
+
|
|
30
|
+
def delete(self, request_id: str):
|
|
31
|
+
"""Delete a download request by ID."""
|
|
32
|
+
|
|
33
|
+
#check if request_id is valid uuid
|
|
34
|
+
if not isinstance(request_id, str) or len(request_id) != 36:
|
|
35
|
+
raise ValueError("Invalid request ID")
|
|
36
|
+
|
|
37
|
+
token = load_token()
|
|
38
|
+
|
|
39
|
+
if (token is None or token == ""):
|
|
40
|
+
raise ValueError("Authorization token is required")
|
|
41
|
+
|
|
42
|
+
headers = {
|
|
43
|
+
"Authorization": f"Bearer {token}",
|
|
44
|
+
"Content-Type": "application/json"
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
url = f"{self.base_url}/Delete?downloadRequestId={request_id}"
|
|
48
|
+
|
|
49
|
+
response = post_data(url, data={}, headers=headers)
|
|
50
|
+
|
|
51
|
+
if response.get('success') == True:
|
|
52
|
+
return response.get('result')
|
|
53
|
+
else:
|
|
54
|
+
raise ValueError(response.get('error'))
|
|
55
|
+
|
|
56
|
+
def get_my_requests(self):
|
|
57
|
+
"""Get all download requests for the current user."""
|
|
58
|
+
token = load_token()
|
|
59
|
+
|
|
60
|
+
if (token is None or token == ""):
|
|
61
|
+
raise ValueError("Authorization token is required")
|
|
62
|
+
|
|
63
|
+
headers = {
|
|
64
|
+
"Authorization": f"Bearer {token}"
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
url = f"{self.base_url}/GetMyRequests"
|
|
68
|
+
response = get_data(url, headers=headers)
|
|
69
|
+
|
|
70
|
+
# Expected API response shape:
|
|
71
|
+
# { success: true, result: { totalCount: number, items: [...] }, ... }
|
|
72
|
+
if isinstance(response, dict) and response.get('success') is True:
|
|
73
|
+
return response.get('result')
|
|
74
|
+
# Some backends might already return the result without 'success'
|
|
75
|
+
if isinstance(response, dict) and 'result' in response and 'success' not in response:
|
|
76
|
+
return response.get('result')
|
|
77
|
+
# If the API directly returns the payload (result), pass it through
|
|
78
|
+
if isinstance(response, dict) and 'items' in response and 'totalCount' in response:
|
|
79
|
+
return response
|
|
80
|
+
# Otherwise raise a meaningful error
|
|
81
|
+
error_msg = None
|
|
82
|
+
if isinstance(response, dict):
|
|
83
|
+
error_msg = response.get('error') or response.get('message')
|
|
84
84
|
raise ValueError(error_msg or 'Failed to fetch download requests')
|
|
@@ -1,11 +1,11 @@
|
|
|
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=G1i6S8AF4Bx3ZSb7ba42h7NTxKxpsydrk7IIz26QJpk,45116
|
|
4
4
|
das/ai/plugins/dasai.py,sha256=R0X0Vey_GOAtWoqcloB-NATZFtXB_l5b9dfPXocNIbI,2165
|
|
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
|
-
das/common/api.py,sha256=
|
|
8
|
+
das/common/api.py,sha256=9kuM8Gcw29uiYbqw9fPK4w5gTpWv9baxjK9NvHNeb5E,3905
|
|
9
9
|
das/common/config.py,sha256=nkWN4-4xUEo6DPlTkaAnHQF_HGwulm73D4U2DyWvibU,5600
|
|
10
10
|
das/common/entry_fields_constants.py,sha256=5Yh4Ujt70HEF-FsnwVBPBm3DB3HHzQWSWR-9Upt7C5I,93
|
|
11
11
|
das/common/enums.py,sha256=jS0frv6717duG_wZNockXMTZ-VfsGu_f8_-lgYGnrcY,1745
|
|
@@ -13,18 +13,18 @@ das/common/file_utils.py,sha256=-zePjYsj8iRpQssVQMHDK3Mh5q8FooKJCUCKCXKS6_Y,7006
|
|
|
13
13
|
das/managers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
14
|
das/managers/download_manager.py,sha256=NqaLhmjw-4nZq8SVdN0g5MAnbMPEnu-A3A4oXxQ-IZQ,3776
|
|
15
15
|
das/managers/entries_manager.py,sha256=Kc_PN71Bp7VICrxoP9MiDCrUzR7OdUXfX5puDDxtm08,19015
|
|
16
|
-
das/managers/search_manager.py,sha256=
|
|
16
|
+
das/managers/search_manager.py,sha256=6nRHSc2YosVj5NBoFp2uM09FZiMMVfchoXT8Q-b5oNY,3505
|
|
17
17
|
das/services/attributes.py,sha256=78E9f1wNZYxG9Hg5HfX_h1CFmACaMjwD2Y6Ilb7PJGY,2616
|
|
18
18
|
das/services/cache.py,sha256=g-vY51gqGV_1Vpza476PkMqGpuDNo1NbTwQWIIsvO0s,1932
|
|
19
|
-
das/services/downloads.py,sha256=
|
|
19
|
+
das/services/downloads.py,sha256=YBDFPmjAQHUK0OUdFprW1Ox81nzpKaJE9xQBJyyEz4Q,3060
|
|
20
20
|
das/services/entries.py,sha256=Uspl7LZcNWEnr7ct5_Kn31jMjrkSKV7UXzrN6nb3HF0,4966
|
|
21
21
|
das/services/entry_fields.py,sha256=x2wUDkKNduj9pf4s56hRo0UW-eBhipkU9gFMEjFw5DA,1290
|
|
22
22
|
das/services/hangfire.py,sha256=hidmVP9yb4znzBaJJRyKawYx7oYaBv5OVL-t0BhvN_A,818
|
|
23
23
|
das/services/search.py,sha256=3X_KPb9fs024FhxoTr4j-xY5ymm5rvvzlekxuh8tLdg,1374
|
|
24
24
|
das/services/users.py,sha256=iNijO2UPIEtcpPy8Tkemdxxym9rYLCUyckQHIQj68W0,795
|
|
25
|
-
das_cli-1.0.
|
|
26
|
-
das_cli-1.0.
|
|
27
|
-
das_cli-1.0.
|
|
28
|
-
das_cli-1.0.
|
|
29
|
-
das_cli-1.0.
|
|
30
|
-
das_cli-1.0.
|
|
25
|
+
das_cli-1.0.4.dist-info/licenses/LICENSE,sha256=4EDhysVgQWBlzo0rdUl_k89s-iVfgCcSa1gUx1TM1vA,1124
|
|
26
|
+
das_cli-1.0.4.dist-info/METADATA,sha256=aOev384umltx9O1PaLA-xAx6IRZhERf7fv3t727LRZI,10469
|
|
27
|
+
das_cli-1.0.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
28
|
+
das_cli-1.0.4.dist-info/entry_points.txt,sha256=ZrdMae7NcvogQhzM1zun8E8n_QwYq-LpZvoJCr2_I4g,36
|
|
29
|
+
das_cli-1.0.4.dist-info/top_level.txt,sha256=OJsPEeJyJ2rJlpEn2DTPgbMSvYG-6FeD13_m5qLpw3E,4
|
|
30
|
+
das_cli-1.0.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|