datamasque-python 1.1.0__py3-none-any.whl → 1.1.2__py3-none-any.whl
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/client/discovery.py +20 -4
- datamasque/client/models/discovery.py +3 -3
- datamasque/client/models/status.py +15 -1
- datamasque/client/runs.py +9 -2
- {datamasque_python-1.1.0.dist-info → datamasque_python-1.1.2.dist-info}/METADATA +1 -1
- {datamasque_python-1.1.0.dist-info → datamasque_python-1.1.2.dist-info}/RECORD +8 -8
- {datamasque_python-1.1.0.dist-info → datamasque_python-1.1.2.dist-info}/WHEEL +0 -0
- {datamasque_python-1.1.0.dist-info → datamasque_python-1.1.2.dist-info}/licenses/LICENSE +0 -0
datamasque/client/discovery.py
CHANGED
|
@@ -98,6 +98,10 @@ class DiscoveryClient(BaseClient):
|
|
|
98
98
|
- A text file handle (e.g. `open(path)`)
|
|
99
99
|
- A binary file handle (e.g. `open(path, 'rb')`)
|
|
100
100
|
|
|
101
|
+
If the content is a zip (for example a split report from `get_db_discovery_result_report()`),
|
|
102
|
+
it is detected by its magic bytes and uploaded as a zip;
|
|
103
|
+
otherwise it is uploaded as CSV.
|
|
104
|
+
|
|
101
105
|
Generation runs asynchronously on the server.
|
|
102
106
|
Poll `get_async_ruleset_generation_task_status` until it returns
|
|
103
107
|
`AsyncRulesetGenerationTaskStatus.finished`,
|
|
@@ -114,14 +118,22 @@ class DiscoveryClient(BaseClient):
|
|
|
114
118
|
else:
|
|
115
119
|
content = csv_content
|
|
116
120
|
|
|
121
|
+
is_zip = False
|
|
122
|
+
if content.seekable():
|
|
123
|
+
is_zip = content.read(4) == b"PK\x03\x04"
|
|
124
|
+
content.seek(0)
|
|
125
|
+
filename = "ruleset.zip" if is_zip else "ruleset.csv"
|
|
126
|
+
content_type = "application/zip" if is_zip else "text/csv"
|
|
127
|
+
|
|
117
128
|
files = [
|
|
118
129
|
UploadFile(
|
|
119
130
|
field_name="csv_or_zip_file",
|
|
120
|
-
filename=
|
|
131
|
+
filename=filename,
|
|
121
132
|
content=content,
|
|
122
|
-
content_type=
|
|
133
|
+
content_type=content_type,
|
|
123
134
|
),
|
|
124
135
|
]
|
|
136
|
+
|
|
125
137
|
self.make_request(
|
|
126
138
|
method="POST",
|
|
127
139
|
path=f"/api/async-generate-ruleset/{connection_id}/from-csv/",
|
|
@@ -154,7 +166,7 @@ class DiscoveryClient(BaseClient):
|
|
|
154
166
|
returns a list containing one ruleset
|
|
155
167
|
|
|
156
168
|
Raises `AsyncRulesetGenerationInProgressError` if the task hasn't finished yet,
|
|
157
|
-
and `DataMasqueException` if it failed.
|
|
169
|
+
and `DataMasqueException` if it failed or was cancelled.
|
|
158
170
|
|
|
159
171
|
Note that the ruleset(s) have autogenerated names, which you may want to customize before uploading.
|
|
160
172
|
"""
|
|
@@ -164,7 +176,11 @@ class DiscoveryClient(BaseClient):
|
|
|
164
176
|
logger.error("Ruleset generation failed for connection: %s", connection_id)
|
|
165
177
|
raise DataMasqueException(f"Ruleset generation failed for connection: {connection_id}")
|
|
166
178
|
|
|
167
|
-
if status is
|
|
179
|
+
if status is AsyncRulesetGenerationTaskStatus.cancelled:
|
|
180
|
+
logger.error("Ruleset generation was cancelled for connection: %s", connection_id)
|
|
181
|
+
raise DataMasqueException(f"Ruleset generation was cancelled for connection: {connection_id}")
|
|
182
|
+
|
|
183
|
+
if not status.is_finished:
|
|
168
184
|
logger.error(
|
|
169
185
|
"Ruleset generation is still in progress for connection: %s. Status: `%s`",
|
|
170
186
|
connection_id,
|
|
@@ -252,7 +252,7 @@ class DiscoveryMatch(BaseModel):
|
|
|
252
252
|
|
|
253
253
|
model_config = ConfigDict(extra="allow")
|
|
254
254
|
|
|
255
|
-
label: str
|
|
255
|
+
label: Optional[str] = None
|
|
256
256
|
categories: list[str]
|
|
257
257
|
flagged_by: str
|
|
258
258
|
description: str
|
|
@@ -343,8 +343,8 @@ class FileDiscoveryMatch(BaseModel):
|
|
|
343
343
|
|
|
344
344
|
flagged_by: str
|
|
345
345
|
description: str
|
|
346
|
-
label: Optional[str] = None # Omitted for non-sensitive
|
|
347
|
-
categories: Optional[list[str]] = None
|
|
346
|
+
label: Optional[str] = None # Omitted for non-sensitive matches.
|
|
347
|
+
categories: Optional[list[str]] = None
|
|
348
348
|
hit_ratio: Optional[int] = None # None for metadata matches, percentage 0-100 for IDD matches.
|
|
349
349
|
|
|
350
350
|
|
|
@@ -60,18 +60,32 @@ class AsyncRulesetGenerationTaskStatus(enum.Enum):
|
|
|
60
60
|
"""List of statuses of async ruleset generation tasks."""
|
|
61
61
|
|
|
62
62
|
finished = "finished"
|
|
63
|
+
finished_with_warnings = "finished_with_warnings"
|
|
63
64
|
failed = "failed"
|
|
64
65
|
running = "running"
|
|
65
66
|
queued = "queued"
|
|
67
|
+
cancelled = "cancelled"
|
|
66
68
|
|
|
67
69
|
@classmethod
|
|
68
70
|
def get_final_states(cls) -> set["AsyncRulesetGenerationTaskStatus"]:
|
|
69
71
|
"""Returns the list of final statuses, i.e. the ruleset generation has completed, successfully or otherwise."""
|
|
70
72
|
|
|
71
|
-
return {cls.finished, cls.failed}
|
|
73
|
+
return {cls.finished, cls.finished_with_warnings, cls.failed, cls.cancelled}
|
|
74
|
+
|
|
75
|
+
@classmethod
|
|
76
|
+
def get_finished_states(cls) -> set["AsyncRulesetGenerationTaskStatus"]:
|
|
77
|
+
"""Returns the list of statuses that indicate the ruleset generation completed successfully."""
|
|
78
|
+
|
|
79
|
+
return {cls.finished, cls.finished_with_warnings}
|
|
72
80
|
|
|
73
81
|
@property
|
|
74
82
|
def is_in_final_state(self) -> bool:
|
|
75
83
|
"""Returns True if this status is a final status."""
|
|
76
84
|
|
|
77
85
|
return self in self.get_final_states()
|
|
86
|
+
|
|
87
|
+
@property
|
|
88
|
+
def is_finished(self) -> bool:
|
|
89
|
+
"""Returns True if this status is a finished status."""
|
|
90
|
+
|
|
91
|
+
return self in self.get_finished_states()
|
datamasque/client/runs.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
import re
|
|
3
|
+
from typing import Union
|
|
3
4
|
|
|
4
5
|
from datamasque.client.base import BaseClient
|
|
5
6
|
from datamasque.client.exceptions import (
|
|
@@ -43,9 +44,12 @@ class RunClient(BaseClient):
|
|
|
43
44
|
response = self.make_request("GET", f"api/runs/{run_id}/run-report/")
|
|
44
45
|
return response.text
|
|
45
46
|
|
|
46
|
-
def get_db_discovery_result_report(self, run_id: RunId, include_selection_column: bool = True) -> str:
|
|
47
|
+
def get_db_discovery_result_report(self, run_id: RunId, include_selection_column: bool = True) -> Union[str, bytes]:
|
|
47
48
|
"""
|
|
48
|
-
Returns the database-discovery result report for the specified run
|
|
49
|
+
Returns the database-discovery result report for the specified run.
|
|
50
|
+
|
|
51
|
+
Returns CSV text (`str`),
|
|
52
|
+
or a zip of numbered CSV parts as `bytes` when the server splits a large report.
|
|
49
53
|
|
|
50
54
|
When `include_selection_column` is true (the default),
|
|
51
55
|
the CSV includes a `selected` column suitable for feeding back into ruleset generation.
|
|
@@ -54,6 +58,9 @@ class RunClient(BaseClient):
|
|
|
54
58
|
url = f"api/runs/{run_id}/db-discovery-results/report/"
|
|
55
59
|
params = None if include_selection_column else {"include_selection_column": "false"}
|
|
56
60
|
response = self.make_request("GET", url, params=params)
|
|
61
|
+
|
|
62
|
+
if response.headers.get("Content-Type", "").startswith("application/zip"):
|
|
63
|
+
return response.content
|
|
57
64
|
return response.text
|
|
58
65
|
|
|
59
66
|
def get_unfinished_runs(self) -> dict[str, UnfinishedRun]:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: datamasque-python
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.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/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
datamasque/client/__init__.py,sha256=GmpVFNWZPu6jyadhY6SOZp4hLR1wUc4cgzwLcqoEA5o,6312
|
|
2
2
|
datamasque/client/base.py,sha256=vP1LuYbqq6U8NAEJWnwNrdt_Fa2wjQTJXHf0gSFO79c,14115
|
|
3
3
|
datamasque/client/connections.py,sha256=EFinx8fJRme0mTxuWY3d29UnmUFbsQhMaUQT0Ma2PK4,2885
|
|
4
|
-
datamasque/client/discovery.py,sha256=
|
|
4
|
+
datamasque/client/discovery.py,sha256=MTDiif6YWkv64hHXZ8YJxtRhoeKIvQVfjNYvjCIZCXE,21261
|
|
5
5
|
datamasque/client/discovery_configs.py,sha256=G-W-X_KizjjQLa-Rb6ixLjlkxbkCe4WGCOfYZrGtxIk,6420
|
|
6
6
|
datamasque/client/dmclient.py,sha256=tA7V8GEQmnsalTHUZch8YmIUynYw2ldK-mmUGbofFL4,1650
|
|
7
7
|
datamasque/client/exceptions.py,sha256=Tx7tE6i1X_oemR3EOJC97_sihZiToHqGuOQmWWxs_BE,3131
|
|
@@ -11,13 +11,13 @@ datamasque/client/license.py,sha256=pluYaSU168OC6_laB9bM9H3Vuuxs8wa9gujCJvtoJCk,
|
|
|
11
11
|
datamasque/client/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
12
|
datamasque/client/ruleset_libraries.py,sha256=bMUMBHdxjDyFOziw9LMRy5xChPvHvCjpjAUoVeTm1e0,7086
|
|
13
13
|
datamasque/client/rulesets.py,sha256=Fsnsv-uAhF1DBnLI-pRpOrWJ7aCSZspcuU1r0RYTzUc,2655
|
|
14
|
-
datamasque/client/runs.py,sha256=
|
|
14
|
+
datamasque/client/runs.py,sha256=l_JpYgelqsDKW_O6LtsHC60IMXHG9ak_RwVnuvJKE1I,7703
|
|
15
15
|
datamasque/client/settings.py,sha256=Ui8AyR2XdoW8MZ9FIrGn2jm8DLzUGWIL8i2DOTvu7hc,2898
|
|
16
16
|
datamasque/client/users.py,sha256=VCUo2CJyOw4-aO_3mp_w_0BcSoa6-h1HcReMcAMyumw,3701
|
|
17
17
|
datamasque/client/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
18
18
|
datamasque/client/models/connection.py,sha256=TSv-bbOFlYCRBZHJiRgiwNuN0es_GdJd-_L3LUsQ-dI,15773
|
|
19
19
|
datamasque/client/models/data_selection.py,sha256=406yyUZ5NmLBSql2lYM1gsTWY5GWmnutmF-DjznAoLc,1904
|
|
20
|
-
datamasque/client/models/discovery.py,sha256=
|
|
20
|
+
datamasque/client/models/discovery.py,sha256=WHSIkFebQ5m47K_BdxY1lvCeeF23q_BbZan7Ryuh5vY,13198
|
|
21
21
|
datamasque/client/models/discovery_config.py,sha256=1CHMgSxMXuarPGfRcz9wX7jeZLn1SDw0UEe-L5naE54,1917
|
|
22
22
|
datamasque/client/models/dm_instance.py,sha256=yjjpHZJTFhJp3lAinTEffgKrxnadrJys1EuhO77wQcA,1561
|
|
23
23
|
datamasque/client/models/files.py,sha256=7hG3Q1-XYb1PF88l3ppsmBp2tjNtvQvv-RNTrOa7Nts,2784
|
|
@@ -28,9 +28,9 @@ datamasque/client/models/pagination.py,sha256=egg9aO2cf6KUDwDANPu5RxpJbdRKdwUdCQ
|
|
|
28
28
|
datamasque/client/models/ruleset.py,sha256=ZYv6SmcrONV5rLK0tKjhlKCwZiCU1dMYtH7olxI4l5A,1678
|
|
29
29
|
datamasque/client/models/ruleset_library.py,sha256=5UbL_M47mgPedo8xt4q5crUh4aeOVoEMAEKbGO8CfiY,950
|
|
30
30
|
datamasque/client/models/runs.py,sha256=UtPMGCJFLFP1f2nyVGAbl3A5_wAONrRNJ63y43Hbpi0,6213
|
|
31
|
-
datamasque/client/models/status.py,sha256=
|
|
31
|
+
datamasque/client/models/status.py,sha256=UUEDHd3CQZA1Mf-1LyhAiE4COuCWvAz5oJx5ECVIwp4,2868
|
|
32
32
|
datamasque/client/models/user.py,sha256=UGAUzgJkf78m24_zFXXoA99zdut48BXkX_ivV8yq1Vc,2043
|
|
33
|
-
datamasque_python-1.1.
|
|
34
|
-
datamasque_python-1.1.
|
|
35
|
-
datamasque_python-1.1.
|
|
36
|
-
datamasque_python-1.1.
|
|
33
|
+
datamasque_python-1.1.2.dist-info/METADATA,sha256=0S1FrNnn9ZEVX8or5A2WcTz3t-ewccuy9O7jx2vY1TY,4187
|
|
34
|
+
datamasque_python-1.1.2.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
|
|
35
|
+
datamasque_python-1.1.2.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
36
|
+
datamasque_python-1.1.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|