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