datamasque-python 1.2.1__tar.gz → 1.2.2__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 (91) hide show
  1. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/HISTORY.rst +11 -0
  2. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/PKG-INFO +1 -1
  3. datamasque_python-1.2.2/RELEASING.rst +223 -0
  4. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/datamasque/client/discovery_config_libraries.py +8 -3
  5. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/datamasque/client/discovery_configs.py +14 -2
  6. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/datamasque/client/models/discovery_config.py +11 -2
  7. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/datamasque/client/models/discovery_config_library.py +2 -0
  8. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/pyproject.toml +1 -2
  9. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/tests/test_discovery_config_libraries.py +28 -11
  10. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/tests/test_discovery_configs.py +94 -0
  11. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/uv.lock +1 -12
  12. datamasque_python-1.2.1/setup.cfg +0 -8
  13. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/.editorconfig +0 -0
  14. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/.github/workflows/ci.yml +0 -0
  15. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/.github/workflows/release-testpypi.yml +0 -0
  16. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/.github/workflows/release.yml +0 -0
  17. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/.gitignore +0 -0
  18. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/.readthedocs.yaml +0 -0
  19. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/CONTRIBUTING.rst +0 -0
  20. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/LICENSE +0 -0
  21. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/MANIFEST.in +0 -0
  22. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/Makefile +0 -0
  23. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/NOTICE +0 -0
  24. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/README.rst +0 -0
  25. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/datamasque/client/__init__.py +0 -0
  26. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/datamasque/client/base.py +0 -0
  27. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/datamasque/client/connections.py +0 -0
  28. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/datamasque/client/discovery.py +0 -0
  29. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/datamasque/client/dmclient.py +0 -0
  30. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/datamasque/client/exceptions.py +0 -0
  31. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/datamasque/client/files.py +0 -0
  32. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/datamasque/client/ifm.py +0 -0
  33. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/datamasque/client/license.py +0 -0
  34. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/datamasque/client/models/__init__.py +0 -0
  35. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/datamasque/client/models/connection.py +0 -0
  36. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/datamasque/client/models/data_selection.py +0 -0
  37. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/datamasque/client/models/discovery.py +0 -0
  38. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/datamasque/client/models/dm_instance.py +0 -0
  39. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/datamasque/client/models/files.py +0 -0
  40. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/datamasque/client/models/git.py +0 -0
  41. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/datamasque/client/models/ifm.py +0 -0
  42. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/datamasque/client/models/license.py +0 -0
  43. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/datamasque/client/models/pagination.py +0 -0
  44. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/datamasque/client/models/rg_config.py +0 -0
  45. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/datamasque/client/models/ruleset.py +0 -0
  46. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/datamasque/client/models/ruleset_library.py +0 -0
  47. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/datamasque/client/models/runs.py +0 -0
  48. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/datamasque/client/models/safe_data_preview.py +0 -0
  49. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/datamasque/client/models/status.py +0 -0
  50. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/datamasque/client/models/table_reference.py +0 -0
  51. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/datamasque/client/models/user.py +0 -0
  52. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/datamasque/client/py.typed +0 -0
  53. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/datamasque/client/rg_configs.py +0 -0
  54. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/datamasque/client/ruleset_libraries.py +0 -0
  55. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/datamasque/client/rulesets.py +0 -0
  56. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/datamasque/client/runs.py +0 -0
  57. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/datamasque/client/settings.py +0 -0
  58. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/datamasque/client/spcs.py +0 -0
  59. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/datamasque/client/table_references.py +0 -0
  60. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/datamasque/client/users.py +0 -0
  61. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/docs/Makefile +0 -0
  62. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/docs/client.models.rst +0 -0
  63. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/docs/client.rst +0 -0
  64. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/docs/conf.py +0 -0
  65. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/docs/contributing.rst +0 -0
  66. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/docs/history.rst +0 -0
  67. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/docs/index.rst +0 -0
  68. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/docs/installation.rst +0 -0
  69. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/docs/make.bat +0 -0
  70. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/docs/modules.rst +0 -0
  71. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/docs/readme.rst +0 -0
  72. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/docs/usage.rst +0 -0
  73. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/tests/__init__.py +0 -0
  74. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/tests/conftest.py +0 -0
  75. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/tests/helpers.py +0 -0
  76. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/tests/test_base.py +0 -0
  77. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/tests/test_connections.py +0 -0
  78. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/tests/test_discovery.py +0 -0
  79. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/tests/test_files.py +0 -0
  80. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/tests/test_ifm.py +0 -0
  81. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/tests/test_license.py +0 -0
  82. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/tests/test_pagination.py +0 -0
  83. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/tests/test_rg_configs.py +0 -0
  84. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/tests/test_ruleset_library.py +0 -0
  85. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/tests/test_rulesets.py +0 -0
  86. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/tests/test_runs.py +0 -0
  87. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/tests/test_safe_data_preview.py +0 -0
  88. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/tests/test_settings.py +0 -0
  89. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/tests/test_spcs.py +0 -0
  90. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/tests/test_table_references.py +0 -0
  91. {datamasque_python-1.2.1 → datamasque_python-1.2.2}/tests/test_users.py +0 -0
