datamasque-python 1.1.0__py3-none-any.whl → 1.1.1__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.
@@ -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="ruleset.csv",
131
+ filename=filename,
121
132
  content=content,
122
- content_type="text/csv",
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/",
@@ -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 and ignored matches.
347
- categories: Optional[list[str]] = None # Omitted for ignored matches.
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,6 +60,7 @@ 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"
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 as CSV.
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.0
3
+ Version: 1.1.1
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=NluzWjC-QGzxWEHr6zMjKDkhx-Z9w5M0IBcR258OEhY,20536
4
+ datamasque/client/discovery.py,sha256=j83yCBlG2xRNQlv2zb6plwL3qcCT1m3nXABG0JRdh_w,21009
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=ZPSkkuyqMiwy7dLbWZ1PAEKaesKLeNRX7xEJGfzieVg,7427
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=wEveTc8vh6dOJx6K2rkbdbU_e1EbI8jSRhZ5SgDF2wY,13225
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=LuTpgocedVqeU0zxuoyJ7LsxMgHtSkrwHVMYaX_7QGg,2320
31
+ datamasque/client/models/status.py,sha256=AcKK7lelGeRCKGuWL3K9i7SiTpOIVTglyveu0tzJEVc,2374
32
32
  datamasque/client/models/user.py,sha256=UGAUzgJkf78m24_zFXXoA99zdut48BXkX_ivV8yq1Vc,2043
33
- datamasque_python-1.1.0.dist-info/METADATA,sha256=xZqEPFC-2faxpi_P_8wKBIRWNqKpZuEQdFWjvhWj26Q,4187
34
- datamasque_python-1.1.0.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
35
- datamasque_python-1.1.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
36
- datamasque_python-1.1.0.dist-info/RECORD,,
33
+ datamasque_python-1.1.1.dist-info/METADATA,sha256=TZeVZqLa38CsvBQS1wmS0xXh3nSWGyn5GKnIz5j2RXg,4187
34
+ datamasque_python-1.1.1.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
35
+ datamasque_python-1.1.1.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
36
+ datamasque_python-1.1.1.dist-info/RECORD,,