datamasque-cli 1.3.0__tar.gz → 1.5.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.
Files changed (94) hide show
  1. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/CHANGELOG.md +43 -0
  2. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/CONTRIBUTING.md +44 -0
  3. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/PKG-INFO +50 -16
  4. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/README.md +46 -13
  5. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/claude-skills/datamasque-cli/skills/datamasque-cli/SKILL.md +14 -4
  6. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/pyproject.toml +4 -3
  7. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/src/datamasque_cli/client.py +69 -5
  8. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/src/datamasque_cli/commands/auth.py +2 -1
  9. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/src/datamasque_cli/commands/connections.py +34 -8
  10. datamasque_cli-1.5.0/src/datamasque_cli/commands/discovery.py +349 -0
  11. datamasque_cli-1.5.0/src/datamasque_cli/commands/discovery_config_libraries.py +197 -0
  12. datamasque_cli-1.5.0/src/datamasque_cli/commands/discovery_configs.py +280 -0
  13. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/src/datamasque_cli/commands/files.py +3 -2
  14. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/src/datamasque_cli/commands/ifm.py +15 -85
  15. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/src/datamasque_cli/commands/ruleset_libraries.py +56 -7
  16. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/src/datamasque_cli/commands/rulesets.py +101 -43
  17. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/src/datamasque_cli/commands/runs.py +53 -19
  18. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/src/datamasque_cli/commands/seeds.py +3 -2
  19. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/src/datamasque_cli/commands/system.py +38 -7
  20. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/src/datamasque_cli/commands/users.py +3 -2
  21. datamasque_cli-1.5.0/src/datamasque_cli/errors.py +233 -0
  22. datamasque_cli-1.5.0/src/datamasque_cli/fileio.py +73 -0
  23. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/src/datamasque_cli/main.py +55 -34
  24. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/src/datamasque_cli/output.py +1 -58
  25. datamasque_cli-1.5.0/src/datamasque_cli/protocols.py +69 -0
  26. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/tests/commands/test_auth.py +7 -6
  27. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/tests/commands/test_catalog.py +6 -0
  28. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/tests/commands/test_connections.py +84 -6
  29. datamasque_cli-1.5.0/tests/commands/test_discovery.py +614 -0
  30. datamasque_cli-1.5.0/tests/commands/test_discovery_config_libraries.py +313 -0
  31. datamasque_cli-1.5.0/tests/commands/test_discovery_configs.py +336 -0
  32. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/tests/commands/test_files.py +3 -2
  33. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/tests/commands/test_ifm.py +27 -21
  34. datamasque_cli-1.5.0/tests/commands/test_ruleset_libraries.py +207 -0
  35. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/tests/commands/test_rulesets.py +154 -25
  36. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/tests/commands/test_runs.py +75 -5
  37. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/tests/commands/test_seeds.py +2 -1
  38. datamasque_cli-1.5.0/tests/commands/test_system.py +195 -0
  39. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/tests/commands/test_users.py +2 -1
  40. datamasque_cli-1.5.0/tests/integration/conftest.py +338 -0
  41. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/tests/integration/test_connections.py +3 -2
  42. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/tests/integration/test_delete_safety.py +2 -1
  43. datamasque_cli-1.5.0/tests/integration/test_discovery.py +114 -0
  44. datamasque_cli-1.5.0/tests/integration/test_discovery_configs.py +271 -0
  45. datamasque_cli-1.5.0/tests/integration/test_rulesets.py +192 -0
  46. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/tests/integration/test_runs.py +30 -0
  47. datamasque_cli-1.5.0/tests/integration/test_system.py +97 -0
  48. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/tests/test_client_auth.py +22 -1
  49. datamasque_cli-1.5.0/tests/test_main.py +117 -0
  50. datamasque_cli-1.5.0/tests/test_output.py +481 -0
  51. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/uv.lock +7 -5
  52. datamasque_cli-1.3.0/src/datamasque_cli/commands/discovery.py +0 -136
  53. datamasque_cli-1.3.0/tests/commands/test_discovery.py +0 -125
  54. datamasque_cli-1.3.0/tests/commands/test_ruleset_libraries.py +0 -65
  55. datamasque_cli-1.3.0/tests/commands/test_system.py +0 -82
  56. datamasque_cli-1.3.0/tests/integration/conftest.py +0 -167
  57. datamasque_cli-1.3.0/tests/integration/test_rulesets.py +0 -84
  58. datamasque_cli-1.3.0/tests/test_output.py +0 -200
  59. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/.claude-plugin/marketplace.json +0 -0
  60. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/.github/workflows/ci.yml +0 -0
  61. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/.github/workflows/release-testpypi.yml +0 -0
  62. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/.github/workflows/release.yml +0 -0
  63. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/.gitignore +0 -0
  64. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/LICENSE +0 -0
  65. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/Makefile +0 -0
  66. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/NOTICE +0 -0
  67. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/assets/demo.gif +0 -0
  68. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/claude-skills/README.md +0 -0
  69. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/claude-skills/datamasque-cli/.claude-plugin/plugin.json +0 -0
  70. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/claude-skills/ruleset-builder/.claude-plugin/plugin.json +0 -0
  71. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/claude-skills/ruleset-builder/skills/ruleset-builder/SKILL.md +0 -0
  72. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/claude-skills/ruleset-builder/skills/ruleset-builder/references/fk-cascade.md +0 -0
  73. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/claude-skills/ruleset-builder/skills/ruleset-builder/references/hash-columns-guide.md +0 -0
  74. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/claude-skills/ruleset-builder/skills/ruleset-builder/references/mask-definitions-guide.md +0 -0
  75. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/claude-skills/ruleset-builder/skills/ruleset-builder/references/ruleset-libraries-guide.md +0 -0
  76. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/claude-skills/ruleset-builder/skills/ruleset-builder/references/ruleset-yaml-reference.md +0 -0
  77. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/claude-skills/ruleset-splitter/.claude-plugin/plugin.json +0 -0
  78. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/claude-skills/ruleset-splitter/skills/ruleset-splitter/SKILL.md +0 -0
  79. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/scripts/active_profile_env.py +0 -0
  80. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/scripts/bump_version.py +0 -0
  81. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/src/datamasque_cli/__init__.py +0 -0
  82. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/src/datamasque_cli/commands/__init__.py +0 -0
  83. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/src/datamasque_cli/config.py +0 -0
  84. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/src/datamasque_cli/py.typed +0 -0
  85. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/tests/__init__.py +0 -0
  86. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/tests/commands/__init__.py +0 -0
  87. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/tests/conftest.py +0 -0
  88. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/tests/integration/README.md +0 -0
  89. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/tests/integration/__init__.py +0 -0
  90. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/tests/test_client_env.py +0 -0
  91. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/tests/test_client_ifm.py +0 -0
  92. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/tests/test_client_profile.py +0 -0
  93. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/tests/test_config.py +0 -0
  94. {datamasque_cli-1.3.0 → datamasque_cli-1.5.0}/tests/test_version.py +0 -0
