das-cli 1.5.25__tar.gz → 1.5.271__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.
Files changed (53) hide show
  1. das_cli-1.5.271/PKG-INFO +788 -0
  2. das_cli-1.5.271/README.md +765 -0
  3. {das_cli-1.5.25 → das_cli-1.5.271}/das/cli.py +1643 -1643
  4. {das_cli-1.5.25 → das_cli-1.5.271}/das/managers/digital_objects_manager.py +15 -78
  5. {das_cli-1.5.25 → das_cli-1.5.271}/das/services/digital_objects.py +28 -56
  6. {das_cli-1.5.25 → das_cli-1.5.271}/das/services/downloads.py +67 -67
  7. das_cli-1.5.271/das_cli.egg-info/PKG-INFO +788 -0
  8. {das_cli-1.5.25 → das_cli-1.5.271}/das_cli.egg-info/SOURCES.txt +1 -10
  9. {das_cli-1.5.25 → das_cli-1.5.271}/pyproject.toml +1 -1
  10. das_cli-1.5.25/PKG-INFO +0 -1295
  11. das_cli-1.5.25/README.md +0 -1272
  12. das_cli-1.5.25/das_cli.egg-info/PKG-INFO +0 -1295
  13. das_cli-1.5.25/tests/__init__.py +0 -3
  14. das_cli-1.5.25/tests/attributes_test.py +0 -77
  15. das_cli-1.5.25/tests/download_manager_test.py +0 -34
  16. das_cli-1.5.25/tests/entries_manager_test.py +0 -511
  17. das_cli-1.5.25/tests/entries_service_test.py +0 -270
  18. das_cli-1.5.25/tests/entries_test.py +0 -43
  19. das_cli-1.5.25/tests/file_utils_test.py +0 -115
  20. das_cli-1.5.25/tests/run_tests.py +0 -18
  21. das_cli-1.5.25/tests/search_manager_test.py +0 -74
  22. {das_cli-1.5.25 → das_cli-1.5.271}/LICENSE +0 -0
  23. {das_cli-1.5.25 → das_cli-1.5.271}/MANIFEST.in +0 -0
  24. {das_cli-1.5.25 → das_cli-1.5.271}/das/__init__.py +0 -0
  25. {das_cli-1.5.25 → das_cli-1.5.271}/das/ai/plugins/dasai.py +0 -0
  26. {das_cli-1.5.25 → das_cli-1.5.271}/das/ai/plugins/entries/entries_plugin.py +0 -0
  27. {das_cli-1.5.25 → das_cli-1.5.271}/das/app.py +0 -0
  28. {das_cli-1.5.25 → das_cli-1.5.271}/das/authentication/auth.py +0 -0
  29. {das_cli-1.5.25 → das_cli-1.5.271}/das/authentication/oauth.py +0 -0
  30. {das_cli-1.5.25 → das_cli-1.5.271}/das/authentication/secure_input.py +0 -0
  31. {das_cli-1.5.25 → das_cli-1.5.271}/das/common/api.py +0 -0
  32. {das_cli-1.5.25 → das_cli-1.5.271}/das/common/config.py +0 -0
  33. {das_cli-1.5.25 → das_cli-1.5.271}/das/common/entry_fields_constants.py +0 -0
  34. {das_cli-1.5.25 → das_cli-1.5.271}/das/common/enums.py +0 -0
  35. {das_cli-1.5.25 → das_cli-1.5.271}/das/common/file_utils.py +0 -0
  36. {das_cli-1.5.25 → das_cli-1.5.271}/das/managers/__init__.py +0 -0
  37. {das_cli-1.5.25 → das_cli-1.5.271}/das/managers/download_manager.py +0 -0
  38. {das_cli-1.5.25 → das_cli-1.5.271}/das/managers/entries_manager.py +0 -0
  39. {das_cli-1.5.25 → das_cli-1.5.271}/das/managers/search_manager.py +0 -0
  40. {das_cli-1.5.25 → das_cli-1.5.271}/das/services/attributes.py +0 -0
  41. {das_cli-1.5.25 → das_cli-1.5.271}/das/services/cache.py +0 -0
  42. {das_cli-1.5.25 → das_cli-1.5.271}/das/services/das_elastic_search.py +0 -0
  43. {das_cli-1.5.25 → das_cli-1.5.271}/das/services/entries.py +0 -0
  44. {das_cli-1.5.25 → das_cli-1.5.271}/das/services/entry_fields.py +0 -0
  45. {das_cli-1.5.25 → das_cli-1.5.271}/das/services/hangfire.py +0 -0
  46. {das_cli-1.5.25 → das_cli-1.5.271}/das/services/search.py +0 -0
  47. {das_cli-1.5.25 → das_cli-1.5.271}/das/services/service_base.py +0 -0
  48. {das_cli-1.5.25 → das_cli-1.5.271}/das/services/users.py +0 -0
  49. {das_cli-1.5.25 → das_cli-1.5.271}/das_cli.egg-info/dependency_links.txt +0 -0
  50. {das_cli-1.5.25 → das_cli-1.5.271}/das_cli.egg-info/entry_points.txt +0 -0
  51. {das_cli-1.5.25 → das_cli-1.5.271}/das_cli.egg-info/requires.txt +0 -0
  52. {das_cli-1.5.25 → das_cli-1.5.271}/das_cli.egg-info/top_level.txt +0 -0
  53. {das_cli-1.5.25 → das_cli-1.5.271}/setup.cfg +0 -0