@@ -2,6 +2,17 @@
2
2
  History
3
3
  =======
4
4
 
5
+ 1.2.2 (2026-07-31)
6
+ ------------------
7
+
8
+ * Added ``validation_error_details`` to ``DiscoveryConfig``.
9
+ * Added ``usage_count`` to ``DiscoveryConfigLibrary``.
10
+ * ``create_discovery_config``, ``update_discovery_config``, ``create_discovery_config_library``, and
11
+ ``update_discovery_config_library`` now raise ``ValueError`` when the passed entity has no ``yaml``
12
+ content, instead of sending a request the server rejects.
13
+
14
+ Requires server version 3.26.14
15
+
5
16
  1.2.1 (2026-07-30)
6
17
  ------------------
7
18
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: datamasque-python
3
- Version: 1.2.1
3
+ Version: 1.2.2
4
4
  Summary: Official Python client for the DataMasque data-masking API.
5
5
  Project-URL: Homepage, https://datamasque.com/
6
6
  Project-URL: Documentation, https://datamasque-python.readthedocs.io/
@@ -0,0 +1,223 @@
1
+ =========
2
+ Releasing
3
+ =========
4
+
5
+ For DataMasque staff / maintainers of this project.
6
+ Covers production releases to PyPI, dev releases to TestPyPI, and how downstream projects pin ``datamasque-python``.
7
+
8
+ The assumed starting point is that you have a ``datamasque-python`` feature/fix PR in progress,
9
+ and want to know how to get it pushed up to PyPI once merged,
10
+ or how to build a test release / pin to a particular commit so you can test before merging the PR.
11
+
12
+ Version numbers live in two places
13
+ ==================================
14
+
15
+ Every release must update both, or CI will reject the tag.
16
+ As part of your PR, update:
17
+
18
+ 1. ``pyproject.toml`` — ``[project] version``.
19
+ This is the version the built sdist/wheel carries,
20
+ and the one ``release.yml`` checks the git tag against.
21
+ 2. ``uv.lock`` — the ``version`` field of the ``datamasque-python`` package entry.
22
+ CI runs ``uv sync --frozen``, so a stale lock fails every job.
23
+
24
+ Edit ``pyproject.toml`` by hand, then run ``uv lock`` to update the lock entry.
25
+ Don't hand-edit ``uv.lock``.
26
+
27
+ Don't update ``datamasque.client.__version__`` or ``docs/conf.py``.
28
+ These read the installed package metadata.
29
+
30
+ Updating the changelog
31
+ ======================
32
+
33
+ Do this as part of your PR.
34
+
35
+ ``HISTORY.rst`` needs a new entry for each release to pypi.
36
+ Add a new entry at the top, under the ``History`` heading, with the new version and today's date.
37
+ Use short summaries of additions and changes, written with past tense and worded for a customer consumer of this library.
38
+ For example::
39
+
40
+ 1.2.2 (2026-08-05)
41
+ ------------------
42
+
43
+ * Added ``get_all_widgets`` API.
44
+ * Fixed issue where ``list_frobs`` would incorrectly raise a ``ValueError`` when using the filtering options.
45
+
46
+ Requires server version 3.26.14.
47
+
48
+ Call out breaking changes explicitly,
49
+ and note the minimum DataMasque server version if the release requires one.
50
+
51
+ Releasing to PyPI
52
+ =================
53
+
54
+ 1. Get your PR approved and merged.
55
+ 2. Tag the merge commit on ``main`` and push the tag::
56
+
57
+ git checkout main
58
+ git pull --ff-only
59
+ git tag v1.2.2 # or whatever is your version number
60
+ git push origin v1.2.2
61
+
62
+ The tag must be ``v`` + the exact ``pyproject.toml`` version.
63
+ ``release.yml`` triggers on ``v*.*.*`` and fails the build if the two disagree.
64
+ Tag only after the PR has merged, so the tag points at a commit on ``main``.
65
+ 3. The admins of the repo will get an automated email asking them to approve the deployment.
66
+ They can do this by visiting the Workflows page or by clicking the link in the email.
67
+ 4. Once approved, the build will appear on PyPI very quickly (around 1 minute).
68
+ You can verify that the release appears at https://pypi.org/project/datamasque-python/,
69
+ and Read the Docs has built the new tag
70
+ at https://datamasque-python.readthedocs.io/.
71
+ 5. Create the GitHub Release (see below).
72
+
73
+ Creating the GitHub Release
74
+ ===========================
75
+
76
+ Do this after the PyPI publish has succeeded,
77
+ so the release never points at a version nobody can install.
78
+
79
+ 1. On the repository home page,
80
+ find **Releases** in the right-hand sidebar under the *About* box,
81
+ and click it,
82
+ then **Draft a new release**.
83
+ 2. **Choose a tag** — pick the existing tag you pushed as part of releasing to PyPI.
84
+ Don't let GitHub create a new one; the tag should already exist from the release flow.
85
+ 3. Set the target to ``main``.
86
+ 4. Title it the same as the tag, e.g. ``v1.2.2``.
87
+ 5. Paste the ``HISTORY.rst`` entry for this version into the body, converted to Markdown.
88
+ **Generate release notes** is a reasonable starting point for the commit list,
89
+ but the hand-written changelog is what users read.
90
+ 6. Leave *Set as a pre-release* unticked for a normal release.
91
+ 7. Click **Publish release**.
92
+
93
+ Creating releases can also be done from the ``gh`` CLI::
94
+
95
+ gh release create v1.2.2 --title v1.2.2 --notes-file notes.md
96
+
97
+ Releasing a dev build to TestPyPI
98
+ =================================
99
+
100
+ Use this to let a downstream project try an unreleased change.
101
+ It builds from any ref and never touches PyPI.
102
+
103
+ 1. Push the branch you want to publish.
104
+ Nothing needs to be merged first.
105
+ 2. Go to *Actions* → *Release (TestPyPI)* → **Run workflow**.
106
+ 3. Fill in the inputs:
107
+
108
+ - **ref** — the branch to build from.
109
+ - **dev_version** — the version to publish, for example ``1.3.0.dev1``.
110
+
111
+ Use a ``.devN`` suffix.
112
+ The input is validated, so a plain release version like ``1.3.0`` is rejected.
113
+
114
+ **Note:** Version numbers cannot be reused. Ensure you increment the suffix each time.
115
+
116
+ 4. No approval is needed — unlike a PyPI release, the build publishes as soon as it passes.
117
+ 5. Verify at https://test.pypi.org/project/datamasque-python/.
118
+
119
+ **Note:** Do **not** create a git tag or a GitHub Release for a TestPyPI build.
120
+
121
+ Pointing a project at a release
122
+ ===============================
123
+
124
+ Three ways to depend on ``datamasque-python``, depending on what you need.
125
+
126
+ A released version on PyPI
127
+ --------------------------
128
+
129
+ The usual case.
130
+ In the consuming project's ``pyproject.toml``::
131
+
132
+ dependencies = [
133
+ "datamasque-python==1.2.2",
134
+ ]
135
+
136
+ Always give a version specifier.
137
+ An unpinned ``"datamasque-python"`` means "whatever is newest at the moment this resolves",
138
+ which is prone to breaking when someone releases a ``datamasque-python`` change before the corresponding server release.
139
+
140
+ Pin exactly (``==1.2.2``) when you want every upgrade to be a deliberate, reviewed change.
141
+ A bounded range (``>=1.2.2,<2``) is acceptable where you need a floor for a specific feature,
142
+ but note that this project does sometimes ship breaking changes
143
+ (e.g. 1.2.0 removed ``config_type`` from the discovery config library APIs),
144
+ so read the ``HISTORY.rst`` entries between your current version and the new one before raising the floor.
145
+
146
+ A dev build on TestPyPI
147
+ -----------------------
148
+
149
+ TestPyPI is a separate index, so it must be declared as well as pinned.
150
+ Pin the exact dev version — TestPyPI content is disposable.
151
+
152
+ **Note:** Always replace a TestPyPI pin with a real PyPI version before merging the consuming project —
153
+ TestPyPI is not a durable index,
154
+ and the downstream project should always use a "proper" (normal PyPI) version of ``datamasque-python`` once merged.
155
+
156
+ With ``uv``::
157
+
158
+ [project]
159
+ dependencies = [
160
+ "datamasque-python==1.3.0.dev1",
161
+ ]
162
+
163
+ [[tool.uv.index]]
164
+ name = "testpypi"
165
+ url = "https://test.pypi.org/simple/"
166
+ explicit = true
167
+
168
+ [tool.uv.sources]
169
+ datamasque-python = { index = "testpypi" }
170
+
171
+ **Note:** Be sure to include the ``explicit = true``:
172
+ without it, ``uv`` will resolve *every* dependency against TestPyPI, which mirrors PyPI only partially.
173
+
174
+ With Poetry::
175
+
176
+ [[tool.poetry.source]]
177
+ name = "testpypi"
178
+ url = "https://test.pypi.org/simple/"
179
+ priority = "explicit"
180
+
181
+ [tool.poetry.dependencies]
182
+ datamasque-python = { version = "1.3.0.dev1", source = "testpypi" }
183
+
184
+ Ad hoc, without editing anything::
185
+
186
+ pip install \
187
+ --index-url https://test.pypi.org/simple/ \
188
+ --extra-index-url https://pypi.org/simple/ \
189
+ datamasque-python==1.3.0.dev1
190
+
191
+
192
+ A branch or commit on GitHub
193
+ ----------------------------
194
+
195
+ For testing an unmerged change without publishing anything at all.
196
+ Prefer a commit SHA over a branch name — a branch ref can change under you, and a lockfile pinned to one is not reproducible.
197
+
198
+ **Note:** Always replace a git pin with a PyPI version before merging the consuming project,
199
+ for the same reasons as above, plus the fact git dependencies break any downstream install that lacks repository access.
200
+
201
+ ``uv`` sources form, which keeps the version constraint readable::
202
+
203
+ [project]
204
+ dependencies = [
205
+ "datamasque-python",
206
+ ]
207
+
208
+ [tool.uv.sources]
209
+ datamasque-python = { git = "https://github.com/datamasque/datamasque-python.git", rev = "ab12cd34" }
210
+
211
+ With Poetry::
212
+
213
+ [tool.poetry.dependencies]
214
+ datamasque-python = { git = "https://github.com/datamasque/datamasque-python.git", rev = "ab12cd34" }
215
+
216
+ Use ``git+ssh://git@github.com/...`` instead of ``https`` if the consumer builds somewhere without an HTTPS credential for the repository.
217
+
218
+ PEP 508 direct reference,
219
+ which ``pip`` and ``uv`` both understand::
220
+
221
+ dependencies = [
222
+ "datamasque-python @ git+https://github.com/datamasque/datamasque-python.git@ab12cd34",
223
+ ]
@@ -76,15 +76,19 @@ class DiscoveryConfigLibraryClient(BaseClient):
76
76
  Creates a new discovery config library on the server.
