das-cli 1.8.0__tar.gz → 1.10.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- das_cli-1.10.0/PKG-INFO +1310 -0
- das_cli-1.10.0/README.md +1287 -0
- {das_cli-1.8.0 → das_cli-1.10.0}/das/cli.py +202 -0
- {das_cli-1.8.0 → das_cli-1.10.0}/das/common/api.py +3 -2
- das_cli-1.10.0/das/managers/batch_update_manager.py +196 -0
- das_cli-1.10.0/das/services/entry_batch_update.py +89 -0
- das_cli-1.10.0/das/services/hangfire.py +101 -0
- das_cli-1.10.0/das_cli.egg-info/PKG-INFO +1310 -0
- {das_cli-1.8.0 → das_cli-1.10.0}/das_cli.egg-info/SOURCES.txt +2 -0
- {das_cli-1.8.0 → das_cli-1.10.0}/pyproject.toml +1 -1
- das_cli-1.8.0/PKG-INFO +0 -1038
- das_cli-1.8.0/README.md +0 -1015
- das_cli-1.8.0/das/services/hangfire.py +0 -19
- das_cli-1.8.0/das_cli.egg-info/PKG-INFO +0 -1038
- {das_cli-1.8.0 → das_cli-1.10.0}/LICENSE +0 -0
- {das_cli-1.8.0 → das_cli-1.10.0}/MANIFEST.in +0 -0
- {das_cli-1.8.0 → das_cli-1.10.0}/das/__init__.py +0 -0
- {das_cli-1.8.0 → das_cli-1.10.0}/das/ai/plugins/dasai.py +0 -0
- {das_cli-1.8.0 → das_cli-1.10.0}/das/ai/plugins/entries/entries_plugin.py +0 -0
- {das_cli-1.8.0 → das_cli-1.10.0}/das/app.py +0 -0
- {das_cli-1.8.0 → das_cli-1.10.0}/das/authentication/auth.py +0 -0
- {das_cli-1.8.0 → das_cli-1.10.0}/das/authentication/oauth.py +0 -0
- {das_cli-1.8.0 → das_cli-1.10.0}/das/authentication/secure_input.py +0 -0
- {das_cli-1.8.0 → das_cli-1.10.0}/das/common/config.py +0 -0
- {das_cli-1.8.0 → das_cli-1.10.0}/das/common/entry_fields_constants.py +0 -0
- {das_cli-1.8.0 → das_cli-1.10.0}/das/common/enums.py +0 -0
- {das_cli-1.8.0 → das_cli-1.10.0}/das/common/errors.py +0 -0
- {das_cli-1.8.0 → das_cli-1.10.0}/das/common/exceptions.py +0 -0
- {das_cli-1.8.0 → das_cli-1.10.0}/das/common/file_utils.py +0 -0
- {das_cli-1.8.0 → das_cli-1.10.0}/das/managers/__init__.py +0 -0
- {das_cli-1.8.0 → das_cli-1.10.0}/das/managers/digital_objects_manager.py +0 -0
- {das_cli-1.8.0 → das_cli-1.10.0}/das/managers/download_manager.py +0 -0
- {das_cli-1.8.0 → das_cli-1.10.0}/das/managers/entries_manager.py +0 -0
- {das_cli-1.8.0 → das_cli-1.10.0}/das/managers/search_manager.py +0 -0
- {das_cli-1.8.0 → das_cli-1.10.0}/das/services/attributes.py +0 -0
- {das_cli-1.8.0 → das_cli-1.10.0}/das/services/cache.py +0 -0
- {das_cli-1.8.0 → das_cli-1.10.0}/das/services/das_elastic_search.py +0 -0
- {das_cli-1.8.0 → das_cli-1.10.0}/das/services/digital_objects.py +0 -0
- {das_cli-1.8.0 → das_cli-1.10.0}/das/services/downloads.py +0 -0
- {das_cli-1.8.0 → das_cli-1.10.0}/das/services/entries.py +0 -0
- {das_cli-1.8.0 → das_cli-1.10.0}/das/services/entry_fields.py +0 -0
- {das_cli-1.8.0 → das_cli-1.10.0}/das/services/search.py +0 -0
- {das_cli-1.8.0 → das_cli-1.10.0}/das/services/service_base.py +0 -0
- {das_cli-1.8.0 → das_cli-1.10.0}/das/services/session.py +0 -0
- {das_cli-1.8.0 → das_cli-1.10.0}/das/services/users.py +0 -0
- {das_cli-1.8.0 → das_cli-1.10.0}/das_cli.egg-info/dependency_links.txt +0 -0
- {das_cli-1.8.0 → das_cli-1.10.0}/das_cli.egg-info/entry_points.txt +0 -0
- {das_cli-1.8.0 → das_cli-1.10.0}/das_cli.egg-info/requires.txt +0 -0
- {das_cli-1.8.0 → das_cli-1.10.0}/das_cli.egg-info/top_level.txt +0 -0
- {das_cli-1.8.0 → das_cli-1.10.0}/setup.cfg +0 -0
das_cli-1.10.0/PKG-INFO
ADDED
|
@@ -0,0 +1,1310 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: das-cli
|
|
3
|
+
Version: 1.10.0
|
|
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 the official command-line tool **and** Python library for the NIOZ
|
|
27
|
+
**Data Archive System (DAS)**. Use it to search, read, create, update and
|
|
28
|
+
download archived research data without opening the web interface.
|
|
29
|
+
|
|
30
|
+
| You are… | Start here |
|
|
31
|
+
|---------------------------------------|-------------------------------------------------------------------|
|
|
32
|
+
| A **researcher** who wants answers fast | [Quickstart](#quickstart-5-minutes) → [Everyday recipes](#everyday-recipes-for-researchers) |
|
|
33
|
+
| A **PhD student / data scientist** scripting analyses | [Python quickstart](#python-quickstart) → [Notebook & pandas recipes](#recipes-for-scripts-and-notebooks) |
|
|
34
|
+
| A **developer** integrating DAS | [Programmatic usage](#programmatic-usage-python) → [Manager API reference](#manager-layer-api-reference) → [`ONBOARDING.md`](ONBOARDING.md) |
|
|
35
|
+
| A **DAS administrator** | [Cache](#cache) · [Hangfire jobs](#hangfire-background-jobs) · [Elastic search](#elastic-search) |
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Table of contents
|
|
40
|
+
|
|
41
|
+
1. [Install](#install)
|
|
42
|
+
2. [Key concepts](#key-concepts) — attributes, entries, codes, digital objects
|
|
43
|
+
3. [Quickstart (5 minutes)](#quickstart-5-minutes)
|
|
44
|
+
4. [CLI reference](#cli-reference) — every command, with examples
|
|
45
|
+
- [Global options](#global-options) · [Authentication](#authentication) · [Search](#search)
|
|
46
|
+
- [Entries](#entries) · [Digital objects](#digital-objects) · [Downloads](#downloads)
|
|
47
|
+
- [Attributes](#attributes) · [Cache](#cache) · [Hangfire](#hangfire-background-jobs)
|
|
48
|
+
- [Elastic search](#elastic-search) · [Configuration](#configuration) · [AI assistant](#ai-assistant-optional)
|
|
49
|
+
5. [Search query syntax](#search-query-syntax)
|
|
50
|
+
6. [Input file formats (create / update)](#input-file-formats-create--update)
|
|
51
|
+
7. [Everyday recipes for researchers](#everyday-recipes-for-researchers)
|
|
52
|
+
8. [Programmatic usage (Python)](#programmatic-usage-python)
|
|
53
|
+
9. [Manager-layer API reference](#manager-layer-api-reference)
|
|
54
|
+
10. [Low-level client (`Das`) and services](#low-level-client-das-and-services)
|
|
55
|
+
11. [Error handling in Python](#error-handling-in-python)
|
|
56
|
+
12. [Recipes for scripts and notebooks](#recipes-for-scripts-and-notebooks)
|
|
57
|
+
13. [Configuration & environment variables](#configuration-and-environment-variables)
|
|
58
|
+
14. [Logging](#logging)
|
|
59
|
+
15. [Troubleshooting](#troubleshooting)
|
|
60
|
+
16. [Testing](#testing) · [Contributing](#contributing) · [License](#license)
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## Install
|
|
65
|
+
|
|
66
|
+
### Requirements
|
|
67
|
+
|
|
68
|
+
- Python **3.10 or newer** (3.13 recommended).
|
|
69
|
+
- Network access to your DAS instance (e.g. `https://api.das.nioz.nl`).
|
|
70
|
+
|
|
71
|
+
### From PyPI
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
pip install das-cli # core: CLI + Python library
|
|
75
|
+
pip install "das-cli[excel]" # + read .xlsx/.xls files (pandas, openpyxl)
|
|
76
|
+
pip install "das-cli[ai]" # + interactive AI assistant (semantic-kernel)
|
|
77
|
+
pip install "das-cli[excel,ai]" # everything
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Check it worked:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
das --version
|
|
84
|
+
das --help
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
> **Tip for researchers:** install into a virtual environment so it does not
|
|
88
|
+
> clash with other tools:
|
|
89
|
+
> `python -m venv .venv && source .venv/bin/activate` (macOS/Linux) or
|
|
90
|
+
> `.venv\Scripts\activate` (Windows), then `pip install das-cli`.
|
|
91
|
+
|
|
92
|
+
### From source (developers)
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
git clone https://git.nioz.nl/ict-projects/das-cli.git
|
|
96
|
+
cd das-cli
|
|
97
|
+
pip install -e ".[excel,ai]"
|
|
98
|
+
python -m das.cli --help # run without the `das` console script
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
See [`ONBOARDING.md`](ONBOARDING.md) for the architecture and contribution workflow.
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## Key concepts
|
|
106
|
+
|
|
107
|
+
DAS stores research metadata as **entries** grouped by **attributes**. Knowing
|
|
108
|
+
these five words makes every command below obvious.
|
|
109
|
+
|
|
110
|
+
| Concept | What it is | Example |
|
|
111
|
+
|---|---|---|
|
|
112
|
+
| **Attribute** | A *type* of record (think: a table). Has an id and a name. | `Cores`, `Cruise`, `Station`, `Event`, `Persons` |
|
|
113
|
+
| **Entry** | One record of an attribute, with dynamic **fields**. | Core `64PE428-02PC#01` |
|
|
114
|
+
| **Code** | Short, server-generated, human-friendly identifier of an entry. | `zb.b.1ub` |
|
|
115
|
+
| **ID** | GUID identifier of an entry. | `6b0e68e6-00cd-43a7-9c51-d56c9c091123` |
|
|
116
|
+
| **Field** | A column of an attribute. You use its **display name** (`"Start Depth"`); the tool maps it to the internal column (`startdepth`). | `Event`, `Comment` |
|
|
117
|
+
| **Digital object** | A file (dataset, image, document…) linked to one or more entries. Has its own code. | `h.b.ac0j` |
|
|
118
|
+
| **Download request** | An asynchronous job that bundles digital objects into a zip you download later. | `6b0e68e6-…` |
|
|
119
|
+
|
|
120
|
+
Relation/select fields (e.g. a Core's `Event`, a Cruise's `Project(s)`) accept
|
|
121
|
+
**codes, GUIDs or display names** — the tool resolves them for you.
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## Quickstart (5 minutes)
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
# 1. Log in once (the URL and credential are remembered)
|
|
129
|
+
das login --api-url https://your-das-instance --username your_user
|
|
130
|
+
# …or with an API key from the web UI (My Settings → API Keys)
|
|
131
|
+
das login --api-url https://your-das-instance --api-key <your-api-key>
|
|
132
|
+
|
|
133
|
+
# 2. Confirm who you are
|
|
134
|
+
das whoami
|
|
135
|
+
|
|
136
|
+
# 3. Find something
|
|
137
|
+
das search entries --attribute Cores --query "name(*64PE428*)" --max-results 5
|
|
138
|
+
|
|
139
|
+
# 4. Read one entry in full
|
|
140
|
+
das entry get --code zb.b.1ub
|
|
141
|
+
|
|
142
|
+
# 5. Download its files
|
|
143
|
+
das download request --entry zb.b.1ub --name "My first download"
|
|
144
|
+
das download my-requests
|
|
145
|
+
das download files <request-id> --out ./downloads
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
## CLI reference
|
|
151
|
+
|
|
152
|
+
Every command prints `--help`:
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
das --help
|
|
156
|
+
das entry --help
|
|
157
|
+
das entry update --help
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Command map
|
|
161
|
+
|
|
162
|
+
| Group | Command | Purpose |
|
|
163
|
+
|---|---|---|
|
|
164
|
+
| — | [`login`](#login) | Authenticate and store the credential |
|
|
165
|
+
| — | [`whoami`](#who-am-i) | Show which credential is used and whose it is |
|
|
166
|
+
| `oauth` | [`configure` · `status` · `clear`](#oauth--azure-entra) | Azure Entra (single sign-on) setup |
|
|
167
|
+
| `search` | [`entries` · `entry` · `help`](#search) | Find entries; read one by ID |
|
|
168
|
+
| `entry` | [`get` · `create` · `update` · `delete`](#entries) | Entry CRUD |
|
|
169
|
+
| `entry` | [`logs` · `chown`](#audit-logs-and-ownership) | Audit history, ownership transfer |
|
|
170
|
+
| `entry` | [`upload-digital-object` · `link-digital-objects` · `direct-download-digital-object`](#digital-objects) | Files attached to entries |
|
|
171
|
+
| `download` | [`request` · `my-requests` · `files` · `digital-object` · `delete-request`](#downloads) | Bulk download workflow |
|
|
172
|
+
| `attribute` | [`get` · `get-id` · `get-name`](#attributes) | Inspect attribute definitions |
|
|
173
|
+
| `cache` | [`list` · `clear` · `clear-all`](#cache) | Server cache management (admin) |
|
|
174
|
+
| `hangfire` | [`list` · `trigger` · `sync-doi`](#hangfire-background-jobs) | Background jobs (admin) |
|
|
175
|
+
| `elastic` | [`search-item`](#elastic-search) | Look up an indexed item by field/value |
|
|
176
|
+
| `config` | [`show` · `ssl-verify` · `ssl-status` · `log-level` · `log-file` · `reset`](#configuration) | Local settings |
|
|
177
|
+
| `ai` | [`enable` · `clear` · `logout`](#ai-assistant-optional) | Optional AI chat assistant |
|
|
178
|
+
|
|
179
|
+
### Global options
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
das --version # installed version
|
|
183
|
+
das --help # list groups and commands
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
> **Quoting.** Queries contain `*`, `(`, `)` and `;`, which shells interpret.
|
|
187
|
+
> Always wrap them in double quotes: `--query "name(*64*);code(zb.*)"`.
|
|
188
|
+
> For `--data`, wrap the whole JSON in double quotes and use single quotes
|
|
189
|
+
> inside: `--data "{ 'Comment': 'hello' }"`.
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
### Authentication
|
|
194
|
+
|
|
195
|
+
#### `login`
|
|
196
|
+
|
|
197
|
+
```text
|
|
198
|
+
das login --api-url URL [--username U] [--password P]
|
|
199
|
+
[--api-key KEY [--skip-verify]]
|
|
200
|
+
[--oauth [--debug]]
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
| Option | Meaning |
|
|
204
|
+
|---|---|
|
|
205
|
+
| `--api-url` | **Required.** Base URL of the DAS API. Saved for later commands. |
|
|
206
|
+
| `--username`, `--password` | Username/password login. Prompts (hidden) if omitted. |
|
|
207
|
+
| `--api-key` | Log in with a DAS API key (sent as `X-Api-Key`). |
|
|
208
|
+
| `--skip-verify` | With `--api-key`: save the key without contacting the server. |
|
|
209
|
+
| `--oauth` | Azure Entra single sign-on (opens your browser). |
|
|
210
|
+
| `--debug` | With `--oauth`: print decoded token claims for troubleshooting. |
|
|
211
|
+
|
|
212
|
+
**Username / password**
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
das login --api-url https://your-das-instance --username alovelace
|
|
216
|
+
# Password: ********
|
|
217
|
+
# ✓ Authentication successful!
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
**API key** — best for scripts, servers and CI. Generate it in the web UI under
|
|
221
|
+
**My Settings → API Keys**.
|
|
222
|
+
|
|
223
|
+
```bash
|
|
224
|
+
das login --api-url https://your-das-instance --api-key das_2702…fe84
|
|
225
|
+
# ✓ API key saved and verified.
|
|
226
|
+
# Authenticated as: alovelace (Ada Lovelace, ada@example.org)
|
|
227
|
+
|
|
228
|
+
das login --api-url https://your-das-instance --api-key das_2702…fe84 --skip-verify
|
|
229
|
+
# ✓ API key saved (not verified).
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
A key the server refuses (mistyped, revoked, expired, or for a different DAS
|
|
233
|
+
environment) is still saved — so nothing is lost if the URL was wrong — but
|
|
234
|
+
reported clearly (`❌ The server did not accept this API key.`). If the server
|
|
235
|
+
is unreachable the key is saved with a warning.
|
|
236
|
+
|
|
237
|
+
#### OAuth / Azure Entra
|
|
238
|
+
|
|
239
|
+
```bash
|
|
240
|
+
# One-time setup (values from your Azure app registration)
|
|
241
|
+
das oauth configure --client-id <client-id> \
|
|
242
|
+
--authority https://login.microsoftonline.com/<tenant>/v2.0 \
|
|
243
|
+
--scope "openid profile email offline_access"
|
|
244
|
+
|
|
245
|
+
das login --api-url https://your-das-instance --oauth # opens browser
|
|
246
|
+
das oauth status # client id, authority, token expiry
|
|
247
|
+
das oauth clear # forget OAuth config + refresh token
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
OAuth tokens are refreshed automatically when they expire.
|
|
251
|
+
|
|
252
|
+
#### Who am I?
|
|
253
|
+
|
|
254
|
+
`das whoami` answers two questions: **which** credential the CLI sends, and
|
|
255
|
+
**whose** it is according to the server.
|
|
256
|
+
|
|
257
|
+
```bash
|
|
258
|
+
das whoami # credential + server verdict
|
|
259
|
+
das whoami --offline # local info only, no server call
|
|
260
|
+
das whoami --format json # machine-readable (credential is masked)
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
```text
|
|
264
|
+
Current DAS credential
|
|
265
|
+
────────────────────────────────────────
|
|
266
|
+
API URL : https://your-das-instance
|
|
267
|
+
Auth type : api_key
|
|
268
|
+
Credential : das_2702…fe84
|
|
269
|
+
Source : DAS_API_KEY environment variable
|
|
270
|
+
Defined in : /home/ada/project/.env
|
|
271
|
+
⚠ DAS_API_KEY overrides the credential saved by 'das login' (eyJhbGci…zZt0).
|
|
272
|
+
|
|
273
|
+
Server
|
|
274
|
+
Status : ✓ credential accepted
|
|
275
|
+
User name : alovelace
|
|
276
|
+
Full name : Ada Lovelace
|
|
277
|
+
Email : ada@example.org
|
|
278
|
+
User ID : 42
|
|
279
|
+
Tenant : Default (id 1)
|
|
280
|
+
DAS version: 12.3.0.0
|
|
281
|
+
────────────────────────────────────────
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
**Credential precedence.** A `DAS_API_KEY` in your environment or `.env` file
|
|
285
|
+
**always wins** over whatever `das login` saved. That is the usual reason
|
|
286
|
+
commands run as someone else; `das whoami` and `das config show` name the
|
|
287
|
+
source and point at the `.env` file that defines it.
|
|
288
|
+
|
|
289
|
+
---
|
|
290
|
+
|
|
291
|
+
### Search
|
|
292
|
+
|
|
293
|
+
#### `search entries`
|
|
294
|
+
|
|
295
|
+
```text
|
|
296
|
+
das search entries --attribute NAME --query QUERY
|
|
297
|
+
[--max-results N=10] [--page N=1]
|
|
298
|
+
[--sort-by FIELD] [--sort-order asc|desc]
|
|
299
|
+
[--format table|json|compact] [--raw]
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
```bash
|
|
303
|
+
# Wildcard on a field
|
|
304
|
+
das search entries --attribute Cores --query "name(*64PE428*)"
|
|
305
|
+
|
|
306
|
+
# AND of two conditions, sorted, 25 per page, page 2
|
|
307
|
+
das search entries --attribute Cores --query "name(*64*);event(*PC*)" \
|
|
308
|
+
--sort-by Name --sort-order desc --max-results 25 --page 2
|
|
309
|
+
|
|
310
|
+
# Every station of a cruise, as JSON (pipe into jq, save to file…)
|
|
311
|
+
das search entries --attribute Station --query "cruise(64PE514)" --format json > stations.json
|
|
312
|
+
|
|
313
|
+
# One line per hit
|
|
314
|
+
das search entries --attribute Cruise --query "displayname(*64PE*)" --format compact
|
|
315
|
+
|
|
316
|
+
# All entries of an attribute (empty query)
|
|
317
|
+
das search entries --attribute Vessel --query "" --max-results 100
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
- `--sort-by` defaults to empty: the server decides the order. Not every
|
|
321
|
+
attribute has a `Name` field (e.g. `Cruise`); an unknown sort field returns
|
|
322
|
+
an error that lists the valid ones.
|
|
323
|
+
- Field names in queries and `--sort-by` are display names
|
|
324
|
+
(`"Start Depth"`) or internal columns (`startdepth`) — both work.
|
|
325
|
+
|
|
326
|
+
#### `search entry`
|
|
327
|
+
|
|
328
|
+
```bash
|
|
329
|
+
das search entry 6b0e68e6-00cd-43a7-9c51-d56c9c091123 # key/value table
|
|
330
|
+
das search entry 6b0e68e6-00cd-43a7-9c51-d56c9c091123 --format json
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
#### `search help`
|
|
334
|
+
|
|
335
|
+
```bash
|
|
336
|
+
das search help # prints the query syntax reference
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
See [Search query syntax](#search-query-syntax) for the full language.
|
|
340
|
+
|
|
341
|
+
---
|
|
342
|
+
|
|
343
|
+
### Entries
|
|
344
|
+
|
|
345
|
+
#### `entry get`
|
|
346
|
+
|
|
347
|
+
```bash
|
|
348
|
+
das entry get --code zb.b.1ub
|
|
349
|
+
das entry get --id 6b0e68e6-00cd-43a7-9c51-d56c9c091123
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
Fields are printed with their display names. Linked files are printed as a
|
|
353
|
+
**Digital Object(s)** block (ID, name, type, links).
|
|
354
|
+
|
|
355
|
+
#### `entry create`
|
|
356
|
+
|
|
357
|
+
```text
|
|
358
|
+
das entry create --attribute NAME (FILE | --data DATA)
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
```bash
|
|
362
|
+
# From a file — .json (list of objects), .csv or .xlsx/.xls (one row per entry)
|
|
363
|
+
das entry create --attribute Cores ./cores.json
|
|
364
|
+
das entry create --attribute Cores ./cores.csv
|
|
365
|
+
das entry create --attribute Cores ./cores.xlsx # needs das-cli[excel]
|
|
366
|
+
|
|
367
|
+
# A single entry inline
|
|
368
|
+
das entry create --attribute Cores \
|
|
369
|
+
--data "{ 'Alias': 'test.001', 'Event': '64PE428-02PC', 'Number': 1, 'Start Depth': 0, 'End Depth': 50 }"
|
|
370
|
+
|
|
371
|
+
# Several entries inline
|
|
372
|
+
das entry create --attribute Cores --data "[{ 'Alias': 'a1', 'Event': '64PE428-02PC' }, { 'Alias': 'a2', 'Event': '64PE428-02PC' }]"
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
Output reports the new IDs and, for bulk creates, one line per failed row:
|
|
376
|
+
|
|
377
|
+
```text
|
|
378
|
+
Found 3 entries to create
|
|
379
|
+
✓ Successfully created 2 entries
|
|
380
|
+
Created entry IDs:
|
|
381
|
+
1c9f…
|
|
382
|
+
77ab…
|
|
383
|
+
✗ Failed to create 1 entries
|
|
384
|
+
Failed creations:
|
|
385
|
+
Entry #3: HTTP 400 — Validation error: Event 'XYZ' not found
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
#### `entry update`
|
|
389
|
+
|
|
390
|
+
```text
|
|
391
|
+
das entry update [--id ID | --code CODE] (FILE | --data DATA) [--regenerate-name]
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
```bash
|
|
395
|
+
# One entry, by code or by id — send only the fields you change
|
|
396
|
+
das entry update --code zb.b.1ub --data "{ 'Comment': 'Re-measured 2026-11' }"
|
|
397
|
+
das entry update --id e1987f3e-7db7-11f0-a7e8-0edcca226f3d --data "{ 'Comment': 'Fixed' }"
|
|
398
|
+
|
|
399
|
+
# Id/Code inside the data is also accepted
|
|
400
|
+
das entry update --data "{ 'Code': 'zb.b.1ub', 'Comment': 'Fixed' }"
|
|
401
|
+
|
|
402
|
+
# Bulk — every row/object must contain a Code or Id column
|
|
403
|
+
das entry update ./corrections.xlsx
|
|
404
|
+
das entry update --data "[{ 'Code': 'zb.b.1', 'Comment': 'x' }, { 'Code': 'zb.b.2', 'Comment': 'y' }]"
|
|
405
|
+
|
|
406
|
+
# Rebuild auto-generated names after changing the fields they are built from
|
|
407
|
+
das entry update --code 4.b.rdg --data "{ 'Cast No.': '02' }" --regenerate-name
|
|
408
|
+
das entry update ./events.xlsx --regenerate-name
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
An auto-generated name (an Event is `<station>_<cast><device acronym>`) is
|
|
412
|
+
**kept as stored** on update, even when the update changes one of its inputs.
|
|
413
|
+
`--regenerate-name` asks the server to rebuild it. It applies to every row of a
|
|
414
|
+
bulk update, overrides a `Name` given in the data, and is ignored for
|
|
415
|
+
attributes whose name has no formula.
|
|
416
|
+
|
|
417
|
+
#### `entry delete`
|
|
418
|
+
|
|
419
|
+
```bash
|
|
420
|
+
das entry delete --code zb.b.1ub # asks for confirmation
|
|
421
|
+
das entry delete --id e1987f3e-… --force # no prompt (scripts)
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
#### Audit logs and ownership
|
|
425
|
+
|
|
426
|
+
```bash
|
|
427
|
+
# Who changed what, when
|
|
428
|
+
das entry logs --code zb.b.1ub
|
|
429
|
+
das entry logs --id d7b99f36-5ccb-11f0-87f3-a84a63c8db73 --max-results 50 --skip 50
|
|
430
|
+
das entry logs --code zb.b.1ub --format json
|
|
431
|
+
|
|
432
|
+
# Transfer ownership of one or more entries
|
|
433
|
+
das entry chown --user alice --code zb.b.1 --code zb.b.2
|
|
434
|
+
das entry chown --user alice -c zb.b.1 -c zb.b.2
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
---
|
|
438
|
+
|
|
439
|
+
### Digital objects
|
|
440
|
+
|
|
441
|
+
```bash
|
|
442
|
+
# Upload a file and link it to an entry (type = a Digital Object Type name)
|
|
443
|
+
das entry upload-digital-object --entry-code zb.b.f7 --type Dataset \
|
|
444
|
+
--description "CTD raw data, cast 2" ./ctd_cast2.zip
|
|
445
|
+
# ✓ Digital object uploaded and linked successfully!
|
|
446
|
+
# Digital Object ID: h.b.ac0j ← the new object's code
|
|
447
|
+
|
|
448
|
+
# Link existing digital objects (by code) to an entry
|
|
449
|
+
das entry link-digital-objects --entry-code 4d.b.1l -d h.b.ac0j -d h.b.ac0k
|
|
450
|
+
|
|
451
|
+
# Unlink
|
|
452
|
+
das entry link-digital-objects --entry-code 4d.b.1l -d h.b.ac0k --unlink
|
|
453
|
+
|
|
454
|
+
# Download one file straight from an entry (no download request needed)
|
|
455
|
+
das entry direct-download-digital-object --entry-code 4d.b.1l \
|
|
456
|
+
--digital-object-code h.b.ac0j --out ./downloads/
|
|
457
|
+
|
|
458
|
+
# …or by IDs (attribute id required with --entry-id)
|
|
459
|
+
das entry direct-download-digital-object --entry-id e1987f3e-… --attribute-id 126 \
|
|
460
|
+
--digital-object-id cf335b17-… --out ./downloads/file.bin
|
|
461
|
+
|
|
462
|
+
# Download a digital object by its own code or id
|
|
463
|
+
das download digital-object --digital-object-code h.b.8j2h --out ./downloads/
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
`--out` may be a directory (the server's file name is used) or a full file path.
|
|
467
|
+
|
|
468
|
+
---
|
|
469
|
+
|
|
470
|
+
### Downloads
|
|
471
|
+
|
|
472
|
+
Large or multi-entry downloads are **asynchronous**: you create a request, the
|
|
473
|
+
server bundles the files (possibly after owner approval), then you download
|
|
474
|
+
the zip.
|
|
475
|
+
|
|
476
|
+
```text
|
|
477
|
+
request ─► Enqueued ─► (Approval Requested ─► Waiting For Approval ─► Approved | Declined)
|
|
478
|
+
─► Handle Files To Be Delivered ─► Compacting Bundle ─► Completed | Incomplete
|
|
479
|
+
(or Failed at any point)
|
|
480
|
+
Completed ─► das download files <id>
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
```bash
|
|
484
|
+
# All files of one entry
|
|
485
|
+
das download request --entry zb.b.lu --name "Core photos"
|
|
486
|
+
|
|
487
|
+
# Selected files (digital-object codes) of one entry
|
|
488
|
+
das download request --entry zb.b.dc --file h.b.z0pg --file h.b.s3pg
|
|
489
|
+
|
|
490
|
+
# Several entries; each --file belongs to the --entry before it
|
|
491
|
+
das download request -e zb.b.dc -f h.b.z0pg -e zb.b.lu --name "Mixed"
|
|
492
|
+
|
|
493
|
+
# From a JSON spec: { "name": "...", "<entry code>": ["<file code>", ...] | [] }
|
|
494
|
+
das download request --entry ignored --from-file request.json
|
|
495
|
+
|
|
496
|
+
# JSON output (just the request id)
|
|
497
|
+
das download request --entry zb.b.lu --format json
|
|
498
|
+
|
|
499
|
+
# Follow your requests (status per request and per file)
|
|
500
|
+
das download my-requests
|
|
501
|
+
das download my-requests --format json
|
|
502
|
+
|
|
503
|
+
# Save the finished bundle
|
|
504
|
+
das download files 6b0e68e6-00cd-43a7-9c51-d56c9c091123 # current dir
|
|
505
|
+
das download files 6b0e68e6-00cd-43a7-9c51-d56c9c091123 --out ./downloads
|
|
506
|
+
das download files 6b0e68e6-00cd-43a7-9c51-d56c9c091123 --out ./b.zip --force # overwrite
|
|
507
|
+
|
|
508
|
+
# Clean up
|
|
509
|
+
das download delete-request 6b0e68e6-00cd-43a7-9c51-d56c9c091123
|
|
510
|
+
```
|
|
511
|
+
|
|
512
|
+
Example `request.json`:
|
|
513
|
+
|
|
514
|
+
```json
|
|
515
|
+
{
|
|
516
|
+
"name": "Cruise 64PE514 data",
|
|
517
|
+
"zb.b.dc": ["h.b.z0pg", "h.b.s3pg"],
|
|
518
|
+
"zb.b.lu": []
|
|
519
|
+
}
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
> `--entry` is a required option even with `--from-file`; its value is ignored
|
|
523
|
+
> when a file is given.
|
|
524
|
+
|
|
525
|
+
---
|
|
526
|
+
|
|
527
|
+
### Attributes
|
|
528
|
+
|
|
529
|
+
```bash
|
|
530
|
+
das attribute get --name Cores # full definition (id, alias, table, index…)
|
|
531
|
+
das attribute get --id 126
|
|
532
|
+
das attribute get --alias core
|
|
533
|
+
das attribute get --table-name cores
|
|
534
|
+
das attribute get-id Cores # → 126
|
|
535
|
+
das attribute get-name 126 # → Cores
|
|
536
|
+
```
|
|
537
|
+
|
|
538
|
+
### Cache
|
|
539
|
+
|
|
540
|
+
Server-side cache management (requires the corresponding admin permission).
|
|
541
|
+
|
|
542
|
+
```bash
|
|
543
|
+
das cache list # names of all caches
|
|
544
|
+
das cache clear "attributes" # one cache
|
|
545
|
+
das cache clear-all # everything
|
|
546
|
+
```
|
|
547
|
+
|
|
548
|
+
### Hangfire background jobs
|
|
549
|
+
|
|
550
|
+
Long-running backend work (imports, downloads, DOI sync, harvests) runs as
|
|
551
|
+
Hangfire jobs on the DAS worker. Needs the **Hangfire dashboard** permission
|
|
552
|
+
(`Pages.Administration.HangfireDashboard`).
|
|
553
|
+
|
|
554
|
+
```bash
|
|
555
|
+
das hangfire list # ID, cron, queue, next/last run (UTC), last state
|
|
556
|
+
das hangfire list --format json
|
|
557
|
+
das hangfire trigger "5. harvest-archive" # run now; schedule unchanged (quote IDs with spaces)
|
|
558
|
+
das hangfire trigger "system health check" # IDs are matched case-insensitively
|
|
559
|
+
das hangfire sync-doi <entry-id> # (re)process the DOI of one entry
|
|
560
|
+
```
|
|
561
|
+
|
|
562
|
+
An unknown ID prints the list of valid IDs.
|
|
563
|
+
|
|
564
|
+
### Elastic search
|
|
565
|
+
|
|
566
|
+
Look up a single indexed item in the data portal index by field and value:
|
|
567
|
+
|
|
568
|
+
```bash
|
|
569
|
+
das elastic search-item --field identifier --value 10.25850/nioz/7b.b.xy
|
|
570
|
+
das elastic search-item --field identifier --value 10.25850/nioz/7b.b.xy --format json
|
|
571
|
+
das elastic search-item --field code --value zb.b.1ub --format compact
|
|
572
|
+
```
|
|
573
|
+
|
|
574
|
+
### Configuration
|
|
575
|
+
|
|
576
|
+
Settings are stored in `config.json` under the OS config directory
|
|
577
|
+
(`%APPDATA%\Data-Archive-System\` on Windows,
|
|
578
|
+
`$XDG_CONFIG_HOME/Data-Archive-System/` or `~/.config/Data-Archive-System/` on
|
|
579
|
+
macOS/Linux). Credentials go to the OS keyring when available.
|
|
580
|
+
|
|
581
|
+
```bash
|
|
582
|
+
das config show # URL, SSL, logging, auth source, OAuth, AI key (all masked)
|
|
583
|
+
das config ssl-verify false # disable TLS verification (dev servers only!)
|
|
584
|
+
das config ssl-verify true
|
|
585
|
+
das config ssl-status
|
|
586
|
+
das config log-level DEBUG # TRACE, DEBUG, INFO, WARN (default), ERROR, FATAL
|
|
587
|
+
das config log-file ./das.log # also log to a file
|
|
588
|
+
das config log-file --clear # console only
|
|
589
|
+
das config reset # remove ALL saved settings and credentials (asks first)
|
|
590
|
+
das config reset --force
|
|
591
|
+
```
|
|
592
|
+
|
|
593
|
+
### AI assistant (optional)
|
|
594
|
+
|
|
595
|
+
An interactive chat assistant that can look up DAS entries for you. Requires
|
|
596
|
+
`pip install "das-cli[ai]"` and an OpenAI API key.
|
|
597
|
+
|
|
598
|
+
```bash
|
|
599
|
+
export OPEN_AI_MODEL_ID=gpt-4o-mini # model to use
|
|
600
|
+
das ai enable # prompts for the OpenAI key once, then starts a chat
|
|
601
|
+
# User > what is the event of core zb.b.1ub?
|
|
602
|
+
# Assistant > …
|
|
603
|
+
# User > exit
|
|
604
|
+
das ai clear # forget the OpenAI key and DAS token (alias: das ai logout)
|
|
605
|
+
```
|
|
606
|
+
|
|
607
|
+
---
|
|
608
|
+
|
|
609
|
+
## Search query syntax
|
|
610
|
+
|
|
611
|
+
```text
|
|
612
|
+
field(value) one condition
|
|
613
|
+
field(value);field2(value2) AND — all conditions must match
|
|
614
|
+
cond1 or cond2 OR
|
|
615
|
+
```
|
|
616
|
+
|
|
617
|
+
| Pattern | Meaning | Example |
|
|
618
|
+
|---|---|---|
|
|
619
|
+
| `field(value)` | exact match | `code(zb.b.1ub)` |
|
|
620
|
+
| `field(*text*)` | contains | `name(*64PE*)` |
|
|
621
|
+
| `field(text*)` / `field(*text)` | starts / ends with | `name(64PE428*)` |
|
|
622
|
+
| `field(>value)` / `field(<value)` | greater / less than (dates, numbers) | `Create at(>2023-01-01)` |
|
|
623
|
+
| `a(x);b(y)` | AND | `name(*64*);event(*PC*)` |
|
|
624
|
+
| `a(x) or b(y)` | OR | `name(64PE320-03BC#01) or code(zb.b.1ub)` |
|
|
625
|
+
| `displayname(...)` | the entry's display name (available on every attribute) | `displayname(*64PE514*)` |
|
|
626
|
+
| `""` (empty) | everything | `--query ""` |
|
|
627
|
+
|
|
628
|
+
Field names are **display names** (as shown in the web UI and `das entry get`)
|
|
629
|
+
or internal **column** names; matching is case-insensitive. Fields inside group
|
|
630
|
+
boxes are resolved too.
|
|
631
|
+
|
|
632
|
+
---
|
|
633
|
+
|
|
634
|
+
## Input file formats (create / update)
|
|
635
|
+
|
|
636
|
+
| Format | Shape | Notes |
|
|
637
|
+
|---|---|---|
|
|
638
|
+
| `.json` | a list of objects (or one object) | `[{ "Alias": "a1", "Event": "64PE428-02PC" }]` |
|
|
639
|
+
| `.csv` | header row = field names, one row per entry | UTF-8 |
|
|
640
|
+
| `.xlsx` / `.xls` | first sheet, header row = field names | needs `das-cli[excel]` |
|
|
641
|
+
| `--data` | JSON-ish string | single quotes allowed; `Yes`/`No` become `true`/`false` |
|
|
642
|
+
|
|
643
|
+
Rules that apply to every format:
|
|
644
|
+
|
|
645
|
+
- Keys are field **display names** or **columns**, case-insensitive.
|
|
646
|
+
- **Update** rows must contain `Code` or `Id`; only the given fields change.
|
|
647
|
+
- **Select / relation** fields accept a code, GUID or display name; multiple
|
|
648
|
+
values are comma-separated: `"Project(s)": "3d.b.q,3d.b.r"`.
|
|
649
|
+
- Numbers from Excel are cleaned (`3.0` → `"3"`).
|
|
650
|
+
- ⚠ **A column that is present but empty clears that field** on update. Only
|
|
651
|
+
include the columns you actually want to change.
|
|
652
|
+
- Auto-generated fields (e.g. `Name` with a formula) are filled by the server.
|
|
653
|
+
|
|
654
|
+
Example CSV for a bulk update:
|
|
655
|
+
|
|
656
|
+
```csv
|
|
657
|
+
Code,Comment,Start Depth
|
|
658
|
+
zb.b.1ub,Re-measured,12
|
|
659
|
+
zb.b.1uc,Re-measured,15
|
|
660
|
+
```
|
|
661
|
+
|
|
662
|
+
More examples: [`ENTRY_COMMANDS.md`](ENTRY_COMMANDS.md).
|
|
663
|
+
|
|
664
|
+
---
|
|
665
|
+
|
|
666
|
+
## Everyday recipes for researchers
|
|
667
|
+
|
|
668
|
+
**Find all cores of a cruise and save them as JSON**
|
|
669
|
+
|
|
670
|
+
```bash
|
|
671
|
+
das search entries --attribute Cores --query "event(*64PE514*)" --max-results 500 --format json > cores_64PE514.json
|
|
672
|
+
```
|
|
673
|
+
|
|
674
|
+
**Check what changed on an entry and who changed it**
|
|
675
|
+
|
|
676
|
+
```bash
|
|
677
|
+
das entry logs --code zb.b.1ub --max-results 20
|
|
678
|
+
```
|
|
679
|
+
|
|
680
|
+
**Attach a processed dataset to the station it belongs to**
|
|
681
|
+
|
|
682
|
+
```bash
|
|
683
|
+
das entry upload-digital-object --entry-code 7b.b.12 --type Dataset \
|
|
684
|
+
--description "Processed CTD profile v2" ./ctd_profile_v2.nc
|
|
685
|
+
```
|
|
686
|
+
|
|
687
|
+
**Fix a typo in 200 entries at once**
|
|
688
|
+
|
|
689
|
+
1. Prepare a spreadsheet with a `Code` column plus **only** the columns to
|
|
690
|
+
change (use `das search entries … --format json` to collect the codes).
|
|
691
|
+
2. `das entry update ./fixes.xlsx`
|
|
692
|
+
3. Read the summary; failed rows are listed with the reason.
|
|
693
|
+
|
|
694
|
+
**Get all files of three cores in one zip**
|
|
695
|
+
|
|
696
|
+
```bash
|
|
697
|
+
das download request -e zb.b.1ub -e zb.b.1uc -e zb.b.1ud --name "Cores for paper"
|
|
698
|
+
das download my-requests # wait until status is "Completed"
|
|
699
|
+
das download files <request-id> --out ~/Downloads
|
|
700
|
+
```
|
|
701
|
+
|
|
702
|
+
**Hand your entries over to a colleague before leaving**
|
|
703
|
+
|
|
704
|
+
```bash
|
|
705
|
+
das entry chown --user colleague -c zb.b.1ub -c zb.b.1uc
|
|
706
|
+
```
|
|
707
|
+
|
|
708
|
+
---
|
|
709
|
+
|
|
710
|
+
## Programmatic usage (Python)
|
|
711
|
+
|
|
712
|
+
The Python API has two levels:
|
|
713
|
+
|
|
714
|
+
| Level | Import | Use it for |
|
|
715
|
+
|---|---|---|
|
|
716
|
+
| **Managers** (recommended) | `das.managers.*` | Domain operations with friendly field names: search, get/create/update entries, uploads, downloads. |
|
|
717
|
+
| **Client + services** | `das.app.Das` | Authentication, `whoami`, and direct access to the raw API services (attributes, cache, hangfire, elastic…). |
|
|
718
|
+
|
|
719
|
+
### Python quickstart
|
|
720
|
+
|
|
721
|
+
```python
|
|
722
|
+
from das.app import Das
|
|
723
|
+
from das.managers.search_manager import SearchManager
|
|
724
|
+
from das.managers.entries_manager import EntryManager
|
|
725
|
+
|
|
726
|
+
Das("https://your-das-instance").set_api_key("das_...") # once per machine
|
|
727
|
+
|
|
728
|
+
search = SearchManager()
|
|
729
|
+
hits = search.search_entries(attribute="Cores", query="name(*64PE428*)", max_results=5)
|
|
730
|
+
for core in hits["items"]:
|
|
731
|
+
print(core["Name"], core.get("Start Depth"), core.get("End Depth"))
|
|
732
|
+
|
|
733
|
+
core = EntryManager().get(code="zb.b.1ub")
|
|
734
|
+
print(core["Name"], core["Digital Object(s)"])
|
|
735
|
+
```
|
|
736
|
+
|
|
737
|
+
### Pattern A — log in once with the CLI, then use managers
|
|
738
|
+
|
|
739
|
+
The managers read the URL and credential stored by `das login`:
|
|
740
|
+
|
|
741
|
+
```python
|
|
742
|
+
from das.managers.entries_manager import EntryManager
|
|
743
|
+
from das.managers.search_manager import SearchManager
|
|
744
|
+
|
|
745
|
+
entries = EntryManager()
|
|
746
|
+
search = SearchManager()
|
|
747
|
+
|
|
748
|
+
core = entries.get(code="zb.b.1ub")
|
|
749
|
+
results = search.search_entries(attribute="Cores", query="name(*64*)", max_results=5)
|
|
750
|
+
```
|
|
751
|
+
|
|
752
|
+
### Pattern B — authenticate in Python with `Das`
|
|
753
|
+
|
|
754
|
+
```python
|
|
755
|
+
from das.app import Das
|
|
756
|
+
from das.managers.entries_manager import EntryManager
|
|
757
|
+
|
|
758
|
+
client = Das("https://your-das-instance")
|
|
759
|
+
|
|
760
|
+
# Username / password
|
|
761
|
+
client.authenticate("your_user", "your_password")
|
|
762
|
+
|
|
763
|
+
# …or API key; validate=True returns the user dict (None if refused)
|
|
764
|
+
user = client.set_api_key("das_...", validate=True)
|
|
765
|
+
if user is None:
|
|
766
|
+
raise SystemExit("The server did not accept this API key.")
|
|
767
|
+
|
|
768
|
+
entry = EntryManager().get(code="zb.b.1ub")
|
|
769
|
+
```
|
|
770
|
+
|
|
771
|
+
### Pattern C — environment only (CI, servers, notebooks on shared machines)
|
|
772
|
+
|
|
773
|
+
```bash
|
|
774
|
+
# .env in the working directory, or real environment variables
|
|
775
|
+
DAS_API_URL=https://your-das-instance
|
|
776
|
+
DAS_API_KEY=das_...
|
|
777
|
+
```
|
|
778
|
+
|
|
779
|
+
```python
|
|
780
|
+
from das.managers.search_manager import SearchManager
|
|
781
|
+
SearchManager().search_entries(attribute="Cruise", query="", max_results=3)
|
|
782
|
+
```
|
|
783
|
+
|
|
784
|
+
> Managers resolve the base URL at construction (`DAS_API_URL`, else the saved
|
|
785
|
+
> one) and raise `ValueError` when none is configured. Create them **after**
|
|
786
|
+
> logging in.
|
|
787
|
+
|
|
788
|
+
### Checking the active credential
|
|
789
|
+
|
|
790
|
+
```python
|
|
791
|
+
from das.app import Das
|
|
792
|
+
|
|
793
|
+
info = Das().whoami() # Das() reuses the saved URL
|
|
794
|
+
print(info["status"]) # 'valid' | 'invalid' | 'no-credential' | 'unreachable'
|
|
795
|
+
print(info["source"]) # 'env' (DAS_API_KEY) | 'keyring' | 'file'
|
|
796
|
+
print(info["masked"]) # 'das_2702…fe84' — never the raw credential
|
|
797
|
+
if info["status"] == "valid":
|
|
798
|
+
print(info["user"]["userName"], info["user"]["emailAddress"])
|
|
799
|
+
|
|
800
|
+
Das().whoami(verify=False) # local only → status 'unverified'
|
|
801
|
+
```
|
|
802
|
+
|
|
803
|
+
---
|
|
804
|
+
|
|
805
|
+
## Manager-layer API reference
|
|
806
|
+
|
|
807
|
+
All managers:
|
|
808
|
+
|
|
809
|
+
- are constructed without arguments and read URL + credential from config;
|
|
810
|
+
- accept **display names or columns** for fields;
|
|
811
|
+
- raise `ValueError` (or a [`DasApiError`](#error-handling-in-python)
|
|
812
|
+
subclass, which *is* a `ValueError`) with a readable message.
|
|
813
|
+
|
|
814
|
+
### `EntryManager`
|
|
815
|
+
|
|
816
|
+
```python
|
|
817
|
+
from das.managers.entries_manager import EntryManager
|
|
818
|
+
entries = EntryManager()
|
|
819
|
+
```
|
|
820
|
+
|
|
821
|
+
| Method | Returns |
|
|
822
|
+
|---|---|
|
|
823
|
+
| `get(id=None, code=None)` | `dict` — fields by display name, plus `ID`, `attributeId`, `Created At`, `Updated At`, `Digital Object(s)` |
|
|
824
|
+
| `get_entry(entry_id)` | same as `get(id=entry_id)` |
|
|
825
|
+
| `create(attribute, entry=None, entries=None, fetch_code=True)` | `list[dict]` — `{"id", "code", "status"}` (single) / `{"id", "status"}` or `{"error", "status"}` (bulk) |
|
|
826
|
+
| `update(id=None, code=None, entry=None, entries=None, regenerate_name=False)` | `list[dict]` — `{"code", "id", "status"}` or `{"code", "error", "status"}` |
|
|
827
|
+
| `delete(id=None, code=None)` | `bool` |
|
|
828
|
+
| `create_from_file(attribute, file_path)` | `None` — `.json`, `.csv`, `.xlsx` |
|
|
829
|
+
| `warm_select_cache(attribute, max_results=1000, page_size=1000)` | `int` — options cached |
|
|
830
|
+
| `chown(user_name, entry_code_list)` | API result |
|
|
831
|
+
| `get_entry_logs(entry_id=None, entry_code=None, sorting="", max_result_count=100, skip_count=0)` | `dict` with `totalCount`, `items` |
|
|
832
|
+
| `get_direct_relations(entry_code=None, entry_id=None, query_string="", sorting="", max_result_count=100, skip_count=0)` | `dict` with `items` |
|
|
833
|
+
|
|
834
|
+
#### `get` — fetch one entry
|
|
835
|
+
|
|
836
|
+
```python
|
|
837
|
+
entry = entries.get(code="zb.b.1ub")
|
|
838
|
+
print(entry["Name"], entry["ID"], entry["attributeId"])
|
|
839
|
+
|
|
840
|
+
entry = entries.get(id="6b0e68e6-00cd-43a7-9c51-d56c9c091123")
|
|
841
|
+
entry = entries.get_entry("6b0e68e6-00cd-43a7-9c51-d56c9c091123") # alias
|
|
842
|
+
```
|
|
843
|
+
|
|
844
|
+
Digital objects are always under the single key `"Digital Object(s)"`, whatever
|
|
845
|
+
the attribute calls its file field (Persons calls it *Files*):
|
|
846
|
+
|
|
847
|
+
```python
|
|
848
|
+
for obj in entry.get("Digital Object(s)", []):
|
|
849
|
+
print(obj["Id"], obj["Name"], obj["Type"], obj["Links"])
|
|
850
|
+
# 1715e27d-… zeynep.erdem.jpg Image 4d.b.cb
|
|
851
|
+
```
|
|
852
|
+
|
|
853
|
+
#### `create` — one or many entries
|
|
854
|
+
|
|
855
|
+
```python
|
|
856
|
+
# Single — returns the server-generated code (costs one extra request)
|
|
857
|
+
result = entries.create(attribute="Cores", entry={
|
|
858
|
+
"Alias": "test.entry.001",
|
|
859
|
+
"Event": "64PE428-02PC", # select field: code, GUID or display name
|
|
860
|
+
"Number": 1,
|
|
861
|
+
"Start Depth": 576,
|
|
862
|
+
"End Depth": 600,
|
|
863
|
+
"Comment": "Created from Python",
|
|
864
|
+
})
|
|
865
|
+
# [{"id": "<guid>", "code": "zb.b.xxx", "status": "success"}]
|
|
866
|
+
|
|
867
|
+
# Skip the code read-back when you only need ids (imports)
|
|
868
|
+
entries.create(attribute="Cores", entry={...}, fetch_code=False)
|
|
869
|
+
# [{"id": "<guid>", "status": "success"}]
|
|
870
|
+
|
|
871
|
+
# Bulk — never raises per row; inspect each result
|
|
872
|
+
results = entries.create(attribute="Cores", entries=[
|
|
873
|
+
{"Alias": "bulk.001", "Event": "64PE428-02PC", "Number": 1},
|
|
874
|
+
{"Alias": "bulk.002", "Event": "64PE428-02PC", "Number": 2},
|
|
875
|
+
])
|
|
876
|
+
failed = [r for r in results if r["status"] == "error"]
|
|
877
|
+
|
|
878
|
+
# Multi-value relation (comma-separated codes or GUIDs)
|
|
879
|
+
entries.create(attribute="Cruise", entry={
|
|
880
|
+
"Cruise Code": "TEST-Cruise-001",
|
|
881
|
+
"Project(s)": "3d.b.q,3d.b.r",
|
|
882
|
+
"Vessel": "Algoa",
|
|
883
|
+
"Start Date": "2026-01-01",
|
|
884
|
+
"End Date": "2026-01-02",
|
|
885
|
+
})
|
|
886
|
+
```
|
|
887
|
+
|
|
888
|
+
#### `warm_select_cache` — speed up big imports
|
|
889
|
+
|
|
890
|
+
Each distinct select value (`"Event": "64PE428-02PC"`) normally costs one
|
|
891
|
+
search request the first time it is seen. Warm the cache once per attribute:
|
|
892
|
+
|
|
893
|
+
```python
|
|
894
|
+
entries = EntryManager()
|
|
895
|
+
print(entries.warm_select_cache("Event"), "select options cached")
|
|
896
|
+
for row in rows:
|
|
897
|
+
entries.create(attribute="Event", entry=row, fetch_code=False) # 1 request per row
|
|
898
|
+
```
|
|
899
|
+
|
|
900
|
+
Values must match the server's spelling/case; anything else falls back to a
|
|
901
|
+
search. The cache lives as long as the manager instance.
|
|
902
|
+
|
|
903
|
+
#### `update` — partial updates
|
|
904
|
+
|
|
905
|
+
```python
|
|
906
|
+
entries.update(code="zb.b.0", entry={"Number": 2, "Comment": "Updated from Python"})
|
|
907
|
+
entries.update(id="c4c6dff6-5ccb-11f0-a78d-a84a63c8db73", entry={"Description": "New text"})
|
|
908
|
+
|
|
909
|
+
# Bulk — each item carries its own Code or Id
|
|
910
|
+
entries.update(entries=[
|
|
911
|
+
{"Code": "ENT001", "Comment": "Updated 1"},
|
|
912
|
+
{"Code": "ENT002", "Comment": "Updated 2"},
|
|
913
|
+
])
|
|
914
|
+
|
|
915
|
+
# Rebuild the auto-generated name from the updated values
|
|
916
|
+
entries.update(code="4.b.rdg", entry={"Cast No.": "02"}, regenerate_name=True)
|
|
917
|
+
```
|
|
918
|
+
|
|
919
|
+
#### `delete`
|
|
920
|
+
|
|
921
|
+
```python
|
|
922
|
+
entries.delete(id="6b0e68e6-00cd-43a7-9c51-d56c9c091123") # → True
|
|
923
|
+
entries.delete(code="zb.b.1ub") # → True
|
|
924
|
+
```
|
|
925
|
+
|
|
926
|
+
#### `create_from_file`
|
|
927
|
+
|
|
928
|
+
```python
|
|
929
|
+
entries.create_from_file(attribute="Cores", file_path="cores.json") # list of objects
|
|
930
|
+
entries.create_from_file(attribute="Cores", file_path="cores.csv")
|
|
931
|
+
entries.create_from_file(attribute="Cores", file_path="cores.xlsx") # needs [excel]
|
|
932
|
+
```
|
|
933
|
+
|
|
934
|
+
> Stops at the first failing row. For per-row results load the file yourself
|
|
935
|
+
> (`das.common.file_utils.load_file_based_on_extension`) and call
|
|
936
|
+
> `create(entries=rows)`.
|
|
937
|
+
|
|
938
|
+
#### `chown`, `get_entry_logs`, `get_direct_relations`
|
|
939
|
+
|
|
940
|
+
```python
|
|
941
|
+
entries.chown(user_name="alice", entry_code_list=["ENT001", "ENT002"])
|
|
942
|
+
|
|
943
|
+
logs = entries.get_entry_logs(entry_code="ENT001", max_result_count=50, skip_count=0)
|
|
944
|
+
for log in logs["items"]:
|
|
945
|
+
print(log["logDateTime"], log["fieldName"], log["valueFrom"], "→", log["valueTo"], log["modifierUserName"])
|
|
946
|
+
|
|
947
|
+
relations = entries.get_direct_relations(entry_code="6.b.sy")
|
|
948
|
+
for rel in relations["items"]:
|
|
949
|
+
print(rel["id"], rel.get("displayname"))
|
|
950
|
+
```
|
|
951
|
+
|
|
952
|
+
---
|
|
953
|
+
|
|
954
|
+
### `SearchManager`
|
|
955
|
+
|
|
956
|
+
```python
|
|
957
|
+
from das.managers.search_manager import SearchManager
|
|
958
|
+
search = SearchManager()
|
|
959
|
+
```
|
|
960
|
+
|
|
961
|
+
| Method | Returns |
|
|
962
|
+
|---|---|
|
|
963
|
+
| `search_entries(attribute, query, max_results=10, page=1, sort_by="", sort_order="asc", includeRelationsId=False)` | `{"items": [dict by display name], "totalCount": int}` |
|
|
964
|
+
|
|
965
|
+
```python
|
|
966
|
+
# Basic
|
|
967
|
+
res = search.search_entries(attribute="Cores", query="name(*64*)", max_results=10, page=1)
|
|
968
|
+
print(res["totalCount"])
|
|
969
|
+
for item in res["items"]:
|
|
970
|
+
print(item.get("Name"), item.get("Event"))
|
|
971
|
+
|
|
972
|
+
# OR, sorted
|
|
973
|
+
search.search_entries(attribute="Cores", query="name(64PE320-03BC#01) or code(zb.b.1ub)",
|
|
974
|
+
sort_by="Name", sort_order="asc")
|
|
975
|
+
|
|
976
|
+
# Stations of a cruise
|
|
977
|
+
search.search_entries(attribute="Station", query="Cruise(64PE514)", sort_by="Code")
|
|
978
|
+
|
|
979
|
+
# Everything, paged
|
|
980
|
+
def iter_all(attribute, query="", page_size=200):
|
|
981
|
+
page = 1
|
|
982
|
+
while True:
|
|
983
|
+
res = search.search_entries(attribute=attribute, query=query, max_results=page_size, page=page)
|
|
984
|
+
yield from res["items"]
|
|
985
|
+
if page * page_size >= res["totalCount"]:
|
|
986
|
+
break
|
|
987
|
+
page += 1
|
|
988
|
+
|
|
989
|
+
all_cruises = list(iter_all("Cruise"))
|
|
990
|
+
```
|
|
991
|
+
|
|
992
|
+
---
|
|
993
|
+
|
|
994
|
+
### `DownloadManager`
|
|
995
|
+
|
|
996
|
+
```python
|
|
997
|
+
from das.managers.download_manager import DownloadManager
|
|
998
|
+
downloads = DownloadManager()
|
|
999
|
+
```
|
|
1000
|
+
|
|
1001
|
+
| Method | Returns |
|
|
1002
|
+
|---|---|
|
|
1003
|
+
| `create_download_request(request_data)` | request id (`str`) or `{"errors": [...]}` |
|
|
1004
|
+
| `get_my_requests()` | `{"totalCount", "items"}` |
|
|
1005
|
+
| `delete_download_request(request_id)` | API result |
|
|
1006
|
+
| `download_files(request_id)` | streaming `requests.Response` |
|
|
1007
|
+
| `save_download(request_id, output_path, overwrite=False)` | `str` — saved path (raises `FileExistsError`) |
|
|
1008
|
+
|
|
1009
|
+
`request_data` maps **entry codes → lists of digital-object codes** (empty list
|
|
1010
|
+
= all files), plus an optional `name`.
|
|
1011
|
+
|
|
1012
|
+
```python
|
|
1013
|
+
request_id = downloads.create_download_request({
|
|
1014
|
+
"name": "Mixed download",
|
|
1015
|
+
"zb.b.dc": ["h.b.z0pg", "h.b.s3pg"], # selected files
|
|
1016
|
+
"zb.b.lu": [], # all files
|
|
1017
|
+
})
|
|
1018
|
+
if isinstance(request_id, dict): # validation problems
|
|
1019
|
+
raise SystemExit("\n".join(request_id["errors"]))
|
|
1020
|
+
|
|
1021
|
+
from das.common.enums import DownloadRequestStatus
|
|
1022
|
+
import time
|
|
1023
|
+
while True:
|
|
1024
|
+
req = next(r for r in downloads.get_my_requests()["items"] if r["id"] == request_id)
|
|
1025
|
+
status = DownloadRequestStatus(req["status"])
|
|
1026
|
+
if status in (DownloadRequestStatus.COMPLETED, DownloadRequestStatus.INCOMPLETE,
|
|
1027
|
+
DownloadRequestStatus.DECLINED, DownloadRequestStatus.FAILED):
|
|
1028
|
+
break
|
|
1029
|
+
time.sleep(10)
|
|
1030
|
+
|
|
1031
|
+
path = downloads.save_download(request_id, output_path="./downloads", overwrite=True)
|
|
1032
|
+
downloads.delete_download_request(request_id)
|
|
1033
|
+
```
|
|
1034
|
+
|
|
1035
|
+
---
|
|
1036
|
+
|
|
1037
|
+
### `DigitalObjectsManager`
|
|
1038
|
+
|
|
1039
|
+
```python
|
|
1040
|
+
from das.managers.digital_objects_manager import DigitalObjectsManager
|
|
1041
|
+
dobj = DigitalObjectsManager()
|
|
1042
|
+
```
|
|
1043
|
+
|
|
1044
|
+
| Method | Returns |
|
|
1045
|
+
|---|---|
|
|
1046
|
+
| `upload_digital_object(entry_code, file_description, digital_object_type, file_path)` | `str` — **code** of the new digital object (uploaded **and** linked) |
|
|
1047
|
+
| `upload_file(file_description, digital_object_type, file_path)` | `str` — code (uploaded, not linked) |
|
|
1048
|
+
| `upload_file_raw(file_description, digital_object_type, file_path)` | `dict` — raw upload result incl. `id` |
|
|
1049
|
+
| `link_existing_digital_objects(entry_code, digital_object_code_list, is_unlink=False)` | `bool` |
|
|
1050
|
+
| `link_digital_objects_by_id(entry_code, digital_object_id_list, is_unlink=False)` | `bool` |
|
|
1051
|
+
| `link_to_entry(entry_code, digital_object_codes)` | `None` |
|
|
1052
|
+
| `download_digital_object(output_path, digital_object_id=None, digital_object_code=None)` | `str` — saved path |
|
|
1053
|
+
| `direct_download_digital_object(entry_code=None, entry_id=None, attribute_id=None, digital_object_id=None, digital_object_code=None, output_path=None)` | `str` — saved path |
|
|
1054
|
+
|
|
1055
|
+
```python
|
|
1056
|
+
code = dobj.upload_digital_object(entry_code="zb.b.f7", file_description="CTD raw data",
|
|
1057
|
+
digital_object_type="Dataset", file_path="ctd.zip")
|
|
1058
|
+
|
|
1059
|
+
# Upload many files first, link them in one call
|
|
1060
|
+
codes = [dobj.upload_file("Photo", "Image", p) for p in ["a.jpg", "b.jpg"]]
|
|
1061
|
+
dobj.link_to_entry("4d.b.1l", codes)
|
|
1062
|
+
|
|
1063
|
+
dobj.link_existing_digital_objects("4d.b.1l", ["h.b.ac0j"], is_unlink=True)
|
|
1064
|
+
|
|
1065
|
+
dobj.download_digital_object(output_path="./downloads/", digital_object_code="h.b.8j2h")
|
|
1066
|
+
dobj.direct_download_digital_object(entry_code="4d.b.1l", digital_object_code="h.b.ac0j",
|
|
1067
|
+
output_path="./downloads/")
|
|
1068
|
+
```
|
|
1069
|
+
|
|
1070
|
+
---
|
|
1071
|
+
|
|
1072
|
+
## Low-level client (`Das`) and services
|
|
1073
|
+
|
|
1074
|
+
`Das(base_url=None)` normalizes and saves the URL, then exposes one service per
|
|
1075
|
+
backend app-service. Services return the raw API `result` (lower-case column
|
|
1076
|
+
keys, ids) — use them when a manager does not cover what you need.
|
|
1077
|
+
|
|
1078
|
+
| Attribute | Service | Main methods |
|
|
1079
|
+
|---|---|---|
|
|
1080
|
+
| `client.attributes` | `AttributesService` | `get_attribute(id=, name=, alias=, table_name=)`, `get_id(name)`, `get_name(id)` |
|
|
1081
|
+
| `client.entries` | `EntriesService` | `get(id=, code=)`, `get_entry(code)`, `create(attribute_id, entry)`, `update(attribute_id, entry)`, `delete(code)`, `delete_by_id(id)`, `get_entry_logs(id, ...)`, `chown(new_user_id, entry_list_ids)`, `get_direct_relations(...)` |
|
|
1082
|
+
| `client.entry_fields` | `EntryFieldsService` | `get_entry_fields(attribute_id, display_type=2)`, `clear_cache()` |
|
|
1083
|
+
| `client.search` | `SearchService` | `search_entries(attributeId=, queryString=, maxResultCount=, skipCount=, sorting=, includeRelationsId=, tableName=)` |
|
|
1084
|
+
| `client.elastic_search` | `DasElasticSearch` | `search_item(field, value)` |
|
|
1085
|
+
| `client.cache` | `CacheService` | `get_all()`, `clear_cache(name)`, `clear_all()` |
|
|
1086
|
+
| `client.hangfire` | `HangfireService` | `get_recurring_jobs()`, `find_recurring_job(id)`, `trigger_recurring_job(id)`, `sync_doi(id)` |
|
|
1087
|
+
| `client.session` | `SessionService` | `get_current_login_information()`, `get_current_user()`, `validate_api_key(key)` |
|
|
1088
|
+
|
|
1089
|
+
`Das` methods: `authenticate(username, password) → token`,
|
|
1090
|
+
`set_api_key(key, validate=False) → user | None`, `whoami(verify=True) → dict`.
|
|
1091
|
+
|
|
1092
|
+
```python
|
|
1093
|
+
from das.app import Das
|
|
1094
|
+
|
|
1095
|
+
das = Das() # saved URL + credential
|
|
1096
|
+
|
|
1097
|
+
attr_id = das.attributes.get_id("Cores")
|
|
1098
|
+
fields = das.entry_fields.get_entry_fields(attr_id)["result"]["items"]
|
|
1099
|
+
print([(f["displayName"], f["column"]) for f in fields])
|
|
1100
|
+
|
|
1101
|
+
raw = das.search.search_entries(attributeId=attr_id, queryString="name(*64*)",
|
|
1102
|
+
maxResultCount=5, skipCount=0)
|
|
1103
|
+
|
|
1104
|
+
for job in das.hangfire.get_recurring_jobs():
|
|
1105
|
+
print(job["id"], job["cron"], job["nextExecution"], job["lastJobState"])
|
|
1106
|
+
print(das.hangfire.trigger_recurring_job("5. harvest-archive")["jobId"])
|
|
1107
|
+
```
|
|
1108
|
+
|
|
1109
|
+
Other services, constructed with the base URL: `das.services.downloads.DownloadRequestService`,
|
|
1110
|
+
`das.services.digital_objects.DigitalObjectsService`, `das.services.users.UsersService`.
|
|
1111
|
+
|
|
1112
|
+
---
|
|
1113
|
+
|
|
1114
|
+
## Error handling in Python
|
|
1115
|
+
|
|
1116
|
+
Every failure is a `ValueError`. API failures are the typed subclasses in
|
|
1117
|
+
`das.common.exceptions`, so you can branch on them:
|
|
1118
|
+
|
|
1119
|
+
| Exception | When |
|
|
1120
|
+
|---|---|
|
|
1121
|
+
| `DasAuthenticationError` | 401 — missing/expired credential |
|
|
1122
|
+
| `DasPermissionError` | 403 — authenticated but not allowed |
|
|
1123
|
+
| `DasNotFoundError` | 404 |
|
|
1124
|
+
| `DasValidationError` | 400/422 with field validation errors |
|
|
1125
|
+
| `DasConflictError` | 409 — duplicate / concurrent change |
|
|
1126
|
+
| `DasClientError` | other 4xx |
|
|
1127
|
+
| `DasServerError` | 5xx — quote the `correlation_id` to support |
|
|
1128
|
+
| `DasConnectionError` | DNS / TLS / timeout / refused |
|
|
1129
|
+
|
|
1130
|
+
Each exposes `status_code`, `correlation_id`, `api_message`,
|
|
1131
|
+
`validation_errors`, and renders a full, human-readable message:
|
|
1132
|
+
|
|
1133
|
+
```python
|
|
1134
|
+
from das.common.exceptions import DasApiError, DasPermissionError
|
|
1135
|
+
from das.app import Das
|
|
1136
|
+
|
|
1137
|
+
try:
|
|
1138
|
+
Das().hangfire.trigger_recurring_job("5. harvest-archive")
|
|
1139
|
+
except DasPermissionError:
|
|
1140
|
+
print("Ask an admin for the Hangfire dashboard permission.")
|
|
1141
|
+
except DasApiError as e:
|
|
1142
|
+
print(e) # HTTP 500 — Server error: … Reference: 0HN…
|
|
1143
|
+
print(e.status_code, e.correlation_id)
|
|
1144
|
+
except ValueError as e: # input validation by the managers
|
|
1145
|
+
print(e)
|
|
1146
|
+
```
|
|
1147
|
+
|
|
1148
|
+
> Most services still raise a plain `ValueError` carrying the same rendered
|
|
1149
|
+
> message; `HangfireService`, `SessionService` and `DigitalObjectsService`
|
|
1150
|
+
> raise the typed classes.
|
|
1151
|
+
|
|
1152
|
+
---
|
|
1153
|
+
|
|
1154
|
+
## Recipes for scripts and notebooks
|
|
1155
|
+
|
|
1156
|
+
**Search results → pandas DataFrame**
|
|
1157
|
+
|
|
1158
|
+
```python
|
|
1159
|
+
import pandas as pd
|
|
1160
|
+
from das.managers.search_manager import SearchManager
|
|
1161
|
+
|
|
1162
|
+
res = SearchManager().search_entries(attribute="Cores", query="event(*64PE514*)", max_results=1000)
|
|
1163
|
+
df = pd.DataFrame(res["items"])
|
|
1164
|
+
df[["Name", "Start Depth", "End Depth"]].describe()
|
|
1165
|
+
```
|
|
1166
|
+
|
|
1167
|
+
**Bulk import from Excel with a progress report**
|
|
1168
|
+
|
|
1169
|
+
```python
|
|
1170
|
+
import pandas as pd
|
|
1171
|
+
from das.managers.entries_manager import EntryManager
|
|
1172
|
+
|
|
1173
|
+
rows = pd.read_excel("new_cores.xlsx").to_dict(orient="records")
|
|
1174
|
+
entries = EntryManager()
|
|
1175
|
+
entries.warm_select_cache("Cores")
|
|
1176
|
+
results = entries.create(attribute="Cores", entries=rows)
|
|
1177
|
+
|
|
1178
|
+
report = pd.DataFrame(results)
|
|
1179
|
+
report.to_csv("import_report.csv", index=False)
|
|
1180
|
+
print(report["status"].value_counts())
|
|
1181
|
+
```
|
|
1182
|
+
|
|
1183
|
+
**Annotate a set of entries**
|
|
1184
|
+
|
|
1185
|
+
```python
|
|
1186
|
+
from das.managers.search_manager import SearchManager
|
|
1187
|
+
from das.managers.entries_manager import EntryManager
|
|
1188
|
+
|
|
1189
|
+
hits = SearchManager().search_entries(attribute="Cores", query="event(*64PE514*)", max_results=500)
|
|
1190
|
+
updates = [{"Code": h["Code"], "Comment": "QC passed 2026-11"} for h in hits["items"]]
|
|
1191
|
+
results = EntryManager().update(entries=updates)
|
|
1192
|
+
```
|
|
1193
|
+
|
|
1194
|
+
**End-to-end: create → upload → download → clean up**
|
|
1195
|
+
|
|
1196
|
+
```python
|
|
1197
|
+
from das.app import Das
|
|
1198
|
+
from das.managers.entries_manager import EntryManager
|
|
1199
|
+
from das.managers.digital_objects_manager import DigitalObjectsManager
|
|
1200
|
+
from das.managers.download_manager import DownloadManager
|
|
1201
|
+
|
|
1202
|
+
Das("https://your-das-instance").authenticate("your_user", "your_password")
|
|
1203
|
+
entries, dobj, downloads = EntryManager(), DigitalObjectsManager(), DownloadManager()
|
|
1204
|
+
|
|
1205
|
+
created = entries.create(attribute="Cores", entry={"Alias": "api.test.001", "Event": "64PE428-02PC", "Number": 1})[0]
|
|
1206
|
+
dobj.upload_digital_object(created["code"], "Test file", "Dataset", "sample.zip")
|
|
1207
|
+
|
|
1208
|
+
request_id = downloads.create_download_request({"name": "API test", created["code"]: []})
|
|
1209
|
+
# …wait for COMPLETED (see DownloadManager example)…
|
|
1210
|
+
print(downloads.save_download(request_id, output_path="./downloads"))
|
|
1211
|
+
|
|
1212
|
+
entries.delete(id=created["id"])
|
|
1213
|
+
downloads.delete_download_request(request_id)
|
|
1214
|
+
```
|
|
1215
|
+
|
|
1216
|
+
---
|
|
1217
|
+
|
|
1218
|
+
## Configuration and environment variables
|
|
1219
|
+
|
|
1220
|
+
Values can come from CLI commands, real environment variables or a `.env` file
|
|
1221
|
+
in the current directory (loaded automatically). Environment variables win
|
|
1222
|
+
over saved config, except `VERIFY_SSL` (an explicit `das config ssl-verify`
|
|
1223
|
+
wins).
|
|
1224
|
+
|
|
1225
|
+
| Variable | Purpose |
|
|
1226
|
+
|---|---|
|
|
1227
|
+
| `DAS_API_URL` | Base URL used by `Das()` and managers when none is passed. |
|
|
1228
|
+
| `DAS_API_KEY` | API key; **overrides** any credential saved by `das login`. |
|
|
1229
|
+
| `VERIFY_SSL` | `True`/`False`; used unless set explicitly with `das config ssl-verify`. |
|
|
1230
|
+
| `DAS_LOG_LEVEL` | `TRACE`/`DEBUG`/`INFO`/`WARN`/`ERROR`/`FATAL`; overrides `das config log-level`. |
|
|
1231
|
+
| `DAS_LOG_FILE` | Also write logs to this file; overrides `das config log-file`. |
|
|
1232
|
+
| `OPENAI_API_KEY`, `OPEN_AI_MODEL_ID` | AI assistant. |
|
|
1233
|
+
| `API_URL`, `USER_NAME`, `USER_PASSWORD` | Integration tests only. |
|
|
1234
|
+
|
|
1235
|
+
```env
|
|
1236
|
+
DAS_API_URL=https://your-das-instance
|
|
1237
|
+
DAS_API_KEY=
|
|
1238
|
+
VERIFY_SSL=True
|
|
1239
|
+
DAS_LOG_LEVEL=WARN
|
|
1240
|
+
DAS_LOG_FILE=
|
|
1241
|
+
```
|
|
1242
|
+
|
|
1243
|
+
Never commit a `.env` containing real keys.
|
|
1244
|
+
|
|
1245
|
+
---
|
|
1246
|
+
|
|
1247
|
+
## Logging
|
|
1248
|
+
|
|
1249
|
+
The `das` logger writes diagnostics (HTTP calls, API error details,
|
|
1250
|
+
correlation ids).
|
|
1251
|
+
|
|
1252
|
+
- **Level** — `TRACE`, `DEBUG`, `INFO`, `WARN` (default), `ERROR`, `FATAL`, via
|
|
1253
|
+
`das config log-level <LEVEL>` or `DAS_LOG_LEVEL`.
|
|
1254
|
+
- **Destination** — console by default; add a file with
|
|
1255
|
+
`das config log-file <path>` or `DAS_LOG_FILE` (timestamps included);
|
|
1256
|
+
`das config log-file --clear` to stop.
|
|
1257
|
+
|
|
1258
|
+
```bash
|
|
1259
|
+
das config log-level DEBUG
|
|
1260
|
+
das config log-file ./das-debug.log
|
|
1261
|
+
das search entries --attribute Cruise --query "cruisecode(*64PE*)"
|
|
1262
|
+
```
|
|
1263
|
+
|
|
1264
|
+
In Python: `import logging; logging.getLogger("das").setLevel(logging.DEBUG)`.
|
|
1265
|
+
|
|
1266
|
+
> This is the CLI's own diagnostic log. For an entry's change history use
|
|
1267
|
+
> [`das entry logs`](#audit-logs-and-ownership).
|
|
1268
|
+
|
|
1269
|
+
---
|
|
1270
|
+
|
|
1271
|
+
## Troubleshooting
|
|
1272
|
+
|
|
1273
|
+
| Symptom | Fix |
|
|
1274
|
+
|---|---|
|
|
1275
|
+
| `No API URL configured` | `das login --api-url …`, set `DAS_API_URL`, or pass the URL to `Das(...)`. |
|
|
1276
|
+
| `HTTP 401 — Authentication error` | Token expired or key revoked → `das login` again; check `das whoami`. |
|
|
1277
|
+
| Commands run as the wrong user | A `DAS_API_KEY` in env/`.env` overrides your login → `das whoami` shows where. |
|
|
1278
|
+
| `HTTP 403 — Permission error` | Your role lacks the permission (e.g. Hangfire, cache). |
|
|
1279
|
+
| SSL / certificate errors on a dev server | `das config ssl-verify false` (never in production). |
|
|
1280
|
+
| `Sorting field 'Name' does not exist` | That attribute has no `Name`; omit `--sort-by` or pick a listed field. |
|
|
1281
|
+
| `pandas is required to read Excel files` | `pip install "das-cli[excel]"`. |
|
|
1282
|
+
| Query returns nothing / shell error | Quote the query: `--query "name(*64*)"`. |
|
|
1283
|
+
| `HTTP 5xx — Server error … Reference: X` | Server-side problem; send the reference to the DAS team. |
|
|
1284
|
+
| Need more detail | `das config log-level DEBUG` (+ `das config log-file <path>`). |
|
|
1285
|
+
|
|
1286
|
+
---
|
|
1287
|
+
|
|
1288
|
+
## Testing
|
|
1289
|
+
|
|
1290
|
+
```bash
|
|
1291
|
+
python run_tests.py # whole suite (unittest discovery, tests/*_test.py)
|
|
1292
|
+
python -m unittest tests.search_manager_unit_test
|
|
1293
|
+
```
|
|
1294
|
+
|
|
1295
|
+
Files ending in `_unit_test.py` are mock-based and run offline. Most other tests
|
|
1296
|
+
are **integration tests** against a live DAS server (they need `API_URL`,
|
|
1297
|
+
`USER_NAME`, `USER_PASSWORD` in `.env`, and some create/delete real entries).
|
|
1298
|
+
See [`TESTING.md`](TESTING.md).
|
|
1299
|
+
|
|
1300
|
+
## Contributing
|
|
1301
|
+
|
|
1302
|
+
New developers: read [`ONBOARDING.md`](ONBOARDING.md) first — architecture,
|
|
1303
|
+
layer responsibilities, coding conventions and a step-by-step guide to adding a
|
|
1304
|
+
feature. Then open a merge request against `dev`.
|
|
1305
|
+
|
|
1306
|
+
Bugs and feature requests: [DAS CLI issue tracker](https://git.nioz.nl/ict-projects/das-cli/-/issues).
|
|
1307
|
+
|
|
1308
|
+
## License
|
|
1309
|
+
|
|
1310
|
+
MIT License
|