das-cli 1.7.3__tar.gz → 1.7.6__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.7.3/das_cli.egg-info → das_cli-1.7.6}/PKG-INFO +16 -4
- {das_cli-1.7.3 → das_cli-1.7.6}/README.md +15 -3
- {das_cli-1.7.3 → das_cli-1.7.6}/das/app.py +2 -1
- {das_cli-1.7.3 → das_cli-1.7.6}/das/cli.py +22 -6
- {das_cli-1.7.3 → das_cli-1.7.6}/das/common/config.py +10 -3
- {das_cli-1.7.3 → das_cli-1.7.6}/das/managers/entries_manager.py +52 -12
- {das_cli-1.7.3 → das_cli-1.7.6/das_cli.egg-info}/PKG-INFO +16 -4
- {das_cli-1.7.3 → das_cli-1.7.6}/pyproject.toml +1 -1
- {das_cli-1.7.3 → das_cli-1.7.6}/LICENSE +0 -0
- {das_cli-1.7.3 → das_cli-1.7.6}/MANIFEST.in +0 -0
- {das_cli-1.7.3 → das_cli-1.7.6}/das/__init__.py +0 -0
- {das_cli-1.7.3 → das_cli-1.7.6}/das/ai/plugins/dasai.py +0 -0
- {das_cli-1.7.3 → das_cli-1.7.6}/das/ai/plugins/entries/entries_plugin.py +0 -0
- {das_cli-1.7.3 → das_cli-1.7.6}/das/authentication/auth.py +0 -0
- {das_cli-1.7.3 → das_cli-1.7.6}/das/authentication/oauth.py +0 -0
- {das_cli-1.7.3 → das_cli-1.7.6}/das/authentication/secure_input.py +0 -0
- {das_cli-1.7.3 → das_cli-1.7.6}/das/common/api.py +0 -0
- {das_cli-1.7.3 → das_cli-1.7.6}/das/common/entry_fields_constants.py +0 -0
- {das_cli-1.7.3 → das_cli-1.7.6}/das/common/enums.py +0 -0
- {das_cli-1.7.3 → das_cli-1.7.6}/das/common/errors.py +0 -0
- {das_cli-1.7.3 → das_cli-1.7.6}/das/common/exceptions.py +0 -0
- {das_cli-1.7.3 → das_cli-1.7.6}/das/common/file_utils.py +0 -0
- {das_cli-1.7.3 → das_cli-1.7.6}/das/managers/__init__.py +0 -0
- {das_cli-1.7.3 → das_cli-1.7.6}/das/managers/digital_objects_manager.py +0 -0
- {das_cli-1.7.3 → das_cli-1.7.6}/das/managers/download_manager.py +0 -0
- {das_cli-1.7.3 → das_cli-1.7.6}/das/managers/search_manager.py +0 -0
- {das_cli-1.7.3 → das_cli-1.7.6}/das/services/attributes.py +0 -0
- {das_cli-1.7.3 → das_cli-1.7.6}/das/services/cache.py +0 -0
- {das_cli-1.7.3 → das_cli-1.7.6}/das/services/das_elastic_search.py +0 -0
- {das_cli-1.7.3 → das_cli-1.7.6}/das/services/digital_objects.py +0 -0
- {das_cli-1.7.3 → das_cli-1.7.6}/das/services/downloads.py +0 -0
- {das_cli-1.7.3 → das_cli-1.7.6}/das/services/entries.py +0 -0
- {das_cli-1.7.3 → das_cli-1.7.6}/das/services/entry_fields.py +0 -0
- {das_cli-1.7.3 → das_cli-1.7.6}/das/services/hangfire.py +0 -0
- {das_cli-1.7.3 → das_cli-1.7.6}/das/services/search.py +0 -0
- {das_cli-1.7.3 → das_cli-1.7.6}/das/services/service_base.py +0 -0
- {das_cli-1.7.3 → das_cli-1.7.6}/das/services/session.py +0 -0
- {das_cli-1.7.3 → das_cli-1.7.6}/das/services/users.py +0 -0
- {das_cli-1.7.3 → das_cli-1.7.6}/das_cli.egg-info/SOURCES.txt +0 -0
- {das_cli-1.7.3 → das_cli-1.7.6}/das_cli.egg-info/dependency_links.txt +0 -0
- {das_cli-1.7.3 → das_cli-1.7.6}/das_cli.egg-info/entry_points.txt +0 -0
- {das_cli-1.7.3 → das_cli-1.7.6}/das_cli.egg-info/requires.txt +0 -0
- {das_cli-1.7.3 → das_cli-1.7.6}/das_cli.egg-info/top_level.txt +0 -0
- {das_cli-1.7.3 → das_cli-1.7.6}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: das-cli
|
|
3
|
-
Version: 1.7.
|
|
3
|
+
Version: 1.7.6
|
|
4
4
|
Summary: DAS api client.
|
|
5
5
|
Author: Royal Netherlands Institute for Sea Research
|
|
6
6
|
License-Expression: MIT
|
|
@@ -233,8 +233,17 @@ das entry update --id e1987f3e-7db7-11f0-a7e8-0edcca226f3d --data "{ 'Comment':
|
|
|
233
233
|
|
|
234
234
|
# Bulk from file (each item should include Id/Code)
|
|
235
235
|
das entry update c:\data\entries-to-update.json
|
|
236
|
+
|
|
237
|
+
# Recalculate the auto-generated name after changing a field it is built from
|
|
238
|
+
das entry update --code 4.b.rdg --data "{ 'Cast No.': '02' }" --regenerate-name
|
|
239
|
+
das entry update c:\data\events.xlsx --regenerate-name
|
|
236
240
|
```
|
|
237
241
|
|
|
242
|
+
An auto-generated name (an Event is `<station>_<cast><device acronym>`) is **kept as stored** on
|
|
243
|
+
update, even when the update changes the cast number or the device. Pass `--regenerate-name` to have
|
|
244
|
+
the server rebuild it from the updated values. The flag applies to every entry of a bulk update,
|
|
245
|
+
overrides a `Name` given in the data, and is ignored for attributes whose name has no formula.
|
|
246
|
+
|
|
238
247
|
#### Logs and ownership
|
|
239
248
|
```bash
|
|
240
249
|
# Audit logs
|
|
@@ -447,7 +456,7 @@ Import: `from das.managers.entries_manager import EntryManager`
|
|
|
447
456
|
| `get(code=..., id=...)` | `dict` — entry with display field names |
|
|
448
457
|
| `get_entry(entry_id)` | `dict` — same as `get(id=...)` |
|
|
449
458
|
| `create(attribute, entry=..., entries=...)` | `list[dict]` — per-item status with `id`, `code`, `status` |
|
|
450
|
-
| `update(id=..., code=..., entry=..., entries
|
|
459
|
+
| `update(id=..., code=..., entry=..., entries=..., regenerate_name=False)` | `list[dict]` — per-item status |
|
|
451
460
|
| `delete(id=..., code=...)` | `bool` |
|
|
452
461
|
| `create_from_file(attribute, file_path)` | `None` |
|
|
453
462
|
| `chown(user_name, entry_code_list)` | API response |
|
|
@@ -543,6 +552,9 @@ entries.update(entries=[
|
|
|
543
552
|
{"Code": "ENT001", "Comment": "Updated 1"},
|
|
544
553
|
{"Code": "ENT002", "Comment": "Updated 2"},
|
|
545
554
|
])
|
|
555
|
+
|
|
556
|
+
# Rebuild the auto-generated name from the updated values (kept as stored by default)
|
|
557
|
+
entries.update(code="4.b.rdg", entry={"Cast No.": "02"}, regenerate_name=True)
|
|
546
558
|
```
|
|
547
559
|
|
|
548
560
|
#### `delete` — delete one entry
|
|
@@ -922,7 +934,7 @@ You can configure values through CLI commands and/or `.env`.
|
|
|
922
934
|
|
|
923
935
|
```env
|
|
924
936
|
# Connection
|
|
925
|
-
DAS_API_URL=https://
|
|
937
|
+
DAS_API_URL=https://your-das-instance/api
|
|
926
938
|
DAS_API_KEY=
|
|
927
939
|
VERIFY_SSL=True
|
|
928
940
|
|
|
@@ -931,7 +943,7 @@ DAS_LOG_LEVEL=WARN
|
|
|
931
943
|
DAS_LOG_FILE=
|
|
932
944
|
|
|
933
945
|
# Test credentials (for integration tests)
|
|
934
|
-
API_URL=https://
|
|
946
|
+
API_URL=https://your-das-instance/api
|
|
935
947
|
USER_NAME=
|
|
936
948
|
USER_PASSWORD=
|
|
937
949
|
|
|
@@ -210,8 +210,17 @@ das entry update --id e1987f3e-7db7-11f0-a7e8-0edcca226f3d --data "{ 'Comment':
|
|
|
210
210
|
|
|
211
211
|
# Bulk from file (each item should include Id/Code)
|
|
212
212
|
das entry update c:\data\entries-to-update.json
|
|
213
|
+
|
|
214
|
+
# Recalculate the auto-generated name after changing a field it is built from
|
|
215
|
+
das entry update --code 4.b.rdg --data "{ 'Cast No.': '02' }" --regenerate-name
|
|
216
|
+
das entry update c:\data\events.xlsx --regenerate-name
|
|
213
217
|
```
|
|
214
218
|
|
|
219
|
+
An auto-generated name (an Event is `<station>_<cast><device acronym>`) is **kept as stored** on
|
|
220
|
+
update, even when the update changes the cast number or the device. Pass `--regenerate-name` to have
|
|
221
|
+
the server rebuild it from the updated values. The flag applies to every entry of a bulk update,
|
|
222
|
+
overrides a `Name` given in the data, and is ignored for attributes whose name has no formula.
|
|
223
|
+
|
|
215
224
|
#### Logs and ownership
|
|
216
225
|
```bash
|
|
217
226
|
# Audit logs
|
|
@@ -424,7 +433,7 @@ Import: `from das.managers.entries_manager import EntryManager`
|
|
|
424
433
|
| `get(code=..., id=...)` | `dict` — entry with display field names |
|
|
425
434
|
| `get_entry(entry_id)` | `dict` — same as `get(id=...)` |
|
|
426
435
|
| `create(attribute, entry=..., entries=...)` | `list[dict]` — per-item status with `id`, `code`, `status` |
|
|
427
|
-
| `update(id=..., code=..., entry=..., entries
|
|
436
|
+
| `update(id=..., code=..., entry=..., entries=..., regenerate_name=False)` | `list[dict]` — per-item status |
|
|
428
437
|
| `delete(id=..., code=...)` | `bool` |
|
|
429
438
|
| `create_from_file(attribute, file_path)` | `None` |
|
|
430
439
|
| `chown(user_name, entry_code_list)` | API response |
|
|
@@ -520,6 +529,9 @@ entries.update(entries=[
|
|
|
520
529
|
{"Code": "ENT001", "Comment": "Updated 1"},
|
|
521
530
|
{"Code": "ENT002", "Comment": "Updated 2"},
|
|
522
531
|
])
|
|
532
|
+
|
|
533
|
+
# Rebuild the auto-generated name from the updated values (kept as stored by default)
|
|
534
|
+
entries.update(code="4.b.rdg", entry={"Cast No.": "02"}, regenerate_name=True)
|
|
523
535
|
```
|
|
524
536
|
|
|
525
537
|
#### `delete` — delete one entry
|
|
@@ -899,7 +911,7 @@ You can configure values through CLI commands and/or `.env`.
|
|
|
899
911
|
|
|
900
912
|
```env
|
|
901
913
|
# Connection
|
|
902
|
-
DAS_API_URL=https://
|
|
914
|
+
DAS_API_URL=https://your-das-instance/api
|
|
903
915
|
DAS_API_KEY=
|
|
904
916
|
VERIFY_SSL=True
|
|
905
917
|
|
|
@@ -908,7 +920,7 @@ DAS_LOG_LEVEL=WARN
|
|
|
908
920
|
DAS_LOG_FILE=
|
|
909
921
|
|
|
910
922
|
# Test credentials (for integration tests)
|
|
911
|
-
API_URL=https://
|
|
923
|
+
API_URL=https://your-das-instance/api
|
|
912
924
|
USER_NAME=
|
|
913
925
|
USER_PASSWORD=
|
|
914
926
|
|
|
@@ -8,13 +8,14 @@ from das.services.search import SearchService
|
|
|
8
8
|
from das.services.das_elastic_search import DasElasticSearch
|
|
9
9
|
from das.services.session import SessionService, pick
|
|
10
10
|
from das.common.config import (
|
|
11
|
-
save_api_url, load_api_url, save_token, set_auth_type, describe_credential,
|
|
11
|
+
save_api_url, load_api_url, normalize_api_url, save_token, set_auth_type, describe_credential,
|
|
12
12
|
)
|
|
13
13
|
|
|
14
14
|
# $env:PYTHONPATH="C:\Workspace\das-cli"
|
|
15
15
|
|
|
16
16
|
class Das:
|
|
17
17
|
def __init__(self, base_url: str = None):
|
|
18
|
+
base_url = normalize_api_url(base_url)
|
|
18
19
|
if base_url is None or base_url == "":
|
|
19
20
|
base_url = load_api_url()
|
|
20
21
|
if base_url is None or base_url == "":
|
|
@@ -4,7 +4,7 @@ import json
|
|
|
4
4
|
import os
|
|
5
5
|
from pathlib import Path
|
|
6
6
|
from das.common.config import (
|
|
7
|
-
save_api_url, load_api_url, DEFAULT_BASE_URL,
|
|
7
|
+
save_api_url, load_api_url, normalize_api_url, DEFAULT_BASE_URL,
|
|
8
8
|
save_verify_ssl, load_verify_ssl, VERIFY_SSL,
|
|
9
9
|
load_openai_api_key, save_openai_api_key, clear_openai_api_key,
|
|
10
10
|
clear_token, _config_dir,
|
|
@@ -158,6 +158,7 @@ def cli(ctx):
|
|
|
158
158
|
def login(das_ctx, api_url, username, password, use_oauth, api_key, skip_verify, debug):
|
|
159
159
|
"""Login and store authentication token"""
|
|
160
160
|
# Save API URL for future use
|
|
161
|
+
api_url = normalize_api_url(api_url)
|
|
161
162
|
save_api_url(api_url)
|
|
162
163
|
das_ctx.api_url = api_url
|
|
163
164
|
|
|
@@ -686,14 +687,21 @@ def entry():
|
|
|
686
687
|
@click.option('--code', default=None, help='Entry code to update (only used with --data for single entry)')
|
|
687
688
|
@click.argument('file_path', required=False)
|
|
688
689
|
@click.option('--data', help='Data string in format { "key1": "value1", "key2": "value2", ... } or a list of such objects')
|
|
690
|
+
@click.option('--regenerate-name', is_flag=True, default=False,
|
|
691
|
+
help='Rebuild the auto-generated name from the updated values instead of keeping the stored one. '
|
|
692
|
+
'Applies to every entry of a bulk update; ignored for attributes whose name has no formula.')
|
|
689
693
|
@pass_das_context
|
|
690
|
-
def update_entry(das_ctx, id, code, file_path, data):
|
|
694
|
+
def update_entry(das_ctx, id, code, file_path, data, regenerate_name):
|
|
691
695
|
"""Update entries from file or data string by ID or code.
|
|
692
|
-
|
|
696
|
+
|
|
693
697
|
For single updates, provide either --id or --code (or Id/Code in the data).
|
|
694
698
|
For bulk updates, each entry must contain a Code or Id field.
|
|
695
699
|
Files can contain multiple entries (rows in CSV/XLS or list of objects in JSON).
|
|
696
|
-
|
|
700
|
+
|
|
701
|
+
An auto-generated name (e.g. an Event's station_cast+device) is kept as it
|
|
702
|
+
is unless --regenerate-name is given, even when the update changes one of
|
|
703
|
+
the fields it is built from.
|
|
704
|
+
|
|
697
705
|
Examples:
|
|
698
706
|
|
|
699
707
|
\b
|
|
@@ -715,6 +723,14 @@ def update_entry(das_ctx, id, code, file_path, data):
|
|
|
715
723
|
\b
|
|
716
724
|
# Update multiple entries from data string
|
|
717
725
|
das entry update --data "[{ 'Code': 'ENT001', ... }, { 'Code': 'ENT002', ... }]"
|
|
726
|
+
|
|
727
|
+
\b
|
|
728
|
+
# Change the cast number and have the name recalculated
|
|
729
|
+
das entry update --code 4.b.rdg --data "{ 'Cast No.': '02' }" --regenerate-name
|
|
730
|
+
|
|
731
|
+
\b
|
|
732
|
+
# Recalculate the names of every entry in a file
|
|
733
|
+
das entry update c:\\data\\events.xlsx --regenerate-name
|
|
718
734
|
"""
|
|
719
735
|
try:
|
|
720
736
|
# Ensure client and entry_manager are initialized
|
|
@@ -769,7 +785,7 @@ def update_entry(das_ctx, id, code, file_path, data):
|
|
|
769
785
|
|
|
770
786
|
# Update the entries
|
|
771
787
|
if is_bulk_update:
|
|
772
|
-
results = das_ctx.entry_manager.update(entries=entry_data)
|
|
788
|
+
results = das_ctx.entry_manager.update(entries=entry_data, regenerate_name=regenerate_name)
|
|
773
789
|
|
|
774
790
|
# Display results
|
|
775
791
|
success_count = sum(1 for result in results if result.get('status') == 'success')
|
|
@@ -789,7 +805,7 @@ def update_entry(das_ctx, id, code, file_path, data):
|
|
|
789
805
|
click.echo(f" {ident}: {result.get('error', 'Unknown error')}")
|
|
790
806
|
else:
|
|
791
807
|
# Single entry update
|
|
792
|
-
results = das_ctx.entry_manager.update(id=id, code=code, entry=entry_data)
|
|
808
|
+
results = das_ctx.entry_manager.update(id=id, code=code, entry=entry_data, regenerate_name=regenerate_name)
|
|
793
809
|
|
|
794
810
|
if results and results[0].get('status') == 'success':
|
|
795
811
|
identifier = id or code
|
|
@@ -64,6 +64,13 @@ def _config_dir() -> Path:
|
|
|
64
64
|
|
|
65
65
|
CONFIG_FILE = _config_dir() / "config.json"
|
|
66
66
|
|
|
67
|
+
def normalize_api_url(api_url: Optional[str]) -> Optional[str]:
|
|
68
|
+
"""Strip whitespace and trailing slashes. Services append "/api/...", and a
|
|
69
|
+
"//api/..." URL makes the backend answer HTTP 200 with a non-JSON body."""
|
|
70
|
+
if api_url is None:
|
|
71
|
+
return None
|
|
72
|
+
return api_url.strip().rstrip("/") or None
|
|
73
|
+
|
|
67
74
|
def save_api_url(api_url: str) -> None:
|
|
68
75
|
config = {}
|
|
69
76
|
if CONFIG_FILE.exists():
|
|
@@ -71,16 +78,16 @@ def save_api_url(api_url: str) -> None:
|
|
|
71
78
|
config = json.loads(CONFIG_FILE.read_text(encoding="utf-8"))
|
|
72
79
|
except Exception:
|
|
73
80
|
config = {}
|
|
74
|
-
config["api_url"] = api_url
|
|
81
|
+
config["api_url"] = normalize_api_url(api_url)
|
|
75
82
|
CONFIG_FILE.write_text(json.dumps(config), encoding="utf-8")
|
|
76
83
|
|
|
77
84
|
def load_api_url() -> Optional[str]:
|
|
78
|
-
env_url = os.getenv("DAS_API_URL")
|
|
85
|
+
env_url = normalize_api_url(os.getenv("DAS_API_URL"))
|
|
79
86
|
if env_url:
|
|
80
87
|
return env_url
|
|
81
88
|
if CONFIG_FILE.exists():
|
|
82
89
|
try:
|
|
83
|
-
return json.loads(CONFIG_FILE.read_text(encoding="utf-8")).get("api_url")
|
|
90
|
+
return normalize_api_url(json.loads(CONFIG_FILE.read_text(encoding="utf-8")).get("api_url"))
|
|
84
91
|
except Exception:
|
|
85
92
|
return None
|
|
86
93
|
return None
|
|
@@ -49,6 +49,26 @@ def _safe_lower(value) -> str:
|
|
|
49
49
|
return str(value).lower()
|
|
50
50
|
|
|
51
51
|
|
|
52
|
+
def _is_generated_field(field: dict) -> bool:
|
|
53
|
+
"""Return True when the field's value is built by the server from a formula.
|
|
54
|
+
|
|
55
|
+
Such a field (typically ``Name``) declares ``generatedFrom`` in its custom
|
|
56
|
+
data, e.g. ``{"generatedFrom": ["x24", "castnumber|_{0:00}", {"x28": "acronym"}]}``.
|
|
57
|
+
"""
|
|
58
|
+
custom_data = field.get("customData") or field.get("customdata")
|
|
59
|
+
|
|
60
|
+
if _is_empty(custom_data):
|
|
61
|
+
return False
|
|
62
|
+
|
|
63
|
+
if isinstance(custom_data, str):
|
|
64
|
+
try:
|
|
65
|
+
custom_data = json.loads(custom_data)
|
|
66
|
+
except ValueError: # includes json.JSONDecodeError
|
|
67
|
+
return False
|
|
68
|
+
|
|
69
|
+
return isinstance(custom_data, dict) and custom_data.get("generatedFrom") is not None
|
|
70
|
+
|
|
71
|
+
|
|
52
72
|
# The single key digital objects are published under, whatever the attribute
|
|
53
73
|
# calls its digital-object field (Persons calls it "Files").
|
|
54
74
|
DIGITAL_OBJECTS_KEY = "Digital Object(s)"
|
|
@@ -313,19 +333,24 @@ class EntryManager:
|
|
|
313
333
|
|
|
314
334
|
return self.entry_service.create(attribute_id=attribute_id, entry=new_entry)
|
|
315
335
|
|
|
316
|
-
def update(self, id: str = None, code: str = None, entry: dict = None, entries: list = None) -> list:
|
|
336
|
+
def update(self, id: str = None, code: str = None, entry: dict = None, entries: list = None, regenerate_name: bool = False) -> list:
|
|
317
337
|
"""
|
|
318
338
|
Update one or more existing entries.
|
|
319
|
-
|
|
339
|
+
|
|
320
340
|
If 'code' and 'entry' are provided, updates a single entry.
|
|
321
341
|
If 'entries' is provided, updates multiple entries based on the code in each entry.
|
|
322
|
-
|
|
342
|
+
|
|
323
343
|
Args:
|
|
324
344
|
id (str, optional): The entry ID for single entry update
|
|
325
345
|
code (str, optional): The entry code for single entry update
|
|
326
346
|
entry (dict, optional): The entry data for single entry update
|
|
327
347
|
entries (list, optional): List of entry data for multiple updates
|
|
328
|
-
|
|
348
|
+
regenerate_name (bool, optional): Have the server rebuild the
|
|
349
|
+
auto-generated name (and any other field with a
|
|
350
|
+
``generatedFrom`` formula) from the updated values. Off by
|
|
351
|
+
default: the stored name is kept. It overrides a name given in
|
|
352
|
+
the data and does nothing for attributes without a formula.
|
|
353
|
+
|
|
329
354
|
Returns:
|
|
330
355
|
list: List of updated entry IDs
|
|
331
356
|
|
|
@@ -354,22 +379,27 @@ class EntryManager:
|
|
|
354
379
|
entry_data['id'] = id
|
|
355
380
|
|
|
356
381
|
try:
|
|
357
|
-
result = self._update_single_entry(
|
|
382
|
+
result = self._update_single_entry(
|
|
383
|
+
id=entry_id or id,
|
|
384
|
+
code=entry_code or code,
|
|
385
|
+
entry=entry_data,
|
|
386
|
+
regenerate_name=regenerate_name,
|
|
387
|
+
)
|
|
358
388
|
results.append({"code": entry_code, "id": result, "status": "success"})
|
|
359
389
|
except Exception as e:
|
|
360
390
|
results.append({"code": entry_code, "error": str(e), "status": "error"})
|
|
361
|
-
|
|
391
|
+
|
|
362
392
|
return results
|
|
363
|
-
|
|
393
|
+
|
|
364
394
|
elif (code or id) and entry:
|
|
365
395
|
# Single entry update
|
|
366
|
-
result = self._update_single_entry(id=id, code=code, entry=entry)
|
|
396
|
+
result = self._update_single_entry(id=id, code=code, entry=entry, regenerate_name=regenerate_name)
|
|
367
397
|
return [{"code": code, "id": result, "status": "success"}]
|
|
368
|
-
|
|
398
|
+
|
|
369
399
|
else:
|
|
370
400
|
raise ValueError("Either 'id', 'code' and 'entry' or 'entries' must be provided")
|
|
371
|
-
|
|
372
|
-
def _update_single_entry(self, id: str = None, code: str = None, entry: dict = None) -> str:
|
|
401
|
+
|
|
402
|
+
def _update_single_entry(self, id: str = None, code: str = None, entry: dict = None, regenerate_name: bool = False) -> str:
|
|
373
403
|
"""Internal method to update a single entry."""
|
|
374
404
|
if not id and not code:
|
|
375
405
|
raise ValueError("Entry ID or code is required")
|
|
@@ -421,7 +451,17 @@ class EntryManager:
|
|
|
421
451
|
elif column_name in entry:
|
|
422
452
|
updated_entry[column_name] = self.__get_value(field, entry[column_name])
|
|
423
453
|
|
|
424
|
-
|
|
454
|
+
if regenerate_name:
|
|
455
|
+
# The server only rebuilds an auto-generated value when it arrives
|
|
456
|
+
# empty; otherwise the stored one is kept, even when the fields it
|
|
457
|
+
# is built from have changed. Fields without a formula are left
|
|
458
|
+
# alone, so the flag cannot blank a name that is typed by hand.
|
|
459
|
+
for field in fields:
|
|
460
|
+
column_name = _safe_lower(field.get("column"))
|
|
461
|
+
if column_name and _is_generated_field(field):
|
|
462
|
+
updated_entry[column_name] = None
|
|
463
|
+
|
|
464
|
+
return self.entry_service.update(attribute_id=attribute_id, entry=updated_entry)
|
|
425
465
|
|
|
426
466
|
|
|
427
467
|
def __set_group_box_field_value(self, current_entry: dict, field, entry: dict) -> dict:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: das-cli
|
|
3
|
-
Version: 1.7.
|
|
3
|
+
Version: 1.7.6
|
|
4
4
|
Summary: DAS api client.
|
|
5
5
|
Author: Royal Netherlands Institute for Sea Research
|
|
6
6
|
License-Expression: MIT
|
|
@@ -233,8 +233,17 @@ das entry update --id e1987f3e-7db7-11f0-a7e8-0edcca226f3d --data "{ 'Comment':
|
|
|
233
233
|
|
|
234
234
|
# Bulk from file (each item should include Id/Code)
|
|
235
235
|
das entry update c:\data\entries-to-update.json
|
|
236
|
+
|
|
237
|
+
# Recalculate the auto-generated name after changing a field it is built from
|
|
238
|
+
das entry update --code 4.b.rdg --data "{ 'Cast No.': '02' }" --regenerate-name
|
|
239
|
+
das entry update c:\data\events.xlsx --regenerate-name
|
|
236
240
|
```
|
|
237
241
|
|
|
242
|
+
An auto-generated name (an Event is `<station>_<cast><device acronym>`) is **kept as stored** on
|
|
243
|
+
update, even when the update changes the cast number or the device. Pass `--regenerate-name` to have
|
|
244
|
+
the server rebuild it from the updated values. The flag applies to every entry of a bulk update,
|
|
245
|
+
overrides a `Name` given in the data, and is ignored for attributes whose name has no formula.
|
|
246
|
+
|
|
238
247
|
#### Logs and ownership
|
|
239
248
|
```bash
|
|
240
249
|
# Audit logs
|
|
@@ -447,7 +456,7 @@ Import: `from das.managers.entries_manager import EntryManager`
|
|
|
447
456
|
| `get(code=..., id=...)` | `dict` — entry with display field names |
|
|
448
457
|
| `get_entry(entry_id)` | `dict` — same as `get(id=...)` |
|
|
449
458
|
| `create(attribute, entry=..., entries=...)` | `list[dict]` — per-item status with `id`, `code`, `status` |
|
|
450
|
-
| `update(id=..., code=..., entry=..., entries
|
|
459
|
+
| `update(id=..., code=..., entry=..., entries=..., regenerate_name=False)` | `list[dict]` — per-item status |
|
|
451
460
|
| `delete(id=..., code=...)` | `bool` |
|
|
452
461
|
| `create_from_file(attribute, file_path)` | `None` |
|
|
453
462
|
| `chown(user_name, entry_code_list)` | API response |
|
|
@@ -543,6 +552,9 @@ entries.update(entries=[
|
|
|
543
552
|
{"Code": "ENT001", "Comment": "Updated 1"},
|
|
544
553
|
{"Code": "ENT002", "Comment": "Updated 2"},
|
|
545
554
|
])
|
|
555
|
+
|
|
556
|
+
# Rebuild the auto-generated name from the updated values (kept as stored by default)
|
|
557
|
+
entries.update(code="4.b.rdg", entry={"Cast No.": "02"}, regenerate_name=True)
|
|
546
558
|
```
|
|
547
559
|
|
|
548
560
|
#### `delete` — delete one entry
|
|
@@ -922,7 +934,7 @@ You can configure values through CLI commands and/or `.env`.
|
|
|
922
934
|
|
|
923
935
|
```env
|
|
924
936
|
# Connection
|
|
925
|
-
DAS_API_URL=https://
|
|
937
|
+
DAS_API_URL=https://your-das-instance/api
|
|
926
938
|
DAS_API_KEY=
|
|
927
939
|
VERIFY_SSL=True
|
|
928
940
|
|
|
@@ -931,7 +943,7 @@ DAS_LOG_LEVEL=WARN
|
|
|
931
943
|
DAS_LOG_FILE=
|
|
932
944
|
|
|
933
945
|
# Test credentials (for integration tests)
|
|
934
|
-
API_URL=https://
|
|
946
|
+
API_URL=https://your-das-instance/api
|
|
935
947
|
USER_NAME=
|
|
936
948
|
USER_PASSWORD=
|
|
937
949
|
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|