@@ -1,5 +1,48 @@
1
1
  # Changelog
2
2
 
3
+ ## v1.5.0
4
+
5
+ ### Added
6
+ - Support for datamasque-python 1.2.3.
7
+ - `dm discover schema-results` handles matches with no label.
8
+ - `dm rulesets validate` and `dm libraries validate` report each validation
9
+ error for invalid YAML, with its line and column.
10
+ - Support for Configurable Discovery:
11
+ - `dm discover configs` — list, get, defaults, create, delete, validate,
12
+ and status for discovery configs (`database` or `file`).
13
+ - `dm discover libraries` — list, get, create, delete, validate, and status
14
+ for discovery config libraries.
15
+ - `dm discover schema --config <name>` and `dm discover file
16
+ [--config <name>]` start discovery runs with or without a specific config.
17
+ - `dm discover config-snapshot <run-id>` downloads the discovery config a run
18
+ actually used.
19
+ - `dm rulesets status` and `dm libraries status` — show a stored ruleset's or
20
+ library's validation state and errors.
21
+ - `dm rulesets validate` and `dm discover configs validate` refuse YAML of
22
+ 60 KiB or larger, which the server validates asynchronously; create it and
23
+ poll `status` instead.
24
+ - Safe Data Preview: `dm discover schema-results` and `dm discover file-report`
25
+ include `safe_data_preview` in their `--json` output.
26
+
27
+ ### Changed
28
+ - A declined confirmation prompt now exits 10 (`cancelled`) instead of 1,
29
+ so a decision is not reported as a failure. Ctrl-C still exits 1.
30
+ - `dm run start --json` and `dm run retry --json` only emit the run id.
31
+ `"status": "queued"` is no longer returned.
32
+
33
+ ### Fixed
34
+ - `dm rulesets generate`, `dm connections update --password`, and the
35
+ deprecated `dm system import` no longer fail.
36
+ - File errors now name the file instead of printing a traceback.
37
+ - Unhandled server and network errors now abort with a code, not a traceback.
38
+
39
+ ## v1.4.0
40
+
41
+ ### Added
42
+ - `dm connections create --file` now supports Databricks SQL Warehouse
43
+ (`"type": "databricks"`) and MongoDB (`"type": "mongodb"`) connections.
44
+ Both list, get, create, and delete like the existing connection types.
45
+
3
46
  ## v1.3.0
4
47
 
5
48
  ### Added
@@ -41,6 +41,50 @@ uv sync
41
41
  Then either activate the venv (`source .venv/bin/activate`)
42
42
  or prefix commands with `uv run`.
43
43
 
