datamasque-python 1.1.7__tar.gz → 1.1.8__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.1.7 → datamasque_python-1.1.8}/HISTORY.rst +12 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/PKG-INFO +1 -1
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/datamasque/client/__init__.py +72 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/datamasque/client/dmclient.py +2 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/datamasque/client/models/discovery.py +8 -0
- datamasque_python-1.1.8/datamasque/client/models/safe_data_preview.py +282 -0
- datamasque_python-1.1.8/datamasque/client/models/table_reference.py +101 -0
- datamasque_python-1.1.8/datamasque/client/table_references.py +144 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/pyproject.toml +1 -1
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/setup.cfg +1 -1
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/tests/test_discovery.py +20 -0
- datamasque_python-1.1.8/tests/test_safe_data_preview.py +178 -0
- datamasque_python-1.1.8/tests/test_table_references.py +502 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/uv.lock +1 -1
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/.editorconfig +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/.github/workflows/ci.yml +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/.github/workflows/release-testpypi.yml +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/.github/workflows/release.yml +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/.gitignore +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/.readthedocs.yaml +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/CONTRIBUTING.rst +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/LICENSE +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/MANIFEST.in +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/Makefile +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/NOTICE +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/README.rst +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/datamasque/client/base.py +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/datamasque/client/connections.py +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/datamasque/client/discovery.py +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/datamasque/client/discovery_config_libraries.py +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/datamasque/client/discovery_configs.py +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/datamasque/client/exceptions.py +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/datamasque/client/files.py +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/datamasque/client/ifm.py +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/datamasque/client/license.py +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/datamasque/client/models/__init__.py +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/datamasque/client/models/connection.py +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/datamasque/client/models/data_selection.py +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/datamasque/client/models/discovery_config.py +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/datamasque/client/models/discovery_config_library.py +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/datamasque/client/models/dm_instance.py +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/datamasque/client/models/files.py +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/datamasque/client/models/git.py +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/datamasque/client/models/ifm.py +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/datamasque/client/models/license.py +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/datamasque/client/models/pagination.py +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/datamasque/client/models/ruleset.py +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/datamasque/client/models/ruleset_library.py +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/datamasque/client/models/runs.py +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/datamasque/client/models/status.py +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/datamasque/client/models/user.py +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/datamasque/client/py.typed +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/datamasque/client/ruleset_libraries.py +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/datamasque/client/rulesets.py +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/datamasque/client/runs.py +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/datamasque/client/settings.py +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/datamasque/client/spcs.py +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/datamasque/client/users.py +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/docs/Makefile +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/docs/client.models.rst +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/docs/client.rst +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/docs/conf.py +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/docs/contributing.rst +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/docs/history.rst +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/docs/index.rst +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/docs/installation.rst +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/docs/make.bat +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/docs/modules.rst +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/docs/readme.rst +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/docs/usage.rst +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/tests/__init__.py +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/tests/conftest.py +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/tests/helpers.py +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/tests/test_base.py +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/tests/test_connections.py +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/tests/test_discovery_config_libraries.py +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/tests/test_discovery_configs.py +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/tests/test_files.py +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/tests/test_ifm.py +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/tests/test_license.py +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/tests/test_pagination.py +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/tests/test_ruleset_library.py +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/tests/test_rulesets.py +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/tests/test_runs.py +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/tests/test_settings.py +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/tests/test_spcs.py +0 -0
- {datamasque_python-1.1.7 → datamasque_python-1.1.8}/tests/test_users.py +0 -0
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
History
|
|
3
3
|
=======
|
|
4
4
|
|
|
5
|
+
1.1.8 (2026-07-27)
|
|
6
|
+
------------------
|
|
7
|
+
|
|
8
|
+
* Added typed Safe Data Preview support:
|
|
9
|
+
|
|
10
|
+
* ``safe_data_preview`` on ``InDataDiscoveryConfig`` (via ``SafeDataPreviewOptions``) to configure or disable it.
|
|
11
|
+
* ``safe_data_preview`` on schema-discovery result columns and file-discovery locators, typed by ``kind``.
|
|
12
|
+
|
|
13
|
+
* Added ``row_count`` to ``TableConstraints`` in schema-discovery ``table_metadata``.
|
|
14
|
+
* Added table-reference management APIs (``list_table_references``, ``create_table_reference``, and friends),
|
|
15
|
+
along with the ``TableReference`` and ``TableReferenceOptions`` models.
|
|
16
|
+
|
|
5
17
|
1.1.7 (2026-07-14)
|
|
6
18
|
------------------
|
|
7
19
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: datamasque-python
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.8
|
|
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/
|
|
@@ -116,6 +116,38 @@ from datamasque.client.models.runs import (
|
|
|
116
116
|
RunInfo,
|
|
117
117
|
UnfinishedRun,
|
|
118
118
|
)
|
|
119
|
+
from datamasque.client.models.safe_data_preview import (
|
|
120
|
+
BooleanPreview,
|
|
121
|
+
BooleanStatistics,
|
|
122
|
+
ColumnKind,
|
|
123
|
+
ColumnPreview,
|
|
124
|
+
CommonStatistics,
|
|
125
|
+
FirstCharsStatistics,
|
|
126
|
+
LengthEntry,
|
|
127
|
+
LengthsStatistics,
|
|
128
|
+
MaskedFormEntry,
|
|
129
|
+
NumericBin,
|
|
130
|
+
NumericHistograms,
|
|
131
|
+
NumericPreview,
|
|
132
|
+
NumericStatistics,
|
|
133
|
+
NumericSummaries,
|
|
134
|
+
NumericTemporalDisclosureLevel,
|
|
135
|
+
PatternComposition,
|
|
136
|
+
PatternEntry,
|
|
137
|
+
PatternsStatistics,
|
|
138
|
+
SafeDataPreview,
|
|
139
|
+
SafeDataPreviewOptions,
|
|
140
|
+
StringDisclosureLevel,
|
|
141
|
+
StringPreview,
|
|
142
|
+
StringStatistics,
|
|
143
|
+
TemporalBin,
|
|
144
|
+
TemporalHistograms,
|
|
145
|
+
TemporalPreview,
|
|
146
|
+
TemporalStatistics,
|
|
147
|
+
TemporalSummaries,
|
|
148
|
+
UnsupportedPreview,
|
|
149
|
+
UnsupportedStatistics,
|
|
150
|
+
)
|
|
119
151
|
from datamasque.client.models.status import (
|
|
120
152
|
AsyncRulesetGenerationTaskStatus,
|
|
121
153
|
MaskingRunStatus,
|
|
@@ -123,6 +155,12 @@ from datamasque.client.models.status import (
|
|
|
123
155
|
ValidationErrorType,
|
|
124
156
|
ValidationStatus,
|
|
125
157
|
)
|
|
158
|
+
from datamasque.client.models.table_reference import (
|
|
159
|
+
TableReference,
|
|
160
|
+
TableReferenceFormat,
|
|
161
|
+
TableReferenceId,
|
|
162
|
+
TableReferenceOptions,
|
|
163
|
+
)
|
|
126
164
|
from datamasque.client.models.user import User, UserId, UserRole
|
|
127
165
|
|
|
128
166
|
__version__ = version("datamasque-python")
|
|
@@ -131,6 +169,11 @@ __all__ = [
|
|
|
131
169
|
"AsyncRulesetGenerationInProgressError",
|
|
132
170
|
"AsyncRulesetGenerationTaskStatus",
|
|
133
171
|
"AzureConnectionConfig",
|
|
172
|
+
"BooleanPreview",
|
|
173
|
+
"BooleanStatistics",
|
|
174
|
+
"ColumnKind",
|
|
175
|
+
"ColumnPreview",
|
|
176
|
+
"CommonStatistics",
|
|
134
177
|
"ConnectionConfig",
|
|
135
178
|
"ConnectionId",
|
|
136
179
|
"ConstraintColumns",
|
|
@@ -171,6 +214,7 @@ __all__ = [
|
|
|
171
214
|
"FileId",
|
|
172
215
|
"FileOrContent",
|
|
173
216
|
"FileRulesetGenerationRequest",
|
|
217
|
+
"FirstCharsStatistics",
|
|
174
218
|
"ForeignKeyRef",
|
|
175
219
|
"GitSnapshot",
|
|
176
220
|
"HashColumnsTableConfig",
|
|
@@ -186,16 +230,28 @@ __all__ = [
|
|
|
186
230
|
"InvalidLibraryError",
|
|
187
231
|
"InvalidRulesetError",
|
|
188
232
|
"JsonPath",
|
|
233
|
+
"LengthEntry",
|
|
234
|
+
"LengthsStatistics",
|
|
189
235
|
"LicenseInfo",
|
|
190
236
|
"Locator",
|
|
191
237
|
"MaskType",
|
|
238
|
+
"MaskedFormEntry",
|
|
192
239
|
"MaskingRunOptions",
|
|
193
240
|
"MaskingRunRequest",
|
|
194
241
|
"MaskingRunStatus",
|
|
195
242
|
"MongoConnectionConfig",
|
|
196
243
|
"MountedShareConnectionConfig",
|
|
197
244
|
"MssqlLinkedServerConnectionConfig",
|
|
245
|
+
"NumericBin",
|
|
246
|
+
"NumericHistograms",
|
|
247
|
+
"NumericPreview",
|
|
248
|
+
"NumericStatistics",
|
|
249
|
+
"NumericSummaries",
|
|
250
|
+
"NumericTemporalDisclosureLevel",
|
|
198
251
|
"OracleWalletFile",
|
|
252
|
+
"PatternComposition",
|
|
253
|
+
"PatternEntry",
|
|
254
|
+
"PatternsStatistics",
|
|
199
255
|
"ReferencingForeignKey",
|
|
200
256
|
"Ruleset",
|
|
201
257
|
"RulesetGenerationRequest",
|
|
@@ -213,6 +269,8 @@ __all__ = [
|
|
|
213
269
|
"RunInfo",
|
|
214
270
|
"RunNotCancellableError",
|
|
215
271
|
"S3ConnectionConfig",
|
|
272
|
+
"SafeDataPreview",
|
|
273
|
+
"SafeDataPreviewOptions",
|
|
216
274
|
"SchemaDiscoveryColumn",
|
|
217
275
|
"SchemaDiscoveryFromConfigRequest",
|
|
218
276
|
"SchemaDiscoveryPage",
|
|
@@ -228,9 +286,23 @@ __all__ = [
|
|
|
228
286
|
"SseConfig",
|
|
229
287
|
"SseSelection",
|
|
230
288
|
"SslZipFile",
|
|
289
|
+
"StringDisclosureLevel",
|
|
290
|
+
"StringPreview",
|
|
291
|
+
"StringStatistics",
|
|
231
292
|
"SwitchableLicenseMetadata",
|
|
232
293
|
"TableConstraints",
|
|
294
|
+
"TableReference",
|
|
295
|
+
"TableReferenceFormat",
|
|
296
|
+
"TableReferenceId",
|
|
297
|
+
"TableReferenceOptions",
|
|
298
|
+
"TemporalBin",
|
|
299
|
+
"TemporalHistograms",
|
|
300
|
+
"TemporalPreview",
|
|
301
|
+
"TemporalStatistics",
|
|
302
|
+
"TemporalSummaries",
|
|
233
303
|
"UnfinishedRun",
|
|
304
|
+
"UnsupportedPreview",
|
|
305
|
+
"UnsupportedStatistics",
|
|
234
306
|
"User",
|
|
235
307
|
"UserId",
|
|
236
308
|
"UserRole",
|
|
@@ -9,6 +9,7 @@ from datamasque.client.ruleset_libraries import RulesetLibraryClient
|
|
|
9
9
|
from datamasque.client.rulesets import RulesetClient
|
|
10
10
|
from datamasque.client.runs import RunClient
|
|
11
11
|
from datamasque.client.settings import SettingsClient
|
|
12
|
+
from datamasque.client.table_references import TableReferenceClient
|
|
12
13
|
from datamasque.client.users import UserClient
|
|
13
14
|
|
|
14
15
|
__all__ = ["DataMasqueClient", "FileOrContent", "UploadFile"]
|
|
@@ -24,6 +25,7 @@ class DataMasqueClient(
|
|
|
24
25
|
DiscoveryClient,
|
|
25
26
|
DiscoveryConfigClient,
|
|
26
27
|
DiscoveryConfigLibraryClient,
|
|
28
|
+
TableReferenceClient,
|
|
27
29
|
UserClient,
|
|
28
30
|
SettingsClient,
|
|
29
31
|
):
|
|
@@ -10,6 +10,10 @@ from datamasque.client.models.data_selection import HashColumnsTableConfig, Loca
|
|
|
10
10
|
from datamasque.client.models.discovery_config import DiscoveryConfig, DiscoveryConfigId, unwrap_discovery_config_id
|
|
11
11
|
from datamasque.client.models.pagination import Page
|
|
12
12
|
from datamasque.client.models.runs import RunConnectionRef
|
|
13
|
+
from datamasque.client.models.safe_data_preview import (
|
|
14
|
+
SafeDataPreview,
|
|
15
|
+
SafeDataPreviewOptions,
|
|
16
|
+
)
|
|
13
17
|
|
|
14
18
|
|
|
15
19
|
class InDataDiscoveryRule(BaseModel):
|
|
@@ -32,6 +36,7 @@ class InDataDiscoveryConfig(BaseModel):
|
|
|
32
36
|
non_sensitive_rules: Optional[list[InDataDiscoveryRule]] = None
|
|
33
37
|
ignore_rules: Optional[list[InDataDiscoveryRule]] = None
|
|
34
38
|
force: Optional[bool] = None
|
|
39
|
+
safe_data_preview: Optional[SafeDataPreviewOptions] = None
|
|
35
40
|
|
|
36
41
|
|
|
37
42
|
class SchemaDiscoveryRequest(BaseModel):
|
|
@@ -294,6 +299,7 @@ class SchemaDiscoveryColumn(BaseModel):
|
|
|
294
299
|
unique_index_names: list[str]
|
|
295
300
|
referencing_foreign_keys: list[ReferencingForeignKey]
|
|
296
301
|
constraint: str # Primary or Unique, or empty string if column does not participate in a PK/UK
|
|
302
|
+
safe_data_preview: Optional[SafeDataPreview] = None
|
|
297
303
|
|
|
298
304
|
|
|
299
305
|
class SchemaDiscoveryResult(BaseModel):
|
|
@@ -324,6 +330,7 @@ class TableConstraints(BaseModel):
|
|
|
324
330
|
primary_keys: Optional[list[ConstraintColumns]] = None
|
|
325
331
|
unique_keys: Optional[list[ConstraintColumns]] = None
|
|
326
332
|
foreign_keys: Optional[list[ConstraintColumns]] = None
|
|
333
|
+
row_count: Optional[int] = None
|
|
327
334
|
|
|
328
335
|
|
|
329
336
|
class SchemaDiscoveryPage(Page[SchemaDiscoveryResult]):
|
|
@@ -356,6 +363,7 @@ class FileDiscoveryLocatorResult(BaseModel):
|
|
|
356
363
|
locator: Locator
|
|
357
364
|
matches: list[FileDiscoveryMatch]
|
|
358
365
|
data_types: list[str]
|
|
366
|
+
safe_data_preview: Optional[SafeDataPreview] = None
|
|
359
367
|
|
|
360
368
|
|
|
361
369
|
class FileDiscoveryFile(BaseModel):
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
"""Typed request and response shapes for Safe Data Preview, part of In-Data Discovery."""
|
|
2
|
+
|
|
3
|
+
from enum import Enum
|
|
4
|
+
from typing import Annotated, Literal, Optional, Union
|
|
5
|
+
|
|
6
|
+
from pydantic import (
|
|
7
|
+
BaseModel,
|
|
8
|
+
ConfigDict,
|
|
9
|
+
Field,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class StringDisclosureLevel(Enum):
|
|
14
|
+
"""How much detail a string Safe Data Preview reveals."""
|
|
15
|
+
|
|
16
|
+
lengths = "lengths"
|
|
17
|
+
patterns = "patterns"
|
|
18
|
+
first_chars = "first_chars"
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class NumericTemporalDisclosureLevel(Enum):
|
|
22
|
+
"""How much detail a numeric or temporal Safe Data Preview reveals."""
|
|
23
|
+
|
|
24
|
+
summaries = "summaries"
|
|
25
|
+
histograms = "histograms"
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class SafeDataPreviewOptions(BaseModel):
|
|
29
|
+
"""Configures whether Safe Data Preview runs and how much detail each column reveals."""
|
|
30
|
+
|
|
31
|
+
model_config = ConfigDict(extra="forbid")
|
|
32
|
+
|
|
33
|
+
enabled: Optional[bool] = None
|
|
34
|
+
min_group_size: Optional[int] = None
|
|
35
|
+
string_level: Optional[StringDisclosureLevel] = None
|
|
36
|
+
numeric_level: Optional[NumericTemporalDisclosureLevel] = None
|
|
37
|
+
temporal_level: Optional[NumericTemporalDisclosureLevel] = None
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class ColumnKind(str, Enum):
|
|
41
|
+
"""Which shape a column's Safe Data Preview takes."""
|
|
42
|
+
|
|
43
|
+
boolean = "boolean"
|
|
44
|
+
numeric = "numeric"
|
|
45
|
+
string = "string"
|
|
46
|
+
temporal = "temporal"
|
|
47
|
+
unsupported = "unsupported"
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class CommonStatistics(BaseModel):
|
|
51
|
+
"""Row counts shared by every preview kind."""
|
|
52
|
+
|
|
53
|
+
model_config = ConfigDict(extra="allow")
|
|
54
|
+
|
|
55
|
+
count_row: int
|
|
56
|
+
count_null: int
|
|
57
|
+
count_distinct: Optional[int] = None
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
class LengthEntry(BaseModel):
|
|
61
|
+
"""A value length and how many sampled rows had it."""
|
|
62
|
+
|
|
63
|
+
model_config = ConfigDict(extra="allow")
|
|
64
|
+
|
|
65
|
+
length: int
|
|
66
|
+
count: int
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class LengthsStatistics(BaseModel):
|
|
70
|
+
"""Distribution of value lengths."""
|
|
71
|
+
|
|
72
|
+
model_config = ConfigDict(extra="allow")
|
|
73
|
+
|
|
74
|
+
min: int
|
|
75
|
+
max: int
|
|
76
|
+
mean: float
|
|
77
|
+
median: float
|
|
78
|
+
most_common: list[LengthEntry]
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
class PatternEntry(BaseModel):
|
|
82
|
+
"""A masked character pattern and how many sampled rows matched it."""
|
|
83
|
+
|
|
84
|
+
model_config = ConfigDict(extra="allow")
|
|
85
|
+
|
|
86
|
+
pattern: str
|
|
87
|
+
count: int
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
class PatternComposition(BaseModel):
|
|
91
|
+
"""The proportion of letter, digit, and other characters across sampled values."""
|
|
92
|
+
|
|
93
|
+
model_config = ConfigDict(extra="allow")
|
|
94
|
+
|
|
95
|
+
letter: float
|
|
96
|
+
digit: float
|
|
97
|
+
other: float
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
class PatternsStatistics(BaseModel):
|
|
101
|
+
"""The most common character patterns and the overall character composition."""
|
|
102
|
+
|
|
103
|
+
model_config = ConfigDict(extra="allow")
|
|
104
|
+
|
|
105
|
+
top: list[PatternEntry]
|
|
106
|
+
composition: PatternComposition
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
class MaskedFormEntry(BaseModel):
|
|
110
|
+
"""A masked leading form of a value and how many sampled rows had it."""
|
|
111
|
+
|
|
112
|
+
model_config = ConfigDict(extra="allow")
|
|
113
|
+
|
|
114
|
+
masked: str
|
|
115
|
+
count: int
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
class FirstCharsStatistics(BaseModel):
|
|
119
|
+
"""The most common masked leading forms."""
|
|
120
|
+
|
|
121
|
+
model_config = ConfigDict(extra="allow")
|
|
122
|
+
|
|
123
|
+
top: list[MaskedFormEntry]
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
class StringStatistics(BaseModel):
|
|
127
|
+
"""String preview statistics; `patterns`/`first_chars` appear at or above certain disclosure levels."""
|
|
128
|
+
|
|
129
|
+
model_config = ConfigDict(extra="allow")
|
|
130
|
+
|
|
131
|
+
lengths: LengthsStatistics
|
|
132
|
+
patterns: Optional[PatternsStatistics] = None
|
|
133
|
+
first_chars: Optional[FirstCharsStatistics] = None
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
class NumericSummaries(BaseModel):
|
|
137
|
+
"""Numeric mean and percentile summary."""
|
|
138
|
+
|
|
139
|
+
model_config = ConfigDict(extra="allow")
|
|
140
|
+
|
|
141
|
+
mean: float
|
|
142
|
+
q1: float
|
|
143
|
+
q2: float
|
|
144
|
+
q3: float
|
|
145
|
+
p5: float
|
|
146
|
+
p95: float
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
class NumericBin(BaseModel):
|
|
150
|
+
"""One half-open interval `[lower_bound, upper_bound)` of a numeric histogram and its row count."""
|
|
151
|
+
|
|
152
|
+
model_config = ConfigDict(extra="allow")
|
|
153
|
+
|
|
154
|
+
lower_bound: float
|
|
155
|
+
upper_bound: float
|
|
156
|
+
count: int
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
class NumericHistograms(BaseModel):
|
|
160
|
+
"""The bins of a numeric histogram."""
|
|
161
|
+
|
|
162
|
+
model_config = ConfigDict(extra="allow")
|
|
163
|
+
|
|
164
|
+
bins: list[NumericBin]
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
class NumericStatistics(BaseModel):
|
|
168
|
+
"""Numeric preview statistics; `histograms` is present only at the histogram disclosure level."""
|
|
169
|
+
|
|
170
|
+
model_config = ConfigDict(extra="allow")
|
|
171
|
+
|
|
172
|
+
summaries: NumericSummaries
|
|
173
|
+
histograms: Optional[NumericHistograms] = None
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
class TemporalSummaries(BaseModel):
|
|
177
|
+
"""Temporal mean and percentile summary, each an ISO-formatted string."""
|
|
178
|
+
|
|
179
|
+
model_config = ConfigDict(extra="allow")
|
|
180
|
+
|
|
181
|
+
mean: str
|
|
182
|
+
q1: str
|
|
183
|
+
q2: str
|
|
184
|
+
q3: str
|
|
185
|
+
p5: str
|
|
186
|
+
p95: str
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
class TemporalBin(BaseModel):
|
|
190
|
+
"""One interval of a temporal histogram, with ISO-formatted bounds and a human-readable label."""
|
|
191
|
+
|
|
192
|
+
model_config = ConfigDict(extra="allow")
|
|
193
|
+
|
|
194
|
+
lower_bound: str
|
|
195
|
+
upper_bound: str
|
|
196
|
+
label: str
|
|
197
|
+
count: int
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
class TemporalHistograms(BaseModel):
|
|
201
|
+
"""The bins of a temporal histogram."""
|
|
202
|
+
|
|
203
|
+
model_config = ConfigDict(extra="allow")
|
|
204
|
+
|
|
205
|
+
bins: list[TemporalBin]
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
class TemporalStatistics(BaseModel):
|
|
209
|
+
"""Temporal preview statistics; `histograms` is present only at the histogram disclosure level."""
|
|
210
|
+
|
|
211
|
+
model_config = ConfigDict(extra="allow")
|
|
212
|
+
|
|
213
|
+
summaries: TemporalSummaries
|
|
214
|
+
histograms: Optional[TemporalHistograms] = None
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
class BooleanStatistics(BaseModel):
|
|
218
|
+
"""Counts of true and false values."""
|
|
219
|
+
|
|
220
|
+
model_config = ConfigDict(extra="allow")
|
|
221
|
+
|
|
222
|
+
count_true: int
|
|
223
|
+
count_false: int
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
class UnsupportedStatistics(BaseModel):
|
|
227
|
+
"""Why a column could not be previewed."""
|
|
228
|
+
|
|
229
|
+
model_config = ConfigDict(extra="allow")
|
|
230
|
+
|
|
231
|
+
reason: str
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
class ColumnPreview(BaseModel):
|
|
235
|
+
"""Fields present on every Safe Data Preview."""
|
|
236
|
+
|
|
237
|
+
model_config = ConfigDict(extra="allow")
|
|
238
|
+
|
|
239
|
+
# For grouped file discovery, the file whose sample produced this preview; None for database columns.
|
|
240
|
+
sampled_from: Optional[str] = None
|
|
241
|
+
statistics_common: CommonStatistics
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
class StringPreview(ColumnPreview):
|
|
245
|
+
"""A preview of a string column."""
|
|
246
|
+
|
|
247
|
+
kind: Literal[ColumnKind.string] = ColumnKind.string
|
|
248
|
+
statistics_kind: StringStatistics
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
class NumericPreview(ColumnPreview):
|
|
252
|
+
"""A preview of a numeric column."""
|
|
253
|
+
|
|
254
|
+
kind: Literal[ColumnKind.numeric] = ColumnKind.numeric
|
|
255
|
+
statistics_kind: NumericStatistics
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
class TemporalPreview(ColumnPreview):
|
|
259
|
+
"""A preview of a date/time column."""
|
|
260
|
+
|
|
261
|
+
kind: Literal[ColumnKind.temporal] = ColumnKind.temporal
|
|
262
|
+
statistics_kind: TemporalStatistics
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
class BooleanPreview(ColumnPreview):
|
|
266
|
+
"""A preview of a boolean column."""
|
|
267
|
+
|
|
268
|
+
kind: Literal[ColumnKind.boolean] = ColumnKind.boolean
|
|
269
|
+
statistics_kind: BooleanStatistics
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
class UnsupportedPreview(ColumnPreview):
|
|
273
|
+
"""A column the preview ran against but declined; `statistics_kind.reason` says why."""
|
|
274
|
+
|
|
275
|
+
kind: Literal[ColumnKind.unsupported] = ColumnKind.unsupported
|
|
276
|
+
statistics_kind: UnsupportedStatistics
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
SafeDataPreview = Annotated[
|
|
280
|
+
Union[StringPreview, NumericPreview, TemporalPreview, BooleanPreview, UnsupportedPreview],
|
|
281
|
+
Field(discriminator="kind"),
|
|
282
|
+
]
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"""Table reference models for the DataMasque API."""
|
|
2
|
+
|
|
3
|
+
import enum
|
|
4
|
+
from datetime import datetime
|
|
5
|
+
from typing import NewType, Optional, Union
|
|
6
|
+
|
|
7
|
+
from pydantic import BaseModel, ConfigDict, Field, field_validator
|
|
8
|
+
|
|
9
|
+
from datamasque.client.models.connection import ConnectionConfig, ConnectionId, unwrap_connection_id
|
|
10
|
+
|
|
11
|
+
TableReferenceId = NewType("TableReferenceId", str)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class TableReferenceFormat(enum.Enum):
|
|
15
|
+
"""
|
|
16
|
+
File format of the data a table reference points at.
|
|
17
|
+
|
|
18
|
+
Only meaningful for a table reference on a file connection,
|
|
19
|
+
and an explicit choice: the source path's suffix carries no meaning.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
csv = "csv"
|
|
23
|
+
parquet = "parquet"
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class TableReferenceOptions(BaseModel):
|
|
27
|
+
"""
|
|
28
|
+
Format and CSV parsing options for a table reference.
|
|
29
|
+
|
|
30
|
+
These apply to file connections only —
|
|
31
|
+
they are ignored for a table reference on a database connection,
|
|
32
|
+
and the CSV options are ignored when the `format` is `parquet`.
|
|
33
|
+
|
|
34
|
+
There is deliberately no header toggle:
|
|
35
|
+
a CSV identity map's columns must be addressable by name,
|
|
36
|
+
so the first row is always read as the header.
|
|
37
|
+
|
|
38
|
+
Every option has a default, and the server fills in any option omitted from a request,
|
|
39
|
+
so the values here are the same defaults the server applies.
|
|
40
|
+
"""
|
|
41
|
+
|
|
42
|
+
model_config = ConfigDict(extra="allow", populate_by_name=True)
|
|
43
|
+
|
|
44
|
+
format: TableReferenceFormat = TableReferenceFormat.csv
|
|
45
|
+
delimiter: str = ","
|
|
46
|
+
encoding: str = "utf-8"
|
|
47
|
+
quotechar: str = '"'
|
|
48
|
+
null_string: Optional[str] = None
|
|
49
|
+
"""The string in the source data to read as a null value, or `None` to read no value as null."""
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class TableReference(BaseModel):
|
|
53
|
+
"""
|
|
54
|
+
Represents a named, persisted reference to a table of identity data held outside DataMasque.
|
|
55
|
+
|
|
56
|
+
The data lives in the referenced connection —
|
|
57
|
+
a CSV or Parquet file in a file connection, or a table in a database connection —
|
|
58
|
+
so a ruleset can reference the identity map once, by name,
|
|
59
|
+
instead of re-declaring the source each time.
|
|
60
|
+
|
|
61
|
+
A table reference stores no credentials of its own; it borrows the referenced connection's.
|
|
62
|
+
|
|
63
|
+
`source` is interpreted according to that connection's own type:
|
|
64
|
+
|
|
65
|
+
* file connection — a path to the file within the connection's fileset.
|
|
66
|
+
The format comes from `options.format`, never from the path's suffix.
|
|
67
|
+
* database connection — a dotted, schema-qualified `schema.table` reference.
|
|
68
|
+
|
|
69
|
+
Names are unique across live table references (a deleted reference frees its name for reuse),
|
|
70
|
+
and the referenced connection must not be archived.
|
|
71
|
+
"""
|
|
72
|
+
|
|
73
|
+
model_config = ConfigDict(extra="allow", populate_by_name=True)
|
|
74
|
+
|
|
75
|
+
name: str
|
|
76
|
+
connection: Union[ConnectionId, ConnectionConfig]
|
|
77
|
+
"""The connection the data lives in. Accepts a `ConnectionId` or a `ConnectionConfig` (its `id` is extracted)."""
|
|
78
|
+
source: str
|
|
79
|
+
options: Optional[TableReferenceOptions] = None
|
|
80
|
+
"""Format and CSV parsing options; when `None`, the server applies its defaults on create."""
|
|
81
|
+
|
|
82
|
+
# Server-populated read-only fields, excluded from request bodies.
|
|
83
|
+
id: Optional[TableReferenceId] = Field(default=None, exclude=True)
|
|
84
|
+
created: Optional[datetime] = Field(default=None, exclude=True)
|
|
85
|
+
modified: Optional[datetime] = Field(default=None, exclude=True)
|
|
86
|
+
|
|
87
|
+
@field_validator("connection", mode="before")
|
|
88
|
+
@classmethod
|
|
89
|
+
def _unwrap_connection(cls, value: object) -> object:
|
|
90
|
+
return unwrap_connection_id(value)
|
|
91
|
+
|
|
92
|
+
@property
|
|
93
|
+
def connection_id(self) -> ConnectionId:
|
|
94
|
+
"""
|
|
95
|
+
The ID of the referenced connection.
|
|
96
|
+
|
|
97
|
+
`connection` accepts a whole `ConnectionConfig` for convenience but always holds an ID
|
|
98
|
+
once validated, so this narrows the declared type back down for callers reading it.
|
|
99
|
+
"""
|
|
100
|
+
|
|
101
|
+
return ConnectionId(unwrap_connection_id(self.connection))
|