datamasque-python 1.2.0__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.
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/HISTORY.rst +16 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/PKG-INFO +1 -1
- datamasque_python-1.2.2/RELEASING.rst +223 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/datamasque/client/__init__.py +9 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/datamasque/client/discovery.py +198 -27
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/datamasque/client/discovery_config_libraries.py +8 -3
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/datamasque/client/discovery_configs.py +14 -2
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/datamasque/client/dmclient.py +2 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/datamasque/client/exceptions.py +8 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/datamasque/client/models/discovery.py +81 -2
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/datamasque/client/models/discovery_config.py +11 -2
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/datamasque/client/models/discovery_config_library.py +2 -0
- datamasque_python-1.2.2/datamasque/client/models/rg_config.py +49 -0
- datamasque_python-1.2.2/datamasque/client/rg_configs.py +155 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/datamasque/client/ruleset_libraries.py +4 -1
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/docs/client.models.rst +8 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/docs/client.rst +8 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/pyproject.toml +1 -2
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/tests/test_discovery.py +349 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/tests/test_discovery_config_libraries.py +28 -11
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/tests/test_discovery_configs.py +94 -0
- datamasque_python-1.2.2/tests/test_rg_configs.py +522 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/uv.lock +1 -12
- datamasque_python-1.2.0/setup.cfg +0 -8
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/.editorconfig +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/.github/workflows/ci.yml +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/.github/workflows/release-testpypi.yml +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/.github/workflows/release.yml +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/.gitignore +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/.readthedocs.yaml +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/CONTRIBUTING.rst +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/LICENSE +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/MANIFEST.in +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/Makefile +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/NOTICE +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/README.rst +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/datamasque/client/base.py +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/datamasque/client/connections.py +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/datamasque/client/files.py +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/datamasque/client/ifm.py +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/datamasque/client/license.py +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/datamasque/client/models/__init__.py +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/datamasque/client/models/connection.py +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/datamasque/client/models/data_selection.py +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/datamasque/client/models/dm_instance.py +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/datamasque/client/models/files.py +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/datamasque/client/models/git.py +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/datamasque/client/models/ifm.py +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/datamasque/client/models/license.py +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/datamasque/client/models/pagination.py +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/datamasque/client/models/ruleset.py +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/datamasque/client/models/ruleset_library.py +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/datamasque/client/models/runs.py +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/datamasque/client/models/safe_data_preview.py +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/datamasque/client/models/status.py +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/datamasque/client/models/table_reference.py +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/datamasque/client/models/user.py +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/datamasque/client/py.typed +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/datamasque/client/rulesets.py +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/datamasque/client/runs.py +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/datamasque/client/settings.py +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/datamasque/client/spcs.py +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/datamasque/client/table_references.py +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/datamasque/client/users.py +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/docs/Makefile +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/docs/conf.py +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/docs/contributing.rst +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/docs/history.rst +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/docs/index.rst +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/docs/installation.rst +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/docs/make.bat +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/docs/modules.rst +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/docs/readme.rst +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/docs/usage.rst +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/tests/__init__.py +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/tests/conftest.py +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/tests/helpers.py +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/tests/test_base.py +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/tests/test_connections.py +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/tests/test_files.py +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/tests/test_ifm.py +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/tests/test_license.py +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/tests/test_pagination.py +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/tests/test_ruleset_library.py +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/tests/test_rulesets.py +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/tests/test_runs.py +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/tests/test_safe_data_preview.py +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/tests/test_settings.py +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/tests/test_spcs.py +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/tests/test_table_references.py +0 -0
- {datamasque_python-1.2.0 → datamasque_python-1.2.2}/tests/test_users.py +0 -0
|
@@ -2,6 +2,22 @@
|
|
|
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
|
+
|
|
16
|
+
1.2.1 (2026-07-30)
|
|
17
|
+
------------------
|
|
18
|
+
|
|
19
|
+
* Added ruleset generation configuration
|
|
20
|
+
|
|
5
21
|
1.2.0 (2026-07-27)
|
|
6
22
|
------------------
|
|
7
23
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: datamasque-python
|
|
3
|
-
Version: 1.2.
|
|
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
|
+
]
|
|
@@ -23,6 +23,7 @@ from datamasque.client.exceptions import (
|
|
|
23
23
|
InvalidDiscoveryConfigError,
|
|
24
24
|
InvalidLibraryError,
|
|
25
25
|
InvalidRulesetError,
|
|
26
|
+
RGConfigNotFoundError,
|
|
26
27
|
RunNotCancellableError,
|
|
27
28
|
)
|
|
28
29
|
from datamasque.client.ifm import DataMasqueIfmClient
|
|
@@ -67,11 +68,13 @@ from datamasque.client.models.discovery import (
|
|
|
67
68
|
FileFilter,
|
|
68
69
|
FileFilterMatchAgainst,
|
|
69
70
|
FileRulesetGenerationRequest,
|
|
71
|
+
FileRulesetGenerationWithRGConfigRequest,
|
|
70
72
|
ForeignKeyRef,
|
|
71
73
|
InDataDiscoveryConfig,
|
|
72
74
|
InDataDiscoveryRule,
|
|
73
75
|
ReferencingForeignKey,
|
|
74
76
|
RulesetGenerationRequest,
|
|
77
|
+
RulesetGenerationWithRGConfigRequest,
|
|
75
78
|
SchemaDiscoveryColumn,
|
|
76
79
|
SchemaDiscoveryFromConfigRequest,
|
|
77
80
|
SchemaDiscoveryPage,
|
|
@@ -105,6 +108,7 @@ from datamasque.client.models.ifm import (
|
|
|
105
108
|
RulesetPlanUpdateRequest,
|
|
106
109
|
)
|
|
107
110
|
from datamasque.client.models.license import LicenseInfo, SwitchableLicenseMetadata
|
|
111
|
+
from datamasque.client.models.rg_config import RGConfig, RGConfigId
|
|
108
112
|
from datamasque.client.models.ruleset import Ruleset, RulesetId, RulesetType
|
|
109
113
|
from datamasque.client.models.ruleset_library import RulesetLibrary, RulesetLibraryId
|
|
110
114
|
from datamasque.client.models.runs import (
|
|
@@ -214,6 +218,7 @@ __all__ = [
|
|
|
214
218
|
"FileId",
|
|
215
219
|
"FileOrContent",
|
|
216
220
|
"FileRulesetGenerationRequest",
|
|
221
|
+
"FileRulesetGenerationWithRGConfigRequest",
|
|
217
222
|
"FirstCharsStatistics",
|
|
218
223
|
"ForeignKeyRef",
|
|
219
224
|
"GitSnapshot",
|
|
@@ -252,9 +257,13 @@ __all__ = [
|
|
|
252
257
|
"PatternComposition",
|
|
253
258
|
"PatternEntry",
|
|
254
259
|
"PatternsStatistics",
|
|
260
|
+
"RGConfig",
|
|
261
|
+
"RGConfigId",
|
|
262
|
+
"RGConfigNotFoundError",
|
|
255
263
|
"ReferencingForeignKey",
|
|
256
264
|
"Ruleset",
|
|
257
265
|
"RulesetGenerationRequest",
|
|
266
|
+
"RulesetGenerationWithRGConfigRequest",
|
|
258
267
|
"RulesetId",
|
|
259
268
|
"RulesetLibrary",
|
|
260
269
|
"RulesetLibraryId",
|
|
@@ -13,6 +13,7 @@ from datamasque.client.exceptions import (
|
|
|
13
13
|
DiscoveryConfigNotFoundError,
|
|
14
14
|
FailedToStartError,
|
|
15
15
|
InvalidDiscoveryConfigError,
|
|
16
|
+
RGConfigNotFoundError,
|
|
16
17
|
)
|
|
17
18
|
from datamasque.client.models.connection import ConnectionId
|
|
18
19
|
from datamasque.client.models.data_selection import (
|
|
@@ -25,12 +26,15 @@ from datamasque.client.models.discovery import (
|
|
|
25
26
|
FileDataDiscoveryRequest,
|
|
26
27
|
FileDiscoveryResult,
|
|
27
28
|
FileRulesetGenerationRequest,
|
|
29
|
+
FileRulesetGenerationWithRGConfigRequest,
|
|
28
30
|
RulesetGenerationRequest,
|
|
31
|
+
RulesetGenerationWithRGConfigRequest,
|
|
29
32
|
SchemaDiscoveryFromConfigRequest,
|
|
30
33
|
SchemaDiscoveryPage,
|
|
31
34
|
SchemaDiscoveryRequest,
|
|
32
35
|
SchemaDiscoveryResult,
|
|
33
36
|
)
|
|
37
|
+
from datamasque.client.models.rg_config import RGConfig, RGConfigId, unwrap_rg_config_id
|
|
34
38
|
from datamasque.client.models.ruleset import Ruleset
|
|
35
39
|
from datamasque.client.models.runs import RunId
|
|
36
40
|
from datamasque.client.models.status import AsyncRulesetGenerationTaskStatus
|
|
@@ -41,21 +45,12 @@ logger = logging.getLogger(__name__)
|
|
|
41
45
|
class DiscoveryClient(BaseClient):
|
|
42
46
|
"""Schema-discovery and ruleset-generation API methods. Mixed into `DataMasqueClient`."""
|
|
43
47
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
If the connection is a database connection, `selected_data` should be of type `SelectedColumns`.
|
|
49
|
-
If the connection is a file connection, `selected_data` should be of type `SelectedFileData`.
|
|
50
|
-
|
|
51
|
-
Generation runs asynchronously on the server.
|
|
52
|
-
Poll `get_async_ruleset_generation_task_status` until it returns
|
|
53
|
-
`AsyncRulesetGenerationTaskStatus.finished`,
|
|
54
|
-
then call `get_generated_rulesets` to retrieve the resulting `Ruleset`.
|
|
55
|
-
"""
|
|
48
|
+
@staticmethod
|
|
49
|
+
def _selected_data_payload(selected_data: SelectedData) -> dict:
|
|
50
|
+
"""Build the async-generation request-body fields for a column or file selection, validating its shape."""
|
|
56
51
|
|
|
57
52
|
if not selected_data:
|
|
58
|
-
raise ValueError("`selected_data` is a required argument to
|
|
53
|
+
raise ValueError("`selected_data` is a required argument to async ruleset generation.")
|
|
59
54
|
|
|
60
55
|
data: dict = {}
|
|
61
56
|
if isinstance(selected_data, SelectedColumns):
|
|
@@ -75,12 +70,56 @@ class DiscoveryClient(BaseClient):
|
|
|
75
70
|
data["selected_data"] = [s.model_dump() for s in selected_data.user_selections]
|
|
76
71
|
else:
|
|
77
72
|
raise TypeError(
|
|
78
|
-
f"The
|
|
73
|
+
f"The `selected_data` argument to async ruleset generation was of an invalid type, "
|
|
79
74
|
f"expected `SelectedColumns` or `SelectedFileData`, got {type(selected_data)}."
|
|
80
75
|
)
|
|
81
76
|
|
|
77
|
+
return data
|
|
78
|
+
|
|
79
|
+
def start_async_ruleset_generation(self, connection_id: ConnectionId, selected_data: SelectedData) -> None:
|
|
80
|
+
"""
|
|
81
|
+
Starts async ruleset generation using the most recent discovery results on the given connection.
|
|
82
|
+
|
|
83
|
+
Masks are assigned from the server's default RG config;
|
|
84
|
+
use `start_async_ruleset_generation_with_rg_config` to generate with a saved RG config.
|
|
85
|
+
|
|
86
|
+
If the connection is a database connection, `selected_data` should be of type `SelectedColumns`.
|
|
87
|
+
If the connection is a file connection, `selected_data` should be of type `SelectedFileData`.
|
|
88
|
+
|
|
89
|
+
Generation runs asynchronously on the server.
|
|
90
|
+
Poll `get_async_ruleset_generation_task_status` until it returns `AsyncRulesetGenerationTaskStatus.finished`,
|
|
91
|
+
then call `get_generated_rulesets` to retrieve the resulting `Ruleset`.
|
|
92
|
+
"""
|
|
93
|
+
|
|
94
|
+
data = self._selected_data_payload(selected_data)
|
|
82
95
|
self.make_request(method="POST", path=f"/api/async-generate-ruleset/{connection_id}/", data=data)
|
|
83
96
|
|
|
97
|
+
def start_async_ruleset_generation_with_rg_config(
|
|
98
|
+
self,
|
|
99
|
+
connection_id: ConnectionId,
|
|
100
|
+
selected_data: SelectedData,
|
|
101
|
+
rg_config: Optional[Union[RGConfigId, RGConfig]],
|
|
102
|
+
) -> None:
|
|
103
|
+
"""
|
|
104
|
+
Starts async ruleset generation with a selected RG config mapping discovered labels to masks.
|
|
105
|
+
|
|
106
|
+
Like `start_async_ruleset_generation`,
|
|
107
|
+
but posts to the v2 endpoint with a required `rg_config`:
|
|
108
|
+
a saved RG config (`RGConfigId` or `RGConfig`),
|
|
109
|
+
or `None` for the server's default RG config.
|
|
110
|
+
|
|
111
|
+
Raises `RGConfigNotFoundError` if the selected RG config does not exist on the server.
|
|
112
|
+
|
|
113
|
+
Generation runs asynchronously on the server.
|
|
114
|
+
Poll `get_async_ruleset_generation_task_status` until it returns `AsyncRulesetGenerationTaskStatus.finished`,
|
|
115
|
+
then call `get_generated_rulesets` to retrieve the resulting `Ruleset`.
|
|
116
|
+
"""
|
|
117
|
+
|
|
118
|
+
data = self._selected_data_payload(selected_data)
|
|
119
|
+
# The server requires `rg_config` to be present; an explicit null selects the default RG config.
|
|
120
|
+
data["rg_config"] = unwrap_rg_config_id(rg_config)
|
|
121
|
+
self._post_with_rg_config(f"/api/async-generate-ruleset/v2/{connection_id}/", data)
|
|
122
|
+
|
|
84
123
|
def start_async_ruleset_generation_from_csv(
|
|
85
124
|
self,
|
|
86
125
|
connection_id: ConnectionId,
|
|
@@ -103,11 +142,57 @@ class DiscoveryClient(BaseClient):
|
|
|
103
142
|
otherwise it is uploaded as CSV.
|
|
104
143
|
|
|
105
144
|
Generation runs asynchronously on the server.
|
|
106
|
-
Poll `get_async_ruleset_generation_task_status` until it returns
|
|
107
|
-
`AsyncRulesetGenerationTaskStatus.finished`,
|
|
145
|
+
Poll `get_async_ruleset_generation_task_status` until it returns `AsyncRulesetGenerationTaskStatus.finished`,
|
|
108
146
|
then call `get_generated_rulesets` to retrieve the resulting `Ruleset` objects.
|
|
109
147
|
"""
|
|
110
148
|
|
|
149
|
+
self.make_request(
|
|
150
|
+
method="POST",
|
|
151
|
+
path=f"/api/async-generate-ruleset/{connection_id}/from-csv/",
|
|
152
|
+
data={"target_size_bytes": target_size_bytes} if target_size_bytes is not None else None,
|
|
153
|
+
files=self._csv_upload_files(csv_content),
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
def start_async_ruleset_generation_from_csv_with_rg_config(
|
|
157
|
+
self,
|
|
158
|
+
connection_id: ConnectionId,
|
|
159
|
+
csv_content: Union[str, bytes, TextIOBase, BufferedIOBase],
|
|
160
|
+
rg_config: Optional[Union[RGConfigId, RGConfig]],
|
|
161
|
+
target_size_bytes: Optional[int] = None,
|
|
162
|
+
) -> None:
|
|
163
|
+
"""
|
|
164
|
+
Generate ruleset(s) from a schema discovery CSV report with a selected RG config.
|
|
165
|
+
|
|
166
|
+
Like `start_async_ruleset_generation_from_csv`,
|
|
167
|
+
but posts to the v2 endpoint with a required `rg_config`:
|
|
168
|
+
a saved RG config (`RGConfigId` or `RGConfig`),
|
|
169
|
+
or `None` for the server's default RG config.
|
|
170
|
+
|
|
171
|
+
Raises `RGConfigNotFoundError` if the selected RG config does not exist on the server.
|
|
172
|
+
|
|
173
|
+
Generation runs asynchronously on the server.
|
|
174
|
+
Poll `get_async_ruleset_generation_task_status` until it returns `AsyncRulesetGenerationTaskStatus.finished`,
|
|
175
|
+
then call `get_generated_rulesets` to retrieve the resulting `Ruleset` objects.
|
|
176
|
+
"""
|
|
177
|
+
|
|
178
|
+
rg_config_id = unwrap_rg_config_id(rg_config)
|
|
179
|
+
# The upload is a multipart form, whose fields cannot carry a JSON null;
|
|
180
|
+
# the server reads an empty string as null for this nullable field,
|
|
181
|
+
# selecting the default RG config.
|
|
182
|
+
data: dict = {"rg_config": rg_config_id if rg_config_id is not None else ""}
|
|
183
|
+
if target_size_bytes is not None:
|
|
184
|
+
data["target_size_bytes"] = target_size_bytes
|
|
185
|
+
|
|
186
|
+
self._post_with_rg_config(
|
|
187
|
+
f"/api/async-generate-ruleset/v2/{connection_id}/from-csv/",
|
|
188
|
+
data,
|
|
189
|
+
files=self._csv_upload_files(csv_content),
|
|
190
|
+
)
|
|
191
|
+
|
|
192
|
+
@staticmethod
|
|
193
|
+
def _csv_upload_files(csv_content: Union[str, bytes, TextIOBase, BufferedIOBase]) -> list[UploadFile]:
|
|
194
|
+
"""Normalise CSV-or-zip report content into the `csv_or_zip_file` multipart upload."""
|
|
195
|
+
|
|
111
196
|
content: BufferedIOBase
|
|
112
197
|
if isinstance(csv_content, str):
|
|
113
198
|
content = BytesIO(csv_content.encode())
|
|
@@ -125,7 +210,7 @@ class DiscoveryClient(BaseClient):
|
|
|
125
210
|
filename = "ruleset.zip" if is_zip else "ruleset.csv"
|
|
126
211
|
content_type = "application/zip" if is_zip else "text/csv"
|
|
127
212
|
|
|
128
|
-
|
|
213
|
+
return [
|
|
129
214
|
UploadFile(
|
|
130
215
|
field_name="csv_or_zip_file",
|
|
131
216
|
filename=filename,
|
|
@@ -134,13 +219,6 @@ class DiscoveryClient(BaseClient):
|
|
|
134
219
|
),
|
|
135
220
|
]
|
|
136
221
|
|
|
137
|
-
self.make_request(
|
|
138
|
-
method="POST",
|
|
139
|
-
path=f"/api/async-generate-ruleset/{connection_id}/from-csv/",
|
|
140
|
-
data={"target_size_bytes": target_size_bytes} if target_size_bytes is not None else None,
|
|
141
|
-
files=files,
|
|
142
|
-
)
|
|
143
|
-
|
|
144
222
|
def get_async_ruleset_generation_task_status(self, connection_id: ConnectionId) -> AsyncRulesetGenerationTaskStatus:
|
|
145
223
|
"""Queries the status of an async ruleset generation task."""
|
|
146
224
|
|
|
@@ -381,7 +459,7 @@ class DiscoveryClient(BaseClient):
|
|
|
381
459
|
if not (errors := run_data.get(cls.DISCOVERY_CONFIG_ERROR_FIELD)):
|
|
382
460
|
return
|
|
383
461
|
|
|
384
|
-
detail = cls.
|
|
462
|
+
detail = cls._format_config_error(errors)
|
|
385
463
|
if cls.MISSING_DISCOVERY_CONFIG_SIGNATURE in detail:
|
|
386
464
|
raise DiscoveryConfigNotFoundError(
|
|
387
465
|
f"{run_kind} run failed to start: the referenced discovery config could not be found: {detail}",
|
|
@@ -394,14 +472,61 @@ class DiscoveryClient(BaseClient):
|
|
|
394
472
|
)
|
|
395
473
|
|
|
396
474
|
@staticmethod
|
|
397
|
-
def
|
|
398
|
-
"""Render the first server error, handling both string and `{message, ...}` dict items."""
|
|
475
|
+
def _format_config_error(errors: object) -> str:
|
|
476
|
+
"""Render the first server error for a config field, handling both string and `{message, ...}` dict items."""
|
|
399
477
|
first = errors[0] if isinstance(errors, list) and errors else errors
|
|
400
478
|
if isinstance(first, dict) and "message" in first:
|
|
401
479
|
return str(first["message"])
|
|
402
480
|
|
|
403
481
|
return str(first)
|
|
404
482
|
|
|
483
|
+
# Server key for an error that names the selected RG config.
|
|
484
|
+
RG_CONFIG_ERROR_FIELD = "rg_config"
|
|
485
|
+
|
|
486
|
+
# The phrase the server uses when the config id cannot be resolved
|
|
487
|
+
# (the config does not exist, or has been archived).
|
|
488
|
+
MISSING_RG_CONFIG_SIGNATURE = "object does not exist"
|
|
489
|
+
|
|
490
|
+
def _post_with_rg_config(
|
|
491
|
+
self,
|
|
492
|
+
path: str,
|
|
493
|
+
data: dict,
|
|
494
|
+
files: Optional[list[UploadFile]] = None,
|
|
495
|
+
) -> Response:
|
|
496
|
+
"""Post a generation request carrying an `rg_config`, classifying a rejected config on failure."""
|
|
497
|
+
|
|
498
|
+
response = self.make_request("POST", path, data=data, files=files, require_status_check=False)
|
|
499
|
+
self._maybe_raise_rg_config_not_found(response)
|
|
500
|
+
self._raise_for_status(response, request_data=data)
|
|
501
|
+
return response
|
|
502
|
+
|
|
503
|
+
@classmethod
|
|
504
|
+
def _maybe_raise_rg_config_not_found(cls, response: Response) -> None:
|
|
505
|
+
"""Raise `RGConfigNotFoundError` if the server's error body says the selected RG config does not exist."""
|
|
506
|
+
|
|
507
|
+
if response.ok:
|
|
508
|
+
return
|
|
509
|
+
|
|
510
|
+
try:
|
|
511
|
+
body = response.json()
|
|
512
|
+
except ValueError:
|
|
513
|
+
return
|
|
514
|
+
|
|
515
|
+
if not isinstance(body, dict):
|
|
516
|
+
return
|
|
517
|
+
|
|
518
|
+
if not (errors := body.get(cls.RG_CONFIG_ERROR_FIELD)):
|
|
519
|
+
return
|
|
520
|
+
|
|
521
|
+
detail = cls._format_config_error(errors)
|
|
522
|
+
if cls.MISSING_RG_CONFIG_SIGNATURE not in detail:
|
|
523
|
+
return
|
|
524
|
+
|
|
525
|
+
raise RGConfigNotFoundError(
|
|
526
|
+
f"The referenced RG config could not be found: {detail}",
|
|
527
|
+
response=response,
|
|
528
|
+
)
|
|
529
|
+
|
|
405
530
|
def iter_schema_discovery_results(self, run_id: RunId) -> Iterator[SchemaDiscoveryResult]:
|
|
406
531
|
"""Lazily iterate all schema discovery results for a run via the paginated v2 endpoint."""
|
|
407
532
|
|
|
@@ -433,6 +558,9 @@ class DiscoveryClient(BaseClient):
|
|
|
433
558
|
"""
|
|
434
559
|
Generates database-masking ruleset YAML from the most recent discovery run on the given connection.
|
|
435
560
|
|
|
561
|
+
Masks are assigned from the server's default RG config;
|
|
562
|
+
use `generate_ruleset_with_rg_config` to generate with a saved RG config.
|
|
563
|
+
|
|
436
564
|
`generation_request` is a `RulesetGenerationRequest`.
|
|
437
565
|
"""
|
|
438
566
|
|
|
@@ -440,10 +568,26 @@ class DiscoveryClient(BaseClient):
|
|
|
440
568
|
response = self.make_request("POST", "/api/generate-ruleset/v2/", data=data)
|
|
441
569
|
return response.content.decode("utf-8")
|
|
442
570
|
|
|
571
|
+
def generate_ruleset_with_rg_config(self, generation_request: RulesetGenerationWithRGConfigRequest) -> str:
|
|
572
|
+
"""
|
|
573
|
+
Generates database-masking ruleset YAML with a selected RG config mapping discovered labels to masks.
|
|
574
|
+
|
|
575
|
+
`generation_request` is a `RulesetGenerationWithRGConfigRequest`;
|
|
576
|
+
its required `rg_config` selects the saved RG config to use
|
|
577
|
+
(`None` for the server's default RG config).
|
|
578
|
+
|
|
579
|
+
Raises `RGConfigNotFoundError` if the selected RG config does not exist on the server.
|
|
580
|
+
"""
|
|
581
|
+
|
|
582
|
+
return self._generate_ruleset_with_rg_config(generation_request, "/api/generate-ruleset/v3/")
|
|
583
|
+
|
|
443
584
|
def generate_file_ruleset(self, generation_request: FileRulesetGenerationRequest) -> str:
|
|
444
585
|
"""
|
|
445
586
|
Generates file-masking ruleset YAML from the most recent file-data-discovery run on the given connection.
|
|
446
587
|
|
|
588
|
+
Masks are assigned from the server's default RG config;
|
|
589
|
+
use `generate_file_ruleset_with_rg_config` to generate with a saved RG config.
|
|
590
|
+
|
|
447
591
|
`generation_request` is a `FileRulesetGenerationRequest`.
|
|
448
592
|
"""
|
|
449
593
|
|
|
@@ -451,6 +595,33 @@ class DiscoveryClient(BaseClient):
|
|
|
451
595
|
response = self.make_request("POST", "/api/generate-file-ruleset/", data=data)
|
|
452
596
|
return response.content.decode("utf-8")
|
|
453
597
|
|
|
598
|
+
def generate_file_ruleset_with_rg_config(self, generation_request: FileRulesetGenerationWithRGConfigRequest) -> str:
|
|
599
|
+
"""
|
|
600
|
+
Generates file-masking ruleset YAML with a selected RG config mapping discovered labels to masks.
|
|
601
|
+
|
|
602
|
+
`generation_request` is a `FileRulesetGenerationWithRGConfigRequest`;
|
|
603
|
+
its required `rg_config` selects the saved RG config to use
|
|
604
|
+
(`None` for the server's default RG config).
|
|
605
|
+
|
|
606
|
+
Raises `RGConfigNotFoundError` if the selected RG config does not exist on the server.
|
|
607
|
+
"""
|
|
608
|
+
|
|
609
|
+
return self._generate_ruleset_with_rg_config(generation_request, "/api/generate-file-ruleset/v2/")
|
|
610
|
+
|
|
611
|
+
def _generate_ruleset_with_rg_config(
|
|
612
|
+
self,
|
|
613
|
+
generation_request: Union[RulesetGenerationWithRGConfigRequest, FileRulesetGenerationWithRGConfigRequest],
|
|
614
|
+
path: str,
|
|
615
|
+
) -> str:
|
|
616
|
+
"""Post a with-RG-config generation request and return the generated ruleset YAML."""
|
|
617
|
+
|
|
618
|
+
data = generation_request.model_dump(exclude_none=True, mode="json")
|
|
619
|
+
# The server requires `rg_config` to be present; a null selects its default RG config,
|
|
620
|
+
# so send it explicitly rather than letting `exclude_none` drop a None.
|
|
621
|
+
data.setdefault("rg_config", None)
|
|
622
|
+
response = self._post_with_rg_config(path, data)
|
|
623
|
+
return response.content.decode("utf-8")
|
|
624
|
+
|
|
454
625
|
def get_file_data_discovery_report(self, run_id: RunId) -> list[FileDiscoveryResult]:
|
|
455
626
|
"""Returns the file-data-discovery results for the specified run."""
|
|
456
627
|
|
{datamasque_python-1.2.0 → datamasque_python-1.2.2}/datamasque/client/discovery_config_libraries.py
RENAMED
|
@@ -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
|
|
108
|
+
if not library.yaml:
|
|
105
109
|
raise ValueError(
|
|
106
|
-
"Cannot update a discovery config library without YAML content (yaml is
|
|
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
|