77
77
 
78
78
  Sets the library's server-assigned fields
79
- (`id`, `is_valid`, `validation_error`, `created`, `modified`) and returns the library.
79
+ (`id`, `is_valid`, `validation_error`, `usage_count`, `created`, `modified`) and returns the library.
80
80
  """
81
81
 
82
+ if not library.yaml:
83
+ raise ValueError("Cannot create a discovery config library without YAML content (yaml is empty)")
84
+
82
85
  data = library.model_dump(exclude_none=True, by_alias=True, mode="json")
83
86
  response = self.make_request("POST", "/api/discovery/config-libraries/", data=data)
84
87
  created = DiscoveryConfigLibrary.model_validate(response.json())
85
88
  library.id = created.id
86
89
  library.is_valid = created.is_valid
87
90
  library.validation_error = created.validation_error
91
+ library.usage_count = created.usage_count
88
92
  library.created = created.created
89
93
  library.modified = created.modified
90
94
  logger.info('Creation of discovery config library "%s" successful', library.name)
@@ -101,9 +105,9 @@ class DiscoveryConfigLibraryClient(BaseClient):
101
105
  if library.id is None:
102
106
  raise ValueError("Cannot update a discovery config library that has not been created yet (id is None)")
103
107
 
104
- if library.yaml is None:
108
+ if not library.yaml:
105
109
  raise ValueError(
106
- "Cannot update a discovery config library without YAML content (yaml is None); "
110
+ "Cannot update a discovery config library without YAML content (yaml is empty or unset); "
107
111
  "list results omit YAML, so fetch the full library with `get_discovery_config_library` first"
108
112
  )
109
113
 
@@ -112,6 +116,7 @@ class DiscoveryConfigLibraryClient(BaseClient):
112
116
  updated = DiscoveryConfigLibrary.model_validate(response.json())
113
117
  library.is_valid = updated.is_valid
114
118
  library.validation_error = updated.validation_error
119
+ library.usage_count = updated.usage_count
115
120
  library.modified = updated.modified
116
121
  logger.debug('Update of discovery config library "%s" successful', library.name)
117
122
  return library
@@ -75,15 +75,20 @@ class DiscoveryConfigClient(BaseClient):
75
75
  Creates a new discovery config on the server.
76
76
 
77
77
  Sets the config's server-assigned fields
78
- (`id`, `is_valid`, `validation_error`, `created`, `modified`) and returns the config.
78
+ (`id`, `is_valid`, `validation_error`, `validation_error_details`, `created`, `modified`)
79
+ and returns the config.
79
80
  """