44
+ ## Running `dm` locally
45
+
46
+ `uv sync` installs the CLI in editable mode,
47
+ so the `dm` entry point on the venv reflects your working tree —
48
+ no reinstall after each edit.
49
+
50
+ ```console
51
+ uv run dm --version # one-shot, no venv activation needed
52
+ source .venv/bin/activate && dm --version # or activate once per shell
53
+ ```
54
+
55
+ Point it at a DataMasque instance.
56
+ For ad-hoc development, env vars are the lowest-friction path
57
+ (no `~/.config/datamasque-cli/config.toml` to clean up afterwards):
58
+
59
+ ```console
60
+ export DATAMASQUE_URL=http://127.0.0.1:8000
61
+ export DATAMASQUE_USERNAME=admin
62
+ export DATAMASQUE_PASSWORD='P@ssword12'
63
+ export DATAMASQUE_VERIFY_SSL=false # for self-signed local builds
64
+ dm system health
65
+ dm connections list
66
+ ```
67
+
68
+ For longer-lived work, save a profile with `dm auth login`
69
+ (stored at `~/.config/datamasque-cli/config.toml`, mode 600).
70
+
71
+ ### Pairing with a local `datamasque-python` checkout
72
+
73
+ `datamasque-cli` depends on the `datamasque-python` package
74
+ for its actual API client.
75
+ If you're changing both repos at once
76
+ (for example, adding a new endpoint that needs a CLI surface),
77
+ install the sibling checkout in editable mode against the CLI's venv:
78
+
79
+ ```console
80
+ uv pip install -e ../datamasque-python
81
+ ```
82
+
83
+ The dependency is satisfied by the local checkout
84
+ and edits to either repo are picked up immediately by `dm`.
85
+ A subsequent `uv sync` will re-pin to the registered version —
86
+ re-run the `uv pip install -e` if you want the local override back.
87
+
44
88
  ## Running the tests
45
89
 
46
90
  ```console
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.5
2
2
  Name: datamasque-cli
3
- Version: 1.3.0
3
+ Version: 1.5.0
4
4
  Summary: Official command-line interface for the DataMasque data-masking platform.
5
5
  Project-URL: Homepage, https://datamasque.com/
6
6
  Project-URL: Repository, https://github.com/datamasque/datamasque-cli
@@ -23,7 +23,8 @@ Classifier: Topic :: Database
23
23
  Classifier: Topic :: Utilities
24
24
  Classifier: Typing :: Typed
25
25
  Requires-Python: >=3.11
26
- Requires-Dist: datamasque-python<2,>=1.0.0
26
+ Requires-Dist: datamasque-python<2,>=1.2.3
27
+ Requires-Dist: pydantic<3,>=2.5
27
28
  Requires-Dist: tomli-w>=1.0.0
28
29
  Requires-Dist: typer>=0.15.0
29
30
  Description-Content-Type: text/markdown
@@ -168,17 +169,16 @@ dm connections delete <name> # Delete a connection
168
169
  ### Rulesets
169
170
 
170
171
  ```console
171
- dm rulesets list # List all rulesets
172
- dm rulesets list --type file # Filter by type
173
- dm rulesets get <name> # Show ruleset details
172
+ dm rulesets list [--type database|file] # List all rulesets, or filter by type
173
+ dm rulesets get <name> [--type database|file] # Show details; --type disambiguates same-name rulesets
174
174
  dm rulesets get <name> --yaml # Print raw YAML only
175
- dm rulesets get <name> --type file # Disambiguate same-name rulesets
176
- dm rulesets create --name <n> --file rules.yaml # Create/update (type auto-detected from YAML)
177
- dm rulesets create --name <n> --file rules.yaml --type file # Force a type
178
- dm rulesets delete <name> [--type file|database] # Delete a ruleset
175
+ dm rulesets create --name <n> --file rules.yaml # Create/update (type read from the existing ruleset)
176
+ dm rulesets create --name <n> --file rules.yaml [--type database|file] # Force a type
177
+ dm rulesets delete <name> [--type database|file] # Delete a ruleset
179
178
  dm rulesets generate --file request.json # Generate from schema
180
179
  dm rulesets generate --file req.json -o out.yaml # Generate to file
181
- dm rulesets validate --file rules.yaml # Validate against server
180
+ dm rulesets validate --file rules.yaml --type database|file # Validate against server (YAML under 60 KiB)
181
+ dm rulesets status <name> # Validation status; poll after creating YAML of 60 KiB+
182
182
  dm rulesets export-bundle -o bundle.zip # Export rulesets + libraries + seeds
183
183
  dm rulesets import-bundle --file bundle.zip # Import a previously exported bundle
184
184
  dm rulesets import-bundle -f bundle.zip --overwrite-rulesets --overwrite-libraries # Replace existing entries
@@ -194,6 +194,7 @@ dm libraries create --name <n> --file lib.yaml # Create/update from file
194
194
  dm libraries create --name <n> --file lib.yaml --namespace pii # With namespace
195
195
  dm libraries delete <name> # Delete a library
196
196
  dm libraries validate <name> # Re-validate against current server schema
197
+ dm libraries status <name> # Validation status; poll after creating YAML of 60 KiB+
197
198
  dm libraries usage <name> # Show rulesets using it