@@ -0,0 +1,788 @@
1
+ Metadata-Version: 2.4
2
+ Name: das-cli
3
+ Version: 1.5.271
4
+ Summary: DAS api client.
5
+ Author: Royal Netherlands Institute for Sea Research
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://git.nioz.nl/ict-projects/das-cli
8
+ Project-URL: Bug Tracker, https://git.nioz.nl/ict-projects/das-cli/-/issues
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.9
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: click>=8.2.1
15
+ Requires-Dist: requests>=2.32.3
16
+ Requires-Dist: python-dotenv>=1.0.0
17
+ Provides-Extra: excel
18
+ Requires-Dist: pandas>=2.2.3; extra == "excel"
19
+ Requires-Dist: openpyxl>=3.1.5; extra == "excel"
20
+ Provides-Extra: ai
21
+ Requires-Dist: semantic-kernel>=1.37.0; extra == "ai"
22
+ Dynamic: license-file
23
+
24
+ # DAS CLI and Python SDK
25
+
26
+ `das-cli` is both:
27
+ - a command-line tool (`das`) for day-to-day DAS operations, and
28
+ - a Python package for scripts, automations, and integrations.
29
+
30
+ This README is organized around how people actually use the project:
31
+ 1. [CLI workflows](#cli-usage)
32
+ 2. [Programmatic workflows](#programmatic-usage-python)
33
+ 3. [Manager-layer API reference with examples](#manager-layer-api-reference-domain-layer) — all methods of `EntryManager`, `SearchManager`, `DownloadManager`, and `DigitalObjectsManager`
34
+
35
+ ## Install
36
+
37
+ ### Requirements
38
+ - Python `3.13+`
39
+
40
+ ### Install from PyPI
41
+
42
+ ```bash
43
+ pip install das-cli
44
+ ```
45
+
46
+ ### Install from source
47
+
48
+ ```bash
49
+ git clone https://git.nioz.nl/ict-projects/das-cli.git
50
+ cd das-cli
51
+ pip install -e .
52
+ ```
53
+
54
+ ## Quickstart (CLI)
55
+
56
+ ```bash
57
+ # 1) Authenticate (choose one)
58
+ das login --api-url https://your-das-instance/api
59
+ das login --api-url https://your-das-instance/api --api-key <your-api-key>
60
+
61
+ # 2) Search
62
+ das search entries --attribute Cores --query "name(*64*)" --max-results 10 --page 1
63
+
64
+ # 3) Get one entry
65
+ das entry get --code zb.b.1ub
66
+ ```
67
+
68
+ ## CLI Usage
69
+
70
+ ### Authentication
71
+
72
+ #### Username/password
73
+ ```bash
74
+ das login --api-url https://your-das-instance/api --username your_user --password your_password
75
+ ```
76
+
77
+ If `--username` or `--password` is omitted, the CLI prompts securely.
78
+
79
+ #### API key
80
+ ```bash
81
+ das login --api-url https://your-das-instance/api --api-key <your-api-key>
82
+ ```
83
+
84
+ Generate the key in DAS Web UI: **My Settings -> API Keys**.
85
+
86
+ #### OAuth / Azure Entra
87
+ ```bash
88
+ das oauth configure --client-id <client-id> --authority https://login.microsoftonline.com/<tenant>/v2.0
89
+ das login --api-url https://your-das-instance/api --oauth
90
+ ```
91
+
92
+ ### Search and Read
93
+
94
+ ```bash
95
+ # Search with paging/sorting/formatting
96
+ das search entries --attribute Cores --query "name(*64*)" --max-results 10 --page 1 --sort-by Name --sort-order asc --format table
97
+
98
+ # Get details of one entry by ID
99
+ das search entry 6b0e68e6-00cd-43a7-9c51-d56c9c091123 --format json
100
+
101
+ # Query syntax help
102
+ das search help
103
+ ```
104
+
105
+ ### Entries
106
+
107
+ ```bash
108
+ # Get by code
109
+ das entry get --code ENT001
110
+
111
+ # Delete by code (with prompt)
112
+ das entry delete --code ENT001
113
+
114
+ # Delete by ID (no prompt)
115
+ das entry delete --id e1987f3e-7db7-11f0-a7e8-0edcca226f3d --force
116
+ ```
117
+
118
+ #### Create entries
119
+ ```bash
120
+ # From file (.json/.csv/.xlsx)
121
+ das entry create --attribute Cores c:\data\entries.json
122
+
123
+ # Single object from --data
124
+ das entry create --attribute Cores --data "{ 'Alias': 'test.entry.001', 'Event': '64PE428-02PC' }"
125
+
126
+ # Bulk from --data
127
+ das entry create --attribute Cores --data "[{ 'Alias': 'a1' }, { 'Alias': 'a2' }]"
128
+ ```
129
+
130
+ #### Update entries
131
+ ```bash
132
+ # Single by code
133
+ das entry update --code ENT001 --data "{ 'Comment': 'Updated by CLI' }"
134
+
135
+ # Single by id
136
+ das entry update --id e1987f3e-7db7-11f0-a7e8-0edcca226f3d --data "{ 'Comment': 'Updated by id' }"
137
+
138
+ # Bulk from file (each item should include Id/Code)
139
+ das entry update c:\data\entries-to-update.json
140
+ ```
141
+
142
+ #### Logs and ownership
143
+ ```bash
144
+ # Audit logs
145
+ das entry logs --code ENT001 --max-results 50 --skip 0 --format table
146
+
147
+ # Change owner
148
+ das entry chown --user alice --code ENT001 --code ENT002
149
+ ```
150
+
151
+ ### Digital Objects
152
+
153
+ ```bash
154
+ # Upload + link to entry
155
+ das entry upload-digital-object --entry-code ENT001 --type Dataset --description "CTD raw" c:\data\ctd.zip
156
+
157
+ # Link existing digital objects
158
+ das entry link-digital-objects --entry-code ENT001 -d DO001 -d DO002
159
+
160
+ # Unlink
161
+ das entry link-digital-objects --entry-code ENT001 -d DO002 --unlink
162
+
163
+ # Direct download by codes
164
+ das entry direct-download-digital-object --entry-code ENT001 --digital-object-code DO001 --out C:\Downloads\
165
+ ```
166
+
167
+ ### Downloads
168
+
169
+ ```bash
170
+ # Create request for all files from entry
171
+ das download request --entry ENT001 --name "My request"
172
+
173
+ # Create request selecting files
174
+ das download request --entry ENT001 --file FILE001 --file FILE002
175
+
176
+ # List your requests
177
+ das download my-requests --format table
178
+
179
+ # Download completed bundle
180
+ das download files 6b0e68e6-00cd-43a7-9c51-d56c9c091123 --out C:\Downloads
181
+
182
+ # Delete request
183
+ das download delete-request 6b0e68e6-00cd-43a7-9c51-d56c9c091123
184
+ ```
185
+
186
+ ### Other CLI groups
187
+
188
+ ```bash
189
+ # Attribute lookup
190
+ das attribute get --name "Cores"
191
+ das attribute get-id "Cores"
192
+ das attribute get-name 126
193
+
194
+ # Cache
195
+ das cache list
196
+ das cache clear "attributes"
197
+ das cache clear-all
198
+
199
+ # Config
200
+ das config ssl-verify true
201
+ das config ssl-status
202
+ das config show
203
+ das config reset --force
204
+ ```
205
+
206
+ ## Programmatic Usage (Python)
207
+
208
+ Two common patterns are supported.
209
+
210
+ ### Pattern A: login once with CLI, then use managers in Python
211
+
212
+ ```python
213
+ from das.managers.entries_manager import EntryManager
214
+ from das.managers.search_manager import SearchManager
215
+
216
+ entries = EntryManager()
217
+ search = SearchManager()
218
+
219
+ core = entries.get(code="zb.b.1ub")
220
+ results = search.search_entries(attribute="Cores", query="name(*64*)", max_results=5)
221
+ ```
222
+
223
+ ### Pattern B: authenticate in Python with `Das`
224
+
225
+ ```python
226
+ from das.app import Das
227
+ from das.managers.entries_manager import EntryManager
228
+
229
+ # Username/password
230
+ client = Das("https://your-das-instance/api")
231
+ client.authenticate("your_user", "your_password")
232
+
233
+ # Or API key
234
+ # client = Das("https://your-das-instance/api")
235
+ # client.authenticate_with_api_key("your-api-key")
236
+
237
+ entry_manager = EntryManager()
238
+ entry = entry_manager.get(code="zb.b.1ub")
239
+ print(entry.get("Name"))
240
+ ```
241
+
242
+ ## Manager Layer API Reference (Domain Layer)
243
+
244
+ Managers are the recommended Python API. They translate user-friendly field names, codes, and query syntax into the lower-level DAS API calls.
245
+
246
+ **Prerequisite:** authenticate first (see [Programmatic Usage](#programmatic-usage-python)), then instantiate any manager:
247
+
248
+ ```python
249
+ from das.managers.entries_manager import EntryManager
250
+
251
+ entries = EntryManager() # reads API URL + token from stored config
252
+ ```
253
+
254
+ All managers raise `ValueError` when the API URL is not configured or when required parameters are missing.
255
+
256
+ ---
257
+
258
+ ### `EntryManager`
259
+
260
+ Import: `from das.managers.entries_manager import EntryManager`
261
+
262
+ | Method | Returns |
263
+ |--------|---------|
264
+ | `get(code=..., id=...)` | `dict` — entry with display field names |
265
+ | `get_entry(entry_id)` | `dict` — same as `get(id=...)` |
266
+ | `create(attribute, entry=..., entries=...)` | `list[dict]` — per-item status with `id`, `code`, `status` |
267
+ | `update(id=..., code=..., entry=..., entries=...)` | `list[dict]` — per-item status |
268
+ | `delete(id=..., code=...)` | `bool` |
269
+ | `create_from_file(attribute, file_path)` | `None` |
270
+ | `chown(user_name, entry_code_list)` | API response |
271
+ | `get_entry_logs(entry_id=..., entry_code=..., ...)` | `dict` with `totalCount` and `items` |
272
+ | `get_direct_relations(entry_code=..., entry_id=..., ...)` | `dict` with relation `items` |
273
+
274
+ #### `get` / `get_entry` — fetch one entry
275
+
276
+ ```python
277
+ entries = EntryManager()
278
+
279
+ # By code (returns display field names like "Name", "Code", "Event", etc.)
280
+ entry = entries.get(code="zb.b.1ub")
281
+ print(entry["Name"], entry["Code"])
282
+
283
+ # By ID (GUID)
284
+ entry = entries.get(id="6b0e68e6-00cd-43a7-9c51-d56c9c091123")
285
+
286
+ # Convenience alias — same result as get(id=...)
287
+ entry = entries.get_entry("6b0e68e6-00cd-43a7-9c51-d56c9c091123")
288
+ ```
289
+
290
+ #### `create` — create one or many entries
291
+
292
+ ```python
293
+ entries = EntryManager()
294
+
295
+ # Single entry (field keys can be display names or column names)
296
+ result = entries.create(attribute="Cores", entry={
297
+ "Alias": "test.entry.001",
298
+ "Event": "64PE428-02PC",
299
+ "Number": 1,
300
+ "Number Alias": "001",
301
+ "Start Depth": 576,
302
+ "End Depth": 600,
303
+ "Comment": "Created from Python",
304
+ })
305
+ # result -> [{"id": "<guid>", "code": "zb.b.xxx", "status": "success"}]
306
+ new_id = result[0]["id"]
307
+
308
+ # Bulk create
309
+ results = entries.create(attribute="Cores", entries=[
310
+ {"Alias": "bulk.001", "Event": "64PE428-02PC", "Number": 1},
311
+ {"Alias": "bulk.002", "Event": "64PE428-02PC", "Number": 2},
312
+ ])
313
+ for item in results:
314
+ print(item.get("id"), item.get("status"), item.get("error"))
315
+
316
+ # Entry with relation fields (comma-separated codes or GUIDs)
317
+ entries.create(attribute="Cruise", entry={
318
+ "Cruise Code": "TEST-Cruise-001",
319
+ "Project(s)": "3d.b.q,3d.b.r", # multiple project codes
320
+ "Vessel": "Algoa",
321
+ "Start Date": "2026-01-01",
322
+ "End Date": "2026-01-02",
323
+ })
324
+ ```
325
+
326
+ #### `update` — update one or many entries
327
+
328
+ ```python
329
+ entries = EntryManager()
330
+
331
+ # Partial update by code (only changed fields needed)
332
+ entries.update(code="zb.b.0", entry={
333
+ "Availability": "pc.b.c",
334
+ "Number": 2,
335
+ "Comment": "Updated from Python",
336
+ })
337
+
338
+ # Partial update by ID
339
+ entries.update(id="c4c6dff6-5ccb-11f0-a78d-a84a63c8db73", entry={
340
+ "description": "New description text",
341
+ "jobtitle": "Head of National Marine Facilities",
342
+ })
343
+
344
+ # Bulk update (each item must include Code or Id)
345
+ entries.update(entries=[
346
+ {"Code": "ENT001", "Comment": "Updated 1"},
347
+ {"Code": "ENT002", "Comment": "Updated 2"},
348
+ ])
349
+ ```
350
+
351
+ #### `delete` — delete one entry
352
+
353
+ ```python
354
+ entries = EntryManager()
355
+
356
+ entries.delete(id="6b0e68e6-00cd-43a7-9c51-d56c9c091123") # -> True
357
+ entries.delete(code="zb.b.1ub") # -> True
358
+ ```
359
+
360
+ #### `create_from_file` — bulk create from file
361
+
362
+ ```python
363
+ entries = EntryManager()
364
+
365
+ entries.create_from_file(attribute="Cores", file_path=r"c:\data\entries.json")
366
+ entries.create_from_file(attribute="Cores", file_path=r"c:\data\entries.csv")
367
+ entries.create_from_file(attribute="Cores", file_path=r"c:\data\entries.xlsx")
368
+ ```
369
+
370
+ Supported formats: `.json` (list of objects), `.csv` (one row per entry), `.xlsx` (one row per entry).
371
+
372
+ #### `chown` — transfer ownership
373
+
374
+ ```python
375
+ entries = EntryManager()
376
+
377
+ result = entries.chown(
378
+ user_name="alice",
379
+ entry_code_list=["ENT001", "ENT002"],
380
+ )
381
+ ```
382
+
383
+ #### `get_entry_logs` — audit / change history
384
+
385
+ ```python
386
+ entries = EntryManager()
387
+
388
+ # By code
389
+ logs = entries.get_entry_logs(entry_code="ENT001", max_result_count=50, skip_count=0)
390
+
391
+ # By ID
392
+ logs = entries.get_entry_logs(entry_id="d7b99f36-5ccb-11f0-87f3-a84a63c8db73")
393
+
394
+ print(logs["totalCount"])
395
+ for log in logs["items"]:
396
+ print(log["fieldName"], log["valueFrom"], "->", log["valueTo"], log["modifierUserName"])
397
+ ```
398
+
399
+ #### `get_direct_relations` — related entries
400
+
401
+ ```python
402
+ entries = EntryManager()
403
+
404
+ relations = entries.get_direct_relations(entry_code="6.b.sy")
405
+ for rel in relations["items"]:
406
+ print(rel["id"], rel.get("displayname"))
407
+ ```
408
+
409
+ ---
410
+
411
+ ### `SearchManager`
412
+
413
+ Import: `from das.managers.search_manager import SearchManager`
414
+
415
+ | Method | Returns |
416
+ |--------|---------|
417
+ | `search_entries(attribute, query, max_results, page, sort_by, sort_order, includeRelationsId)` | `dict` with `items` and `totalCount` |
418
+
419
+ Query and sort field names are automatically converted from display names to internal column names.
420
+
421
+ #### `search_entries` — search within an attribute
422
+
423
+ ```python
424
+ search = SearchManager()
425
+
426
+ # Basic search
427
+ results = search.search_entries(
428
+ attribute="Cores",
429
+ query="name(*64*)",
430
+ max_results=10,
431
+ page=1,
432
+ )
433
+ print(results["totalCount"])
434
+ for item in results["items"]:
435
+ print(item.get("Name"), item.get("Code"))
436
+
437
+ # Composite query (AND / OR)
438
+ results = search.search_entries(
439
+ attribute="Cores",
440
+ query="name(64PE320-03BC#01) or code(zb.b.1ub)",
441
+ max_results=5,
442
+ sort_by="Name",
443
+ sort_order="asc",
444
+ )
445
+
446
+ # Search all entries in an attribute (empty query)
447
+ results = search.search_entries(
448
+ attribute="Cores",
449
+ query="",
450
+ max_results=1000,
451
+ page=1,
452
+ )
453
+
454
+ # Find stations by cruise code
455
+ stations = search.search_entries(
456
+ attribute="Station",
457
+ query="Cruise(64PE514)",
458
+ max_results=5,
459
+ sort_by="Code",
460
+ )
461
+
462
+ # Wildcard search on display name
463
+ projects = search.search_entries(
464
+ attribute="Cruise",
465
+ query="displayname(*64PE514*)",
466
+ max_results=5,
467
+ sort_by="displayname",
468
+ )
469
+
470
+ # Paginate to page 2
471
+ page2 = search.search_entries(
472
+ attribute="Cores",
473
+ query="name(*64*)",
474
+ max_results=50,
475
+ page=2,
476
+ )
477
+ ```
478
+
479
+ ---
480
+
481
+ ### `DownloadManager`
482
+
483
+ Import: `from das.managers.download_manager import DownloadManager`
484
+
485
+ | Method | Returns |
486
+ |--------|---------|
487
+ | `create_download_request(request_data)` | `str` (request ID) or `dict` with `errors` |
488
+ | `get_my_requests()` | `dict` or `list` of download requests |
489
+ | `delete_download_request(request_id)` | API response |
490
+ | `download_files(request_id)` | `requests.Response` (streaming) |
491
+ | `save_download(request_id, output_path, overwrite)` | `str` — saved file path |
492
+
493
+ The `request_data` dict uses entry codes as keys. Values are lists of digital-object codes; an empty list means all files from that entry.
494
+
495
+ #### `create_download_request` — request files for download
496
+
497
+ ```python
498
+ downloads = DownloadManager()
499
+
500
+ # Specific files from one entry
501
+ request_id = downloads.create_download_request({
502
+ "name": "My download",
503
+ "zb.b.dc": ["h.b.z0pg", "h.b.s3pg"],
504
+ })
505
+
506
+ # All files from one entry (empty list)
507
+ request_id = downloads.create_download_request({
508
+ "name": "All files",
509
+ "zb.b.lu": [],
510
+ })
511
+
512
+ # Mixed: selected files from one entry, all files from another
513
+ request_id = downloads.create_download_request({
514
+ "name": "Mixed download",
515
+ "zb.b.dc": ["h.b.z0pg", "h.b.s3pg"],
516
+ "zb.b.lu": [],
517
+ })
518
+
519
+ # Handle validation errors
520
+ result = downloads.create_download_request({"name": "Bad", "INVALID": []})
521
+ if isinstance(result, dict) and "errors" in result:
522
+ for err in result["errors"]:
523
+ print(err)
524
+ ```
525
+
526
+ #### `get_my_requests` — list your download requests
527
+
528
+ ```python
529
+ downloads = DownloadManager()
530
+
531
+ requests = downloads.get_my_requests()
532
+ items = requests.get("items", []) if isinstance(requests, dict) else requests
533
+ for req in items:
534
+ print(req["id"], req.get("status"), len(req.get("files", [])))
535
+ ```
536
+
537
+ #### `delete_download_request` — remove a request
538
+
539
+ ```python
540
+ downloads = DownloadManager()
541
+
542
+ downloads.delete_download_request("6b0e68e6-00cd-43a7-9c51-d56c9c091123")
543
+ ```
544
+
545
+ #### `download_files` — get streaming response
546
+
547
+ ```python
548
+ downloads = DownloadManager()
549
+
550
+ response = downloads.download_files("6b0e68e6-00cd-43a7-9c51-d56c9c091123")
551
+
552
+ # Manual save from stream
553
+ with open(r"C:\Downloads\bundle.zip", "wb") as f:
554
+ for chunk in response.iter_content(chunk_size=8192):
555
+ if chunk:
556
+ f.write(chunk)
557
+ ```
558
+
559
+ #### `save_download` — download and save in one step
560
+
561
+ ```python
562
+ downloads = DownloadManager()
563
+
564
+ # Save to directory (filename taken from server response)
565
+ path = downloads.save_download(
566
+ request_id="6b0e68e6-00cd-43a7-9c51-d56c9c091123",
567
+ output_path=r"C:\Downloads",
568
+ )
569
+
570
+ # Save to explicit file path, overwrite if exists
571
+ path = downloads.save_download(
572
+ request_id="6b0e68e6-00cd-43a7-9c51-d56c9c091123",
573
+ output_path=r"C:\Downloads\bundle.zip",
574
+ overwrite=True,
575
+ )
576
+ ```
577
+
578
+ ---
579
+
580
+ ### `DigitalObjectsManager`
581
+
582
+ Import: `from das.managers.digital_objects_manager import DigitalObjectsManager`
583
+
584
+ | Method | Returns |
585
+ |--------|---------|
586
+ | `upload_digital_object(entry_code, file_description, digital_object_type, file_path)` | `str` — digital object ID |
587
+ | `link_existing_digital_objects(entry_code, digital_object_code_list, is_unlink)` | `bool` |
588
+ | `download_digital_object(output_path, digital_object_id, digital_object_code)` | `str` — saved file path |
589
+ | `direct_download_digital_object(...)` | `str` — saved file path |
590
+
591
+ #### `upload_digital_object` — upload file and link to entry
592
+
593
+ ```python
594
+ digital_objects = DigitalObjectsManager()
595
+
596
+ do_id = digital_objects.upload_digital_object(
597
+ entry_code="zb.b.f7",
598
+ file_description="CTD raw data",
599
+ digital_object_type="Dataset",
600
+ file_path=r"c:\data\ctd.zip",
601
+ )
602
+ print(do_id) # GUID of the new digital object
603
+ ```
604
+
605
+ #### `link_existing_digital_objects` — link or unlink by codes
606
+
607
+ ```python
608
+ digital_objects = DigitalObjectsManager()
609
+
610
+ # Link
611
+ digital_objects.link_existing_digital_objects(
612
+ entry_code="4d.b.1l",
613
+ digital_object_code_list=["h.b.ac0j"],
614
+ is_unlink=False,
615
+ )
616
+
617
+ # Unlink
618
+ digital_objects.link_existing_digital_objects(
619
+ entry_code="4d.b.1l",
620
+ digital_object_code_list=["h.b.ac0j"],
621
+ is_unlink=True,
622
+ )
623
+ ```
624
+
625
+ #### `download_digital_object` — download by digital object code or ID
626
+
627
+ ```python
628
+ digital_objects = DigitalObjectsManager()
629
+
630
+ # By code (output_path can be a directory or a file path)
631
+ path = digital_objects.download_digital_object(
632
+ output_path=r"c:\temp\",
633
+ digital_object_code="h.b.8j2h",
634
+ )
635
+
636
+ # By ID
637
+ path = digital_objects.download_digital_object(
638
+ output_path=r"c:\temp\file.bin",
639
+ digital_object_id="b47c3de3-d754-4a25-8528-c4fd88e1fdbb",
640
+ )
641
+ ```
642
+
643
+ #### `direct_download_digital_object` — download from a specific entry
644
+
645
+ ```python
646
+ digital_objects = DigitalObjectsManager()
647
+
648
+ # By entry code + digital object code
649
+ path = digital_objects.direct_download_digital_object(
650
+ entry_code="4d.b.1l",
651
+ digital_object_code="h.b.ac0j",
652
+ output_path=r"c:\temp\",
653
+ )
654
+
655
+ # By IDs (when you already have them)
656
+ path = digital_objects.direct_download_digital_object(
657
+ entry_id="e1987f3e-7db7-11f0-a7e8-0edcca226f3d",
658
+ attribute_id=126,
659
+ digital_object_id="cf335b17-80e3-4151-aa80-40b69fe0567e",
660
+ output_path=r"c:\temp\file.bin",
661
+ )
662
+ ```
663
+
664
+ ---
665
+
666
+ ### Complete end-to-end script
667
+
668
+ ```python
669
+ from das.app import Das
670
+ from das.managers.entries_manager import EntryManager
671
+ from das.managers.search_manager import SearchManager
672
+ from das.managers.download_manager import DownloadManager
673
+ from das.managers.digital_objects_manager import DigitalObjectsManager
674
+
675
+ # 1. Authenticate
676
+ client = Das("https://your-das-instance/api")
677
+ client.authenticate("your_user", "your_password")
678
+
679
+ # 2. Instantiate managers
680
+ entries = EntryManager()
681
+ search = SearchManager()
682
+ downloads = DownloadManager()
683
+ digital_objects = DigitalObjectsManager()
684
+
685
+ # 3. Search
686
+ hits = search.search_entries(attribute="Cores", query="name(*64*)", max_results=5)
687
+ print(f"Found {hits['totalCount']} cores")
688
+
689
+ # 4. Read one entry
690
+ core = entries.get(code="zb.b.1ub")
691
+ print(core["Name"])
692
+
693
+ # 5. Create a new entry
694
+ created = entries.create(attribute="Cores", entry={
695
+ "Alias": "api.test.001",
696
+ "Event": "64PE428-02PC",
697
+ "Number": 1,
698
+ })
699
+ print(f"Created {created[0]['code']}")
700
+
701
+ # 6. Upload a file
702
+ do_id = digital_objects.upload_digital_object(
703
+ entry_code=created[0]["code"],
704
+ file_description="Test file",
705
+ digital_object_type="Dataset",
706
+ file_path=r"c:\data\sample.zip",
707
+ )
708
+
709
+ # 7. Request download and save
710
+ request_id = downloads.create_download_request({
711
+ "name": "API test download",
712
+ created[0]["code"]: [],
713
+ })
714
+ saved = downloads.save_download(request_id, output_path=r"C:\Downloads")
715
+ print(f"Saved to {saved}")
716
+
717
+ # 8. Clean up
718
+ entries.delete(id=created[0]["id"])
719
+ downloads.delete_download_request(request_id)
720
+ ```
721
+
722
+ ## Configuration and Environment Variables
723
+
724
+ You can configure values through CLI commands and/or `.env`.
725
+
726
+ ```env
727
+ # Connection
728
+ DAS_API_URL=https://api.das-dev.nioz.nl
729
+ DAS_API_KEY=
730
+ VERIFY_SSL=True
731
+
732
+ # Test credentials (for integration tests)
733
+ API_URL=https://api.das-dev.nioz.nl
734
+ USER_NAME=
735
+ USER_PASSWORD=
736
+
737
+ # AI feature
738
+ OPENAI_API_KEY=
739
+ OPEN_AI_MODEL_ID=gpt-4o-mini
740
+ ```
741
+
742
+ - `DAS_API_URL`: default API URL for app/managers when no explicit URL is provided.
743
+ - `DAS_API_KEY`: API key auth (takes precedence over stored token in auth layer).
744
+ - `VERIFY_SSL`: TLS verification (`True`/`False`).
745
+ - `API_URL`, `USER_NAME`, `USER_PASSWORD`: used by integration tests.
746
+
747
+ ## Unit Tests and Integration Tests
748
+
749
+ Run complete suite:
750
+
751
+ ```bash
752
+ python run_tests.py
753
+ ```
754
+
755
+ Run a single test module:
756
+
757
+ ```bash
758
+ python -m pytest tests/entries_manager_test.py
759
+ ```
760
+
761
+ The tests are a good source of realistic payload examples, especially:
762
+ - `tests/entries_manager_test.py`
763
+ - `tests/search_manager_test.py`
764
+ - `tests/download_manager_test.py`
765
+ - `tests/digital_object_manager_test.py`
766
+
767
+ ## Troubleshooting
768
+
769
+ - Authentication errors:
770
+ - verify the URL includes your DAS API base (often ending in `/api`).
771
+ - run `das login` again to refresh stored auth.
772
+ - SSL errors in local/dev environments:
773
+ - temporarily disable with `das config ssl-verify false` (avoid in production).
774
+ - PowerShell quoting:
775
+ - prefer double quotes around query arguments containing `*`, `;`, and parentheses.
776
+ - No API URL configured:
777
+ - set `DAS_API_URL`, pass URL to `Das(...)`, or run `das login --api-url ...`.
778
+
779
+ ## Contributing
780
+
781
+ Contributions are welcome through pull requests.
782
+
783
+ For bugs or feature requests, use the project issue tracker:
784
+ - [DAS CLI issue tracker](https://git.nioz.nl/ict-projects/das-cli/-/issues)
785
+
786
+ ## License
787
+
788
+ MIT License