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