198
199
  ```
199
200
 
@@ -246,11 +247,42 @@ dm users delete <username> # Delete a user
246
247
  ### Discovery
247
248
 
248
249
  ```console
249
- dm discover schema <connection> # Start a schema-discovery run
250
- dm discover schema-results <run-id> # List schema-discovery results once the run finishes
251
- dm discover sdd-report <run-id> # Sensitive data discovery report
252
- dm discover db-report <run-id> # Database discovery CSV
253
- dm discover file-report <run-id> # File discovery report
250
+ dm discover schema <connection> # Schema discovery (built-in keyword-driven)
251
+ dm discover schema <connection> --config <name> # Schema discovery from a saved database config
252
+ dm discover schema <connection> --json # {"id": <run-id>}
253
+ dm discover schema-results <run-id> # List schema-discovery results once the run finishes
254
+ dm discover file <connection> # File data discovery (built-in keyword-driven)
255
+ dm discover file <connection> --config <name> # File data discovery from a saved file config
256
+ dm discover file <connection> --json # {"id": <run-id>}
257
+ dm discover sdd-report <run-id> # Sensitive data discovery report
258
+ dm discover db-report <run-id> # Database discovery CSV
259
+ dm discover file-report <run-id> # File discovery report
260
+ dm discover config-snapshot <run-id> -o used.yaml # Download the discovery config a run actually used
261
+ ```
262
+
263
+ #### Discovery configs
264
+
265
+ ```console
266
+ dm discover configs list [--type database|file] # List configs
267
+ dm discover configs get <name> [--type database|file] [--yaml] # Show details or raw YAML
268
+ dm discover configs defaults [--type database|file] -o cfg.yaml # Built-in default as a starting point
269
+ dm discover configs create --name <n> -f cfg.yaml [--type database|file] # Create/update from YAML
270
+ dm discover configs delete <name> [--type database|file] # Delete a config
271
+ dm discover configs validate -f cfg.yaml --type database|file # Validate against server (YAML under 60 KiB)
272
+ dm discover configs status <name> [--type database|file] # Validation status; poll after creating YAML of 60 KiB+
273
+ ```
274
+
275
+ #### Discovery config libraries
276
+
277
+ The same library can be imported by both database and file discovery configs.
278
+
279
+ ```console
280
+ dm discover libraries list
281
+ dm discover libraries get <name> [--namespace org] [--yaml]
282
+ dm discover libraries create --name <n> --namespace org -f lib.yaml
283
+ dm discover libraries delete <name> [--namespace org] [--force] # --force if imported by configs
284
+ dm discover libraries validate -f lib.yaml
285
+ dm discover libraries status <name> [--namespace org]
254
286
  ```
255
287
 
256
288
  ### Seeds
@@ -338,6 +370,8 @@ empty on failure):
338
370
  | 7 | auth_failed | credentials rejected by server |
339
371
  | 8 | conflict | operation rejected by server state |
340
372
  | 9 | transport_error | network or TLS failure |
373
+ | 10 | cancelled | you answered no to a confirmation prompt |
374
+ | 11 | forbidden | user lacks permission for the operation |
341
375
 
342
376
  Exit codes are stable across minor versions. The `error.code` string in the
343
377
  JSON envelope mirrors these names.
@@ -138,17 +138,16 @@ dm connections delete <name> # Delete a connection
138
138
  ### Rulesets
139
139
 
140
140
  ```console
141
- dm rulesets list # List all rulesets
142
- dm rulesets list --type file # Filter by type
143
- dm rulesets get <name> # Show ruleset details
141
+ dm rulesets list [--type database|file] # List all rulesets, or filter by type
142
+ dm rulesets get <name> [--type database|file] # Show details; --type disambiguates same-name rulesets
144
143
  dm rulesets get <name> --yaml # Print raw YAML only
145
- dm rulesets get <name> --type file # Disambiguate same-name rulesets
146
- dm rulesets create --name <n> --file rules.yaml # Create/update (type auto-detected from YAML)
147
- dm rulesets create --name <n> --file rules.yaml --type file # Force a type
148
- dm rulesets delete <name> [--type file|database] # Delete a ruleset
144
+ dm rulesets create --name <n> --file rules.yaml # Create/update (type read from the existing ruleset)
145
+ dm rulesets create --name <n> --file rules.yaml [--type database|file] # Force a type
146
+ dm rulesets delete <name> [--type database|file] # Delete a ruleset
149
147
  dm rulesets generate --file request.json # Generate from schema
150
148
  dm rulesets generate --file req.json -o out.yaml # Generate to file
151
- dm rulesets validate --file rules.yaml # Validate against server
149
+ dm rulesets validate --file rules.yaml --type database|file # Validate against server (YAML under 60 KiB)
150
+ dm rulesets status <name> # Validation status; poll after creating YAML of 60 KiB+
152
151
  dm rulesets export-bundle -o bundle.zip # Export rulesets + libraries + seeds
153
152
  dm rulesets import-bundle --file bundle.zip # Import a previously exported bundle
