pvw-cli 1.2.8__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.
Potentially problematic release.
This version of pvw-cli might be problematic. Click here for more details.
- purviewcli/__init__.py +27 -0
- purviewcli/__main__.py +15 -0
- purviewcli/cli/__init__.py +5 -0
- purviewcli/cli/account.py +199 -0
- purviewcli/cli/cli.py +170 -0
- purviewcli/cli/collections.py +502 -0
- purviewcli/cli/domain.py +361 -0
- purviewcli/cli/entity.py +2436 -0
- purviewcli/cli/glossary.py +533 -0
- purviewcli/cli/health.py +250 -0
- purviewcli/cli/insight.py +113 -0
- purviewcli/cli/lineage.py +1103 -0
- purviewcli/cli/management.py +141 -0
- purviewcli/cli/policystore.py +103 -0
- purviewcli/cli/relationship.py +75 -0
- purviewcli/cli/scan.py +357 -0
- purviewcli/cli/search.py +527 -0
- purviewcli/cli/share.py +478 -0
- purviewcli/cli/types.py +831 -0
- purviewcli/cli/unified_catalog.py +3540 -0
- purviewcli/cli/workflow.py +402 -0
- purviewcli/client/__init__.py +21 -0
- purviewcli/client/_account.py +1877 -0
- purviewcli/client/_collections.py +1761 -0
- purviewcli/client/_domain.py +414 -0
- purviewcli/client/_entity.py +3545 -0
- purviewcli/client/_glossary.py +3233 -0
- purviewcli/client/_health.py +501 -0
- purviewcli/client/_insight.py +2873 -0
- purviewcli/client/_lineage.py +2138 -0
- purviewcli/client/_management.py +2202 -0
- purviewcli/client/_policystore.py +2915 -0
- purviewcli/client/_relationship.py +1351 -0
- purviewcli/client/_scan.py +2607 -0
- purviewcli/client/_search.py +1472 -0
- purviewcli/client/_share.py +272 -0
- purviewcli/client/_types.py +2708 -0
- purviewcli/client/_unified_catalog.py +5112 -0
- purviewcli/client/_workflow.py +2734 -0
- purviewcli/client/api_client.py +1295 -0
- purviewcli/client/business_rules.py +675 -0
- purviewcli/client/config.py +231 -0
- purviewcli/client/data_quality.py +433 -0
- purviewcli/client/endpoint.py +123 -0
- purviewcli/client/endpoints.py +554 -0
- purviewcli/client/exceptions.py +38 -0
- purviewcli/client/lineage_visualization.py +797 -0
- purviewcli/client/monitoring_dashboard.py +712 -0
- purviewcli/client/rate_limiter.py +30 -0
- purviewcli/client/retry_handler.py +125 -0
- purviewcli/client/scanning_operations.py +523 -0
- purviewcli/client/settings.py +1 -0
- purviewcli/client/sync_client.py +250 -0
- purviewcli/plugins/__init__.py +1 -0
- purviewcli/plugins/plugin_system.py +709 -0
- pvw_cli-1.2.8.dist-info/METADATA +1618 -0
- pvw_cli-1.2.8.dist-info/RECORD +60 -0
- pvw_cli-1.2.8.dist-info/WHEEL +5 -0
- pvw_cli-1.2.8.dist-info/entry_points.txt +3 -0
- pvw_cli-1.2.8.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,2607 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Scanning Management Client for Microsoft Purview Scanning API
|
|
3
|
+
Based on official API: https://learn.microsoft.com/en-us/rest/api/purview/scanningdataplane/
|
|
4
|
+
API Version: 2023-09-01 / 2022-07-01-preview
|
|
5
|
+
|
|
6
|
+
Complete implementation of ALL Scanning operations from the official specification with 100% coverage:
|
|
7
|
+
- Data Source Management (Create, Read, Update, Delete)
|
|
8
|
+
- Scan Configuration and Execution
|
|
9
|
+
- Scan Rules and Filters
|
|
10
|
+
- Classification Rules Management
|
|
11
|
+
- Scan Scheduling and Analytics
|
|
12
|
+
- Scan Results and History
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from .endpoint import Endpoint, decorator, get_json, no_api_call_decorator
|
|
16
|
+
from .endpoints import ENDPOINTS, get_api_version_params
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class Scan(Endpoint):
|
|
20
|
+
"""Scanning Management Operations - Complete Official API Implementation with 100% Coverage"""
|
|
21
|
+
|
|
22
|
+
def __init__(self):
|
|
23
|
+
Endpoint.__init__(self)
|
|
24
|
+
self.app = "scanning"
|
|
25
|
+
|
|
26
|
+
# === DATA SOURCE MANAGEMENT ===
|
|
27
|
+
|
|
28
|
+
@decorator
|
|
29
|
+
def scanDataSourcesRead(self, args):
|
|
30
|
+
"""
|
|
31
|
+
Retrieve scan information.
|
|
32
|
+
|
|
33
|
+
Retrieves detailed information about the specified scan.
|
|
34
|
+
Returns complete scan metadata and properties.
|
|
35
|
+
|
|
36
|
+
Args:
|
|
37
|
+
args: Dictionary of operation arguments.
|
|
38
|
+
Contains operation-specific parameters.
|
|
39
|
+
See method implementation for details.
|
|
40
|
+
|
|
41
|
+
Returns:
|
|
42
|
+
Dictionary containing scan information:
|
|
43
|
+
{
|
|
44
|
+
'guid': str, # Unique identifier
|
|
45
|
+
'name': str, # Resource name
|
|
46
|
+
'attributes': dict, # Resource attributes
|
|
47
|
+
'status': str, # Resource status
|
|
48
|
+
'updateTime': int # Last update timestamp
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
Raises:
|
|
52
|
+
ValueError: When required parameters are missing or invalid:
|
|
53
|
+
- Empty or None values for required fields
|
|
54
|
+
- Invalid GUID format
|
|
55
|
+
- Out-of-range values
|
|
56
|
+
|
|
57
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
58
|
+
- DefaultAzureCredential not configured
|
|
59
|
+
- Insufficient permissions
|
|
60
|
+
- Expired authentication token
|
|
61
|
+
|
|
62
|
+
HTTPError: When Purview API returns error:
|
|
63
|
+
- 400: Bad request (invalid parameters)
|
|
64
|
+
- 401: Unauthorized (authentication failed)
|
|
65
|
+
- 403: Forbidden (insufficient permissions)
|
|
66
|
+
- 404: Resource not found
|
|
67
|
+
- 429: Rate limit exceeded
|
|
68
|
+
- 500: Internal server error
|
|
69
|
+
|
|
70
|
+
NetworkError: When network connectivity fails
|
|
71
|
+
|
|
72
|
+
Example:
|
|
73
|
+
# Basic usage
|
|
74
|
+
client = Scan()
|
|
75
|
+
|
|
76
|
+
result = client.scanDataSourcesRead(args=...)
|
|
77
|
+
print(f"Result: {result}")
|
|
78
|
+
|
|
79
|
+
Use Cases:
|
|
80
|
+
- Data Discovery: Find and explore data assets
|
|
81
|
+
- Compliance Auditing: Review metadata and classifications
|
|
82
|
+
- Reporting: Generate catalog reports
|
|
83
|
+
"""
|
|
84
|
+
self.method = "GET"
|
|
85
|
+
self.endpoint = ENDPOINTS["scanning"]["list_data_sources"]
|
|
86
|
+
self.params = {
|
|
87
|
+
**get_api_version_params("scanning"),
|
|
88
|
+
"collectionName": args.get("--collectionName"),
|
|
89
|
+
"dataSourceType": args.get("--dataSourceType"),
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
@decorator
|
|
93
|
+
def scanDataSourceCreate(self, args):
|
|
94
|
+
"""
|
|
95
|
+
Create a new scan.
|
|
96
|
+
|
|
97
|
+
Creates a new scan in Microsoft Purview.
|
|
98
|
+
Requires appropriate permissions and valid scan definition.
|
|
99
|
+
|
|
100
|
+
Args:
|
|
101
|
+
args: Dictionary of operation arguments.
|
|
102
|
+
Contains operation-specific parameters.
|
|
103
|
+
See method implementation for details.
|
|
104
|
+
|
|
105
|
+
Returns:
|
|
106
|
+
Dictionary containing created scan:
|
|
107
|
+
{
|
|
108
|
+
'guid': str, # Unique identifier
|
|
109
|
+
'name': str, # Resource name
|
|
110
|
+
'status': str, # Creation status
|
|
111
|
+
'attributes': dict, # Resource attributes
|
|
112
|
+
'createTime': int # Creation timestamp
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
Raises:
|
|
116
|
+
ValueError: When required parameters are missing or invalid:
|
|
117
|
+
- Empty or None values for required fields
|
|
118
|
+
- Invalid GUID format
|
|
119
|
+
- Out-of-range values
|
|
120
|
+
|
|
121
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
122
|
+
- DefaultAzureCredential not configured
|
|
123
|
+
- Insufficient permissions
|
|
124
|
+
- Expired authentication token
|
|
125
|
+
|
|
126
|
+
HTTPError: When Purview API returns error:
|
|
127
|
+
- 400: Bad request (invalid parameters)
|
|
128
|
+
- 401: Unauthorized (authentication failed)
|
|
129
|
+
- 403: Forbidden (insufficient permissions)
|
|
130
|
+
- 404: Resource not found
|
|
131
|
+
- 409: Conflict (resource already exists)
|
|
132
|
+
- 429: Rate limit exceeded
|
|
133
|
+
- 500: Internal server error
|
|
134
|
+
|
|
135
|
+
NetworkError: When network connectivity fails
|
|
136
|
+
|
|
137
|
+
Example:
|
|
138
|
+
# Basic usage
|
|
139
|
+
client = Scan()
|
|
140
|
+
|
|
141
|
+
result = client.scanDataSourceCreate(args=...)
|
|
142
|
+
print(f"Result: {result}")
|
|
143
|
+
|
|
144
|
+
# With detailed data
|
|
145
|
+
data = {
|
|
146
|
+
'name': 'My Resource',
|
|
147
|
+
'description': 'Resource description',
|
|
148
|
+
'attributes': {
|
|
149
|
+
'key1': 'value1',
|
|
150
|
+
'key2': 'value2'
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
result = client.scanDataSourceCreate(data)
|
|
155
|
+
print(f"Created/Updated: {result['guid']}")
|
|
156
|
+
|
|
157
|
+
Use Cases:
|
|
158
|
+
- Data Onboarding: Register new data sources in catalog
|
|
159
|
+
- Metadata Management: Add descriptive metadata to assets
|
|
160
|
+
- Automation: Programmatically populate catalog
|
|
161
|
+
"""
|
|
162
|
+
self.method = "PUT"
|
|
163
|
+
self.endpoint = ENDPOINTS["scanning"]["create_data_source"].format(dataSourceName=args["--dataSourceName"])
|
|
164
|
+
self.params = get_api_version_params("scanning")
|
|
165
|
+
self.payload = get_json(args, "--payloadFile")
|
|
166
|
+
|
|
167
|
+
@decorator
|
|
168
|
+
def scanDataSourceRead(self, args):
|
|
169
|
+
"""
|
|
170
|
+
Retrieve scan information.
|
|
171
|
+
|
|
172
|
+
Retrieves detailed information about the specified scan.
|
|
173
|
+
Returns complete scan metadata and properties.
|
|
174
|
+
|
|
175
|
+
Args:
|
|
176
|
+
args: Dictionary of operation arguments.
|
|
177
|
+
Contains operation-specific parameters.
|
|
178
|
+
See method implementation for details.
|
|
179
|
+
|
|
180
|
+
Returns:
|
|
181
|
+
Dictionary containing scan information:
|
|
182
|
+
{
|
|
183
|
+
'guid': str, # Unique identifier
|
|
184
|
+
'name': str, # Resource name
|
|
185
|
+
'attributes': dict, # Resource attributes
|
|
186
|
+
'status': str, # Resource status
|
|
187
|
+
'updateTime': int # Last update timestamp
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
Raises:
|
|
191
|
+
ValueError: When required parameters are missing or invalid:
|
|
192
|
+
- Empty or None values for required fields
|
|
193
|
+
- Invalid GUID format
|
|
194
|
+
- Out-of-range values
|
|
195
|
+
|
|
196
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
197
|
+
- DefaultAzureCredential not configured
|
|
198
|
+
- Insufficient permissions
|
|
199
|
+
- Expired authentication token
|
|
200
|
+
|
|
201
|
+
HTTPError: When Purview API returns error:
|
|
202
|
+
- 400: Bad request (invalid parameters)
|
|
203
|
+
- 401: Unauthorized (authentication failed)
|
|
204
|
+
- 403: Forbidden (insufficient permissions)
|
|
205
|
+
- 404: Resource not found
|
|
206
|
+
- 429: Rate limit exceeded
|
|
207
|
+
- 500: Internal server error
|
|
208
|
+
|
|
209
|
+
NetworkError: When network connectivity fails
|
|
210
|
+
|
|
211
|
+
Example:
|
|
212
|
+
# Basic usage
|
|
213
|
+
client = Scan()
|
|
214
|
+
|
|
215
|
+
result = client.scanDataSourceRead(args=...)
|
|
216
|
+
print(f"Result: {result}")
|
|
217
|
+
|
|
218
|
+
Use Cases:
|
|
219
|
+
- Data Discovery: Find and explore data assets
|
|
220
|
+
- Compliance Auditing: Review metadata and classifications
|
|
221
|
+
- Reporting: Generate catalog reports
|
|
222
|
+
"""
|
|
223
|
+
self.method = "GET"
|
|
224
|
+
self.endpoint = ENDPOINTS["scanning"]["get_data_source"].format(dataSourceName=args["--dataSourceName"])
|
|
225
|
+
self.params = get_api_version_params("scanning")
|
|
226
|
+
|
|
227
|
+
@decorator
|
|
228
|
+
def scanDataSourceUpdate(self, args):
|
|
229
|
+
"""
|
|
230
|
+
Update an existing scan.
|
|
231
|
+
|
|
232
|
+
Updates an existing scan with new values.
|
|
233
|
+
Only specified fields are modified; others remain unchanged.
|
|
234
|
+
|
|
235
|
+
Args:
|
|
236
|
+
args: Dictionary of operation arguments.
|
|
237
|
+
Contains operation-specific parameters.
|
|
238
|
+
See method implementation for details.
|
|
239
|
+
|
|
240
|
+
Returns:
|
|
241
|
+
Dictionary containing updated scan:
|
|
242
|
+
{
|
|
243
|
+
'guid': str, # Unique identifier
|
|
244
|
+
'attributes': dict, # Updated attributes
|
|
245
|
+
'updateTime': int # Update timestamp
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
Raises:
|
|
249
|
+
ValueError: When required parameters are missing or invalid:
|
|
250
|
+
- Empty or None values for required fields
|
|
251
|
+
- Invalid GUID format
|
|
252
|
+
- Out-of-range values
|
|
253
|
+
|
|
254
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
255
|
+
- DefaultAzureCredential not configured
|
|
256
|
+
- Insufficient permissions
|
|
257
|
+
- Expired authentication token
|
|
258
|
+
|
|
259
|
+
HTTPError: When Purview API returns error:
|
|
260
|
+
- 400: Bad request (invalid parameters)
|
|
261
|
+
- 401: Unauthorized (authentication failed)
|
|
262
|
+
- 403: Forbidden (insufficient permissions)
|
|
263
|
+
- 404: Resource not found
|
|
264
|
+
- 429: Rate limit exceeded
|
|
265
|
+
- 500: Internal server error
|
|
266
|
+
|
|
267
|
+
NetworkError: When network connectivity fails
|
|
268
|
+
|
|
269
|
+
Example:
|
|
270
|
+
# Basic usage
|
|
271
|
+
client = Scan()
|
|
272
|
+
|
|
273
|
+
result = client.scanDataSourceUpdate(args=...)
|
|
274
|
+
print(f"Result: {result}")
|
|
275
|
+
|
|
276
|
+
# With detailed data
|
|
277
|
+
data = {
|
|
278
|
+
'name': 'My Resource',
|
|
279
|
+
'description': 'Resource description',
|
|
280
|
+
'attributes': {
|
|
281
|
+
'key1': 'value1',
|
|
282
|
+
'key2': 'value2'
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
result = client.scanDataSourceUpdate(data)
|
|
287
|
+
print(f"Created/Updated: {result['guid']}")
|
|
288
|
+
|
|
289
|
+
Use Cases:
|
|
290
|
+
- Metadata Enrichment: Update descriptions and tags
|
|
291
|
+
- Ownership Changes: Reassign data ownership
|
|
292
|
+
- Classification: Apply or modify data classifications
|
|
293
|
+
"""
|
|
294
|
+
return self.scanDataSourceCreate(args)
|
|
295
|
+
|
|
296
|
+
@decorator
|
|
297
|
+
def scanDataSourceDelete(self, args):
|
|
298
|
+
"""
|
|
299
|
+
Delete a scan.
|
|
300
|
+
|
|
301
|
+
Permanently deletes the specified scan.
|
|
302
|
+
This operation cannot be undone. Use with caution.
|
|
303
|
+
|
|
304
|
+
Args:
|
|
305
|
+
args: Dictionary of operation arguments.
|
|
306
|
+
Contains operation-specific parameters.
|
|
307
|
+
See method implementation for details.
|
|
308
|
+
|
|
309
|
+
Returns:
|
|
310
|
+
Dictionary with deletion status:
|
|
311
|
+
{
|
|
312
|
+
'guid': str, # Deleted resource ID
|
|
313
|
+
'status': str, # Deletion status
|
|
314
|
+
'message': str # Confirmation message
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
Raises:
|
|
318
|
+
ValueError: When required parameters are missing or invalid:
|
|
319
|
+
- Empty or None values for required fields
|
|
320
|
+
- Invalid GUID format
|
|
321
|
+
- Out-of-range values
|
|
322
|
+
|
|
323
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
324
|
+
- DefaultAzureCredential not configured
|
|
325
|
+
- Insufficient permissions
|
|
326
|
+
- Expired authentication token
|
|
327
|
+
|
|
328
|
+
HTTPError: When Purview API returns error:
|
|
329
|
+
- 400: Bad request (invalid parameters)
|
|
330
|
+
- 401: Unauthorized (authentication failed)
|
|
331
|
+
- 403: Forbidden (insufficient permissions)
|
|
332
|
+
- 404: Resource not found
|
|
333
|
+
- 429: Rate limit exceeded
|
|
334
|
+
- 500: Internal server error
|
|
335
|
+
|
|
336
|
+
NetworkError: When network connectivity fails
|
|
337
|
+
|
|
338
|
+
Example:
|
|
339
|
+
# Basic usage
|
|
340
|
+
client = Scan()
|
|
341
|
+
|
|
342
|
+
result = client.scanDataSourceDelete(args=...)
|
|
343
|
+
print(f"Result: {result}")
|
|
344
|
+
|
|
345
|
+
Use Cases:
|
|
346
|
+
- Data Cleanup: Remove obsolete or test data
|
|
347
|
+
- Decommissioning: Delete resources no longer in use
|
|
348
|
+
- Testing: Clean up test environments
|
|
349
|
+
"""
|
|
350
|
+
self.method = "DELETE"
|
|
351
|
+
self.endpoint = ENDPOINTS["scanning"]["delete_data_source"].format(dataSourceName=args["--dataSourceName"])
|
|
352
|
+
self.params = get_api_version_params("scanning")
|
|
353
|
+
|
|
354
|
+
# === SCAN CONFIGURATION ===
|
|
355
|
+
|
|
356
|
+
@decorator
|
|
357
|
+
def scanRead(self, args):
|
|
358
|
+
"""
|
|
359
|
+
Retrieve scan information.
|
|
360
|
+
|
|
361
|
+
Retrieves detailed information about the specified scan.
|
|
362
|
+
Returns complete scan metadata and properties.
|
|
363
|
+
|
|
364
|
+
Args:
|
|
365
|
+
args: Dictionary of operation arguments.
|
|
366
|
+
Contains operation-specific parameters.
|
|
367
|
+
See method implementation for details.
|
|
368
|
+
|
|
369
|
+
Returns:
|
|
370
|
+
Dictionary containing scan information:
|
|
371
|
+
{
|
|
372
|
+
'guid': str, # Unique identifier
|
|
373
|
+
'name': str, # Resource name
|
|
374
|
+
'attributes': dict, # Resource attributes
|
|
375
|
+
'status': str, # Resource status
|
|
376
|
+
'updateTime': int # Last update timestamp
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
Raises:
|
|
380
|
+
ValueError: When required parameters are missing or invalid:
|
|
381
|
+
- Empty or None values for required fields
|
|
382
|
+
- Invalid GUID format
|
|
383
|
+
- Out-of-range values
|
|
384
|
+
|
|
385
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
386
|
+
- DefaultAzureCredential not configured
|
|
387
|
+
- Insufficient permissions
|
|
388
|
+
- Expired authentication token
|
|
389
|
+
|
|
390
|
+
HTTPError: When Purview API returns error:
|
|
391
|
+
- 400: Bad request (invalid parameters)
|
|
392
|
+
- 401: Unauthorized (authentication failed)
|
|
393
|
+
- 403: Forbidden (insufficient permissions)
|
|
394
|
+
- 404: Resource not found
|
|
395
|
+
- 429: Rate limit exceeded
|
|
396
|
+
- 500: Internal server error
|
|
397
|
+
|
|
398
|
+
NetworkError: When network connectivity fails
|
|
399
|
+
|
|
400
|
+
Example:
|
|
401
|
+
# Basic usage
|
|
402
|
+
client = Scan()
|
|
403
|
+
|
|
404
|
+
result = client.scanRead(args=...)
|
|
405
|
+
print(f"Result: {result}")
|
|
406
|
+
|
|
407
|
+
Use Cases:
|
|
408
|
+
- Data Discovery: Find and explore data assets
|
|
409
|
+
- Compliance Auditing: Review metadata and classifications
|
|
410
|
+
- Reporting: Generate catalog reports
|
|
411
|
+
"""
|
|
412
|
+
self.method = "GET"
|
|
413
|
+
if args.get("--scanName"):
|
|
414
|
+
self.endpoint = ENDPOINTS["scanning"]["get_scan"].format(
|
|
415
|
+
dataSourceName=args["--dataSourceName"], scanName=args["--scanName"]
|
|
416
|
+
)
|
|
417
|
+
else:
|
|
418
|
+
self.endpoint = ENDPOINTS["scanning"]["list_scans"].format(dataSourceName=args["--dataSourceName"])
|
|
419
|
+
self.params = get_api_version_params("scanning")
|
|
420
|
+
|
|
421
|
+
@decorator
|
|
422
|
+
def scanCreate(self, args):
|
|
423
|
+
"""
|
|
424
|
+
Create a new scan.
|
|
425
|
+
|
|
426
|
+
Creates a new scan in Microsoft Purview.
|
|
427
|
+
Requires appropriate permissions and valid scan definition.
|
|
428
|
+
|
|
429
|
+
Args:
|
|
430
|
+
args: Dictionary of operation arguments.
|
|
431
|
+
Contains operation-specific parameters.
|
|
432
|
+
See method implementation for details.
|
|
433
|
+
|
|
434
|
+
Returns:
|
|
435
|
+
Dictionary containing created scan:
|
|
436
|
+
{
|
|
437
|
+
'guid': str, # Unique identifier
|
|
438
|
+
'name': str, # Resource name
|
|
439
|
+
'status': str, # Creation status
|
|
440
|
+
'attributes': dict, # Resource attributes
|
|
441
|
+
'createTime': int # Creation timestamp
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
Raises:
|
|
445
|
+
ValueError: When required parameters are missing or invalid:
|
|
446
|
+
- Empty or None values for required fields
|
|
447
|
+
- Invalid GUID format
|
|
448
|
+
- Out-of-range values
|
|
449
|
+
|
|
450
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
451
|
+
- DefaultAzureCredential not configured
|
|
452
|
+
- Insufficient permissions
|
|
453
|
+
- Expired authentication token
|
|
454
|
+
|
|
455
|
+
HTTPError: When Purview API returns error:
|
|
456
|
+
- 400: Bad request (invalid parameters)
|
|
457
|
+
- 401: Unauthorized (authentication failed)
|
|
458
|
+
- 403: Forbidden (insufficient permissions)
|
|
459
|
+
- 404: Resource not found
|
|
460
|
+
- 409: Conflict (resource already exists)
|
|
461
|
+
- 429: Rate limit exceeded
|
|
462
|
+
- 500: Internal server error
|
|
463
|
+
|
|
464
|
+
NetworkError: When network connectivity fails
|
|
465
|
+
|
|
466
|
+
Example:
|
|
467
|
+
# Basic usage
|
|
468
|
+
client = Scan()
|
|
469
|
+
|
|
470
|
+
result = client.scanCreate(args=...)
|
|
471
|
+
print(f"Result: {result}")
|
|
472
|
+
|
|
473
|
+
# With detailed data
|
|
474
|
+
data = {
|
|
475
|
+
'name': 'My Resource',
|
|
476
|
+
'description': 'Resource description',
|
|
477
|
+
'attributes': {
|
|
478
|
+
'key1': 'value1',
|
|
479
|
+
'key2': 'value2'
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
result = client.scanCreate(data)
|
|
484
|
+
print(f"Created/Updated: {result['guid']}")
|
|
485
|
+
|
|
486
|
+
Use Cases:
|
|
487
|
+
- Data Onboarding: Register new data sources in catalog
|
|
488
|
+
- Metadata Management: Add descriptive metadata to assets
|
|
489
|
+
- Automation: Programmatically populate catalog
|
|
490
|
+
"""
|
|
491
|
+
self.method = "PUT"
|
|
492
|
+
self.endpoint = ENDPOINTS["scanning"]["create_scan"].format(
|
|
493
|
+
dataSourceName=args["--dataSourceName"], scanName=args["--scanName"]
|
|
494
|
+
)
|
|
495
|
+
self.params = get_api_version_params("scanning")
|
|
496
|
+
self.payload = get_json(args, "--payloadFile")
|
|
497
|
+
|
|
498
|
+
@decorator
|
|
499
|
+
def scanUpdate(self, args):
|
|
500
|
+
"""
|
|
501
|
+
Update an existing scan.
|
|
502
|
+
|
|
503
|
+
Updates an existing scan with new values.
|
|
504
|
+
Only specified fields are modified; others remain unchanged.
|
|
505
|
+
|
|
506
|
+
Args:
|
|
507
|
+
args: Dictionary of operation arguments.
|
|
508
|
+
Contains operation-specific parameters.
|
|
509
|
+
See method implementation for details.
|
|
510
|
+
|
|
511
|
+
Returns:
|
|
512
|
+
Dictionary containing updated scan:
|
|
513
|
+
{
|
|
514
|
+
'guid': str, # Unique identifier
|
|
515
|
+
'attributes': dict, # Updated attributes
|
|
516
|
+
'updateTime': int # Update timestamp
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
Raises:
|
|
520
|
+
ValueError: When required parameters are missing or invalid:
|
|
521
|
+
- Empty or None values for required fields
|
|
522
|
+
- Invalid GUID format
|
|
523
|
+
- Out-of-range values
|
|
524
|
+
|
|
525
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
526
|
+
- DefaultAzureCredential not configured
|
|
527
|
+
- Insufficient permissions
|
|
528
|
+
- Expired authentication token
|
|
529
|
+
|
|
530
|
+
HTTPError: When Purview API returns error:
|
|
531
|
+
- 400: Bad request (invalid parameters)
|
|
532
|
+
- 401: Unauthorized (authentication failed)
|
|
533
|
+
- 403: Forbidden (insufficient permissions)
|
|
534
|
+
- 404: Resource not found
|
|
535
|
+
- 429: Rate limit exceeded
|
|
536
|
+
- 500: Internal server error
|
|
537
|
+
|
|
538
|
+
NetworkError: When network connectivity fails
|
|
539
|
+
|
|
540
|
+
Example:
|
|
541
|
+
# Basic usage
|
|
542
|
+
client = Scan()
|
|
543
|
+
|
|
544
|
+
result = client.scanUpdate(args=...)
|
|
545
|
+
print(f"Result: {result}")
|
|
546
|
+
|
|
547
|
+
# With detailed data
|
|
548
|
+
data = {
|
|
549
|
+
'name': 'My Resource',
|
|
550
|
+
'description': 'Resource description',
|
|
551
|
+
'attributes': {
|
|
552
|
+
'key1': 'value1',
|
|
553
|
+
'key2': 'value2'
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
result = client.scanUpdate(data)
|
|
558
|
+
print(f"Created/Updated: {result['guid']}")
|
|
559
|
+
|
|
560
|
+
Use Cases:
|
|
561
|
+
- Metadata Enrichment: Update descriptions and tags
|
|
562
|
+
- Ownership Changes: Reassign data ownership
|
|
563
|
+
- Classification: Apply or modify data classifications
|
|
564
|
+
"""
|
|
565
|
+
return self.scanCreate(args)
|
|
566
|
+
|
|
567
|
+
@decorator
|
|
568
|
+
def scanDelete(self, args):
|
|
569
|
+
"""
|
|
570
|
+
Delete a scan.
|
|
571
|
+
|
|
572
|
+
Permanently deletes the specified scan.
|
|
573
|
+
This operation cannot be undone. Use with caution.
|
|
574
|
+
|
|
575
|
+
Args:
|
|
576
|
+
args: Dictionary of operation arguments.
|
|
577
|
+
Contains operation-specific parameters.
|
|
578
|
+
See method implementation for details.
|
|
579
|
+
|
|
580
|
+
Returns:
|
|
581
|
+
Dictionary with deletion status:
|
|
582
|
+
{
|
|
583
|
+
'guid': str, # Deleted resource ID
|
|
584
|
+
'status': str, # Deletion status
|
|
585
|
+
'message': str # Confirmation message
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
Raises:
|
|
589
|
+
ValueError: When required parameters are missing or invalid:
|
|
590
|
+
- Empty or None values for required fields
|
|
591
|
+
- Invalid GUID format
|
|
592
|
+
- Out-of-range values
|
|
593
|
+
|
|
594
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
595
|
+
- DefaultAzureCredential not configured
|
|
596
|
+
- Insufficient permissions
|
|
597
|
+
- Expired authentication token
|
|
598
|
+
|
|
599
|
+
HTTPError: When Purview API returns error:
|
|
600
|
+
- 400: Bad request (invalid parameters)
|
|
601
|
+
- 401: Unauthorized (authentication failed)
|
|
602
|
+
- 403: Forbidden (insufficient permissions)
|
|
603
|
+
- 404: Resource not found
|
|
604
|
+
- 429: Rate limit exceeded
|
|
605
|
+
- 500: Internal server error
|
|
606
|
+
|
|
607
|
+
NetworkError: When network connectivity fails
|
|
608
|
+
|
|
609
|
+
Example:
|
|
610
|
+
# Basic usage
|
|
611
|
+
client = Scan()
|
|
612
|
+
|
|
613
|
+
result = client.scanDelete(args=...)
|
|
614
|
+
print(f"Result: {result}")
|
|
615
|
+
|
|
616
|
+
Use Cases:
|
|
617
|
+
- Data Cleanup: Remove obsolete or test data
|
|
618
|
+
- Decommissioning: Delete resources no longer in use
|
|
619
|
+
- Testing: Clean up test environments
|
|
620
|
+
"""
|
|
621
|
+
self.method = "DELETE"
|
|
622
|
+
self.endpoint = ENDPOINTS["scanning"]["delete_scan"].format(
|
|
623
|
+
dataSourceName=args["--dataSourceName"], scanName=args["--scanName"]
|
|
624
|
+
)
|
|
625
|
+
self.params = get_api_version_params("scanning")
|
|
626
|
+
|
|
627
|
+
# === SCAN EXECUTION ===
|
|
628
|
+
|
|
629
|
+
@decorator
|
|
630
|
+
def scanRun(self, args):
|
|
631
|
+
"""
|
|
632
|
+
Perform operation on resource.
|
|
633
|
+
|
|
634
|
+
|
|
635
|
+
|
|
636
|
+
Args:
|
|
637
|
+
args: Dictionary of operation arguments.
|
|
638
|
+
Contains operation-specific parameters.
|
|
639
|
+
See method implementation for details.
|
|
640
|
+
|
|
641
|
+
Returns:
|
|
642
|
+
[TODO: Specify return type and structure]
|
|
643
|
+
[TODO: Document nested fields]
|
|
644
|
+
|
|
645
|
+
Raises:
|
|
646
|
+
ValueError: When required parameters are missing or invalid:
|
|
647
|
+
- Empty or None values for required fields
|
|
648
|
+
- Invalid GUID format
|
|
649
|
+
- Out-of-range values
|
|
650
|
+
|
|
651
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
652
|
+
- DefaultAzureCredential not configured
|
|
653
|
+
- Insufficient permissions
|
|
654
|
+
- Expired authentication token
|
|
655
|
+
|
|
656
|
+
HTTPError: When Purview API returns error:
|
|
657
|
+
- 400: Bad request (invalid parameters)
|
|
658
|
+
- 401: Unauthorized (authentication failed)
|
|
659
|
+
- 403: Forbidden (insufficient permissions)
|
|
660
|
+
- 404: Resource not found
|
|
661
|
+
- 429: Rate limit exceeded
|
|
662
|
+
- 500: Internal server error
|
|
663
|
+
|
|
664
|
+
NetworkError: When network connectivity fails
|
|
665
|
+
|
|
666
|
+
Example:
|
|
667
|
+
# Basic usage
|
|
668
|
+
client = Scan()
|
|
669
|
+
|
|
670
|
+
result = client.scanRun(args=...)
|
|
671
|
+
print(f"Result: {result}")
|
|
672
|
+
|
|
673
|
+
Use Cases:
|
|
674
|
+
- [TODO: Add specific use cases for this operation]
|
|
675
|
+
- [TODO: Include business context]
|
|
676
|
+
- [TODO: Explain when to use this method]
|
|
677
|
+
"""
|
|
678
|
+
self.method = "PUT"
|
|
679
|
+
self.endpoint = ENDPOINTS["scanning"]["run_scan"].format(
|
|
680
|
+
dataSourceName=args["--dataSourceName"], scanName=args["--scanName"]
|
|
681
|
+
)
|
|
682
|
+
self.params = {
|
|
683
|
+
**get_api_version_params("scanning"),
|
|
684
|
+
"runId": args.get("--runId"),
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
# Optional scan level parameter
|
|
688
|
+
scan_level = args.get("--scanLevel")
|
|
689
|
+
if scan_level:
|
|
690
|
+
self.params["scanLevel"] = scan_level
|
|
691
|
+
|
|
692
|
+
@decorator
|
|
693
|
+
def scanReadResult(self, args):
|
|
694
|
+
"""
|
|
695
|
+
Retrieve scan information.
|
|
696
|
+
|
|
697
|
+
Retrieves detailed information about the specified scan.
|
|
698
|
+
Returns complete scan metadata and properties.
|
|
699
|
+
|
|
700
|
+
Args:
|
|
701
|
+
args: Dictionary of operation arguments.
|
|
702
|
+
Contains operation-specific parameters.
|
|
703
|
+
See method implementation for details.
|
|
704
|
+
|
|
705
|
+
Returns:
|
|
706
|
+
Dictionary containing scan information:
|
|
707
|
+
{
|
|
708
|
+
'guid': str, # Unique identifier
|
|
709
|
+
'name': str, # Resource name
|
|
710
|
+
'attributes': dict, # Resource attributes
|
|
711
|
+
'status': str, # Resource status
|
|
712
|
+
'updateTime': int # Last update timestamp
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
Raises:
|
|
716
|
+
ValueError: When required parameters are missing or invalid:
|
|
717
|
+
- Empty or None values for required fields
|
|
718
|
+
- Invalid GUID format
|
|
719
|
+
- Out-of-range values
|
|
720
|
+
|
|
721
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
722
|
+
- DefaultAzureCredential not configured
|
|
723
|
+
- Insufficient permissions
|
|
724
|
+
- Expired authentication token
|
|
725
|
+
|
|
726
|
+
HTTPError: When Purview API returns error:
|
|
727
|
+
- 400: Bad request (invalid parameters)
|
|
728
|
+
- 401: Unauthorized (authentication failed)
|
|
729
|
+
- 403: Forbidden (insufficient permissions)
|
|
730
|
+
- 404: Resource not found
|
|
731
|
+
- 429: Rate limit exceeded
|
|
732
|
+
- 500: Internal server error
|
|
733
|
+
|
|
734
|
+
NetworkError: When network connectivity fails
|
|
735
|
+
|
|
736
|
+
Example:
|
|
737
|
+
# Basic usage
|
|
738
|
+
client = Scan()
|
|
739
|
+
|
|
740
|
+
result = client.scanReadResult(args=...)
|
|
741
|
+
print(f"Result: {result}")
|
|
742
|
+
|
|
743
|
+
Use Cases:
|
|
744
|
+
- Data Discovery: Find and explore data assets
|
|
745
|
+
- Compliance Auditing: Review metadata and classifications
|
|
746
|
+
- Reporting: Generate catalog reports
|
|
747
|
+
"""
|
|
748
|
+
self.method = "GET"
|
|
749
|
+
if args.get("--runId"):
|
|
750
|
+
self.endpoint = ENDPOINTS["scanning"]["get_scan_result"].format(
|
|
751
|
+
dataSourceName=args["--dataSourceName"], scanName=args["--scanName"], runId=args["--runId"]
|
|
752
|
+
)
|
|
753
|
+
else:
|
|
754
|
+
self.endpoint = ENDPOINTS["scanning"]["list_scan_results"].format(
|
|
755
|
+
dataSourceName=args["--dataSourceName"], scanName=args["--scanName"]
|
|
756
|
+
)
|
|
757
|
+
self.params = get_api_version_params("scanning")
|
|
758
|
+
|
|
759
|
+
@decorator
|
|
760
|
+
def scanCancel(self, args):
|
|
761
|
+
"""
|
|
762
|
+
Perform operation on resource.
|
|
763
|
+
|
|
764
|
+
|
|
765
|
+
|
|
766
|
+
Args:
|
|
767
|
+
args: Dictionary of operation arguments.
|
|
768
|
+
Contains operation-specific parameters.
|
|
769
|
+
See method implementation for details.
|
|
770
|
+
|
|
771
|
+
Returns:
|
|
772
|
+
[TODO: Specify return type and structure]
|
|
773
|
+
[TODO: Document nested fields]
|
|
774
|
+
|
|
775
|
+
Raises:
|
|
776
|
+
ValueError: When required parameters are missing or invalid:
|
|
777
|
+
- Empty or None values for required fields
|
|
778
|
+
- Invalid GUID format
|
|
779
|
+
- Out-of-range values
|
|
780
|
+
|
|
781
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
782
|
+
- DefaultAzureCredential not configured
|
|
783
|
+
- Insufficient permissions
|
|
784
|
+
- Expired authentication token
|
|
785
|
+
|
|
786
|
+
HTTPError: When Purview API returns error:
|
|
787
|
+
- 400: Bad request (invalid parameters)
|
|
788
|
+
- 401: Unauthorized (authentication failed)
|
|
789
|
+
- 403: Forbidden (insufficient permissions)
|
|
790
|
+
- 404: Resource not found
|
|
791
|
+
- 429: Rate limit exceeded
|
|
792
|
+
- 500: Internal server error
|
|
793
|
+
|
|
794
|
+
NetworkError: When network connectivity fails
|
|
795
|
+
|
|
796
|
+
Example:
|
|
797
|
+
# Basic usage
|
|
798
|
+
client = Scan()
|
|
799
|
+
|
|
800
|
+
result = client.scanCancel(args=...)
|
|
801
|
+
print(f"Result: {result}")
|
|
802
|
+
|
|
803
|
+
Use Cases:
|
|
804
|
+
- [TODO: Add specific use cases for this operation]
|
|
805
|
+
- [TODO: Include business context]
|
|
806
|
+
- [TODO: Explain when to use this method]
|
|
807
|
+
"""
|
|
808
|
+
self.method = "POST"
|
|
809
|
+
self.endpoint = ENDPOINTS["scanning"]["cancel_scan"].format(
|
|
810
|
+
dataSourceName=args["--dataSourceName"], scanName=args["--scanName"], runId=args["--runId"]
|
|
811
|
+
)
|
|
812
|
+
self.params = get_api_version_params("scanning")
|
|
813
|
+
|
|
814
|
+
# === SCAN RULE SETS ===
|
|
815
|
+
|
|
816
|
+
@decorator
|
|
817
|
+
def scanRuleSetRead(self, args):
|
|
818
|
+
"""
|
|
819
|
+
Retrieve scan information.
|
|
820
|
+
|
|
821
|
+
Retrieves detailed information about the specified scan.
|
|
822
|
+
Returns complete scan metadata and properties.
|
|
823
|
+
|
|
824
|
+
Args:
|
|
825
|
+
args: Dictionary of operation arguments.
|
|
826
|
+
Contains operation-specific parameters.
|
|
827
|
+
See method implementation for details.
|
|
828
|
+
|
|
829
|
+
Returns:
|
|
830
|
+
Dictionary containing scan information:
|
|
831
|
+
{
|
|
832
|
+
'guid': str, # Unique identifier
|
|
833
|
+
'name': str, # Resource name
|
|
834
|
+
'attributes': dict, # Resource attributes
|
|
835
|
+
'status': str, # Resource status
|
|
836
|
+
'updateTime': int # Last update timestamp
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
Raises:
|
|
840
|
+
ValueError: When required parameters are missing or invalid:
|
|
841
|
+
- Empty or None values for required fields
|
|
842
|
+
- Invalid GUID format
|
|
843
|
+
- Out-of-range values
|
|
844
|
+
|
|
845
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
846
|
+
- DefaultAzureCredential not configured
|
|
847
|
+
- Insufficient permissions
|
|
848
|
+
- Expired authentication token
|
|
849
|
+
|
|
850
|
+
HTTPError: When Purview API returns error:
|
|
851
|
+
- 400: Bad request (invalid parameters)
|
|
852
|
+
- 401: Unauthorized (authentication failed)
|
|
853
|
+
- 403: Forbidden (insufficient permissions)
|
|
854
|
+
- 404: Resource not found
|
|
855
|
+
- 429: Rate limit exceeded
|
|
856
|
+
- 500: Internal server error
|
|
857
|
+
|
|
858
|
+
NetworkError: When network connectivity fails
|
|
859
|
+
|
|
860
|
+
Example:
|
|
861
|
+
# Basic usage
|
|
862
|
+
client = Scan()
|
|
863
|
+
|
|
864
|
+
result = client.scanRuleSetRead(args=...)
|
|
865
|
+
print(f"Result: {result}")
|
|
866
|
+
|
|
867
|
+
Use Cases:
|
|
868
|
+
- Data Discovery: Find and explore data assets
|
|
869
|
+
- Compliance Auditing: Review metadata and classifications
|
|
870
|
+
- Reporting: Generate catalog reports
|
|
871
|
+
"""
|
|
872
|
+
self.method = "GET"
|
|
873
|
+
if args.get("--scanRulesetName"):
|
|
874
|
+
self.endpoint = ENDPOINTS["scanning"]["get_scan_rule_set"].format(scanRulesetName=args["--scanRulesetName"])
|
|
875
|
+
else:
|
|
876
|
+
self.endpoint = ENDPOINTS["scanning"]["list_scan_rule_sets"]
|
|
877
|
+
self.params = get_api_version_params("scanning")
|
|
878
|
+
|
|
879
|
+
@decorator
|
|
880
|
+
def scanRuleSetCreate(self, args):
|
|
881
|
+
"""
|
|
882
|
+
Create a new scan.
|
|
883
|
+
|
|
884
|
+
Creates a new scan in Microsoft Purview.
|
|
885
|
+
Requires appropriate permissions and valid scan definition.
|
|
886
|
+
|
|
887
|
+
Args:
|
|
888
|
+
args: Dictionary of operation arguments.
|
|
889
|
+
Contains operation-specific parameters.
|
|
890
|
+
See method implementation for details.
|
|
891
|
+
|
|
892
|
+
Returns:
|
|
893
|
+
Dictionary containing created scan:
|
|
894
|
+
{
|
|
895
|
+
'guid': str, # Unique identifier
|
|
896
|
+
'name': str, # Resource name
|
|
897
|
+
'status': str, # Creation status
|
|
898
|
+
'attributes': dict, # Resource attributes
|
|
899
|
+
'createTime': int # Creation timestamp
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
Raises:
|
|
903
|
+
ValueError: When required parameters are missing or invalid:
|
|
904
|
+
- Empty or None values for required fields
|
|
905
|
+
- Invalid GUID format
|
|
906
|
+
- Out-of-range values
|
|
907
|
+
|
|
908
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
909
|
+
- DefaultAzureCredential not configured
|
|
910
|
+
- Insufficient permissions
|
|
911
|
+
- Expired authentication token
|
|
912
|
+
|
|
913
|
+
HTTPError: When Purview API returns error:
|
|
914
|
+
- 400: Bad request (invalid parameters)
|
|
915
|
+
- 401: Unauthorized (authentication failed)
|
|
916
|
+
- 403: Forbidden (insufficient permissions)
|
|
917
|
+
- 404: Resource not found
|
|
918
|
+
- 409: Conflict (resource already exists)
|
|
919
|
+
- 429: Rate limit exceeded
|
|
920
|
+
- 500: Internal server error
|
|
921
|
+
|
|
922
|
+
NetworkError: When network connectivity fails
|
|
923
|
+
|
|
924
|
+
Example:
|
|
925
|
+
# Basic usage
|
|
926
|
+
client = Scan()
|
|
927
|
+
|
|
928
|
+
result = client.scanRuleSetCreate(args=...)
|
|
929
|
+
print(f"Result: {result}")
|
|
930
|
+
|
|
931
|
+
# With detailed data
|
|
932
|
+
data = {
|
|
933
|
+
'name': 'My Resource',
|
|
934
|
+
'description': 'Resource description',
|
|
935
|
+
'attributes': {
|
|
936
|
+
'key1': 'value1',
|
|
937
|
+
'key2': 'value2'
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
result = client.scanRuleSetCreate(data)
|
|
942
|
+
print(f"Created/Updated: {result['guid']}")
|
|
943
|
+
|
|
944
|
+
Use Cases:
|
|
945
|
+
- Data Onboarding: Register new data sources in catalog
|
|
946
|
+
- Metadata Management: Add descriptive metadata to assets
|
|
947
|
+
- Automation: Programmatically populate catalog
|
|
948
|
+
"""
|
|
949
|
+
self.method = "PUT"
|
|
950
|
+
self.endpoint = ENDPOINTS["scanning"]["create_scan_rule_set"].format(scanRulesetName=args["--scanRulesetName"])
|
|
951
|
+
self.params = get_api_version_params("scanning")
|
|
952
|
+
self.payload = get_json(args, "--payloadFile")
|
|
953
|
+
|
|
954
|
+
@decorator
|
|
955
|
+
def scanRuleSetUpdate(self, args):
|
|
956
|
+
"""
|
|
957
|
+
Update an existing scan.
|
|
958
|
+
|
|
959
|
+
Updates an existing scan with new values.
|
|
960
|
+
Only specified fields are modified; others remain unchanged.
|
|
961
|
+
|
|
962
|
+
Args:
|
|
963
|
+
args: Dictionary of operation arguments.
|
|
964
|
+
Contains operation-specific parameters.
|
|
965
|
+
See method implementation for details.
|
|
966
|
+
|
|
967
|
+
Returns:
|
|
968
|
+
Dictionary containing updated scan:
|
|
969
|
+
{
|
|
970
|
+
'guid': str, # Unique identifier
|
|
971
|
+
'attributes': dict, # Updated attributes
|
|
972
|
+
'updateTime': int # Update timestamp
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
Raises:
|
|
976
|
+
ValueError: When required parameters are missing or invalid:
|
|
977
|
+
- Empty or None values for required fields
|
|
978
|
+
- Invalid GUID format
|
|
979
|
+
- Out-of-range values
|
|
980
|
+
|
|
981
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
982
|
+
- DefaultAzureCredential not configured
|
|
983
|
+
- Insufficient permissions
|
|
984
|
+
- Expired authentication token
|
|
985
|
+
|
|
986
|
+
HTTPError: When Purview API returns error:
|
|
987
|
+
- 400: Bad request (invalid parameters)
|
|
988
|
+
- 401: Unauthorized (authentication failed)
|
|
989
|
+
- 403: Forbidden (insufficient permissions)
|
|
990
|
+
- 404: Resource not found
|
|
991
|
+
- 429: Rate limit exceeded
|
|
992
|
+
- 500: Internal server error
|
|
993
|
+
|
|
994
|
+
NetworkError: When network connectivity fails
|
|
995
|
+
|
|
996
|
+
Example:
|
|
997
|
+
# Basic usage
|
|
998
|
+
client = Scan()
|
|
999
|
+
|
|
1000
|
+
result = client.scanRuleSetUpdate(args=...)
|
|
1001
|
+
print(f"Result: {result}")
|
|
1002
|
+
|
|
1003
|
+
# With detailed data
|
|
1004
|
+
data = {
|
|
1005
|
+
'name': 'My Resource',
|
|
1006
|
+
'description': 'Resource description',
|
|
1007
|
+
'attributes': {
|
|
1008
|
+
'key1': 'value1',
|
|
1009
|
+
'key2': 'value2'
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
result = client.scanRuleSetUpdate(data)
|
|
1014
|
+
print(f"Created/Updated: {result['guid']}")
|
|
1015
|
+
|
|
1016
|
+
Use Cases:
|
|
1017
|
+
- Metadata Enrichment: Update descriptions and tags
|
|
1018
|
+
- Ownership Changes: Reassign data ownership
|
|
1019
|
+
- Classification: Apply or modify data classifications
|
|
1020
|
+
"""
|
|
1021
|
+
return self.scanRuleSetCreate(args)
|
|
1022
|
+
|
|
1023
|
+
@decorator
|
|
1024
|
+
def scanRuleSetDelete(self, args):
|
|
1025
|
+
"""
|
|
1026
|
+
Update an existing scan.
|
|
1027
|
+
|
|
1028
|
+
Updates an existing scan with new values.
|
|
1029
|
+
Only specified fields are modified; others remain unchanged.
|
|
1030
|
+
|
|
1031
|
+
Args:
|
|
1032
|
+
args: Dictionary of operation arguments.
|
|
1033
|
+
Contains operation-specific parameters.
|
|
1034
|
+
See method implementation for details.
|
|
1035
|
+
|
|
1036
|
+
Returns:
|
|
1037
|
+
Dictionary containing updated scan:
|
|
1038
|
+
{
|
|
1039
|
+
'guid': str, # Unique identifier
|
|
1040
|
+
'attributes': dict, # Updated attributes
|
|
1041
|
+
'updateTime': int # Update timestamp
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
Raises:
|
|
1045
|
+
ValueError: When required parameters are missing or invalid:
|
|
1046
|
+
- Empty or None values for required fields
|
|
1047
|
+
- Invalid GUID format
|
|
1048
|
+
- Out-of-range values
|
|
1049
|
+
|
|
1050
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
1051
|
+
- DefaultAzureCredential not configured
|
|
1052
|
+
- Insufficient permissions
|
|
1053
|
+
- Expired authentication token
|
|
1054
|
+
|
|
1055
|
+
HTTPError: When Purview API returns error:
|
|
1056
|
+
- 400: Bad request (invalid parameters)
|
|
1057
|
+
- 401: Unauthorized (authentication failed)
|
|
1058
|
+
- 403: Forbidden (insufficient permissions)
|
|
1059
|
+
- 404: Resource not found
|
|
1060
|
+
- 429: Rate limit exceeded
|
|
1061
|
+
- 500: Internal server error
|
|
1062
|
+
|
|
1063
|
+
NetworkError: When network connectivity fails
|
|
1064
|
+
|
|
1065
|
+
Example:
|
|
1066
|
+
# Basic usage
|
|
1067
|
+
client = Scan()
|
|
1068
|
+
|
|
1069
|
+
result = client.scanRuleSetDelete(args=...)
|
|
1070
|
+
print(f"Result: {result}")
|
|
1071
|
+
|
|
1072
|
+
# With detailed data
|
|
1073
|
+
data = {
|
|
1074
|
+
'name': 'My Resource',
|
|
1075
|
+
'description': 'Resource description',
|
|
1076
|
+
'attributes': {
|
|
1077
|
+
'key1': 'value1',
|
|
1078
|
+
'key2': 'value2'
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
result = client.scanRuleSetDelete(data)
|
|
1083
|
+
print(f"Created/Updated: {result['guid']}")
|
|
1084
|
+
|
|
1085
|
+
Use Cases:
|
|
1086
|
+
- Metadata Enrichment: Update descriptions and tags
|
|
1087
|
+
- Ownership Changes: Reassign data ownership
|
|
1088
|
+
- Classification: Apply or modify data classifications
|
|
1089
|
+
"""
|
|
1090
|
+
self.method = "DELETE"
|
|
1091
|
+
self.endpoint = ENDPOINTS["scanning"]["delete_scan_rule_set"].format(scanRulesetName=args["--scanRulesetName"])
|
|
1092
|
+
self.params = get_api_version_params("scanning")
|
|
1093
|
+
|
|
1094
|
+
# === CLASSIFICATION RULES ===
|
|
1095
|
+
|
|
1096
|
+
@decorator
|
|
1097
|
+
def scanClassificationRuleRead(self, args):
|
|
1098
|
+
"""
|
|
1099
|
+
Retrieve scan information.
|
|
1100
|
+
|
|
1101
|
+
Retrieves detailed information about the specified scan.
|
|
1102
|
+
Returns complete scan metadata and properties.
|
|
1103
|
+
|
|
1104
|
+
Args:
|
|
1105
|
+
args: Dictionary of operation arguments.
|
|
1106
|
+
Contains operation-specific parameters.
|
|
1107
|
+
See method implementation for details.
|
|
1108
|
+
|
|
1109
|
+
Returns:
|
|
1110
|
+
Dictionary containing scan information:
|
|
1111
|
+
{
|
|
1112
|
+
'guid': str, # Unique identifier
|
|
1113
|
+
'name': str, # Resource name
|
|
1114
|
+
'attributes': dict, # Resource attributes
|
|
1115
|
+
'status': str, # Resource status
|
|
1116
|
+
'updateTime': int # Last update timestamp
|
|
1117
|
+
}
|
|
1118
|
+
|
|
1119
|
+
Raises:
|
|
1120
|
+
ValueError: When required parameters are missing or invalid:
|
|
1121
|
+
- Empty or None values for required fields
|
|
1122
|
+
- Invalid GUID format
|
|
1123
|
+
- Out-of-range values
|
|
1124
|
+
|
|
1125
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
1126
|
+
- DefaultAzureCredential not configured
|
|
1127
|
+
- Insufficient permissions
|
|
1128
|
+
- Expired authentication token
|
|
1129
|
+
|
|
1130
|
+
HTTPError: When Purview API returns error:
|
|
1131
|
+
- 400: Bad request (invalid parameters)
|
|
1132
|
+
- 401: Unauthorized (authentication failed)
|
|
1133
|
+
- 403: Forbidden (insufficient permissions)
|
|
1134
|
+
- 404: Resource not found
|
|
1135
|
+
- 429: Rate limit exceeded
|
|
1136
|
+
- 500: Internal server error
|
|
1137
|
+
|
|
1138
|
+
NetworkError: When network connectivity fails
|
|
1139
|
+
|
|
1140
|
+
Example:
|
|
1141
|
+
# Basic usage
|
|
1142
|
+
client = Scan()
|
|
1143
|
+
|
|
1144
|
+
result = client.scanClassificationRuleRead(args=...)
|
|
1145
|
+
print(f"Result: {result}")
|
|
1146
|
+
|
|
1147
|
+
Use Cases:
|
|
1148
|
+
- Data Discovery: Find and explore data assets
|
|
1149
|
+
- Compliance Auditing: Review metadata and classifications
|
|
1150
|
+
- Reporting: Generate catalog reports
|
|
1151
|
+
"""
|
|
1152
|
+
self.method = "GET"
|
|
1153
|
+
if args.get("--classificationRuleName"):
|
|
1154
|
+
self.endpoint = ENDPOINTS["scanning"]["get_classification_rule"].format(
|
|
1155
|
+
classificationRuleName=args["--classificationRuleName"]
|
|
1156
|
+
)
|
|
1157
|
+
else:
|
|
1158
|
+
self.endpoint = ENDPOINTS["scanning"]["list_classification_rules"]
|
|
1159
|
+
self.params = get_api_version_params("scanning")
|
|
1160
|
+
|
|
1161
|
+
@decorator
|
|
1162
|
+
def scanClassificationRuleCreate(self, args):
|
|
1163
|
+
"""
|
|
1164
|
+
Create a new scan.
|
|
1165
|
+
|
|
1166
|
+
Creates a new scan in Microsoft Purview.
|
|
1167
|
+
Requires appropriate permissions and valid scan definition.
|
|
1168
|
+
|
|
1169
|
+
Args:
|
|
1170
|
+
args: Dictionary of operation arguments.
|
|
1171
|
+
Contains operation-specific parameters.
|
|
1172
|
+
See method implementation for details.
|
|
1173
|
+
|
|
1174
|
+
Returns:
|
|
1175
|
+
Dictionary containing created scan:
|
|
1176
|
+
{
|
|
1177
|
+
'guid': str, # Unique identifier
|
|
1178
|
+
'name': str, # Resource name
|
|
1179
|
+
'status': str, # Creation status
|
|
1180
|
+
'attributes': dict, # Resource attributes
|
|
1181
|
+
'createTime': int # Creation timestamp
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
Raises:
|
|
1185
|
+
ValueError: When required parameters are missing or invalid:
|
|
1186
|
+
- Empty or None values for required fields
|
|
1187
|
+
- Invalid GUID format
|
|
1188
|
+
- Out-of-range values
|
|
1189
|
+
|
|
1190
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
1191
|
+
- DefaultAzureCredential not configured
|
|
1192
|
+
- Insufficient permissions
|
|
1193
|
+
- Expired authentication token
|
|
1194
|
+
|
|
1195
|
+
HTTPError: When Purview API returns error:
|
|
1196
|
+
- 400: Bad request (invalid parameters)
|
|
1197
|
+
- 401: Unauthorized (authentication failed)
|
|
1198
|
+
- 403: Forbidden (insufficient permissions)
|
|
1199
|
+
- 404: Resource not found
|
|
1200
|
+
- 409: Conflict (resource already exists)
|
|
1201
|
+
- 429: Rate limit exceeded
|
|
1202
|
+
- 500: Internal server error
|
|
1203
|
+
|
|
1204
|
+
NetworkError: When network connectivity fails
|
|
1205
|
+
|
|
1206
|
+
Example:
|
|
1207
|
+
# Basic usage
|
|
1208
|
+
client = Scan()
|
|
1209
|
+
|
|
1210
|
+
result = client.scanClassificationRuleCreate(args=...)
|
|
1211
|
+
print(f"Result: {result}")
|
|
1212
|
+
|
|
1213
|
+
# With detailed data
|
|
1214
|
+
data = {
|
|
1215
|
+
'name': 'My Resource',
|
|
1216
|
+
'description': 'Resource description',
|
|
1217
|
+
'attributes': {
|
|
1218
|
+
'key1': 'value1',
|
|
1219
|
+
'key2': 'value2'
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1223
|
+
result = client.scanClassificationRuleCreate(data)
|
|
1224
|
+
print(f"Created/Updated: {result['guid']}")
|
|
1225
|
+
|
|
1226
|
+
Use Cases:
|
|
1227
|
+
- Data Onboarding: Register new data sources in catalog
|
|
1228
|
+
- Metadata Management: Add descriptive metadata to assets
|
|
1229
|
+
- Automation: Programmatically populate catalog
|
|
1230
|
+
"""
|
|
1231
|
+
self.method = "PUT"
|
|
1232
|
+
self.endpoint = ENDPOINTS["scanning"]["create_classification_rule"].format(
|
|
1233
|
+
classificationRuleName=args["--classificationRuleName"]
|
|
1234
|
+
)
|
|
1235
|
+
self.params = get_api_version_params("scanning")
|
|
1236
|
+
self.payload = get_json(args, "--payloadFile")
|
|
1237
|
+
|
|
1238
|
+
@decorator
|
|
1239
|
+
def scanClassificationRuleUpdate(self, args):
|
|
1240
|
+
"""
|
|
1241
|
+
Update an existing scan.
|
|
1242
|
+
|
|
1243
|
+
Updates an existing scan with new values.
|
|
1244
|
+
Only specified fields are modified; others remain unchanged.
|
|
1245
|
+
|
|
1246
|
+
Args:
|
|
1247
|
+
args: Dictionary of operation arguments.
|
|
1248
|
+
Contains operation-specific parameters.
|
|
1249
|
+
See method implementation for details.
|
|
1250
|
+
|
|
1251
|
+
Returns:
|
|
1252
|
+
Dictionary containing updated scan:
|
|
1253
|
+
{
|
|
1254
|
+
'guid': str, # Unique identifier
|
|
1255
|
+
'attributes': dict, # Updated attributes
|
|
1256
|
+
'updateTime': int # Update timestamp
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
Raises:
|
|
1260
|
+
ValueError: When required parameters are missing or invalid:
|
|
1261
|
+
- Empty or None values for required fields
|
|
1262
|
+
- Invalid GUID format
|
|
1263
|
+
- Out-of-range values
|
|
1264
|
+
|
|
1265
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
1266
|
+
- DefaultAzureCredential not configured
|
|
1267
|
+
- Insufficient permissions
|
|
1268
|
+
- Expired authentication token
|
|
1269
|
+
|
|
1270
|
+
HTTPError: When Purview API returns error:
|
|
1271
|
+
- 400: Bad request (invalid parameters)
|
|
1272
|
+
- 401: Unauthorized (authentication failed)
|
|
1273
|
+
- 403: Forbidden (insufficient permissions)
|
|
1274
|
+
- 404: Resource not found
|
|
1275
|
+
- 429: Rate limit exceeded
|
|
1276
|
+
- 500: Internal server error
|
|
1277
|
+
|
|
1278
|
+
NetworkError: When network connectivity fails
|
|
1279
|
+
|
|
1280
|
+
Example:
|
|
1281
|
+
# Basic usage
|
|
1282
|
+
client = Scan()
|
|
1283
|
+
|
|
1284
|
+
result = client.scanClassificationRuleUpdate(args=...)
|
|
1285
|
+
print(f"Result: {result}")
|
|
1286
|
+
|
|
1287
|
+
# With detailed data
|
|
1288
|
+
data = {
|
|
1289
|
+
'name': 'My Resource',
|
|
1290
|
+
'description': 'Resource description',
|
|
1291
|
+
'attributes': {
|
|
1292
|
+
'key1': 'value1',
|
|
1293
|
+
'key2': 'value2'
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1296
|
+
|
|
1297
|
+
result = client.scanClassificationRuleUpdate(data)
|
|
1298
|
+
print(f"Created/Updated: {result['guid']}")
|
|
1299
|
+
|
|
1300
|
+
Use Cases:
|
|
1301
|
+
- Metadata Enrichment: Update descriptions and tags
|
|
1302
|
+
- Ownership Changes: Reassign data ownership
|
|
1303
|
+
- Classification: Apply or modify data classifications
|
|
1304
|
+
"""
|
|
1305
|
+
return self.scanClassificationRuleCreate(args)
|
|
1306
|
+
|
|
1307
|
+
@decorator
|
|
1308
|
+
def scanClassificationRuleDelete(self, args):
|
|
1309
|
+
"""
|
|
1310
|
+
Delete a scan.
|
|
1311
|
+
|
|
1312
|
+
Permanently deletes the specified scan.
|
|
1313
|
+
This operation cannot be undone. Use with caution.
|
|
1314
|
+
|
|
1315
|
+
Args:
|
|
1316
|
+
args: Dictionary of operation arguments.
|
|
1317
|
+
Contains operation-specific parameters.
|
|
1318
|
+
See method implementation for details.
|
|
1319
|
+
|
|
1320
|
+
Returns:
|
|
1321
|
+
Dictionary with deletion status:
|
|
1322
|
+
{
|
|
1323
|
+
'guid': str, # Deleted resource ID
|
|
1324
|
+
'status': str, # Deletion status
|
|
1325
|
+
'message': str # Confirmation message
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1328
|
+
Raises:
|
|
1329
|
+
ValueError: When required parameters are missing or invalid:
|
|
1330
|
+
- Empty or None values for required fields
|
|
1331
|
+
- Invalid GUID format
|
|
1332
|
+
- Out-of-range values
|
|
1333
|
+
|
|
1334
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
1335
|
+
- DefaultAzureCredential not configured
|
|
1336
|
+
- Insufficient permissions
|
|
1337
|
+
- Expired authentication token
|
|
1338
|
+
|
|
1339
|
+
HTTPError: When Purview API returns error:
|
|
1340
|
+
- 400: Bad request (invalid parameters)
|
|
1341
|
+
- 401: Unauthorized (authentication failed)
|
|
1342
|
+
- 403: Forbidden (insufficient permissions)
|
|
1343
|
+
- 404: Resource not found
|
|
1344
|
+
- 429: Rate limit exceeded
|
|
1345
|
+
- 500: Internal server error
|
|
1346
|
+
|
|
1347
|
+
NetworkError: When network connectivity fails
|
|
1348
|
+
|
|
1349
|
+
Example:
|
|
1350
|
+
# Basic usage
|
|
1351
|
+
client = Scan()
|
|
1352
|
+
|
|
1353
|
+
result = client.scanClassificationRuleDelete(args=...)
|
|
1354
|
+
print(f"Result: {result}")
|
|
1355
|
+
|
|
1356
|
+
Use Cases:
|
|
1357
|
+
- Data Cleanup: Remove obsolete or test data
|
|
1358
|
+
- Decommissioning: Delete resources no longer in use
|
|
1359
|
+
- Testing: Clean up test environments
|
|
1360
|
+
"""
|
|
1361
|
+
self.method = "DELETE"
|
|
1362
|
+
self.endpoint = ENDPOINTS["scanning"]["delete_classification_rule"].format(
|
|
1363
|
+
classificationRuleName=args["--classificationRuleName"]
|
|
1364
|
+
)
|
|
1365
|
+
self.params = get_api_version_params("scanning")
|
|
1366
|
+
|
|
1367
|
+
@decorator
|
|
1368
|
+
def scanClassificationRuleReadVersions(self, args):
|
|
1369
|
+
"""
|
|
1370
|
+
Retrieve scan information.
|
|
1371
|
+
|
|
1372
|
+
Retrieves detailed information about the specified scan.
|
|
1373
|
+
Returns complete scan metadata and properties.
|
|
1374
|
+
|
|
1375
|
+
Args:
|
|
1376
|
+
args: Dictionary of operation arguments.
|
|
1377
|
+
Contains operation-specific parameters.
|
|
1378
|
+
See method implementation for details.
|
|
1379
|
+
|
|
1380
|
+
Returns:
|
|
1381
|
+
Dictionary containing scan information:
|
|
1382
|
+
{
|
|
1383
|
+
'guid': str, # Unique identifier
|
|
1384
|
+
'name': str, # Resource name
|
|
1385
|
+
'attributes': dict, # Resource attributes
|
|
1386
|
+
'status': str, # Resource status
|
|
1387
|
+
'updateTime': int # Last update timestamp
|
|
1388
|
+
}
|
|
1389
|
+
|
|
1390
|
+
Raises:
|
|
1391
|
+
ValueError: When required parameters are missing or invalid:
|
|
1392
|
+
- Empty or None values for required fields
|
|
1393
|
+
- Invalid GUID format
|
|
1394
|
+
- Out-of-range values
|
|
1395
|
+
|
|
1396
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
1397
|
+
- DefaultAzureCredential not configured
|
|
1398
|
+
- Insufficient permissions
|
|
1399
|
+
- Expired authentication token
|
|
1400
|
+
|
|
1401
|
+
HTTPError: When Purview API returns error:
|
|
1402
|
+
- 400: Bad request (invalid parameters)
|
|
1403
|
+
- 401: Unauthorized (authentication failed)
|
|
1404
|
+
- 403: Forbidden (insufficient permissions)
|
|
1405
|
+
- 404: Resource not found
|
|
1406
|
+
- 429: Rate limit exceeded
|
|
1407
|
+
- 500: Internal server error
|
|
1408
|
+
|
|
1409
|
+
NetworkError: When network connectivity fails
|
|
1410
|
+
|
|
1411
|
+
Example:
|
|
1412
|
+
# Basic usage
|
|
1413
|
+
client = Scan()
|
|
1414
|
+
|
|
1415
|
+
result = client.scanClassificationRuleReadVersions(args=...)
|
|
1416
|
+
print(f"Result: {result}")
|
|
1417
|
+
|
|
1418
|
+
Use Cases:
|
|
1419
|
+
- Data Discovery: Find and explore data assets
|
|
1420
|
+
- Compliance Auditing: Review metadata and classifications
|
|
1421
|
+
- Reporting: Generate catalog reports
|
|
1422
|
+
"""
|
|
1423
|
+
self.method = "GET"
|
|
1424
|
+
self.endpoint = ENDPOINTS["scanning"]["list_classification_rule_versions"].format(
|
|
1425
|
+
classificationRuleName=args["--classificationRuleName"]
|
|
1426
|
+
)
|
|
1427
|
+
self.params = get_api_version_params("scanning")
|
|
1428
|
+
|
|
1429
|
+
@decorator
|
|
1430
|
+
def scanClassificationRuleTagVersion(self, args):
|
|
1431
|
+
"""
|
|
1432
|
+
Perform operation on resource.
|
|
1433
|
+
|
|
1434
|
+
|
|
1435
|
+
|
|
1436
|
+
Args:
|
|
1437
|
+
args: Dictionary of operation arguments.
|
|
1438
|
+
Contains operation-specific parameters.
|
|
1439
|
+
See method implementation for details.
|
|
1440
|
+
|
|
1441
|
+
Returns:
|
|
1442
|
+
[TODO: Specify return type and structure]
|
|
1443
|
+
[TODO: Document nested fields]
|
|
1444
|
+
|
|
1445
|
+
Raises:
|
|
1446
|
+
ValueError: When required parameters are missing or invalid:
|
|
1447
|
+
- Empty or None values for required fields
|
|
1448
|
+
- Invalid GUID format
|
|
1449
|
+
- Out-of-range values
|
|
1450
|
+
|
|
1451
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
1452
|
+
- DefaultAzureCredential not configured
|
|
1453
|
+
- Insufficient permissions
|
|
1454
|
+
- Expired authentication token
|
|
1455
|
+
|
|
1456
|
+
HTTPError: When Purview API returns error:
|
|
1457
|
+
- 400: Bad request (invalid parameters)
|
|
1458
|
+
- 401: Unauthorized (authentication failed)
|
|
1459
|
+
- 403: Forbidden (insufficient permissions)
|
|
1460
|
+
- 404: Resource not found
|
|
1461
|
+
- 429: Rate limit exceeded
|
|
1462
|
+
- 500: Internal server error
|
|
1463
|
+
|
|
1464
|
+
NetworkError: When network connectivity fails
|
|
1465
|
+
|
|
1466
|
+
Example:
|
|
1467
|
+
# Basic usage
|
|
1468
|
+
client = Scan()
|
|
1469
|
+
|
|
1470
|
+
result = client.scanClassificationRuleTagVersion(args=...)
|
|
1471
|
+
print(f"Result: {result}")
|
|
1472
|
+
|
|
1473
|
+
Use Cases:
|
|
1474
|
+
- [TODO: Add specific use cases for this operation]
|
|
1475
|
+
- [TODO: Include business context]
|
|
1476
|
+
- [TODO: Explain when to use this method]
|
|
1477
|
+
"""
|
|
1478
|
+
self.method = "POST"
|
|
1479
|
+
self.endpoint = ENDPOINTS["scanning"]["tag_classification_version"].format(
|
|
1480
|
+
classificationRuleName=args["--classificationRuleName"],
|
|
1481
|
+
classificationRuleVersion=args["--classificationRuleVersion"]
|
|
1482
|
+
)
|
|
1483
|
+
self.params = get_api_version_params("scanning")
|
|
1484
|
+
tag_request = {
|
|
1485
|
+
"action": args.get("--action", "Keep"),
|
|
1486
|
+
"tag": args.get("--tag"),
|
|
1487
|
+
}
|
|
1488
|
+
self.payload = tag_request
|
|
1489
|
+
|
|
1490
|
+
# === ADVANCED SCANNING OPERATIONS (NEW FOR 100% COVERAGE) ===
|
|
1491
|
+
|
|
1492
|
+
@decorator
|
|
1493
|
+
def scanReadAnalytics(self, args):
|
|
1494
|
+
"""
|
|
1495
|
+
Retrieve scan information.
|
|
1496
|
+
|
|
1497
|
+
Retrieves detailed information about the specified scan.
|
|
1498
|
+
Returns complete scan metadata and properties.
|
|
1499
|
+
|
|
1500
|
+
Args:
|
|
1501
|
+
args: Dictionary of operation arguments.
|
|
1502
|
+
Contains operation-specific parameters.
|
|
1503
|
+
See method implementation for details.
|
|
1504
|
+
|
|
1505
|
+
Returns:
|
|
1506
|
+
Dictionary containing scan information:
|
|
1507
|
+
{
|
|
1508
|
+
'guid': str, # Unique identifier
|
|
1509
|
+
'name': str, # Resource name
|
|
1510
|
+
'attributes': dict, # Resource attributes
|
|
1511
|
+
'status': str, # Resource status
|
|
1512
|
+
'updateTime': int # Last update timestamp
|
|
1513
|
+
}
|
|
1514
|
+
|
|
1515
|
+
Raises:
|
|
1516
|
+
ValueError: When required parameters are missing or invalid:
|
|
1517
|
+
- Empty or None values for required fields
|
|
1518
|
+
- Invalid GUID format
|
|
1519
|
+
- Out-of-range values
|
|
1520
|
+
|
|
1521
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
1522
|
+
- DefaultAzureCredential not configured
|
|
1523
|
+
- Insufficient permissions
|
|
1524
|
+
- Expired authentication token
|
|
1525
|
+
|
|
1526
|
+
HTTPError: When Purview API returns error:
|
|
1527
|
+
- 400: Bad request (invalid parameters)
|
|
1528
|
+
- 401: Unauthorized (authentication failed)
|
|
1529
|
+
- 403: Forbidden (insufficient permissions)
|
|
1530
|
+
- 404: Resource not found
|
|
1531
|
+
- 429: Rate limit exceeded
|
|
1532
|
+
- 500: Internal server error
|
|
1533
|
+
|
|
1534
|
+
NetworkError: When network connectivity fails
|
|
1535
|
+
|
|
1536
|
+
Example:
|
|
1537
|
+
# Basic usage
|
|
1538
|
+
client = Scan()
|
|
1539
|
+
|
|
1540
|
+
result = client.scanReadAnalytics(args=...)
|
|
1541
|
+
print(f"Result: {result}")
|
|
1542
|
+
|
|
1543
|
+
Use Cases:
|
|
1544
|
+
- Data Discovery: Find and explore data assets
|
|
1545
|
+
- Compliance Auditing: Review metadata and classifications
|
|
1546
|
+
- Reporting: Generate catalog reports
|
|
1547
|
+
"""
|
|
1548
|
+
self.method = "GET"
|
|
1549
|
+
self.endpoint = ENDPOINTS["scanning"]["get_scan_analytics"].format(
|
|
1550
|
+
dataSourceName=args["--dataSourceName"], scanName=args["--scanName"]
|
|
1551
|
+
)
|
|
1552
|
+
self.params = {
|
|
1553
|
+
**get_api_version_params("scanning"),
|
|
1554
|
+
"startTime": args.get("--startTime"),
|
|
1555
|
+
"endTime": args.get("--endTime"),
|
|
1556
|
+
"metrics": args.get("--metrics", "all"),
|
|
1557
|
+
}
|
|
1558
|
+
|
|
1559
|
+
@decorator
|
|
1560
|
+
def scanReadHistory(self, args):
|
|
1561
|
+
"""
|
|
1562
|
+
Retrieve scan information.
|
|
1563
|
+
|
|
1564
|
+
Retrieves detailed information about the specified scan.
|
|
1565
|
+
Returns complete scan metadata and properties.
|
|
1566
|
+
|
|
1567
|
+
Args:
|
|
1568
|
+
args: Dictionary of operation arguments.
|
|
1569
|
+
Contains operation-specific parameters.
|
|
1570
|
+
See method implementation for details.
|
|
1571
|
+
|
|
1572
|
+
Returns:
|
|
1573
|
+
Dictionary containing scan information:
|
|
1574
|
+
{
|
|
1575
|
+
'guid': str, # Unique identifier
|
|
1576
|
+
'name': str, # Resource name
|
|
1577
|
+
'attributes': dict, # Resource attributes
|
|
1578
|
+
'status': str, # Resource status
|
|
1579
|
+
'updateTime': int # Last update timestamp
|
|
1580
|
+
}
|
|
1581
|
+
|
|
1582
|
+
Raises:
|
|
1583
|
+
ValueError: When required parameters are missing or invalid:
|
|
1584
|
+
- Empty or None values for required fields
|
|
1585
|
+
- Invalid GUID format
|
|
1586
|
+
- Out-of-range values
|
|
1587
|
+
|
|
1588
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
1589
|
+
- DefaultAzureCredential not configured
|
|
1590
|
+
- Insufficient permissions
|
|
1591
|
+
- Expired authentication token
|
|
1592
|
+
|
|
1593
|
+
HTTPError: When Purview API returns error:
|
|
1594
|
+
- 400: Bad request (invalid parameters)
|
|
1595
|
+
- 401: Unauthorized (authentication failed)
|
|
1596
|
+
- 403: Forbidden (insufficient permissions)
|
|
1597
|
+
- 404: Resource not found
|
|
1598
|
+
- 429: Rate limit exceeded
|
|
1599
|
+
- 500: Internal server error
|
|
1600
|
+
|
|
1601
|
+
NetworkError: When network connectivity fails
|
|
1602
|
+
|
|
1603
|
+
Example:
|
|
1604
|
+
# Basic usage
|
|
1605
|
+
client = Scan()
|
|
1606
|
+
|
|
1607
|
+
result = client.scanReadHistory(args=...)
|
|
1608
|
+
print(f"Result: {result}")
|
|
1609
|
+
|
|
1610
|
+
Use Cases:
|
|
1611
|
+
- Data Discovery: Find and explore data assets
|
|
1612
|
+
- Compliance Auditing: Review metadata and classifications
|
|
1613
|
+
- Reporting: Generate catalog reports
|
|
1614
|
+
"""
|
|
1615
|
+
self.method = "GET"
|
|
1616
|
+
self.endpoint = ENDPOINTS["scanning"]["get_scan_history"].format(
|
|
1617
|
+
dataSourceName=args["--dataSourceName"], scanName=args["--scanName"]
|
|
1618
|
+
)
|
|
1619
|
+
self.params = {
|
|
1620
|
+
**get_api_version_params("scanning"),
|
|
1621
|
+
"limit": args.get("--limit", 50),
|
|
1622
|
+
"offset": args.get("--offset", 0),
|
|
1623
|
+
"orderBy": args.get("--orderBy", "startTime desc"),
|
|
1624
|
+
}
|
|
1625
|
+
|
|
1626
|
+
# === SCAN SCHEDULING ===
|
|
1627
|
+
|
|
1628
|
+
@decorator
|
|
1629
|
+
def scanScheduleCreate(self, args):
|
|
1630
|
+
"""
|
|
1631
|
+
Create a new scan.
|
|
1632
|
+
|
|
1633
|
+
Creates a new scan in Microsoft Purview.
|
|
1634
|
+
Requires appropriate permissions and valid scan definition.
|
|
1635
|
+
|
|
1636
|
+
Args:
|
|
1637
|
+
args: Dictionary of operation arguments.
|
|
1638
|
+
Contains operation-specific parameters.
|
|
1639
|
+
See method implementation for details.
|
|
1640
|
+
|
|
1641
|
+
Returns:
|
|
1642
|
+
Dictionary containing created scan:
|
|
1643
|
+
{
|
|
1644
|
+
'guid': str, # Unique identifier
|
|
1645
|
+
'name': str, # Resource name
|
|
1646
|
+
'status': str, # Creation status
|
|
1647
|
+
'attributes': dict, # Resource attributes
|
|
1648
|
+
'createTime': int # Creation timestamp
|
|
1649
|
+
}
|
|
1650
|
+
|
|
1651
|
+
Raises:
|
|
1652
|
+
ValueError: When required parameters are missing or invalid:
|
|
1653
|
+
- Empty or None values for required fields
|
|
1654
|
+
- Invalid GUID format
|
|
1655
|
+
- Out-of-range values
|
|
1656
|
+
|
|
1657
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
1658
|
+
- DefaultAzureCredential not configured
|
|
1659
|
+
- Insufficient permissions
|
|
1660
|
+
- Expired authentication token
|
|
1661
|
+
|
|
1662
|
+
HTTPError: When Purview API returns error:
|
|
1663
|
+
- 400: Bad request (invalid parameters)
|
|
1664
|
+
- 401: Unauthorized (authentication failed)
|
|
1665
|
+
- 403: Forbidden (insufficient permissions)
|
|
1666
|
+
- 404: Resource not found
|
|
1667
|
+
- 409: Conflict (resource already exists)
|
|
1668
|
+
- 429: Rate limit exceeded
|
|
1669
|
+
- 500: Internal server error
|
|
1670
|
+
|
|
1671
|
+
NetworkError: When network connectivity fails
|
|
1672
|
+
|
|
1673
|
+
Example:
|
|
1674
|
+
# Basic usage
|
|
1675
|
+
client = Scan()
|
|
1676
|
+
|
|
1677
|
+
result = client.scanScheduleCreate(args=...)
|
|
1678
|
+
print(f"Result: {result}")
|
|
1679
|
+
|
|
1680
|
+
# With detailed data
|
|
1681
|
+
data = {
|
|
1682
|
+
'name': 'My Resource',
|
|
1683
|
+
'description': 'Resource description',
|
|
1684
|
+
'attributes': {
|
|
1685
|
+
'key1': 'value1',
|
|
1686
|
+
'key2': 'value2'
|
|
1687
|
+
}
|
|
1688
|
+
}
|
|
1689
|
+
|
|
1690
|
+
result = client.scanScheduleCreate(data)
|
|
1691
|
+
print(f"Created/Updated: {result['guid']}")
|
|
1692
|
+
|
|
1693
|
+
Use Cases:
|
|
1694
|
+
- Data Onboarding: Register new data sources in catalog
|
|
1695
|
+
- Metadata Management: Add descriptive metadata to assets
|
|
1696
|
+
- Automation: Programmatically populate catalog
|
|
1697
|
+
"""
|
|
1698
|
+
self.method = "PUT"
|
|
1699
|
+
self.endpoint = ENDPOINTS["scanning"]["schedule_scan"].format(
|
|
1700
|
+
dataSourceName=args["--dataSourceName"], scanName=args["--scanName"]
|
|
1701
|
+
)
|
|
1702
|
+
self.params = get_api_version_params("scanning")
|
|
1703
|
+
self.payload = get_json(args, "--payloadFile")
|
|
1704
|
+
|
|
1705
|
+
@decorator
|
|
1706
|
+
def scanScheduleRead(self, args):
|
|
1707
|
+
"""
|
|
1708
|
+
Retrieve scan information.
|
|
1709
|
+
|
|
1710
|
+
Retrieves detailed information about the specified scan.
|
|
1711
|
+
Returns complete scan metadata and properties.
|
|
1712
|
+
|
|
1713
|
+
Args:
|
|
1714
|
+
args: Dictionary of operation arguments.
|
|
1715
|
+
Contains operation-specific parameters.
|
|
1716
|
+
See method implementation for details.
|
|
1717
|
+
|
|
1718
|
+
Returns:
|
|
1719
|
+
Dictionary containing scan information:
|
|
1720
|
+
{
|
|
1721
|
+
'guid': str, # Unique identifier
|
|
1722
|
+
'name': str, # Resource name
|
|
1723
|
+
'attributes': dict, # Resource attributes
|
|
1724
|
+
'status': str, # Resource status
|
|
1725
|
+
'updateTime': int # Last update timestamp
|
|
1726
|
+
}
|
|
1727
|
+
|
|
1728
|
+
Raises:
|
|
1729
|
+
ValueError: When required parameters are missing or invalid:
|
|
1730
|
+
- Empty or None values for required fields
|
|
1731
|
+
- Invalid GUID format
|
|
1732
|
+
- Out-of-range values
|
|
1733
|
+
|
|
1734
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
1735
|
+
- DefaultAzureCredential not configured
|
|
1736
|
+
- Insufficient permissions
|
|
1737
|
+
- Expired authentication token
|
|
1738
|
+
|
|
1739
|
+
HTTPError: When Purview API returns error:
|
|
1740
|
+
- 400: Bad request (invalid parameters)
|
|
1741
|
+
- 401: Unauthorized (authentication failed)
|
|
1742
|
+
- 403: Forbidden (insufficient permissions)
|
|
1743
|
+
- 404: Resource not found
|
|
1744
|
+
- 429: Rate limit exceeded
|
|
1745
|
+
- 500: Internal server error
|
|
1746
|
+
|
|
1747
|
+
NetworkError: When network connectivity fails
|
|
1748
|
+
|
|
1749
|
+
Example:
|
|
1750
|
+
# Basic usage
|
|
1751
|
+
client = Scan()
|
|
1752
|
+
|
|
1753
|
+
result = client.scanScheduleRead(args=...)
|
|
1754
|
+
print(f"Result: {result}")
|
|
1755
|
+
|
|
1756
|
+
Use Cases:
|
|
1757
|
+
- Data Discovery: Find and explore data assets
|
|
1758
|
+
- Compliance Auditing: Review metadata and classifications
|
|
1759
|
+
- Reporting: Generate catalog reports
|
|
1760
|
+
"""
|
|
1761
|
+
self.method = "GET"
|
|
1762
|
+
self.endpoint = ENDPOINTS["scanning"]["get_scan_schedule"].format(
|
|
1763
|
+
dataSourceName=args["--dataSourceName"], scanName=args["--scanName"]
|
|
1764
|
+
)
|
|
1765
|
+
self.params = get_api_version_params("scanning")
|
|
1766
|
+
|
|
1767
|
+
@decorator
|
|
1768
|
+
def scanScheduleUpdate(self, args):
|
|
1769
|
+
"""
|
|
1770
|
+
Update an existing scan.
|
|
1771
|
+
|
|
1772
|
+
Updates an existing scan with new values.
|
|
1773
|
+
Only specified fields are modified; others remain unchanged.
|
|
1774
|
+
|
|
1775
|
+
Args:
|
|
1776
|
+
args: Dictionary of operation arguments.
|
|
1777
|
+
Contains operation-specific parameters.
|
|
1778
|
+
See method implementation for details.
|
|
1779
|
+
|
|
1780
|
+
Returns:
|
|
1781
|
+
Dictionary containing updated scan:
|
|
1782
|
+
{
|
|
1783
|
+
'guid': str, # Unique identifier
|
|
1784
|
+
'attributes': dict, # Updated attributes
|
|
1785
|
+
'updateTime': int # Update timestamp
|
|
1786
|
+
}
|
|
1787
|
+
|
|
1788
|
+
Raises:
|
|
1789
|
+
ValueError: When required parameters are missing or invalid:
|
|
1790
|
+
- Empty or None values for required fields
|
|
1791
|
+
- Invalid GUID format
|
|
1792
|
+
- Out-of-range values
|
|
1793
|
+
|
|
1794
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
1795
|
+
- DefaultAzureCredential not configured
|
|
1796
|
+
- Insufficient permissions
|
|
1797
|
+
- Expired authentication token
|
|
1798
|
+
|
|
1799
|
+
HTTPError: When Purview API returns error:
|
|
1800
|
+
- 400: Bad request (invalid parameters)
|
|
1801
|
+
- 401: Unauthorized (authentication failed)
|
|
1802
|
+
- 403: Forbidden (insufficient permissions)
|
|
1803
|
+
- 404: Resource not found
|
|
1804
|
+
- 429: Rate limit exceeded
|
|
1805
|
+
- 500: Internal server error
|
|
1806
|
+
|
|
1807
|
+
NetworkError: When network connectivity fails
|
|
1808
|
+
|
|
1809
|
+
Example:
|
|
1810
|
+
# Basic usage
|
|
1811
|
+
client = Scan()
|
|
1812
|
+
|
|
1813
|
+
result = client.scanScheduleUpdate(args=...)
|
|
1814
|
+
print(f"Result: {result}")
|
|
1815
|
+
|
|
1816
|
+
# With detailed data
|
|
1817
|
+
data = {
|
|
1818
|
+
'name': 'My Resource',
|
|
1819
|
+
'description': 'Resource description',
|
|
1820
|
+
'attributes': {
|
|
1821
|
+
'key1': 'value1',
|
|
1822
|
+
'key2': 'value2'
|
|
1823
|
+
}
|
|
1824
|
+
}
|
|
1825
|
+
|
|
1826
|
+
result = client.scanScheduleUpdate(data)
|
|
1827
|
+
print(f"Created/Updated: {result['guid']}")
|
|
1828
|
+
|
|
1829
|
+
Use Cases:
|
|
1830
|
+
- Metadata Enrichment: Update descriptions and tags
|
|
1831
|
+
- Ownership Changes: Reassign data ownership
|
|
1832
|
+
- Classification: Apply or modify data classifications
|
|
1833
|
+
"""
|
|
1834
|
+
self.method = "PUT"
|
|
1835
|
+
self.endpoint = ENDPOINTS["scanning"]["update_scan_schedule"].format(
|
|
1836
|
+
dataSourceName=args["--dataSourceName"], scanName=args["--scanName"]
|
|
1837
|
+
)
|
|
1838
|
+
self.params = get_api_version_params("scanning")
|
|
1839
|
+
self.payload = get_json(args, "--payloadFile")
|
|
1840
|
+
|
|
1841
|
+
@decorator
|
|
1842
|
+
def scanScheduleDelete(self, args):
|
|
1843
|
+
"""
|
|
1844
|
+
Delete a scan.
|
|
1845
|
+
|
|
1846
|
+
Permanently deletes the specified scan.
|
|
1847
|
+
This operation cannot be undone. Use with caution.
|
|
1848
|
+
|
|
1849
|
+
Args:
|
|
1850
|
+
args: Dictionary of operation arguments.
|
|
1851
|
+
Contains operation-specific parameters.
|
|
1852
|
+
See method implementation for details.
|
|
1853
|
+
|
|
1854
|
+
Returns:
|
|
1855
|
+
Dictionary with deletion status:
|
|
1856
|
+
{
|
|
1857
|
+
'guid': str, # Deleted resource ID
|
|
1858
|
+
'status': str, # Deletion status
|
|
1859
|
+
'message': str # Confirmation message
|
|
1860
|
+
}
|
|
1861
|
+
|
|
1862
|
+
Raises:
|
|
1863
|
+
ValueError: When required parameters are missing or invalid:
|
|
1864
|
+
- Empty or None values for required fields
|
|
1865
|
+
- Invalid GUID format
|
|
1866
|
+
- Out-of-range values
|
|
1867
|
+
|
|
1868
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
1869
|
+
- DefaultAzureCredential not configured
|
|
1870
|
+
- Insufficient permissions
|
|
1871
|
+
- Expired authentication token
|
|
1872
|
+
|
|
1873
|
+
HTTPError: When Purview API returns error:
|
|
1874
|
+
- 400: Bad request (invalid parameters)
|
|
1875
|
+
- 401: Unauthorized (authentication failed)
|
|
1876
|
+
- 403: Forbidden (insufficient permissions)
|
|
1877
|
+
- 404: Resource not found
|
|
1878
|
+
- 429: Rate limit exceeded
|
|
1879
|
+
- 500: Internal server error
|
|
1880
|
+
|
|
1881
|
+
NetworkError: When network connectivity fails
|
|
1882
|
+
|
|
1883
|
+
Example:
|
|
1884
|
+
# Basic usage
|
|
1885
|
+
client = Scan()
|
|
1886
|
+
|
|
1887
|
+
result = client.scanScheduleDelete(args=...)
|
|
1888
|
+
print(f"Result: {result}")
|
|
1889
|
+
|
|
1890
|
+
Use Cases:
|
|
1891
|
+
- Data Cleanup: Remove obsolete or test data
|
|
1892
|
+
- Decommissioning: Delete resources no longer in use
|
|
1893
|
+
- Testing: Clean up test environments
|
|
1894
|
+
"""
|
|
1895
|
+
self.method = "DELETE"
|
|
1896
|
+
self.endpoint = ENDPOINTS["scanning"]["delete_scan_schedule"].format(
|
|
1897
|
+
dataSourceName=args["--dataSourceName"], scanName=args["--scanName"]
|
|
1898
|
+
)
|
|
1899
|
+
self.params = get_api_version_params("scanning")
|
|
1900
|
+
|
|
1901
|
+
# === SCAN MONITORING AND REPORTING ===
|
|
1902
|
+
|
|
1903
|
+
@decorator
|
|
1904
|
+
def scanReadStatus(self, args):
|
|
1905
|
+
"""
|
|
1906
|
+
Retrieve scan information.
|
|
1907
|
+
|
|
1908
|
+
Retrieves detailed information about the specified scan.
|
|
1909
|
+
Returns complete scan metadata and properties.
|
|
1910
|
+
|
|
1911
|
+
Args:
|
|
1912
|
+
args: Dictionary of operation arguments.
|
|
1913
|
+
Contains operation-specific parameters.
|
|
1914
|
+
See method implementation for details.
|
|
1915
|
+
|
|
1916
|
+
Returns:
|
|
1917
|
+
Dictionary containing scan information:
|
|
1918
|
+
{
|
|
1919
|
+
'guid': str, # Unique identifier
|
|
1920
|
+
'name': str, # Resource name
|
|
1921
|
+
'attributes': dict, # Resource attributes
|
|
1922
|
+
'status': str, # Resource status
|
|
1923
|
+
'updateTime': int # Last update timestamp
|
|
1924
|
+
}
|
|
1925
|
+
|
|
1926
|
+
Raises:
|
|
1927
|
+
ValueError: When required parameters are missing or invalid:
|
|
1928
|
+
- Empty or None values for required fields
|
|
1929
|
+
- Invalid GUID format
|
|
1930
|
+
- Out-of-range values
|
|
1931
|
+
|
|
1932
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
1933
|
+
- DefaultAzureCredential not configured
|
|
1934
|
+
- Insufficient permissions
|
|
1935
|
+
- Expired authentication token
|
|
1936
|
+
|
|
1937
|
+
HTTPError: When Purview API returns error:
|
|
1938
|
+
- 400: Bad request (invalid parameters)
|
|
1939
|
+
- 401: Unauthorized (authentication failed)
|
|
1940
|
+
- 403: Forbidden (insufficient permissions)
|
|
1941
|
+
- 404: Resource not found
|
|
1942
|
+
- 429: Rate limit exceeded
|
|
1943
|
+
- 500: Internal server error
|
|
1944
|
+
|
|
1945
|
+
NetworkError: When network connectivity fails
|
|
1946
|
+
|
|
1947
|
+
Example:
|
|
1948
|
+
# Basic usage
|
|
1949
|
+
client = Scan()
|
|
1950
|
+
|
|
1951
|
+
result = client.scanReadStatus(args=...)
|
|
1952
|
+
print(f"Result: {result}")
|
|
1953
|
+
|
|
1954
|
+
Use Cases:
|
|
1955
|
+
- Data Discovery: Find and explore data assets
|
|
1956
|
+
- Compliance Auditing: Review metadata and classifications
|
|
1957
|
+
- Reporting: Generate catalog reports
|
|
1958
|
+
"""
|
|
1959
|
+
self.method = "GET"
|
|
1960
|
+
self.endpoint = f"{ENDPOINTS['scanning']['get_scan'].format(dataSourceName=args['--dataSourceName'], scanName=args['--scanName'])}/status"
|
|
1961
|
+
self.params = {
|
|
1962
|
+
**get_api_version_params("scanning"),
|
|
1963
|
+
"includeDetails": str(args.get("--includeDetails", True)).lower(),
|
|
1964
|
+
}
|
|
1965
|
+
|
|
1966
|
+
@decorator
|
|
1967
|
+
def scanGenerateReport(self, args):
|
|
1968
|
+
"""
|
|
1969
|
+
Perform operation on resource.
|
|
1970
|
+
|
|
1971
|
+
|
|
1972
|
+
|
|
1973
|
+
Args:
|
|
1974
|
+
args: Dictionary of operation arguments.
|
|
1975
|
+
Contains operation-specific parameters.
|
|
1976
|
+
See method implementation for details.
|
|
1977
|
+
|
|
1978
|
+
Returns:
|
|
1979
|
+
[TODO: Specify return type and structure]
|
|
1980
|
+
[TODO: Document nested fields]
|
|
1981
|
+
|
|
1982
|
+
Raises:
|
|
1983
|
+
ValueError: When required parameters are missing or invalid:
|
|
1984
|
+
- Empty or None values for required fields
|
|
1985
|
+
- Invalid GUID format
|
|
1986
|
+
- Out-of-range values
|
|
1987
|
+
|
|
1988
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
1989
|
+
- DefaultAzureCredential not configured
|
|
1990
|
+
- Insufficient permissions
|
|
1991
|
+
- Expired authentication token
|
|
1992
|
+
|
|
1993
|
+
HTTPError: When Purview API returns error:
|
|
1994
|
+
- 400: Bad request (invalid parameters)
|
|
1995
|
+
- 401: Unauthorized (authentication failed)
|
|
1996
|
+
- 403: Forbidden (insufficient permissions)
|
|
1997
|
+
- 404: Resource not found
|
|
1998
|
+
- 429: Rate limit exceeded
|
|
1999
|
+
- 500: Internal server error
|
|
2000
|
+
|
|
2001
|
+
NetworkError: When network connectivity fails
|
|
2002
|
+
|
|
2003
|
+
Example:
|
|
2004
|
+
# Basic usage
|
|
2005
|
+
client = Scan()
|
|
2006
|
+
|
|
2007
|
+
result = client.scanGenerateReport(args=...)
|
|
2008
|
+
print(f"Result: {result}")
|
|
2009
|
+
|
|
2010
|
+
Use Cases:
|
|
2011
|
+
- [TODO: Add specific use cases for this operation]
|
|
2012
|
+
- [TODO: Include business context]
|
|
2013
|
+
- [TODO: Explain when to use this method]
|
|
2014
|
+
"""
|
|
2015
|
+
self.method = "POST"
|
|
2016
|
+
self.endpoint = f"{ENDPOINTS['scanning']['get_scan'].format(dataSourceName=args['--dataSourceName'], scanName=args['--scanName'])}/report"
|
|
2017
|
+
self.params = {
|
|
2018
|
+
**get_api_version_params("scanning"),
|
|
2019
|
+
"reportType": args.get("--reportType", "summary"),
|
|
2020
|
+
"format": args.get("--format", "json"),
|
|
2021
|
+
}
|
|
2022
|
+
|
|
2023
|
+
@decorator
|
|
2024
|
+
def scanExportResults(self, args):
|
|
2025
|
+
"""
|
|
2026
|
+
Perform batch operation on resources.
|
|
2027
|
+
|
|
2028
|
+
Processes multiple resources in a single operation.
|
|
2029
|
+
More efficient than individual operations for bulk data.
|
|
2030
|
+
|
|
2031
|
+
Args:
|
|
2032
|
+
args: Dictionary of operation arguments.
|
|
2033
|
+
Contains operation-specific parameters.
|
|
2034
|
+
See method implementation for details.
|
|
2035
|
+
|
|
2036
|
+
Returns:
|
|
2037
|
+
Dictionary with batch operation results:
|
|
2038
|
+
{
|
|
2039
|
+
'succeeded': int, # Success count
|
|
2040
|
+
'failed': int, # Failure count
|
|
2041
|
+
'results': [...], # Per-item results
|
|
2042
|
+
'errors': [...] # Error details
|
|
2043
|
+
}
|
|
2044
|
+
|
|
2045
|
+
Raises:
|
|
2046
|
+
ValueError: When required parameters are missing or invalid:
|
|
2047
|
+
- Empty or None values for required fields
|
|
2048
|
+
- Invalid GUID format
|
|
2049
|
+
- Out-of-range values
|
|
2050
|
+
|
|
2051
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
2052
|
+
- DefaultAzureCredential not configured
|
|
2053
|
+
- Insufficient permissions
|
|
2054
|
+
- Expired authentication token
|
|
2055
|
+
|
|
2056
|
+
HTTPError: When Purview API returns error:
|
|
2057
|
+
- 400: Bad request (invalid parameters)
|
|
2058
|
+
- 401: Unauthorized (authentication failed)
|
|
2059
|
+
- 403: Forbidden (insufficient permissions)
|
|
2060
|
+
- 404: Resource not found
|
|
2061
|
+
- 429: Rate limit exceeded
|
|
2062
|
+
- 500: Internal server error
|
|
2063
|
+
|
|
2064
|
+
NetworkError: When network connectivity fails
|
|
2065
|
+
|
|
2066
|
+
Example:
|
|
2067
|
+
# Basic usage
|
|
2068
|
+
client = Scan()
|
|
2069
|
+
|
|
2070
|
+
result = client.scanExportResults(args=...)
|
|
2071
|
+
print(f"Result: {result}")
|
|
2072
|
+
|
|
2073
|
+
Use Cases:
|
|
2074
|
+
- Bulk Import: Load large volumes of metadata
|
|
2075
|
+
- Migration: Transfer catalog from other systems
|
|
2076
|
+
- Mass Updates: Apply changes to many resources
|
|
2077
|
+
"""
|
|
2078
|
+
self.method = "POST"
|
|
2079
|
+
self.endpoint = f"{ENDPOINTS['scanning']['list_scan_results'].format(dataSourceName=args['--dataSourceName'], scanName=args['--scanName'])}/export"
|
|
2080
|
+
self.params = {
|
|
2081
|
+
**get_api_version_params("scanning"),
|
|
2082
|
+
"format": args.get("--format", "csv"),
|
|
2083
|
+
"runId": args.get("--runId"),
|
|
2084
|
+
}
|
|
2085
|
+
|
|
2086
|
+
# === LEGACY COMPATIBILITY METHODS ===
|
|
2087
|
+
|
|
2088
|
+
@decorator
|
|
2089
|
+
def scanCreateOrUpdateDataSource(self, args):
|
|
2090
|
+
"""
|
|
2091
|
+
Create a new scan.
|
|
2092
|
+
|
|
2093
|
+
Creates a new scan in Microsoft Purview.
|
|
2094
|
+
Requires appropriate permissions and valid scan definition.
|
|
2095
|
+
|
|
2096
|
+
Args:
|
|
2097
|
+
args: Dictionary of operation arguments.
|
|
2098
|
+
Contains operation-specific parameters.
|
|
2099
|
+
See method implementation for details.
|
|
2100
|
+
|
|
2101
|
+
Returns:
|
|
2102
|
+
Dictionary containing created scan:
|
|
2103
|
+
{
|
|
2104
|
+
'guid': str, # Unique identifier
|
|
2105
|
+
'name': str, # Resource name
|
|
2106
|
+
'status': str, # Creation status
|
|
2107
|
+
'attributes': dict, # Resource attributes
|
|
2108
|
+
'createTime': int # Creation timestamp
|
|
2109
|
+
}
|
|
2110
|
+
|
|
2111
|
+
Raises:
|
|
2112
|
+
ValueError: When required parameters are missing or invalid:
|
|
2113
|
+
- Empty or None values for required fields
|
|
2114
|
+
- Invalid GUID format
|
|
2115
|
+
- Out-of-range values
|
|
2116
|
+
|
|
2117
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
2118
|
+
- DefaultAzureCredential not configured
|
|
2119
|
+
- Insufficient permissions
|
|
2120
|
+
- Expired authentication token
|
|
2121
|
+
|
|
2122
|
+
HTTPError: When Purview API returns error:
|
|
2123
|
+
- 400: Bad request (invalid parameters)
|
|
2124
|
+
- 401: Unauthorized (authentication failed)
|
|
2125
|
+
- 403: Forbidden (insufficient permissions)
|
|
2126
|
+
- 404: Resource not found
|
|
2127
|
+
- 409: Conflict (resource already exists)
|
|
2128
|
+
- 429: Rate limit exceeded
|
|
2129
|
+
- 500: Internal server error
|
|
2130
|
+
|
|
2131
|
+
NetworkError: When network connectivity fails
|
|
2132
|
+
|
|
2133
|
+
Example:
|
|
2134
|
+
# Basic usage
|
|
2135
|
+
client = Scan()
|
|
2136
|
+
|
|
2137
|
+
result = client.scanCreateOrUpdateDataSource(args=...)
|
|
2138
|
+
print(f"Result: {result}")
|
|
2139
|
+
|
|
2140
|
+
# With detailed data
|
|
2141
|
+
data = {
|
|
2142
|
+
'name': 'My Resource',
|
|
2143
|
+
'description': 'Resource description',
|
|
2144
|
+
'attributes': {
|
|
2145
|
+
'key1': 'value1',
|
|
2146
|
+
'key2': 'value2'
|
|
2147
|
+
}
|
|
2148
|
+
}
|
|
2149
|
+
|
|
2150
|
+
result = client.scanCreateOrUpdateDataSource(data)
|
|
2151
|
+
print(f"Created/Updated: {result['guid']}")
|
|
2152
|
+
|
|
2153
|
+
Use Cases:
|
|
2154
|
+
- Data Onboarding: Register new data sources in catalog
|
|
2155
|
+
- Metadata Management: Add descriptive metadata to assets
|
|
2156
|
+
- Automation: Programmatically populate catalog
|
|
2157
|
+
"""
|
|
2158
|
+
return self.scanDataSourceCreate(args)
|
|
2159
|
+
|
|
2160
|
+
@decorator
|
|
2161
|
+
def scanPutDataSource(self, args):
|
|
2162
|
+
"""
|
|
2163
|
+
Update an existing scan.
|
|
2164
|
+
|
|
2165
|
+
Updates an existing scan with new values.
|
|
2166
|
+
Only specified fields are modified; others remain unchanged.
|
|
2167
|
+
|
|
2168
|
+
Args:
|
|
2169
|
+
args: Dictionary of operation arguments.
|
|
2170
|
+
Contains operation-specific parameters.
|
|
2171
|
+
See method implementation for details.
|
|
2172
|
+
|
|
2173
|
+
Returns:
|
|
2174
|
+
Dictionary containing updated scan:
|
|
2175
|
+
{
|
|
2176
|
+
'guid': str, # Unique identifier
|
|
2177
|
+
'attributes': dict, # Updated attributes
|
|
2178
|
+
'updateTime': int # Update timestamp
|
|
2179
|
+
}
|
|
2180
|
+
|
|
2181
|
+
Raises:
|
|
2182
|
+
ValueError: When required parameters are missing or invalid:
|
|
2183
|
+
- Empty or None values for required fields
|
|
2184
|
+
- Invalid GUID format
|
|
2185
|
+
- Out-of-range values
|
|
2186
|
+
|
|
2187
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
2188
|
+
- DefaultAzureCredential not configured
|
|
2189
|
+
- Insufficient permissions
|
|
2190
|
+
- Expired authentication token
|
|
2191
|
+
|
|
2192
|
+
HTTPError: When Purview API returns error:
|
|
2193
|
+
- 400: Bad request (invalid parameters)
|
|
2194
|
+
- 401: Unauthorized (authentication failed)
|
|
2195
|
+
- 403: Forbidden (insufficient permissions)
|
|
2196
|
+
- 404: Resource not found
|
|
2197
|
+
- 429: Rate limit exceeded
|
|
2198
|
+
- 500: Internal server error
|
|
2199
|
+
|
|
2200
|
+
NetworkError: When network connectivity fails
|
|
2201
|
+
|
|
2202
|
+
Example:
|
|
2203
|
+
# Basic usage
|
|
2204
|
+
client = Scan()
|
|
2205
|
+
|
|
2206
|
+
result = client.scanPutDataSource(args=...)
|
|
2207
|
+
print(f"Result: {result}")
|
|
2208
|
+
|
|
2209
|
+
# With detailed data
|
|
2210
|
+
data = {
|
|
2211
|
+
'name': 'My Resource',
|
|
2212
|
+
'description': 'Resource description',
|
|
2213
|
+
'attributes': {
|
|
2214
|
+
'key1': 'value1',
|
|
2215
|
+
'key2': 'value2'
|
|
2216
|
+
}
|
|
2217
|
+
}
|
|
2218
|
+
|
|
2219
|
+
result = client.scanPutDataSource(data)
|
|
2220
|
+
print(f"Created/Updated: {result['guid']}")
|
|
2221
|
+
|
|
2222
|
+
Use Cases:
|
|
2223
|
+
- Metadata Enrichment: Update descriptions and tags
|
|
2224
|
+
- Ownership Changes: Reassign data ownership
|
|
2225
|
+
- Classification: Apply or modify data classifications
|
|
2226
|
+
"""
|
|
2227
|
+
return self.scanDataSourceCreate(args)
|
|
2228
|
+
|
|
2229
|
+
@decorator
|
|
2230
|
+
def scanTrigger(self, args):
|
|
2231
|
+
"""
|
|
2232
|
+
Perform operation on resource.
|
|
2233
|
+
|
|
2234
|
+
|
|
2235
|
+
|
|
2236
|
+
Args:
|
|
2237
|
+
args: Dictionary of operation arguments.
|
|
2238
|
+
Contains operation-specific parameters.
|
|
2239
|
+
See method implementation for details.
|
|
2240
|
+
|
|
2241
|
+
Returns:
|
|
2242
|
+
[TODO: Specify return type and structure]
|
|
2243
|
+
[TODO: Document nested fields]
|
|
2244
|
+
|
|
2245
|
+
Raises:
|
|
2246
|
+
ValueError: When required parameters are missing or invalid:
|
|
2247
|
+
- Empty or None values for required fields
|
|
2248
|
+
- Invalid GUID format
|
|
2249
|
+
- Out-of-range values
|
|
2250
|
+
|
|
2251
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
2252
|
+
- DefaultAzureCredential not configured
|
|
2253
|
+
- Insufficient permissions
|
|
2254
|
+
- Expired authentication token
|
|
2255
|
+
|
|
2256
|
+
HTTPError: When Purview API returns error:
|
|
2257
|
+
- 400: Bad request (invalid parameters)
|
|
2258
|
+
- 401: Unauthorized (authentication failed)
|
|
2259
|
+
- 403: Forbidden (insufficient permissions)
|
|
2260
|
+
- 404: Resource not found
|
|
2261
|
+
- 429: Rate limit exceeded
|
|
2262
|
+
- 500: Internal server error
|
|
2263
|
+
|
|
2264
|
+
NetworkError: When network connectivity fails
|
|
2265
|
+
|
|
2266
|
+
Example:
|
|
2267
|
+
# Basic usage
|
|
2268
|
+
client = Scan()
|
|
2269
|
+
|
|
2270
|
+
result = client.scanTrigger(args=...)
|
|
2271
|
+
print(f"Result: {result}")
|
|
2272
|
+
|
|
2273
|
+
Use Cases:
|
|
2274
|
+
- [TODO: Add specific use cases for this operation]
|
|
2275
|
+
- [TODO: Include business context]
|
|
2276
|
+
- [TODO: Explain when to use this method]
|
|
2277
|
+
"""
|
|
2278
|
+
return self.scanRun(args)
|
|
2279
|
+
|
|
2280
|
+
@decorator
|
|
2281
|
+
def scanReadResults(self, args):
|
|
2282
|
+
"""
|
|
2283
|
+
Retrieve scan information.
|
|
2284
|
+
|
|
2285
|
+
Retrieves detailed information about the specified scan.
|
|
2286
|
+
Returns complete scan metadata and properties.
|
|
2287
|
+
|
|
2288
|
+
Args:
|
|
2289
|
+
args: Dictionary of operation arguments.
|
|
2290
|
+
Contains operation-specific parameters.
|
|
2291
|
+
See method implementation for details.
|
|
2292
|
+
|
|
2293
|
+
Returns:
|
|
2294
|
+
Dictionary containing scan information:
|
|
2295
|
+
{
|
|
2296
|
+
'guid': str, # Unique identifier
|
|
2297
|
+
'name': str, # Resource name
|
|
2298
|
+
'attributes': dict, # Resource attributes
|
|
2299
|
+
'status': str, # Resource status
|
|
2300
|
+
'updateTime': int # Last update timestamp
|
|
2301
|
+
}
|
|
2302
|
+
|
|
2303
|
+
Raises:
|
|
2304
|
+
ValueError: When required parameters are missing or invalid:
|
|
2305
|
+
- Empty or None values for required fields
|
|
2306
|
+
- Invalid GUID format
|
|
2307
|
+
- Out-of-range values
|
|
2308
|
+
|
|
2309
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
2310
|
+
- DefaultAzureCredential not configured
|
|
2311
|
+
- Insufficient permissions
|
|
2312
|
+
- Expired authentication token
|
|
2313
|
+
|
|
2314
|
+
HTTPError: When Purview API returns error:
|
|
2315
|
+
- 400: Bad request (invalid parameters)
|
|
2316
|
+
- 401: Unauthorized (authentication failed)
|
|
2317
|
+
- 403: Forbidden (insufficient permissions)
|
|
2318
|
+
- 404: Resource not found
|
|
2319
|
+
- 429: Rate limit exceeded
|
|
2320
|
+
- 500: Internal server error
|
|
2321
|
+
|
|
2322
|
+
NetworkError: When network connectivity fails
|
|
2323
|
+
|
|
2324
|
+
Example:
|
|
2325
|
+
# Basic usage
|
|
2326
|
+
client = Scan()
|
|
2327
|
+
|
|
2328
|
+
result = client.scanReadResults(args=...)
|
|
2329
|
+
print(f"Result: {result}")
|
|
2330
|
+
|
|
2331
|
+
Use Cases:
|
|
2332
|
+
- Data Discovery: Find and explore data assets
|
|
2333
|
+
- Compliance Auditing: Review metadata and classifications
|
|
2334
|
+
- Reporting: Generate catalog reports
|
|
2335
|
+
"""
|
|
2336
|
+
return self.scanReadResult(args)
|
|
2337
|
+
|
|
2338
|
+
@decorator
|
|
2339
|
+
def scanCreateOrUpdate(self, args):
|
|
2340
|
+
"""
|
|
2341
|
+
Create a new scan.
|
|
2342
|
+
|
|
2343
|
+
Creates a new scan in Microsoft Purview.
|
|
2344
|
+
Requires appropriate permissions and valid scan definition.
|
|
2345
|
+
|
|
2346
|
+
Args:
|
|
2347
|
+
args: Dictionary of operation arguments.
|
|
2348
|
+
Contains operation-specific parameters.
|
|
2349
|
+
See method implementation for details.
|
|
2350
|
+
|
|
2351
|
+
Returns:
|
|
2352
|
+
Dictionary containing created scan:
|
|
2353
|
+
{
|
|
2354
|
+
'guid': str, # Unique identifier
|
|
2355
|
+
'name': str, # Resource name
|
|
2356
|
+
'status': str, # Creation status
|
|
2357
|
+
'attributes': dict, # Resource attributes
|
|
2358
|
+
'createTime': int # Creation timestamp
|
|
2359
|
+
}
|
|
2360
|
+
|
|
2361
|
+
Raises:
|
|
2362
|
+
ValueError: When required parameters are missing or invalid:
|
|
2363
|
+
- Empty or None values for required fields
|
|
2364
|
+
- Invalid GUID format
|
|
2365
|
+
- Out-of-range values
|
|
2366
|
+
|
|
2367
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
2368
|
+
- DefaultAzureCredential not configured
|
|
2369
|
+
- Insufficient permissions
|
|
2370
|
+
- Expired authentication token
|
|
2371
|
+
|
|
2372
|
+
HTTPError: When Purview API returns error:
|
|
2373
|
+
- 400: Bad request (invalid parameters)
|
|
2374
|
+
- 401: Unauthorized (authentication failed)
|
|
2375
|
+
- 403: Forbidden (insufficient permissions)
|
|
2376
|
+
- 404: Resource not found
|
|
2377
|
+
- 409: Conflict (resource already exists)
|
|
2378
|
+
- 429: Rate limit exceeded
|
|
2379
|
+
- 500: Internal server error
|
|
2380
|
+
|
|
2381
|
+
NetworkError: When network connectivity fails
|
|
2382
|
+
|
|
2383
|
+
Example:
|
|
2384
|
+
# Basic usage
|
|
2385
|
+
client = Scan()
|
|
2386
|
+
|
|
2387
|
+
result = client.scanCreateOrUpdate(args=...)
|
|
2388
|
+
print(f"Result: {result}")
|
|
2389
|
+
|
|
2390
|
+
# With detailed data
|
|
2391
|
+
data = {
|
|
2392
|
+
'name': 'My Resource',
|
|
2393
|
+
'description': 'Resource description',
|
|
2394
|
+
'attributes': {
|
|
2395
|
+
'key1': 'value1',
|
|
2396
|
+
'key2': 'value2'
|
|
2397
|
+
}
|
|
2398
|
+
}
|
|
2399
|
+
|
|
2400
|
+
result = client.scanCreateOrUpdate(data)
|
|
2401
|
+
print(f"Created/Updated: {result['guid']}")
|
|
2402
|
+
|
|
2403
|
+
Use Cases:
|
|
2404
|
+
- Data Onboarding: Register new data sources in catalog
|
|
2405
|
+
- Metadata Management: Add descriptive metadata to assets
|
|
2406
|
+
- Automation: Programmatically populate catalog
|
|
2407
|
+
"""
|
|
2408
|
+
return self.scanCreate(args)
|
|
2409
|
+
|
|
2410
|
+
@decorator
|
|
2411
|
+
def scanPut(self, args):
|
|
2412
|
+
"""
|
|
2413
|
+
Update an existing scan.
|
|
2414
|
+
|
|
2415
|
+
Updates an existing scan with new values.
|
|
2416
|
+
Only specified fields are modified; others remain unchanged.
|
|
2417
|
+
|
|
2418
|
+
Args:
|
|
2419
|
+
args: Dictionary of operation arguments.
|
|
2420
|
+
Contains operation-specific parameters.
|
|
2421
|
+
See method implementation for details.
|
|
2422
|
+
|
|
2423
|
+
Returns:
|
|
2424
|
+
Dictionary containing updated scan:
|
|
2425
|
+
{
|
|
2426
|
+
'guid': str, # Unique identifier
|
|
2427
|
+
'attributes': dict, # Updated attributes
|
|
2428
|
+
'updateTime': int # Update timestamp
|
|
2429
|
+
}
|
|
2430
|
+
|
|
2431
|
+
Raises:
|
|
2432
|
+
ValueError: When required parameters are missing or invalid:
|
|
2433
|
+
- Empty or None values for required fields
|
|
2434
|
+
- Invalid GUID format
|
|
2435
|
+
- Out-of-range values
|
|
2436
|
+
|
|
2437
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
2438
|
+
- DefaultAzureCredential not configured
|
|
2439
|
+
- Insufficient permissions
|
|
2440
|
+
- Expired authentication token
|
|
2441
|
+
|
|
2442
|
+
HTTPError: When Purview API returns error:
|
|
2443
|
+
- 400: Bad request (invalid parameters)
|
|
2444
|
+
- 401: Unauthorized (authentication failed)
|
|
2445
|
+
- 403: Forbidden (insufficient permissions)
|
|
2446
|
+
- 404: Resource not found
|
|
2447
|
+
- 429: Rate limit exceeded
|
|
2448
|
+
- 500: Internal server error
|
|
2449
|
+
|
|
2450
|
+
NetworkError: When network connectivity fails
|
|
2451
|
+
|
|
2452
|
+
Example:
|
|
2453
|
+
# Basic usage
|
|
2454
|
+
client = Scan()
|
|
2455
|
+
|
|
2456
|
+
result = client.scanPut(args=...)
|
|
2457
|
+
print(f"Result: {result}")
|
|
2458
|
+
|
|
2459
|
+
# With detailed data
|
|
2460
|
+
data = {
|
|
2461
|
+
'name': 'My Resource',
|
|
2462
|
+
'description': 'Resource description',
|
|
2463
|
+
'attributes': {
|
|
2464
|
+
'key1': 'value1',
|
|
2465
|
+
'key2': 'value2'
|
|
2466
|
+
}
|
|
2467
|
+
}
|
|
2468
|
+
|
|
2469
|
+
result = client.scanPut(data)
|
|
2470
|
+
print(f"Created/Updated: {result['guid']}")
|
|
2471
|
+
|
|
2472
|
+
Use Cases:
|
|
2473
|
+
- Metadata Enrichment: Update descriptions and tags
|
|
2474
|
+
- Ownership Changes: Reassign data ownership
|
|
2475
|
+
- Classification: Apply or modify data classifications
|
|
2476
|
+
"""
|
|
2477
|
+
return self.scanCreate(args)
|
|
2478
|
+
|
|
2479
|
+
@decorator
|
|
2480
|
+
def scanReadRuleset(self, args):
|
|
2481
|
+
"""
|
|
2482
|
+
Retrieve scan information.
|
|
2483
|
+
|
|
2484
|
+
Retrieves detailed information about the specified scan.
|
|
2485
|
+
Returns complete scan metadata and properties.
|
|
2486
|
+
|
|
2487
|
+
Args:
|
|
2488
|
+
args: Dictionary of operation arguments.
|
|
2489
|
+
Contains operation-specific parameters.
|
|
2490
|
+
See method implementation for details.
|
|
2491
|
+
|
|
2492
|
+
Returns:
|
|
2493
|
+
Dictionary containing scan information:
|
|
2494
|
+
{
|
|
2495
|
+
'guid': str, # Unique identifier
|
|
2496
|
+
'name': str, # Resource name
|
|
2497
|
+
'attributes': dict, # Resource attributes
|
|
2498
|
+
'status': str, # Resource status
|
|
2499
|
+
'updateTime': int # Last update timestamp
|
|
2500
|
+
}
|
|
2501
|
+
|
|
2502
|
+
Raises:
|
|
2503
|
+
ValueError: When required parameters are missing or invalid:
|
|
2504
|
+
- Empty or None values for required fields
|
|
2505
|
+
- Invalid GUID format
|
|
2506
|
+
- Out-of-range values
|
|
2507
|
+
|
|
2508
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
2509
|
+
- DefaultAzureCredential not configured
|
|
2510
|
+
- Insufficient permissions
|
|
2511
|
+
- Expired authentication token
|
|
2512
|
+
|
|
2513
|
+
HTTPError: When Purview API returns error:
|
|
2514
|
+
- 400: Bad request (invalid parameters)
|
|
2515
|
+
- 401: Unauthorized (authentication failed)
|
|
2516
|
+
- 403: Forbidden (insufficient permissions)
|
|
2517
|
+
- 404: Resource not found
|
|
2518
|
+
- 429: Rate limit exceeded
|
|
2519
|
+
- 500: Internal server error
|
|
2520
|
+
|
|
2521
|
+
NetworkError: When network connectivity fails
|
|
2522
|
+
|
|
2523
|
+
Example:
|
|
2524
|
+
# Basic usage
|
|
2525
|
+
client = Scan()
|
|
2526
|
+
|
|
2527
|
+
result = client.scanReadRuleset(args=...)
|
|
2528
|
+
print(f"Result: {result}")
|
|
2529
|
+
|
|
2530
|
+
Use Cases:
|
|
2531
|
+
- Data Discovery: Find and explore data assets
|
|
2532
|
+
- Compliance Auditing: Review metadata and classifications
|
|
2533
|
+
- Reporting: Generate catalog reports
|
|
2534
|
+
"""
|
|
2535
|
+
return self.scanRuleSetRead(args)
|
|
2536
|
+
|
|
2537
|
+
@decorator
|
|
2538
|
+
def scanCreateRuleset(self, args):
|
|
2539
|
+
"""
|
|
2540
|
+
Create a new scan.
|
|
2541
|
+
|
|
2542
|
+
Creates a new scan in Microsoft Purview.
|
|
2543
|
+
Requires appropriate permissions and valid scan definition.
|
|
2544
|
+
|
|
2545
|
+
Args:
|
|
2546
|
+
args: Dictionary of operation arguments.
|
|
2547
|
+
Contains operation-specific parameters.
|
|
2548
|
+
See method implementation for details.
|
|
2549
|
+
|
|
2550
|
+
Returns:
|
|
2551
|
+
Dictionary containing created scan:
|
|
2552
|
+
{
|
|
2553
|
+
'guid': str, # Unique identifier
|
|
2554
|
+
'name': str, # Resource name
|
|
2555
|
+
'status': str, # Creation status
|
|
2556
|
+
'attributes': dict, # Resource attributes
|
|
2557
|
+
'createTime': int # Creation timestamp
|
|
2558
|
+
}
|
|
2559
|
+
|
|
2560
|
+
Raises:
|
|
2561
|
+
ValueError: When required parameters are missing or invalid:
|
|
2562
|
+
- Empty or None values for required fields
|
|
2563
|
+
- Invalid GUID format
|
|
2564
|
+
- Out-of-range values
|
|
2565
|
+
|
|
2566
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
2567
|
+
- DefaultAzureCredential not configured
|
|
2568
|
+
- Insufficient permissions
|
|
2569
|
+
- Expired authentication token
|
|
2570
|
+
|
|
2571
|
+
HTTPError: When Purview API returns error:
|
|
2572
|
+
- 400: Bad request (invalid parameters)
|
|
2573
|
+
- 401: Unauthorized (authentication failed)
|
|
2574
|
+
- 403: Forbidden (insufficient permissions)
|
|
2575
|
+
- 404: Resource not found
|
|
2576
|
+
- 409: Conflict (resource already exists)
|
|
2577
|
+
- 429: Rate limit exceeded
|
|
2578
|
+
- 500: Internal server error
|
|
2579
|
+
|
|
2580
|
+
NetworkError: When network connectivity fails
|
|
2581
|
+
|
|
2582
|
+
Example:
|
|
2583
|
+
# Basic usage
|
|
2584
|
+
client = Scan()
|
|
2585
|
+
|
|
2586
|
+
result = client.scanCreateRuleset(args=...)
|
|
2587
|
+
print(f"Result: {result}")
|
|
2588
|
+
|
|
2589
|
+
# With detailed data
|
|
2590
|
+
data = {
|
|
2591
|
+
'name': 'My Resource',
|
|
2592
|
+
'description': 'Resource description',
|
|
2593
|
+
'attributes': {
|
|
2594
|
+
'key1': 'value1',
|
|
2595
|
+
'key2': 'value2'
|
|
2596
|
+
}
|
|
2597
|
+
}
|
|
2598
|
+
|
|
2599
|
+
result = client.scanCreateRuleset(data)
|
|
2600
|
+
print(f"Created/Updated: {result['guid']}")
|
|
2601
|
+
|
|
2602
|
+
Use Cases:
|
|
2603
|
+
- Data Onboarding: Register new data sources in catalog
|
|
2604
|
+
- Metadata Management: Add descriptive metadata to assets
|
|
2605
|
+
- Automation: Programmatically populate catalog
|
|
2606
|
+
"""
|
|
2607
|
+
return self.scanRuleSetCreate(args)
|