80
81
 
82
+ if not config.yaml:
83
+ raise ValueError("Cannot create a discovery config without YAML content (yaml is empty)")
84
+
81
85
  data = config.model_dump(exclude_none=True, by_alias=True, mode="json")
82
86
  response = self.make_request("POST", "/api/discovery/configs/", data=data)
83
87
  created = DiscoveryConfig.model_validate(response.json())
84
88
  config.id = created.id
85
89
  config.is_valid = created.is_valid
86
90
  config.validation_error = created.validation_error
91
+ config.validation_error_details = created.validation_error_details
87
92
  config.created = created.created
88
93
  config.modified = created.modified
89
94
  logger.info('Creation of discovery config "%s" successful', config.name)
@@ -94,17 +99,24 @@ class DiscoveryConfigClient(BaseClient):
94
99
  Performs a full update of the discovery config.
95
100
 
96
101
  The config must have its `id` set
97
- (i.e., it must have been previously created or retrieved from the server).
102
+ and its `yaml` content present.
98
103
  """
99
104
 
100
105
  if config.id is None:
101
106
  raise ValueError("Cannot update a discovery config that has not been created yet (id is None)")
102
107
 
108
+ if not config.yaml:
109
+ raise ValueError(
110
+ "Cannot update a discovery config without YAML content (yaml is empty or unset); "
111
+ "list results omit YAML, so fetch the full config with `get_discovery_config` first"
112
+ )
113
+
103
114
  data = config.model_dump(exclude_none=True, by_alias=True, mode="json")
104
115
  response = self.make_request("PUT", f"/api/discovery/configs/{config.id}/", data=data)
105
116
  updated = DiscoveryConfig.model_validate(response.json())
106
117
  config.is_valid = updated.is_valid
107
118
  config.validation_error = updated.validation_error
119
+ config.validation_error_details = updated.validation_error_details
108
120
  config.modified = updated.modified
109
121
  logger.debug('Update of discovery config "%s" successful', config.name)
110
122
  return config
@@ -2,9 +2,9 @@ import enum
2
2
  from datetime import datetime
3
3
  from typing import Any, NewType, Optional
4
4
 
5
- from pydantic import BaseModel, ConfigDict, Field
5
+ from pydantic import AliasChoices, AliasPath, BaseModel, ConfigDict, Field
6
6
 
7
- from datamasque.client.models.status import ValidationStatus
7
+ from datamasque.client.models.status import ValidationErrorDetails, ValidationStatus
8
8
 
9
9
  DiscoveryConfigId = NewType("DiscoveryConfigId", str)
10
10
 
@@ -49,5 +49,14 @@ class DiscoveryConfig(BaseModel):
49
49
  """Validation status; may be `in_progress` briefly after creating a large config."""
50
50
  validation_error: Optional[str] = Field(default=None, exclude=True)
51
51
  """Human-readable validation error, or `None` when valid."""
52
+ # Deliberately not `validation_errors`:
53
+ # this is a different shape to `Ruleset.validation_errors`,
54
+ # and would sit one character from `validation_error` above.
55
+ validation_error_details: list[ValidationErrorDetails] = Field(
56
+ default_factory=list,
57
+ exclude=True,
58
+ validation_alias=AliasChoices(AliasPath("errors", "config_yaml"), "validation_error_details"),
59
+ )
60
+ """Structured, positional validation errors."""
52
61
  created: Optional[datetime] = Field(default=None, exclude=True)
53
62
  modified: Optional[datetime] = Field(default=None, exclude=True)
@@ -27,5 +27,7 @@ class DiscoveryConfigLibrary(BaseModel):
27
27
  """Validation status; libraries are validated synchronously on create/update."""
28
28
  validation_error: Optional[str] = Field(default=None, exclude=True)
29
29
  """Human-readable validation error, or `None` when valid."""
30
+ usage_count: Optional[int] = Field(default=None, exclude=True)
31
+ """Number of active discovery configs that import this library."""
30
32
  created: Optional[datetime] = Field(default=None, exclude=True)
31
33
  modified: Optional[datetime] = Field(default=None, exclude=True)
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "datamasque-python"
3
- version = "1.2.1"
3
+ version = "1.2.2"
4
4
  description = "Official Python client for the DataMasque data-masking API."
5
5
  authors = [
6
6
  { name = "DataMasque Ltd" },
@@ -47,7 +47,6 @@ Issues = "https://github.com/datamasque/datamasque-python/issues"
47
47
 
48
48
  [dependency-groups]
49
49
  dev = [
50
- "bump2version>=1.0.1",
51
50
  "ruff>=0.9.0",
52
51
  "pytest>=7.4.4",
53
52
  "Sphinx>=7.2.6",
@@ -93,10 +93,12 @@ def test_list_discovery_config_libraries(
93
93
  assert libraries[0].namespace == "org"
94
94
  assert libraries[0].yaml is None
95
95
  assert libraries[0].is_valid is ValidationStatus.valid
96
+ assert libraries[0].usage_count == 0
96
97
  assert libraries[1].id == DiscoveryConfigLibraryId(LIBRARY_ID_2)
97
98
  assert libraries[1].name == "another_library"
98
99
  assert libraries[1].is_valid is ValidationStatus.invalid
99
100
  assert libraries[1].validation_error == "bad yaml"
101
+ assert libraries[1].usage_count == 2
100
102
 
101
103
 
102
104
  def test_list_discovery_config_libraries_empty(client: DataMasqueClient) -> None:
@@ -125,6 +127,7 @@ def test_get_discovery_config_library(client: DataMasqueClient, sample_library_d
125
127
  assert library.namespace == "org"
126
128
  assert library.yaml == "labels: []\nmetadata_rules: []\nidd_rules: []\n"
127
129
  assert library.is_valid is ValidationStatus.valid
130
+ assert library.usage_count == 0
128
131
 
129
132
 
130
133
  def test_get_discovery_config_library_by_name_found(
@@ -248,6 +251,7 @@ def test_create_discovery_config_library(client: DataMasqueClient, config_librar
248
251
  "config_yaml": "labels: []\nmetadata_rules: []\nidd_rules: []\n",
249
252
  "is_valid": "valid",
250
253
  "validation_error": None,
254
+ "usage_count": 0,
251
255
  "created": "2025-06-01T10:00:00Z",
252
256
  "modified": "2025-06-01T10:00:00Z",
253
257
  }
@@ -263,16 +267,16 @@ def test_create_discovery_config_library(client: DataMasqueClient, config_librar
263
267
  assert result is config_library
264
268
  assert result.id == DiscoveryConfigLibraryId(LIBRARY_ID_1)
265
269
  assert result.is_valid is ValidationStatus.valid
270
+ assert result.usage_count == 0
266
271
  assert result.created == datetime.fromisoformat("2025-06-01T10:00:00+00:00")
267
272
  assert result.modified == datetime.fromisoformat("2025-06-01T10:00:00+00:00")
268
273
 
269
274
  request_body = m.last_request.json()
270
- assert request_body["name"] == "test_library"
271
- assert request_body["namespace"] == "test_ns"
272
- assert "config_type" not in request_body
273
- assert request_body["config_yaml"] == "labels: []\nmetadata_rules: []\nidd_rules: []\n"
274
- read_only_fields = {"id", "is_valid", "validation_error", "created", "modified"}
275
- assert not read_only_fields & request_body.keys()
275
+ assert request_body == {
276
+ "name": "test_library",
277
+ "namespace": "test_ns",
278
+ "config_yaml": "labels: []\nmetadata_rules: []\nidd_rules: []\n",
279
+ }
276
280
 
277
281
 
278
282
  def test_create_discovery_config_library_reports_validation_error(
@@ -312,6 +316,7 @@ def test_update_discovery_config_library(client: DataMasqueClient, config_librar
312
316
  "config_yaml": "labels: []\nmetadata_rules: []\nidd_rules: []\n",
313
317
  "is_valid": "valid",
314
318
  "validation_error": None,
319
+ "usage_count": 3,
315
320
  "created": "2025-06-01T10:00:00Z",
316
321
  "modified": "2025-06-02T10:00:00Z",
317
322
  }
@@ -327,13 +332,15 @@ def test_update_discovery_config_library(client: DataMasqueClient, config_librar
327
332
  assert result is config_library
328
333
  assert result.is_valid is ValidationStatus.valid
329
334
  assert result.validation_error is None
335
+ assert result.usage_count == 3
330
336
  assert result.modified == datetime.fromisoformat("2025-06-02T10:00:00+00:00")
331
337
 
332
338
  request_body = m.last_request.json()
333
- assert request_body["name"] == "test_library"
334
- assert request_body["config_yaml"] == "labels: []\nmetadata_rules: []\nidd_rules: []\n"
335
- read_only_fields = {"id", "is_valid", "validation_error", "created", "modified"}
336
- assert not read_only_fields & request_body.keys()
339
+ assert request_body == {
340
+ "name": "test_library",
341
+ "namespace": "test_ns",
342
+ "config_yaml": "labels: []\nmetadata_rules: []\nidd_rules: []\n",
343
+ }
337
344
 
338
345
 
339
346
  def test_update_discovery_config_library_no_id_raises(
@@ -349,7 +356,7 @@ def test_update_discovery_config_library_without_yaml_raises(
349
356
  config_library.id = DiscoveryConfigLibraryId(LIBRARY_ID_1)
350
357
  config_library.yaml = None
351
358
 
352
- with pytest.raises(ValueError, match="yaml is None"):
359
+ with pytest.raises(ValueError, match="without YAML content"):
353
360
  client.update_discovery_config_library(config_library)
354
361
 
355
362
 
@@ -493,3 +500,13 @@ def test_delete_discovery_config_library_by_name_not_found(
493
500
 
494
501
  assert m.call_count == 1
495
502
  assert m.request_history[0].method == "GET"
503
+
504
+
505
+ def test_create_discovery_config_library_with_empty_yaml_raises(client: DataMasqueClient) -> None:
506
+ library = DiscoveryConfigLibrary(name="test_library", yaml="")
507
+
508
+ with requests_mock.Mocker() as m:
509
+ with pytest.raises(ValueError, match="without YAML content"):
510
+ client.create_discovery_config_library(library)
511
+
512
+ assert not any(request.method == "POST" for request in m.request_history)
@@ -5,6 +5,7 @@ from typing import Any
5
5
 
6
6
  import pytest
7
7
  import requests_mock
8
+ from pydantic import JsonValue, ValidationError
8
9
 
9
10
  from datamasque.client import DataMasqueClient
10
11
  from datamasque.client.exceptions import DataMasqueApiError, DataMasqueException
@@ -310,6 +311,16 @@ def test_update_discovery_config_no_id_raises(client: DataMasqueClient, discover
310
311
  client.update_discovery_config(discovery_config)
311
312
 
312
313
 
314
+ def test_update_discovery_config_without_yaml_raises(
315
+ client: DataMasqueClient, discovery_config: DiscoveryConfig
316
+ ) -> None:
317
+ discovery_config.id = DiscoveryConfigId(CONFIG_ID_1)
318
+ discovery_config.yaml = None
319
+
320
+ with pytest.raises(ValueError, match="without YAML content"):
321
+ client.update_discovery_config(discovery_config)
322
+
323
+
313
324
  def test_create_or_update_discovery_config_create(client: DataMasqueClient, discovery_config: DiscoveryConfig) -> None:
314
325
  empty_list = {"count": 0, "next": None, "previous": None, "results": []}
315
326
  create_response = {
@@ -518,3 +529,86 @@ def test_unwrap_discovery_config_id_raises_without_id() -> None:
518
529
  config = DiscoveryConfig(name="x", config_type="database")
519
530
  with pytest.raises(ValueError, match="id is None"):
520
531
  unwrap_discovery_config_id(config)
532
+
533
+
534
+ def _build_config_response(is_valid: str, **extra: JsonValue) -> dict[str, JsonValue]:
535
+ return {
536
+ "id": CONFIG_ID_1,
537
+ "name": "test_config",
538
+ "config_type": "database",
539
+ "is_valid": is_valid,
540
+ "validation_error": None,
541
+ **extra,
542
+ }
543
+
544
+
545
+ def test_discovery_config_promotes_errors_payload() -> None:
546
+ config = DiscoveryConfig.model_validate(
547
+ _build_config_response(
548
+ "invalid",
549
+ validation_error="Unknown mask 'foo'",
550
+ errors={"config_yaml": [{"message": "Unknown mask 'foo'", "line_number": 3, "column_number": 5}]},
551
+ )
552
+ )
553
+
554
+ assert config.is_valid is ValidationStatus.invalid
555
+ assert len(config.validation_error_details) == 1
556
+ detail = config.validation_error_details[0]
557
+ assert detail.message == "Unknown mask 'foo'"
558
+ assert detail.line_number == 3
559
+ assert detail.column_number == 5
560
+ assert "errors" not in (config.model_extra or {})
561
+
562
+
563
+ def test_discovery_config_accepts_flat_details_list() -> None:
564
+ config = DiscoveryConfig.model_validate(
565
+ _build_config_response(
566
+ "invalid",
567
+ validation_error_details=[{"message": "Unknown mask 'foo'", "line_number": 3}],
568
+ )
569
+ )
570
+
571
+ assert [detail.message for detail in config.validation_error_details] == ["Unknown mask 'foo'"]
572
+
573
+
574
+ def test_discovery_config_accepts_empty_errors_map() -> None:
575
+ config = DiscoveryConfig.model_validate(_build_config_response("valid", errors={}))
576
+
577
+ assert config.validation_error_details == []
578
+
579
+
580
+ def test_discovery_config_rejects_non_list_error_group() -> None:
581
+ with pytest.raises(ValidationError, match="config_yaml"):
582
+ DiscoveryConfig.model_validate(_build_config_response("invalid", errors={"config_yaml": "Unknown mask 'foo'"}))
583
+
584
+
585
+ def test_discovery_config_rejects_null_error_group() -> None:
586
+ with pytest.raises(ValidationError, match="config_yaml"):
587
+ DiscoveryConfig.model_validate(_build_config_response("invalid", errors={"config_yaml": None}))
588
+
589
+
590
+ def test_discovery_config_rejects_malformed_error_entry() -> None:
591
+ with pytest.raises(ValidationError):
592
+ DiscoveryConfig.model_validate(
593
+ _build_config_response("invalid", errors={"config_yaml": ["Unknown mask 'foo'"]})
594
+ )
595
+
596
+
597
+ def test_create_discovery_config_with_empty_yaml_raises(client: DataMasqueClient) -> None:
598
+ config = DiscoveryConfig(name="test_config", yaml="", config_type="database")
599
+
600
+ with requests_mock.Mocker() as m:
601
+ with pytest.raises(ValueError, match="without YAML content"):
602
+ client.create_discovery_config(config)
603
+
604
+ assert not any(request.method == "POST" for request in m.request_history)
605
+
606
+
607
+ def test_update_discovery_config_with_empty_yaml_raises(client: DataMasqueClient) -> None:
608
+ config = DiscoveryConfig(id=CONFIG_ID_1, name="test_config", yaml="", config_type="database")
609
+
610
+ with requests_mock.Mocker() as m:
611
+ with pytest.raises(ValueError, match="without YAML content"):
612
+ client.update_discovery_config(config)
613
+
614
+ assert not any(request.method == "PUT" for request in m.request_history)
@@ -52,15 +52,6 @@ wheels = [
52
52
  { url = "https://files.pythonhosted.org/packages/77/f5/21d2de20e8b8b0408f0681956ca2c69f1320a3848ac50e6e7f39c6159675/babel-2.18.0-py3-none-any.whl", hash = "sha256:e2b422b277c2b9a9630c1d7903c2a00d0830c409c59ac8cae9081c92f1aeba35", size = 10196845, upload-time = "2026-02-01T12:30:53.445Z" },
53
53
  ]
54
54
 
55
- [[package]]
56
- name = "bump2version"
57
- version = "1.0.1"
58
- source = { registry = "https://pypi.org/simple" }
59
- sdist = { url = "https://files.pythonhosted.org/packages/29/2a/688aca6eeebfe8941235be53f4da780c6edee05dbbea5d7abaa3aab6fad2/bump2version-1.0.1.tar.gz", hash = "sha256:762cb2bfad61f4ec8e2bdf452c7c267416f8c70dd9ecb1653fd0bbb01fa936e6", size = 36236, upload-time = "2020-10-07T18:38:40.119Z" }
60
- wheels = [
61
- { url = "https://files.pythonhosted.org/packages/1d/e3/fa60c47d7c344533142eb3af0b73234ef8ea3fb2da742ab976b947e717df/bump2version-1.0.1-py2.py3-none-any.whl", hash = "sha256:37f927ea17cde7ae2d7baf832f8e80ce3777624554a653006c9144f8017fe410", size = 22030, upload-time = "2020-10-07T18:38:38.148Z" },
62
- ]
63
-
64
55
  [[package]]
65
56
  name = "certifi"
66
57
  version = "2026.2.25"
@@ -428,7 +419,7 @@ toml = [
428
419
 
429
420
  [[package]]
430
421
  name = "datamasque-python"
431
- version = "1.2.1"
422
+ version = "1.2.2"
432
423
  source = { editable = "." }
433
424
  dependencies = [
434
425
  { name = "pydantic" },
@@ -437,7 +428,6 @@ dependencies = [
437
428
 
438
429
  [package.dev-dependencies]
439
430
  dev = [
440
- { name = "bump2version" },
441
431
  { name = "faker", version = "37.12.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.10'" },
442
432
  { name = "faker", version = "40.8.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.10'" },
443
433
  { name = "mypy" },
@@ -461,7 +451,6 @@ requires-dist = [
461
451
 
462
452
  [package.metadata.requires-dev]
463
453
  dev = [
464
- { name = "bump2version", specifier = ">=1.0.1" },
465
454
  { name = "faker", specifier = ">=22.2.0" },
466
455
  { name = "mypy", specifier = ">=1.8.0" },
467
456
  { name = "pytest", specifier = ">=7.4.4" },
@@ -1,8 +0,0 @@
1
- [bumpversion]
2
- current_version = 1.2.1
3
- commit = True
4
- tag = True
5
-
6
- [bumpversion:file:pyproject.toml]
7
- search = version = "{current_version}"
8
- replace = version = "{new_version}"