154
153
  dm rulesets import-bundle -f bundle.zip --overwrite-rulesets --overwrite-libraries # Replace existing entries
@@ -164,6 +163,7 @@ dm libraries create --name <n> --file lib.yaml # Create/update from file
164
163
  dm libraries create --name <n> --file lib.yaml --namespace pii # With namespace
165
164
  dm libraries delete <name> # Delete a library
166
165
  dm libraries validate <name> # Re-validate against current server schema
166
+ dm libraries status <name> # Validation status; poll after creating YAML of 60 KiB+
167
167
  dm libraries usage <name> # Show rulesets using it
168
168
  ```
169
169
 
@@ -216,11 +216,42 @@ dm users delete <username> # Delete a user
216
216
  ### Discovery
217
217
 
218
218
  ```console
219
- dm discover schema <connection> # Start a schema-discovery run
220
- dm discover schema-results <run-id> # List schema-discovery results once the run finishes
221
- dm discover sdd-report <run-id> # Sensitive data discovery report
222
- dm discover db-report <run-id> # Database discovery CSV
223
- dm discover file-report <run-id> # File discovery report
219
+ dm discover schema <connection> # Schema discovery (built-in keyword-driven)
220
+ dm discover schema <connection> --config <name> # Schema discovery from a saved database config
221
+ dm discover schema <connection> --json # {"id": <run-id>}
222
+ dm discover schema-results <run-id> # List schema-discovery results once the run finishes
223
+ dm discover file <connection> # File data discovery (built-in keyword-driven)
224
+ dm discover file <connection> --config <name> # File data discovery from a saved file config
225
+ dm discover file <connection> --json # {"id": <run-id>}
226
+ dm discover sdd-report <run-id> # Sensitive data discovery report
227
+ dm discover db-report <run-id> # Database discovery CSV
228
+ dm discover file-report <run-id> # File discovery report
229
+ dm discover config-snapshot <run-id> -o used.yaml # Download the discovery config a run actually used
230
+ ```
231
+
232
+ #### Discovery configs
233
+
234
+ ```console
235
+ dm discover configs list [--type database|file] # List configs
236
+ dm discover configs get <name> [--type database|file] [--yaml] # Show details or raw YAML
237
+ dm discover configs defaults [--type database|file] -o cfg.yaml # Built-in default as a starting point
238
+ dm discover configs create --name <n> -f cfg.yaml [--type database|file] # Create/update from YAML
239
+ dm discover configs delete <name> [--type database|file] # Delete a config
240
+ dm discover configs validate -f cfg.yaml --type database|file # Validate against server (YAML under 60 KiB)
241
+ dm discover configs status <name> [--type database|file] # Validation status; poll after creating YAML of 60 KiB+
242
+ ```
243
+
244
+ #### Discovery config libraries
245
+
246
+ The same library can be imported by both database and file discovery configs.
247
+
248
+ ```console
249
+ dm discover libraries list
250
+ dm discover libraries get <name> [--namespace org] [--yaml]
251
+ dm discover libraries create --name <n> --namespace org -f lib.yaml
252
+ dm discover libraries delete <name> [--namespace org] [--force] # --force if imported by configs
253
+ dm discover libraries validate -f lib.yaml
254
+ dm discover libraries status <name> [--namespace org]
224
255
  ```
225
256
 
226
257
  ### Seeds
@@ -308,6 +339,8 @@ empty on failure):
308
339
  | 7 | auth_failed | credentials rejected by server |
309
340
  | 8 | conflict | operation rejected by server state |
310
341
  | 9 | transport_error | network or TLS failure |
342
+ | 10 | cancelled | you answered no to a confirmation prompt |
343
+ | 11 | forbidden | user lacks permission for the operation |
311
344
 
312
345
  Exit codes are stable across minor versions. The `error.code` string in the
313
346
  JSON envelope mirrors these names.
@@ -23,9 +23,11 @@ In agent mode — auto-detected when stdout is not a TTY, `AI_AGENT` is set, or
23
23
 
24
24
  `error.code` is the stable identifier; branch on it rather than the message.
25
25
  The set is `not_found`, `invalid_input`, `ambiguous`, `auth_required`,
26
- `auth_failed`, `conflict`, `transport_error`, `error`. Exit code is non-zero
27
- on any error; exit 2 specifically means a CLI usage error (unknown flag,
28
- missing argument) from typer.
26
+ `auth_failed`, `conflict`, `transport_error`, `cancelled`, `forbidden`,
27
+ `error`. Exit code is non-zero on any error; exit 2 specifically means a CLI
28
+ usage error (unknown flag, missing argument) from typer, exit 10 means the user
29
+ declined a confirmation prompt, and exit 11 means the logged-in user lacks
30
+ permission.
29
31
 
30
32
  `DM_OUTPUT=table` forces human-readable output.
31
33
 
@@ -55,7 +57,7 @@ Pass repeated `--options key=value` for server-side knobs
55
57
  - **Ruleset namespaces.** `database` and `file` rulesets share a name
56
58
  namespace, so `customers` can exist in both. `dm run start` reads the
57
59
  source connection's type and picks the matching ruleset automatically.
58
- For `get` / `create` / `delete`, pass `--type file|database` only when
60
+ For `get` / `create` / `delete`, pass `--type database|file` only when
59
61
  two rows share the name and you need to disambiguate.
60
62
 
61
63
  - **File masking needs a destination.** Database masking is in-place;
@@ -89,6 +91,14 @@ Pass repeated `--options key=value` for server-side knobs
89
91
  then fetch results with `dm discover schema-results <id>` /
90
92
  `sdd-report` / `db-report` / `file-report`.
91
93
 
94
+ - **Configurable discovery and Safe Data Preview.** Save a discovery config
95
+ with `dm discover configs create` (start from `dm discover configs defaults`),
96
+ then run `dm discover schema <connection> --config <name>`. When the config
97
+ enables in-data discovery with safe data preview, `dm discover schema-results
98
+ <id> --json` carries a `safe_data_preview` per column — value distributions,
99
+ patterns, and cardinality worth reading before choosing masks. It is JSON-only;
100
+ `file-report --json` exposes the same per locator.
101
+
92
102
  - **`dm rulesets validate --file <file> --type <type>`** runs server-side
93
103
  validation without committing the ruleset. Use this before `create`
94
104
  when you want a clean failure mode for bad YAML.
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "datamasque-cli"
3
- version = "1.3.0"
3
+ version = "1.5.0"
4
4
  description = "Official command-line interface for the DataMasque data-masking platform."
5
5
  authors = [
6
6
  { name = "DataMasque Ltd" },
@@ -12,7 +12,8 @@ requires-python = ">=3.11"
12
12
  dependencies = [
13
13
  "typer>=0.15.0",
14
14
  "tomli-w>=1.0.0",
15
- "datamasque-python>=1.0.0,<2",
15
+ "datamasque-python>=1.2.3,<2",
16
+ "pydantic>=2.5,<3",
16
17
  ]
17
18
  classifiers = [
18
19
  "Development Status :: 4 - Beta",
@@ -37,7 +38,7 @@ Repository = "https://github.com/datamasque/datamasque-cli"
37
38
  Issues = "https://github.com/datamasque/datamasque-cli/issues"
38
39
 
39
40
  [project.scripts]
40
- dm = "datamasque_cli.main:app"
41
+ dm = "datamasque_cli.main:main"
41
42
 
42
43
  [dependency-groups]
43
44
  dev = [
@@ -14,7 +14,7 @@ from datamasque.client.models.dm_instance import DataMasqueInstanceConfig
14
14
  from datamasque.client.models.ifm import DataMasqueIfmInstanceConfig
15
15
 
16
16
  from datamasque_cli.config import Config, Profile, load_config
17
- from datamasque_cli.output import ErrorCode, abort
17
+ from datamasque_cli.errors import ErrorCode, abort
18
18
 
19
19
  ENV_URL = "DATAMASQUE_URL"
20
20
  ENV_USERNAME = "DATAMASQUE_USERNAME"
@@ -48,6 +48,25 @@ def profile_from_env() -> Profile | None:
48
48
  return None
49
49
 
50
50
 
51
+ def _profile_from_env_url_only() -> Profile | None:
52
+ """Build a URL-only profile from `DATAMASQUE_URL`, with empty username/password.
53
+
54
+ Used by the unauthenticated client factory so callers can hit anonymous
55
+ endpoints (admin-install, health) without setting `DATAMASQUE_USERNAME`
56
+ and `DATAMASQUE_PASSWORD` -- those fields aren't read by anonymous calls
57
+ and demanding them is friction for the first-run setup workflow.
58
+ """
59
+ url = os.environ.get(ENV_URL)
60
+ if not url:
61
+ return None
62
+ return Profile(
63
+ url=url.rstrip("/"),
64
+ username="",
65
+ password="",
66
+ verify_ssl=_verify_ssl_from_env(default=True),
67
+ )
68
+
69
+
51
70
  def _resolve_profile(config: Config, profile_name: str | None) -> Profile:
52
71
  profile = config.get_profile(profile_name)
53
72
  if not profile.is_configured:
@@ -60,6 +79,25 @@ def _resolve_profile(config: Config, profile_name: str | None) -> Profile:
60
79
  return profile
61
80
 
62
81
 
82
+ def _resolve_profile_for_unauthenticated(profile_name: str | None) -> Profile:
83
+ """Resolve a profile for an unauthenticated call -- only the URL is required.
84
+
85
+ Order: explicit `--profile`, env vars (URL-only is sufficient here),
86
+ saved active profile. If none yield a URL, abort with a clear hint.
87
+ """
88
+ if profile_name is not None:
89
+ profile = load_config().get_profile(profile_name)
90
+ else:
91
+ profile = _profile_from_env_url_only() or load_config().get_profile()
92
+ if not profile.url:
93
+ abort(
94
+ "No DataMasque URL configured.",
95
+ code=ErrorCode.AUTH_REQUIRED,
96
+ hint=f"Set {ENV_URL} or run: dm auth login",
97
+ )
98
+ return profile
99
+
100
+
63
101
  def _resolve_profile_with_verify(profile_name: str | None) -> tuple[Profile, bool]:
64
102
  """Resolve the active `Profile` and apply env-var overrides for `verify_ssl`."""
65
103
  env_profile = profile_from_env() if profile_name is None else None
@@ -98,17 +136,43 @@ def get_client(profile_name: str | None = None) -> DataMasqueClient:
98
136
  `DATAMASQUE_VERIFY_SSL` always wins over the stored profile so you can
99
137
  flip TLS verification per-call without re-running `dm auth login`.
100
138
  """
101
- profile, verify_ssl = _resolve_profile_with_verify(profile_name)
139
+ client, profile, verify_ssl = _build_client(profile_name)
140
+ _authenticate_or_abort(client, profile.url, verify_ssl=verify_ssl)
141
+ return client
142
+
143
+
144
+ def get_unauthenticated_client(profile_name: str | None = None) -> DataMasqueClient:
145
+ """Build a `DataMasqueClient` without performing the up-front login handshake.
146
+
147
+ Used by commands that hit endpoints which don't require — or can't yet
148
+ use — a token. `admin-install` is the canonical example: on a fresh
149
+ server there's no user to authenticate as, so `client.authenticate()`
150
+ would always fail before the command ran.
151
+
152
+ Only `DATAMASQUE_URL` (or a profile with a URL) is required — username
153
+ and password aren't read by anonymous endpoints, so demanding them
154
+ would be unnecessary friction for first-run setup.
155
+ """
156
+ profile = _resolve_profile_for_unauthenticated(profile_name)
157
+ verify_ssl = _verify_ssl_from_env(default=profile.verify_ssl)
102
158
  instance_config = DataMasqueInstanceConfig(
103
159
  base_url=profile.url,
104
160
  username=profile.username,
105
161
  password=profile.password,
106
162
  verify_ssl=verify_ssl,
107
163
  )
164
+ return DataMasqueClient(instance_config)
108
165
 
109
- client = DataMasqueClient(instance_config)
110
- _authenticate_or_abort(client, profile.url, verify_ssl=verify_ssl)
111
- return client
166
+
167
+ def _build_client(profile_name: str | None) -> tuple[DataMasqueClient, Profile, bool]:
168
+ profile, verify_ssl = _resolve_profile_with_verify(profile_name)
169
+ instance_config = DataMasqueInstanceConfig(
170
+ base_url=profile.url,
171
+ username=profile.username,
172
+ password=profile.password,
173
+ verify_ssl=verify_ssl,
174
+ )
175
+ return DataMasqueClient(instance_config), profile, verify_ssl
112
176
 
113
177
 
114
178
  # Substrings that suggest the underlying error was a TLS failure rather than
@@ -6,7 +6,8 @@ import typer
6
6
 
7
7
  from datamasque_cli.client import get_client, profile_from_env
8
8
  from datamasque_cli.config import DEFAULT_PROFILE, Profile, load_config, save_config
9
- from datamasque_cli.output import ErrorCode, abort, print_info, print_success, print_table
9
+ from datamasque_cli.errors import ErrorCode, abort
10
+ from datamasque_cli.output import print_info, print_success, print_table
10
11
 
11
12
  # `login` and `status` handle connection errors locally
12
13
  # because they need softer behaviour than `get_client`'s hard abort:
@@ -2,25 +2,29 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- import json
6
5
  from enum import StrEnum
7
6
  from pathlib import Path
8
7
 
9
8
  import typer
10
9
  from datamasque.client import DataMasqueClient
10
+ from datamasque.client.exceptions import DataMasqueApiError
11
11
  from datamasque.client.models.connection import (
12
12
  AzureConnectionConfig,
13
13
  ConnectionConfig,
14
14
  DatabaseConnectionConfig,
15
15
  DatabaseType,
16
+ DatabricksConnectionConfig,
16
17
  DynamoConnectionConfig,
18
+ MongoConnectionConfig,
17
19
  MountedShareConnectionConfig,
18
20
  S3ConnectionConfig,
19
21
  SnowflakeConnectionConfig,
20
22
  )
21
23
 
22
24
  from datamasque_cli.client import get_client
23
- from datamasque_cli.output import ErrorCode, abort, print_success, redact_sensitive_fields, render_output
25
+ from datamasque_cli.errors import ErrorCode, abort, abort_api_error, confirm_or_abort
26
+ from datamasque_cli.fileio import read_json_object_or_abort
27
+ from datamasque_cli.output import print_success, redact_sensitive_fields, render_output
24
28
 
25
29
 
26
30
  class ConnectionType(StrEnum):
@@ -37,6 +41,8 @@ class ConnectionType(StrEnum):
37
41
  MOUNTED_SHARE = "mounted_share"
38
42
  SNOWFLAKE = "snowflake"
39
43
  DYNAMODB = "dynamodb"
44
+ DATABRICKS = "databricks"
45
+ MONGODB = "mongodb"
40
46
 
41
47
 
42
48
  _FILE_CONNECTION_TYPES = (MountedShareConnectionConfig, S3ConnectionConfig, AzureConnectionConfig)
@@ -69,6 +75,8 @@ _CONNECTION_CLASSES: dict[ConnectionType, type[ConnectionConfig]] = {
69
75
  ConnectionType.MOUNTED_SHARE: MountedShareConnectionConfig,
70
76
  ConnectionType.SNOWFLAKE: SnowflakeConnectionConfig,
71
77
  ConnectionType.DYNAMODB: DynamoConnectionConfig,
78
+ ConnectionType.DATABRICKS: DatabricksConnectionConfig,
79
+ ConnectionType.MONGODB: MongoConnectionConfig,
72
80
  }
73
81
 
74
82
 
@@ -131,7 +139,9 @@ def get_connection(
131
139
  def create_connection(
132
140
  file: Path | None = typer.Option(None, "--file", "-f", help="JSON file defining the connection"),
133
141
  name: str | None = typer.Option(None, help="Connection name"),
134
- conn_type: str | None = typer.Option(None, "--type", "-t", help="database, s3, azure, mounted_share"),
142
+ conn_type: str | None = typer.Option(
143
+ None, "--type", "-t", help="database, s3, azure, mounted_share, snowflake, dynamodb, databricks, mongodb"
144
+ ),
135
145
  host: str | None = typer.Option(None, help="Database host"),
136
146
  port: str | None = typer.Option(None, help="Database port"),
137
147
  database: str | None = typer.Option(None, help="Database name"),
@@ -160,6 +170,11 @@ def create_connection(
160
170
 
161
171
  # Quick mounted share
162
172
  dm connections create --name input --type mounted_share --base-dir my-data --source
173
+
174
+ # Databricks, MongoDB, Snowflake and DynamoDB have many fields, so use --file:
175
+ # {"type": "databricks", "name": "dbx", "server_hostname": "...", "http_path": "...",
176
+ # "access_token": "...", "catalog": "main", "schema": "default"}
177
+ dm connections create --file databricks.json
163
178
  """
164
179
  client = get_client(profile)
165
180
 
@@ -192,8 +207,11 @@ def create_connection(
192
207
 
193
208
  def _create_from_file(client: DataMasqueClient, file: Path) -> None:
194
209
  """Create a connection from a JSON file."""
195
- data = json.loads(file.read_text())
196
- conn_type = _parse_connection_type(data.pop("type", "database"))
210
+ data = read_json_object_or_abort(file)
211
+ raw_type = data.pop("type", "database")
212
+ if not isinstance(raw_type, str):
213
+ abort(f'{file}: "type" must be a string.', code=ErrorCode.INVALID_INPUT)
214
+ conn_type = _parse_connection_type(raw_type)
197
215
 
198
216
  # Convert db_type string to enum for database connections.
199
217
  if conn_type is ConnectionType.DATABASE and "database_type" in data:
@@ -285,7 +303,10 @@ def test_connection(
285
303
  if match is None:
286
304
  abort(f"Connection '{name}' not found.", code=ErrorCode.NOT_FOUND)
287
305
 
288
- response = client.make_request("POST", f"/api/connections/{match.id}/test/", data={})
306
+ try:
307
+ response = client.make_request("POST", f"/api/connections/{match.id}/test/", data={})
308
+ except DataMasqueApiError as exc:
309
+ abort_api_error(f"Connection '{match.name}' is not reachable", exc)
289
310
  body = response.json() if response.content else {}
290
311
  warning = body.get("message") if isinstance(body, dict) else None
291
312
 
@@ -334,7 +355,12 @@ def update_connection(
334
355
  if not updates:
335
356
  abort("Pass at least one field to update (e.g. --password, --host).", code=ErrorCode.INVALID_INPUT)
336
357
 
337
- client.make_request("PATCH", f"/api/connections/{match.id}/", data=updates)
358
+ payload = dict(updates)
359
+ # `dbpassword` is the server's field name for the database password on connection PATCH.
360
+ if "password" in payload:
361
+ payload["dbpassword"] = payload.pop("password")
362
+
363
+ client.make_request("PATCH", f"/api/connections/{match.id}/", data=payload)
338
364
  print_success(f"Connection '{match.name}' updated: {', '.join(updates)}.")
339
365
 
340
366
 
@@ -350,7 +376,7 @@ def delete_connection(
350
376
  abort(f"Connection '{name}' not found.", code=ErrorCode.NOT_FOUND)
351
377
 
352
378
  if not is_confirmed:
353
- typer.confirm(f"Delete connection '{name}'?", abort=True)
379
+ confirm_or_abort(f"Delete connection '{name}'?")
354
380
 
355
381
  client.delete_connection_by_name_if_exists(name)
356
382
  print_success(f"Connection '{name}' deleted.")