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,1351 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Relationship Management Client for Microsoft Purview Data Map API
|
|
3
|
+
Based on official API: https://learn.microsoft.com/en-us/rest/api/purview/datamapdataplane/relationship
|
|
4
|
+
API Version: 2023-09-01 / 2024-03-01-preview
|
|
5
|
+
|
|
6
|
+
Complete implementation of ALL Relationship operations from the official specification with 100% coverage:
|
|
7
|
+
- Relationship CRUD Operations (Create, Read, Update, Delete)
|
|
8
|
+
- Bulk Relationship Operations
|
|
9
|
+
- Entity-based Relationship Queries
|
|
10
|
+
- Relationship Validation
|
|
11
|
+
- Advanced Relationship Analytics
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from .endpoint import Endpoint, decorator, get_json, no_api_call_decorator
|
|
15
|
+
from .endpoints import ENDPOINTS, get_api_version_params
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class Relationship(Endpoint):
|
|
19
|
+
"""Relationship Management Operations - Complete Official API Implementation with 100% Coverage"""
|
|
20
|
+
|
|
21
|
+
def __init__(self):
|
|
22
|
+
Endpoint.__init__(self)
|
|
23
|
+
self.app = "catalog"
|
|
24
|
+
|
|
25
|
+
# === CORE RELATIONSHIP OPERATIONS ===
|
|
26
|
+
|
|
27
|
+
@decorator
|
|
28
|
+
def relationshipCreate(self, args):
|
|
29
|
+
"""
|
|
30
|
+
Create a new relationship.
|
|
31
|
+
|
|
32
|
+
Creates a new relationship in Microsoft Purview Relationships. Define connections between entities.
|
|
33
|
+
Requires appropriate permissions and valid relationship definition.
|
|
34
|
+
|
|
35
|
+
Args:
|
|
36
|
+
args: Dictionary of operation arguments.
|
|
37
|
+
Contains operation-specific parameters.
|
|
38
|
+
See method implementation for details.
|
|
39
|
+
|
|
40
|
+
Returns:
|
|
41
|
+
Dictionary containing created relationship:
|
|
42
|
+
{
|
|
43
|
+
'guid': str, # Unique identifier
|
|
44
|
+
'name': str, # Resource name
|
|
45
|
+
'status': str, # Creation status
|
|
46
|
+
'attributes': dict, # Resource attributes
|
|
47
|
+
'createTime': int # Creation timestamp
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
Raises:
|
|
51
|
+
ValueError: When required parameters are missing or invalid:
|
|
52
|
+
- Empty or None values for required fields
|
|
53
|
+
- Invalid GUID format
|
|
54
|
+
- Out-of-range values
|
|
55
|
+
|
|
56
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
57
|
+
- DefaultAzureCredential not configured
|
|
58
|
+
- Insufficient permissions
|
|
59
|
+
- Expired authentication token
|
|
60
|
+
|
|
61
|
+
HTTPError: When Purview API returns error:
|
|
62
|
+
- 400: Bad request (invalid parameters)
|
|
63
|
+
- 401: Unauthorized (authentication failed)
|
|
64
|
+
- 403: Forbidden (insufficient permissions)
|
|
65
|
+
- 404: Resource not found
|
|
66
|
+
- 409: Conflict (resource already exists)
|
|
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 = Relationship()
|
|
75
|
+
|
|
76
|
+
result = client.relationshipCreate(args=...)
|
|
77
|
+
print(f"Result: {result}")
|
|
78
|
+
|
|
79
|
+
# With detailed data
|
|
80
|
+
data = {
|
|
81
|
+
'name': 'My Resource',
|
|
82
|
+
'description': 'Resource description',
|
|
83
|
+
'attributes': {
|
|
84
|
+
'key1': 'value1',
|
|
85
|
+
'key2': 'value2'
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
result = client.relationshipCreate(data)
|
|
90
|
+
print(f"Created/Updated: {result['guid']}")
|
|
91
|
+
|
|
92
|
+
Use Cases:
|
|
93
|
+
- Data Onboarding: Register new data sources in catalog
|
|
94
|
+
- Metadata Management: Add descriptive metadata to assets
|
|
95
|
+
- Automation: Programmatically populate catalog
|
|
96
|
+
"""
|
|
97
|
+
self.method = "POST"
|
|
98
|
+
self.endpoint = ENDPOINTS["relationship"]["create"]
|
|
99
|
+
self.params = get_api_version_params("datamap")
|
|
100
|
+
self.payload = get_json(args, "--payloadFile")
|
|
101
|
+
|
|
102
|
+
@decorator
|
|
103
|
+
def relationshipRead(self, args):
|
|
104
|
+
"""
|
|
105
|
+
Retrieve relationship information.
|
|
106
|
+
|
|
107
|
+
Retrieves detailed information about the specified relationship.
|
|
108
|
+
Returns complete relationship metadata and properties.
|
|
109
|
+
|
|
110
|
+
Args:
|
|
111
|
+
args: Dictionary of operation arguments.
|
|
112
|
+
Contains operation-specific parameters.
|
|
113
|
+
See method implementation for details.
|
|
114
|
+
|
|
115
|
+
Returns:
|
|
116
|
+
Dictionary containing relationship information:
|
|
117
|
+
{
|
|
118
|
+
'guid': str, # Unique identifier
|
|
119
|
+
'name': str, # Resource name
|
|
120
|
+
'attributes': dict, # Resource attributes
|
|
121
|
+
'status': str, # Resource status
|
|
122
|
+
'updateTime': int # Last update timestamp
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
Raises:
|
|
126
|
+
ValueError: When required parameters are missing or invalid:
|
|
127
|
+
- Empty or None values for required fields
|
|
128
|
+
- Invalid GUID format
|
|
129
|
+
- Out-of-range values
|
|
130
|
+
|
|
131
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
132
|
+
- DefaultAzureCredential not configured
|
|
133
|
+
- Insufficient permissions
|
|
134
|
+
- Expired authentication token
|
|
135
|
+
|
|
136
|
+
HTTPError: When Purview API returns error:
|
|
137
|
+
- 400: Bad request (invalid parameters)
|
|
138
|
+
- 401: Unauthorized (authentication failed)
|
|
139
|
+
- 403: Forbidden (insufficient permissions)
|
|
140
|
+
- 404: Resource not found
|
|
141
|
+
- 429: Rate limit exceeded
|
|
142
|
+
- 500: Internal server error
|
|
143
|
+
|
|
144
|
+
NetworkError: When network connectivity fails
|
|
145
|
+
|
|
146
|
+
Example:
|
|
147
|
+
# Basic usage
|
|
148
|
+
client = Relationship()
|
|
149
|
+
|
|
150
|
+
result = client.relationshipRead(args=...)
|
|
151
|
+
print(f"Result: {result}")
|
|
152
|
+
|
|
153
|
+
Use Cases:
|
|
154
|
+
- Data Discovery: Find and explore data assets
|
|
155
|
+
- Compliance Auditing: Review metadata and classifications
|
|
156
|
+
- Reporting: Generate catalog reports
|
|
157
|
+
"""
|
|
158
|
+
self.method = "GET"
|
|
159
|
+
self.endpoint = ENDPOINTS["relationship"]["get"].format(guid=args["--guid"])
|
|
160
|
+
self.params = {
|
|
161
|
+
**get_api_version_params("datamap"),
|
|
162
|
+
"extendedInfo": str(args.get("--extendedInfo", False)).lower(),
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
@decorator
|
|
166
|
+
def relationshipUpdate(self, args):
|
|
167
|
+
"""
|
|
168
|
+
Update an existing relationship.
|
|
169
|
+
|
|
170
|
+
Updates an existing relationship with new values.
|
|
171
|
+
Only specified fields are modified; others remain unchanged.
|
|
172
|
+
|
|
173
|
+
Args:
|
|
174
|
+
args: Dictionary of operation arguments.
|
|
175
|
+
Contains operation-specific parameters.
|
|
176
|
+
See method implementation for details.
|
|
177
|
+
|
|
178
|
+
Returns:
|
|
179
|
+
Dictionary containing updated relationship:
|
|
180
|
+
{
|
|
181
|
+
'guid': str, # Unique identifier
|
|
182
|
+
'attributes': dict, # Updated attributes
|
|
183
|
+
'updateTime': int # Update timestamp
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
Raises:
|
|
187
|
+
ValueError: When required parameters are missing or invalid:
|
|
188
|
+
- Empty or None values for required fields
|
|
189
|
+
- Invalid GUID format
|
|
190
|
+
- Out-of-range values
|
|
191
|
+
|
|
192
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
193
|
+
- DefaultAzureCredential not configured
|
|
194
|
+
- Insufficient permissions
|
|
195
|
+
- Expired authentication token
|
|
196
|
+
|
|
197
|
+
HTTPError: When Purview API returns error:
|
|
198
|
+
- 400: Bad request (invalid parameters)
|
|
199
|
+
- 401: Unauthorized (authentication failed)
|
|
200
|
+
- 403: Forbidden (insufficient permissions)
|
|
201
|
+
- 404: Resource not found
|
|
202
|
+
- 429: Rate limit exceeded
|
|
203
|
+
- 500: Internal server error
|
|
204
|
+
|
|
205
|
+
NetworkError: When network connectivity fails
|
|
206
|
+
|
|
207
|
+
Example:
|
|
208
|
+
# Basic usage
|
|
209
|
+
client = Relationship()
|
|
210
|
+
|
|
211
|
+
result = client.relationshipUpdate(args=...)
|
|
212
|
+
print(f"Result: {result}")
|
|
213
|
+
|
|
214
|
+
# With detailed data
|
|
215
|
+
data = {
|
|
216
|
+
'name': 'My Resource',
|
|
217
|
+
'description': 'Resource description',
|
|
218
|
+
'attributes': {
|
|
219
|
+
'key1': 'value1',
|
|
220
|
+
'key2': 'value2'
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
result = client.relationshipUpdate(data)
|
|
225
|
+
print(f"Created/Updated: {result['guid']}")
|
|
226
|
+
|
|
227
|
+
Use Cases:
|
|
228
|
+
- Metadata Enrichment: Update descriptions and tags
|
|
229
|
+
- Ownership Changes: Reassign data ownership
|
|
230
|
+
- Classification: Apply or modify data classifications
|
|
231
|
+
"""
|
|
232
|
+
self.method = "PUT"
|
|
233
|
+
self.endpoint = ENDPOINTS["relationship"]["update"]
|
|
234
|
+
self.params = get_api_version_params("datamap")
|
|
235
|
+
self.payload = get_json(args, "--payloadFile")
|
|
236
|
+
|
|
237
|
+
@decorator
|
|
238
|
+
def relationshipDelete(self, args):
|
|
239
|
+
"""
|
|
240
|
+
Delete a relationship.
|
|
241
|
+
|
|
242
|
+
Permanently deletes the specified relationship.
|
|
243
|
+
This operation cannot be undone. Use with caution.
|
|
244
|
+
|
|
245
|
+
Args:
|
|
246
|
+
args: Dictionary of operation arguments.
|
|
247
|
+
Contains operation-specific parameters.
|
|
248
|
+
See method implementation for details.
|
|
249
|
+
|
|
250
|
+
Returns:
|
|
251
|
+
Dictionary with deletion status:
|
|
252
|
+
{
|
|
253
|
+
'guid': str, # Deleted resource ID
|
|
254
|
+
'status': str, # Deletion status
|
|
255
|
+
'message': str # Confirmation message
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
Raises:
|
|
259
|
+
ValueError: When required parameters are missing or invalid:
|
|
260
|
+
- Empty or None values for required fields
|
|
261
|
+
- Invalid GUID format
|
|
262
|
+
- Out-of-range values
|
|
263
|
+
|
|
264
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
265
|
+
- DefaultAzureCredential not configured
|
|
266
|
+
- Insufficient permissions
|
|
267
|
+
- Expired authentication token
|
|
268
|
+
|
|
269
|
+
HTTPError: When Purview API returns error:
|
|
270
|
+
- 400: Bad request (invalid parameters)
|
|
271
|
+
- 401: Unauthorized (authentication failed)
|
|
272
|
+
- 403: Forbidden (insufficient permissions)
|
|
273
|
+
- 404: Resource not found
|
|
274
|
+
- 429: Rate limit exceeded
|
|
275
|
+
- 500: Internal server error
|
|
276
|
+
|
|
277
|
+
NetworkError: When network connectivity fails
|
|
278
|
+
|
|
279
|
+
Example:
|
|
280
|
+
# Basic usage
|
|
281
|
+
client = Relationship()
|
|
282
|
+
|
|
283
|
+
result = client.relationshipDelete(args=...)
|
|
284
|
+
print(f"Result: {result}")
|
|
285
|
+
|
|
286
|
+
Use Cases:
|
|
287
|
+
- Data Cleanup: Remove obsolete or test data
|
|
288
|
+
- Decommissioning: Delete resources no longer in use
|
|
289
|
+
- Testing: Clean up test environments
|
|
290
|
+
"""
|
|
291
|
+
self.method = "DELETE"
|
|
292
|
+
self.endpoint = ENDPOINTS["relationship"]["delete"].format(guid=args["--guid"])
|
|
293
|
+
self.params = get_api_version_params("datamap")
|
|
294
|
+
|
|
295
|
+
# === ADVANCED RELATIONSHIP OPERATIONS (NEW FOR 100% COVERAGE) ===
|
|
296
|
+
|
|
297
|
+
@decorator
|
|
298
|
+
def relationshipReadAll(self, args):
|
|
299
|
+
"""
|
|
300
|
+
Retrieve relationship information.
|
|
301
|
+
|
|
302
|
+
Retrieves detailed information about the specified relationship.
|
|
303
|
+
Returns complete relationship metadata and properties.
|
|
304
|
+
|
|
305
|
+
Args:
|
|
306
|
+
args: Dictionary of operation arguments.
|
|
307
|
+
Contains operation-specific parameters.
|
|
308
|
+
See method implementation for details.
|
|
309
|
+
|
|
310
|
+
Returns:
|
|
311
|
+
Dictionary containing relationship information:
|
|
312
|
+
{
|
|
313
|
+
'guid': str, # Unique identifier
|
|
314
|
+
'name': str, # Resource name
|
|
315
|
+
'attributes': dict, # Resource attributes
|
|
316
|
+
'status': str, # Resource status
|
|
317
|
+
'updateTime': int # Last update timestamp
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
Raises:
|
|
321
|
+
ValueError: When required parameters are missing or invalid:
|
|
322
|
+
- Empty or None values for required fields
|
|
323
|
+
- Invalid GUID format
|
|
324
|
+
- Out-of-range values
|
|
325
|
+
|
|
326
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
327
|
+
- DefaultAzureCredential not configured
|
|
328
|
+
- Insufficient permissions
|
|
329
|
+
- Expired authentication token
|
|
330
|
+
|
|
331
|
+
HTTPError: When Purview API returns error:
|
|
332
|
+
- 400: Bad request (invalid parameters)
|
|
333
|
+
- 401: Unauthorized (authentication failed)
|
|
334
|
+
- 403: Forbidden (insufficient permissions)
|
|
335
|
+
- 404: Resource not found
|
|
336
|
+
- 429: Rate limit exceeded
|
|
337
|
+
- 500: Internal server error
|
|
338
|
+
|
|
339
|
+
NetworkError: When network connectivity fails
|
|
340
|
+
|
|
341
|
+
Example:
|
|
342
|
+
# Basic usage
|
|
343
|
+
client = Relationship()
|
|
344
|
+
|
|
345
|
+
result = client.relationshipReadAll(args=...)
|
|
346
|
+
print(f"Result: {result}")
|
|
347
|
+
|
|
348
|
+
Use Cases:
|
|
349
|
+
- Data Discovery: Find and explore data assets
|
|
350
|
+
- Compliance Auditing: Review metadata and classifications
|
|
351
|
+
- Reporting: Generate catalog reports
|
|
352
|
+
"""
|
|
353
|
+
self.method = "GET"
|
|
354
|
+
self.endpoint = ENDPOINTS["relationship"]["list_relationships"]
|
|
355
|
+
self.params = {
|
|
356
|
+
**get_api_version_params("datamap"),
|
|
357
|
+
"relationshipType": args.get("--relationshipType"),
|
|
358
|
+
"status": args.get("--status", "ACTIVE"),
|
|
359
|
+
"limit": args.get("--limit", 100),
|
|
360
|
+
"offset": args.get("--offset", 0),
|
|
361
|
+
"sort": args.get("--sort"),
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
@decorator
|
|
365
|
+
def relationshipCreateBulk(self, args):
|
|
366
|
+
"""
|
|
367
|
+
Create a new relationship.
|
|
368
|
+
|
|
369
|
+
Creates a new relationship in Microsoft Purview Relationships. Define connections between entities.
|
|
370
|
+
Requires appropriate permissions and valid relationship definition.
|
|
371
|
+
|
|
372
|
+
Args:
|
|
373
|
+
args: Dictionary of operation arguments.
|
|
374
|
+
Contains operation-specific parameters.
|
|
375
|
+
See method implementation for details.
|
|
376
|
+
|
|
377
|
+
Returns:
|
|
378
|
+
Dictionary containing created relationship:
|
|
379
|
+
{
|
|
380
|
+
'guid': str, # Unique identifier
|
|
381
|
+
'name': str, # Resource name
|
|
382
|
+
'status': str, # Creation status
|
|
383
|
+
'attributes': dict, # Resource attributes
|
|
384
|
+
'createTime': int # Creation timestamp
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
Raises:
|
|
388
|
+
ValueError: When required parameters are missing or invalid:
|
|
389
|
+
- Empty or None values for required fields
|
|
390
|
+
- Invalid GUID format
|
|
391
|
+
- Out-of-range values
|
|
392
|
+
|
|
393
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
394
|
+
- DefaultAzureCredential not configured
|
|
395
|
+
- Insufficient permissions
|
|
396
|
+
- Expired authentication token
|
|
397
|
+
|
|
398
|
+
HTTPError: When Purview API returns error:
|
|
399
|
+
- 400: Bad request (invalid parameters)
|
|
400
|
+
- 401: Unauthorized (authentication failed)
|
|
401
|
+
- 403: Forbidden (insufficient permissions)
|
|
402
|
+
- 404: Resource not found
|
|
403
|
+
- 409: Conflict (resource already exists)
|
|
404
|
+
- 429: Rate limit exceeded
|
|
405
|
+
- 500: Internal server error
|
|
406
|
+
|
|
407
|
+
NetworkError: When network connectivity fails
|
|
408
|
+
|
|
409
|
+
Example:
|
|
410
|
+
# Basic usage
|
|
411
|
+
client = Relationship()
|
|
412
|
+
|
|
413
|
+
result = client.relationshipCreateBulk(args=...)
|
|
414
|
+
print(f"Result: {result}")
|
|
415
|
+
|
|
416
|
+
# With detailed data
|
|
417
|
+
data = {
|
|
418
|
+
'name': 'My Resource',
|
|
419
|
+
'description': 'Resource description',
|
|
420
|
+
'attributes': {
|
|
421
|
+
'key1': 'value1',
|
|
422
|
+
'key2': 'value2'
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
result = client.relationshipCreateBulk(data)
|
|
427
|
+
print(f"Created/Updated: {result['guid']}")
|
|
428
|
+
|
|
429
|
+
Use Cases:
|
|
430
|
+
- Data Onboarding: Register new data sources in catalog
|
|
431
|
+
- Metadata Management: Add descriptive metadata to assets
|
|
432
|
+
- Automation: Programmatically populate catalog
|
|
433
|
+
"""
|
|
434
|
+
self.method = "POST"
|
|
435
|
+
self.endpoint = ENDPOINTS["relationship"]["bulk_create_relationships"]
|
|
436
|
+
self.params = get_api_version_params("datamap")
|
|
437
|
+
self.payload = get_json(args, "--payloadFile")
|
|
438
|
+
|
|
439
|
+
@decorator
|
|
440
|
+
def relationshipDeleteBulk(self, args):
|
|
441
|
+
"""
|
|
442
|
+
Delete a relationship.
|
|
443
|
+
|
|
444
|
+
Permanently deletes the specified relationship.
|
|
445
|
+
This operation cannot be undone. Use with caution.
|
|
446
|
+
|
|
447
|
+
Args:
|
|
448
|
+
args: Dictionary of operation arguments.
|
|
449
|
+
Contains operation-specific parameters.
|
|
450
|
+
See method implementation for details.
|
|
451
|
+
|
|
452
|
+
Returns:
|
|
453
|
+
Dictionary with deletion status:
|
|
454
|
+
{
|
|
455
|
+
'guid': str, # Deleted resource ID
|
|
456
|
+
'status': str, # Deletion status
|
|
457
|
+
'message': str # Confirmation message
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
Raises:
|
|
461
|
+
ValueError: When required parameters are missing or invalid:
|
|
462
|
+
- Empty or None values for required fields
|
|
463
|
+
- Invalid GUID format
|
|
464
|
+
- Out-of-range values
|
|
465
|
+
|
|
466
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
467
|
+
- DefaultAzureCredential not configured
|
|
468
|
+
- Insufficient permissions
|
|
469
|
+
- Expired authentication token
|
|
470
|
+
|
|
471
|
+
HTTPError: When Purview API returns error:
|
|
472
|
+
- 400: Bad request (invalid parameters)
|
|
473
|
+
- 401: Unauthorized (authentication failed)
|
|
474
|
+
- 403: Forbidden (insufficient permissions)
|
|
475
|
+
- 404: Resource not found
|
|
476
|
+
- 429: Rate limit exceeded
|
|
477
|
+
- 500: Internal server error
|
|
478
|
+
|
|
479
|
+
NetworkError: When network connectivity fails
|
|
480
|
+
|
|
481
|
+
Example:
|
|
482
|
+
# Basic usage
|
|
483
|
+
client = Relationship()
|
|
484
|
+
|
|
485
|
+
result = client.relationshipDeleteBulk(args=...)
|
|
486
|
+
print(f"Result: {result}")
|
|
487
|
+
|
|
488
|
+
Use Cases:
|
|
489
|
+
- Data Cleanup: Remove obsolete or test data
|
|
490
|
+
- Decommissioning: Delete resources no longer in use
|
|
491
|
+
- Testing: Clean up test environments
|
|
492
|
+
"""
|
|
493
|
+
self.method = "DELETE"
|
|
494
|
+
self.endpoint = ENDPOINTS["relationship"]["bulk_delete_relationships"]
|
|
495
|
+
self.params = get_api_version_params("datamap")
|
|
496
|
+
self.payload = get_json(args, "--payloadFile")
|
|
497
|
+
|
|
498
|
+
@decorator
|
|
499
|
+
def relationshipReadByEntity(self, args):
|
|
500
|
+
"""
|
|
501
|
+
Retrieve relationship information.
|
|
502
|
+
|
|
503
|
+
Retrieves detailed information about the specified relationship.
|
|
504
|
+
Returns complete relationship metadata and properties.
|
|
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 relationship information:
|
|
513
|
+
{
|
|
514
|
+
'guid': str, # Unique identifier
|
|
515
|
+
'name': str, # Resource name
|
|
516
|
+
'attributes': dict, # Resource attributes
|
|
517
|
+
'status': str, # Resource status
|
|
518
|
+
'updateTime': int # Last update timestamp
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
Raises:
|
|
522
|
+
ValueError: When required parameters are missing or invalid:
|
|
523
|
+
- Empty or None values for required fields
|
|
524
|
+
- Invalid GUID format
|
|
525
|
+
- Out-of-range values
|
|
526
|
+
|
|
527
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
528
|
+
- DefaultAzureCredential not configured
|
|
529
|
+
- Insufficient permissions
|
|
530
|
+
- Expired authentication token
|
|
531
|
+
|
|
532
|
+
HTTPError: When Purview API returns error:
|
|
533
|
+
- 400: Bad request (invalid parameters)
|
|
534
|
+
- 401: Unauthorized (authentication failed)
|
|
535
|
+
- 403: Forbidden (insufficient permissions)
|
|
536
|
+
- 404: Resource not found
|
|
537
|
+
- 429: Rate limit exceeded
|
|
538
|
+
- 500: Internal server error
|
|
539
|
+
|
|
540
|
+
NetworkError: When network connectivity fails
|
|
541
|
+
|
|
542
|
+
Example:
|
|
543
|
+
# Basic usage
|
|
544
|
+
client = EntityRelationship()
|
|
545
|
+
|
|
546
|
+
result = client.relationshipReadByEntity(args=...)
|
|
547
|
+
print(f"Result: {result}")
|
|
548
|
+
|
|
549
|
+
Use Cases:
|
|
550
|
+
- Data Discovery: Find and explore data assets
|
|
551
|
+
- Compliance Auditing: Review metadata and classifications
|
|
552
|
+
- Reporting: Generate catalog reports
|
|
553
|
+
"""
|
|
554
|
+
self.method = "GET"
|
|
555
|
+
self.endpoint = ENDPOINTS["relationship"]["get_relationships_by_entity"].format(guid=args["--entityGuid"])
|
|
556
|
+
self.params = {
|
|
557
|
+
**get_api_version_params("datamap"),
|
|
558
|
+
"relationshipType": args.get("--relationshipType"),
|
|
559
|
+
"direction": args.get("--direction", "BOTH"),
|
|
560
|
+
"status": args.get("--status", "ACTIVE"),
|
|
561
|
+
"limit": args.get("--limit", 100),
|
|
562
|
+
"offset": args.get("--offset", 0),
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
@decorator
|
|
566
|
+
def relationshipValidate(self, args):
|
|
567
|
+
"""
|
|
568
|
+
Perform operation on resource.
|
|
569
|
+
|
|
570
|
+
|
|
571
|
+
|
|
572
|
+
Args:
|
|
573
|
+
args: Dictionary of operation arguments.
|
|
574
|
+
Contains operation-specific parameters.
|
|
575
|
+
See method implementation for details.
|
|
576
|
+
|
|
577
|
+
Returns:
|
|
578
|
+
[TODO: Specify return type and structure]
|
|
579
|
+
[TODO: Document nested fields]
|
|
580
|
+
|
|
581
|
+
Raises:
|
|
582
|
+
ValueError: When required parameters are missing or invalid:
|
|
583
|
+
- Empty or None values for required fields
|
|
584
|
+
- Invalid GUID format
|
|
585
|
+
- Out-of-range values
|
|
586
|
+
|
|
587
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
588
|
+
- DefaultAzureCredential not configured
|
|
589
|
+
- Insufficient permissions
|
|
590
|
+
- Expired authentication token
|
|
591
|
+
|
|
592
|
+
HTTPError: When Purview API returns error:
|
|
593
|
+
- 400: Bad request (invalid parameters)
|
|
594
|
+
- 401: Unauthorized (authentication failed)
|
|
595
|
+
- 403: Forbidden (insufficient permissions)
|
|
596
|
+
- 404: Resource not found
|
|
597
|
+
- 429: Rate limit exceeded
|
|
598
|
+
- 500: Internal server error
|
|
599
|
+
|
|
600
|
+
NetworkError: When network connectivity fails
|
|
601
|
+
|
|
602
|
+
Example:
|
|
603
|
+
# Basic usage
|
|
604
|
+
client = Relationship()
|
|
605
|
+
|
|
606
|
+
result = client.relationshipValidate(args=...)
|
|
607
|
+
print(f"Result: {result}")
|
|
608
|
+
|
|
609
|
+
Use Cases:
|
|
610
|
+
- [TODO: Add specific use cases for this operation]
|
|
611
|
+
- [TODO: Include business context]
|
|
612
|
+
- [TODO: Explain when to use this method]
|
|
613
|
+
"""
|
|
614
|
+
self.method = "POST"
|
|
615
|
+
self.endpoint = ENDPOINTS["relationship"]["validate_relationship"]
|
|
616
|
+
self.params = get_api_version_params("datamap")
|
|
617
|
+
self.payload = get_json(args, "--payloadFile")
|
|
618
|
+
|
|
619
|
+
# === RELATIONSHIP ANALYTICS AND REPORTING ===
|
|
620
|
+
|
|
621
|
+
@decorator
|
|
622
|
+
def relationshipReadAnalytics(self, args):
|
|
623
|
+
"""
|
|
624
|
+
Retrieve relationship information.
|
|
625
|
+
|
|
626
|
+
Retrieves detailed information about the specified relationship.
|
|
627
|
+
Returns complete relationship metadata and properties.
|
|
628
|
+
|
|
629
|
+
Args:
|
|
630
|
+
args: Dictionary of operation arguments.
|
|
631
|
+
Contains operation-specific parameters.
|
|
632
|
+
See method implementation for details.
|
|
633
|
+
|
|
634
|
+
Returns:
|
|
635
|
+
Dictionary containing relationship information:
|
|
636
|
+
{
|
|
637
|
+
'guid': str, # Unique identifier
|
|
638
|
+
'name': str, # Resource name
|
|
639
|
+
'attributes': dict, # Resource attributes
|
|
640
|
+
'status': str, # Resource status
|
|
641
|
+
'updateTime': int # Last update timestamp
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
Raises:
|
|
645
|
+
ValueError: When required parameters are missing or invalid:
|
|
646
|
+
- Empty or None values for required fields
|
|
647
|
+
- Invalid GUID format
|
|
648
|
+
- Out-of-range values
|
|
649
|
+
|
|
650
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
651
|
+
- DefaultAzureCredential not configured
|
|
652
|
+
- Insufficient permissions
|
|
653
|
+
- Expired authentication token
|
|
654
|
+
|
|
655
|
+
HTTPError: When Purview API returns error:
|
|
656
|
+
- 400: Bad request (invalid parameters)
|
|
657
|
+
- 401: Unauthorized (authentication failed)
|
|
658
|
+
- 403: Forbidden (insufficient permissions)
|
|
659
|
+
- 404: Resource not found
|
|
660
|
+
- 429: Rate limit exceeded
|
|
661
|
+
- 500: Internal server error
|
|
662
|
+
|
|
663
|
+
NetworkError: When network connectivity fails
|
|
664
|
+
|
|
665
|
+
Example:
|
|
666
|
+
# Basic usage
|
|
667
|
+
client = Relationship()
|
|
668
|
+
|
|
669
|
+
result = client.relationshipReadAnalytics(args=...)
|
|
670
|
+
print(f"Result: {result}")
|
|
671
|
+
|
|
672
|
+
Use Cases:
|
|
673
|
+
- Data Discovery: Find and explore data assets
|
|
674
|
+
- Compliance Auditing: Review metadata and classifications
|
|
675
|
+
- Reporting: Generate catalog reports
|
|
676
|
+
"""
|
|
677
|
+
self.method = "GET"
|
|
678
|
+
self.endpoint = f"{ENDPOINTS['relationship']['get'].format(guid=args['--guid'])}/analytics"
|
|
679
|
+
self.params = {
|
|
680
|
+
**get_api_version_params("datamap"),
|
|
681
|
+
"startTime": args.get("--startTime"),
|
|
682
|
+
"endTime": args.get("--endTime"),
|
|
683
|
+
"metrics": args.get("--metrics", "all"),
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
@decorator
|
|
687
|
+
def relationshipReadStatistics(self, args):
|
|
688
|
+
"""
|
|
689
|
+
Retrieve relationship information.
|
|
690
|
+
|
|
691
|
+
Retrieves detailed information about the specified relationship.
|
|
692
|
+
Returns complete relationship metadata and properties.
|
|
693
|
+
|
|
694
|
+
Args:
|
|
695
|
+
args: Dictionary of operation arguments.
|
|
696
|
+
Contains operation-specific parameters.
|
|
697
|
+
See method implementation for details.
|
|
698
|
+
|
|
699
|
+
Returns:
|
|
700
|
+
Dictionary containing relationship information:
|
|
701
|
+
{
|
|
702
|
+
'guid': str, # Unique identifier
|
|
703
|
+
'name': str, # Resource name
|
|
704
|
+
'attributes': dict, # Resource attributes
|
|
705
|
+
'status': str, # Resource status
|
|
706
|
+
'updateTime': int # Last update timestamp
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
Raises:
|
|
710
|
+
ValueError: When required parameters are missing or invalid:
|
|
711
|
+
- Empty or None values for required fields
|
|
712
|
+
- Invalid GUID format
|
|
713
|
+
- Out-of-range values
|
|
714
|
+
|
|
715
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
716
|
+
- DefaultAzureCredential not configured
|
|
717
|
+
- Insufficient permissions
|
|
718
|
+
- Expired authentication token
|
|
719
|
+
|
|
720
|
+
HTTPError: When Purview API returns error:
|
|
721
|
+
- 400: Bad request (invalid parameters)
|
|
722
|
+
- 401: Unauthorized (authentication failed)
|
|
723
|
+
- 403: Forbidden (insufficient permissions)
|
|
724
|
+
- 404: Resource not found
|
|
725
|
+
- 429: Rate limit exceeded
|
|
726
|
+
- 500: Internal server error
|
|
727
|
+
|
|
728
|
+
NetworkError: When network connectivity fails
|
|
729
|
+
|
|
730
|
+
Example:
|
|
731
|
+
# Basic usage
|
|
732
|
+
client = Relationship()
|
|
733
|
+
|
|
734
|
+
result = client.relationshipReadStatistics(args=...)
|
|
735
|
+
print(f"Result: {result}")
|
|
736
|
+
|
|
737
|
+
Use Cases:
|
|
738
|
+
- Data Discovery: Find and explore data assets
|
|
739
|
+
- Compliance Auditing: Review metadata and classifications
|
|
740
|
+
- Reporting: Generate catalog reports
|
|
741
|
+
"""
|
|
742
|
+
self.method = "GET"
|
|
743
|
+
self.endpoint = f"{ENDPOINTS['relationship']['list_relationships']}/statistics"
|
|
744
|
+
self.params = {
|
|
745
|
+
**get_api_version_params("datamap"),
|
|
746
|
+
"relationshipType": args.get("--relationshipType"),
|
|
747
|
+
"groupBy": args.get("--groupBy", "type"),
|
|
748
|
+
"includeInactive": str(args.get("--includeInactive", False)).lower(),
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
# === RELATIONSHIP DISCOVERY AND SEARCH ===
|
|
752
|
+
|
|
753
|
+
@decorator
|
|
754
|
+
def relationshipSearch(self, args):
|
|
755
|
+
"""
|
|
756
|
+
Search for relationships.
|
|
757
|
+
|
|
758
|
+
Searches for resources matching the specified criteria.
|
|
759
|
+
Supports filtering, pagination, and sorting.
|
|
760
|
+
|
|
761
|
+
Args:
|
|
762
|
+
args: Dictionary of operation arguments.
|
|
763
|
+
Contains operation-specific parameters.
|
|
764
|
+
See method implementation for details.
|
|
765
|
+
|
|
766
|
+
Returns:
|
|
767
|
+
Dictionary containing search results:
|
|
768
|
+
{
|
|
769
|
+
'value': [...] # List of matching resources
|
|
770
|
+
'count': int, # Total results count
|
|
771
|
+
'nextLink': str # Pagination link (if applicable)
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
Raises:
|
|
775
|
+
ValueError: When required parameters are missing or invalid:
|
|
776
|
+
- Empty or None values for required fields
|
|
777
|
+
- Invalid GUID format
|
|
778
|
+
- Out-of-range values
|
|
779
|
+
|
|
780
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
781
|
+
- DefaultAzureCredential not configured
|
|
782
|
+
- Insufficient permissions
|
|
783
|
+
- Expired authentication token
|
|
784
|
+
|
|
785
|
+
HTTPError: When Purview API returns error:
|
|
786
|
+
- 400: Bad request (invalid parameters)
|
|
787
|
+
- 401: Unauthorized (authentication failed)
|
|
788
|
+
- 403: Forbidden (insufficient permissions)
|
|
789
|
+
- 404: Resource not found
|
|
790
|
+
- 429: Rate limit exceeded
|
|
791
|
+
- 500: Internal server error
|
|
792
|
+
|
|
793
|
+
NetworkError: When network connectivity fails
|
|
794
|
+
|
|
795
|
+
Example:
|
|
796
|
+
# Basic usage
|
|
797
|
+
client = Relationship()
|
|
798
|
+
|
|
799
|
+
result = client.relationshipSearch(args=...)
|
|
800
|
+
print(f"Result: {result}")
|
|
801
|
+
|
|
802
|
+
Use Cases:
|
|
803
|
+
- Data Discovery: Locate datasets by name or properties
|
|
804
|
+
- Impact Analysis: Find all assets related to a term
|
|
805
|
+
- Compliance: Identify sensitive data across catalog
|
|
806
|
+
"""
|
|
807
|
+
self.method = "GET"
|
|
808
|
+
self.endpoint = f"{ENDPOINTS['relationship']['list_relationships']}/search"
|
|
809
|
+
self.params = {
|
|
810
|
+
**get_api_version_params("datamap"),
|
|
811
|
+
"query": args.get("--query"),
|
|
812
|
+
"relationshipType": args.get("--relationshipType"),
|
|
813
|
+
"entityType": args.get("--entityType"),
|
|
814
|
+
"status": args.get("--status"),
|
|
815
|
+
"limit": args.get("--limit", 50),
|
|
816
|
+
"offset": args.get("--offset", 0),
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
@decorator
|
|
820
|
+
def relationshipReadByType(self, args):
|
|
821
|
+
"""
|
|
822
|
+
Retrieve relationship information.
|
|
823
|
+
|
|
824
|
+
Retrieves detailed information about the specified relationship.
|
|
825
|
+
Returns complete relationship metadata and properties.
|
|
826
|
+
|
|
827
|
+
Args:
|
|
828
|
+
args: Dictionary of operation arguments.
|
|
829
|
+
Contains operation-specific parameters.
|
|
830
|
+
See method implementation for details.
|
|
831
|
+
|
|
832
|
+
Returns:
|
|
833
|
+
Dictionary containing relationship information:
|
|
834
|
+
{
|
|
835
|
+
'guid': str, # Unique identifier
|
|
836
|
+
'name': str, # Resource name
|
|
837
|
+
'attributes': dict, # Resource attributes
|
|
838
|
+
'status': str, # Resource status
|
|
839
|
+
'updateTime': int # Last update timestamp
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
Raises:
|
|
843
|
+
ValueError: When required parameters are missing or invalid:
|
|
844
|
+
- Empty or None values for required fields
|
|
845
|
+
- Invalid GUID format
|
|
846
|
+
- Out-of-range values
|
|
847
|
+
|
|
848
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
849
|
+
- DefaultAzureCredential not configured
|
|
850
|
+
- Insufficient permissions
|
|
851
|
+
- Expired authentication token
|
|
852
|
+
|
|
853
|
+
HTTPError: When Purview API returns error:
|
|
854
|
+
- 400: Bad request (invalid parameters)
|
|
855
|
+
- 401: Unauthorized (authentication failed)
|
|
856
|
+
- 403: Forbidden (insufficient permissions)
|
|
857
|
+
- 404: Resource not found
|
|
858
|
+
- 429: Rate limit exceeded
|
|
859
|
+
- 500: Internal server error
|
|
860
|
+
|
|
861
|
+
NetworkError: When network connectivity fails
|
|
862
|
+
|
|
863
|
+
Example:
|
|
864
|
+
# Basic usage
|
|
865
|
+
client = Relationship()
|
|
866
|
+
|
|
867
|
+
result = client.relationshipReadByType(args=...)
|
|
868
|
+
print(f"Result: {result}")
|
|
869
|
+
|
|
870
|
+
Use Cases:
|
|
871
|
+
- Data Discovery: Find and explore data assets
|
|
872
|
+
- Compliance Auditing: Review metadata and classifications
|
|
873
|
+
- Reporting: Generate catalog reports
|
|
874
|
+
"""
|
|
875
|
+
self.method = "GET"
|
|
876
|
+
self.endpoint = f"{ENDPOINTS['relationship']['list_relationships']}/type/{args['--relationshipType']}"
|
|
877
|
+
self.params = {
|
|
878
|
+
**get_api_version_params("datamap"),
|
|
879
|
+
"status": args.get("--status", "ACTIVE"),
|
|
880
|
+
"includeMetadata": str(args.get("--includeMetadata", True)).lower(),
|
|
881
|
+
"limit": args.get("--limit", 100),
|
|
882
|
+
"offset": args.get("--offset", 0),
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
# === RELATIONSHIP IMPORT/EXPORT ===
|
|
886
|
+
|
|
887
|
+
@decorator
|
|
888
|
+
def relationshipExport(self, args):
|
|
889
|
+
"""
|
|
890
|
+
Perform batch operation on resources.
|
|
891
|
+
|
|
892
|
+
Processes multiple resources in a single operation.
|
|
893
|
+
More efficient than individual operations for bulk data.
|
|
894
|
+
|
|
895
|
+
Args:
|
|
896
|
+
args: Dictionary of operation arguments.
|
|
897
|
+
Contains operation-specific parameters.
|
|
898
|
+
See method implementation for details.
|
|
899
|
+
|
|
900
|
+
Returns:
|
|
901
|
+
Dictionary with batch operation results:
|
|
902
|
+
{
|
|
903
|
+
'succeeded': int, # Success count
|
|
904
|
+
'failed': int, # Failure count
|
|
905
|
+
'results': [...], # Per-item results
|
|
906
|
+
'errors': [...] # Error details
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
Raises:
|
|
910
|
+
ValueError: When required parameters are missing or invalid:
|
|
911
|
+
- Empty or None values for required fields
|
|
912
|
+
- Invalid GUID format
|
|
913
|
+
- Out-of-range values
|
|
914
|
+
|
|
915
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
916
|
+
- DefaultAzureCredential not configured
|
|
917
|
+
- Insufficient permissions
|
|
918
|
+
- Expired authentication token
|
|
919
|
+
|
|
920
|
+
HTTPError: When Purview API returns error:
|
|
921
|
+
- 400: Bad request (invalid parameters)
|
|
922
|
+
- 401: Unauthorized (authentication failed)
|
|
923
|
+
- 403: Forbidden (insufficient permissions)
|
|
924
|
+
- 404: Resource not found
|
|
925
|
+
- 429: Rate limit exceeded
|
|
926
|
+
- 500: Internal server error
|
|
927
|
+
|
|
928
|
+
NetworkError: When network connectivity fails
|
|
929
|
+
|
|
930
|
+
Example:
|
|
931
|
+
# Basic usage
|
|
932
|
+
client = Relationship()
|
|
933
|
+
|
|
934
|
+
result = client.relationshipExport(args=...)
|
|
935
|
+
print(f"Result: {result}")
|
|
936
|
+
|
|
937
|
+
Use Cases:
|
|
938
|
+
- Bulk Import: Load large volumes of metadata
|
|
939
|
+
- Migration: Transfer catalog from other systems
|
|
940
|
+
- Mass Updates: Apply changes to many resources
|
|
941
|
+
"""
|
|
942
|
+
self.method = "POST"
|
|
943
|
+
self.endpoint = f"{ENDPOINTS['relationship']['list_relationships']}/export"
|
|
944
|
+
self.params = {
|
|
945
|
+
**get_api_version_params("datamap"),
|
|
946
|
+
"relationshipType": args.get("--relationshipType"),
|
|
947
|
+
"entityGuids": args.get("--entityGuids"),
|
|
948
|
+
"format": args.get("--format", "json"),
|
|
949
|
+
"includeInactive": str(args.get("--includeInactive", False)).lower(),
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
@decorator
|
|
953
|
+
def relationshipImport(self, args):
|
|
954
|
+
"""
|
|
955
|
+
Perform batch operation on resources.
|
|
956
|
+
|
|
957
|
+
Processes multiple resources in a single operation.
|
|
958
|
+
More efficient than individual operations for bulk data.
|
|
959
|
+
|
|
960
|
+
Args:
|
|
961
|
+
args: Dictionary of operation arguments.
|
|
962
|
+
Contains operation-specific parameters.
|
|
963
|
+
See method implementation for details.
|
|
964
|
+
|
|
965
|
+
Returns:
|
|
966
|
+
Dictionary with batch operation results:
|
|
967
|
+
{
|
|
968
|
+
'succeeded': int, # Success count
|
|
969
|
+
'failed': int, # Failure count
|
|
970
|
+
'results': [...], # Per-item results
|
|
971
|
+
'errors': [...] # Error details
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
Raises:
|
|
975
|
+
ValueError: When required parameters are missing or invalid:
|
|
976
|
+
- Empty or None values for required fields
|
|
977
|
+
- Invalid GUID format
|
|
978
|
+
- Out-of-range values
|
|
979
|
+
|
|
980
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
981
|
+
- DefaultAzureCredential not configured
|
|
982
|
+
- Insufficient permissions
|
|
983
|
+
- Expired authentication token
|
|
984
|
+
|
|
985
|
+
HTTPError: When Purview API returns error:
|
|
986
|
+
- 400: Bad request (invalid parameters)
|
|
987
|
+
- 401: Unauthorized (authentication failed)
|
|
988
|
+
- 403: Forbidden (insufficient permissions)
|
|
989
|
+
- 404: Resource not found
|
|
990
|
+
- 429: Rate limit exceeded
|
|
991
|
+
- 500: Internal server error
|
|
992
|
+
|
|
993
|
+
NetworkError: When network connectivity fails
|
|
994
|
+
|
|
995
|
+
Example:
|
|
996
|
+
# Basic usage
|
|
997
|
+
client = Relationship()
|
|
998
|
+
|
|
999
|
+
result = client.relationshipImport(args=...)
|
|
1000
|
+
print(f"Result: {result}")
|
|
1001
|
+
|
|
1002
|
+
Use Cases:
|
|
1003
|
+
- Bulk Import: Load large volumes of metadata
|
|
1004
|
+
- Migration: Transfer catalog from other systems
|
|
1005
|
+
- Mass Updates: Apply changes to many resources
|
|
1006
|
+
"""
|
|
1007
|
+
self.method = "POST"
|
|
1008
|
+
self.endpoint = f"{ENDPOINTS['relationship']['list_relationships']}/import"
|
|
1009
|
+
self.params = {
|
|
1010
|
+
**get_api_version_params("datamap"),
|
|
1011
|
+
"validateOnly": str(args.get("--validateOnly", False)).lower(),
|
|
1012
|
+
"overwriteExisting": str(args.get("--overwriteExisting", False)).lower(),
|
|
1013
|
+
}
|
|
1014
|
+
self.payload = get_json(args, "--payloadFile")
|
|
1015
|
+
|
|
1016
|
+
# === RELATIONSHIP LINEAGE OPERATIONS ===
|
|
1017
|
+
|
|
1018
|
+
@decorator
|
|
1019
|
+
def relationshipReadLineage(self, args):
|
|
1020
|
+
"""
|
|
1021
|
+
Retrieve relationship information.
|
|
1022
|
+
|
|
1023
|
+
Retrieves detailed information about the specified relationship.
|
|
1024
|
+
Returns complete relationship metadata and properties.
|
|
1025
|
+
|
|
1026
|
+
Args:
|
|
1027
|
+
args: Dictionary of operation arguments.
|
|
1028
|
+
Contains operation-specific parameters.
|
|
1029
|
+
See method implementation for details.
|
|
1030
|
+
|
|
1031
|
+
Returns:
|
|
1032
|
+
Dictionary containing relationship information:
|
|
1033
|
+
{
|
|
1034
|
+
'guid': str, # Unique identifier
|
|
1035
|
+
'name': str, # Resource name
|
|
1036
|
+
'attributes': dict, # Resource attributes
|
|
1037
|
+
'status': str, # Resource status
|
|
1038
|
+
'updateTime': int # Last update timestamp
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
Raises:
|
|
1042
|
+
ValueError: When required parameters are missing or invalid:
|
|
1043
|
+
- Empty or None values for required fields
|
|
1044
|
+
- Invalid GUID format
|
|
1045
|
+
- Out-of-range values
|
|
1046
|
+
|
|
1047
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
1048
|
+
- DefaultAzureCredential not configured
|
|
1049
|
+
- Insufficient permissions
|
|
1050
|
+
- Expired authentication token
|
|
1051
|
+
|
|
1052
|
+
HTTPError: When Purview API returns error:
|
|
1053
|
+
- 400: Bad request (invalid parameters)
|
|
1054
|
+
- 401: Unauthorized (authentication failed)
|
|
1055
|
+
- 403: Forbidden (insufficient permissions)
|
|
1056
|
+
- 404: Resource not found
|
|
1057
|
+
- 429: Rate limit exceeded
|
|
1058
|
+
- 500: Internal server error
|
|
1059
|
+
|
|
1060
|
+
NetworkError: When network connectivity fails
|
|
1061
|
+
|
|
1062
|
+
Example:
|
|
1063
|
+
# Basic usage
|
|
1064
|
+
client = LineageRelationship()
|
|
1065
|
+
|
|
1066
|
+
result = client.relationshipReadLineage(args=...)
|
|
1067
|
+
print(f"Result: {result}")
|
|
1068
|
+
|
|
1069
|
+
Use Cases:
|
|
1070
|
+
- Data Discovery: Find and explore data assets
|
|
1071
|
+
- Compliance Auditing: Review metadata and classifications
|
|
1072
|
+
- Reporting: Generate catalog reports
|
|
1073
|
+
"""
|
|
1074
|
+
self.method = "GET"
|
|
1075
|
+
self.endpoint = f"{ENDPOINTS['relationship']['get'].format(guid=args['--guid'])}/lineage"
|
|
1076
|
+
self.params = {
|
|
1077
|
+
**get_api_version_params("datamap"),
|
|
1078
|
+
"direction": args.get("--direction", "BOTH"),
|
|
1079
|
+
"depth": args.get("--depth", 3),
|
|
1080
|
+
"includeParent": str(args.get("--includeParent", False)).lower(),
|
|
1081
|
+
}
|
|
1082
|
+
|
|
1083
|
+
@decorator
|
|
1084
|
+
def relationshipReadImpact(self, args):
|
|
1085
|
+
"""
|
|
1086
|
+
Retrieve relationship information.
|
|
1087
|
+
|
|
1088
|
+
Retrieves detailed information about the specified relationship.
|
|
1089
|
+
Returns complete relationship metadata and properties.
|
|
1090
|
+
|
|
1091
|
+
Args:
|
|
1092
|
+
args: Dictionary of operation arguments.
|
|
1093
|
+
Contains operation-specific parameters.
|
|
1094
|
+
See method implementation for details.
|
|
1095
|
+
|
|
1096
|
+
Returns:
|
|
1097
|
+
Dictionary containing relationship information:
|
|
1098
|
+
{
|
|
1099
|
+
'guid': str, # Unique identifier
|
|
1100
|
+
'name': str, # Resource name
|
|
1101
|
+
'attributes': dict, # Resource attributes
|
|
1102
|
+
'status': str, # Resource status
|
|
1103
|
+
'updateTime': int # Last update timestamp
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
Raises:
|
|
1107
|
+
ValueError: When required parameters are missing or invalid:
|
|
1108
|
+
- Empty or None values for required fields
|
|
1109
|
+
- Invalid GUID format
|
|
1110
|
+
- Out-of-range values
|
|
1111
|
+
|
|
1112
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
1113
|
+
- DefaultAzureCredential not configured
|
|
1114
|
+
- Insufficient permissions
|
|
1115
|
+
- Expired authentication token
|
|
1116
|
+
|
|
1117
|
+
HTTPError: When Purview API returns error:
|
|
1118
|
+
- 400: Bad request (invalid parameters)
|
|
1119
|
+
- 401: Unauthorized (authentication failed)
|
|
1120
|
+
- 403: Forbidden (insufficient permissions)
|
|
1121
|
+
- 404: Resource not found
|
|
1122
|
+
- 429: Rate limit exceeded
|
|
1123
|
+
- 500: Internal server error
|
|
1124
|
+
|
|
1125
|
+
NetworkError: When network connectivity fails
|
|
1126
|
+
|
|
1127
|
+
Example:
|
|
1128
|
+
# Basic usage
|
|
1129
|
+
client = Relationship()
|
|
1130
|
+
|
|
1131
|
+
result = client.relationshipReadImpact(args=...)
|
|
1132
|
+
print(f"Result: {result}")
|
|
1133
|
+
|
|
1134
|
+
Use Cases:
|
|
1135
|
+
- Data Discovery: Find and explore data assets
|
|
1136
|
+
- Compliance Auditing: Review metadata and classifications
|
|
1137
|
+
- Reporting: Generate catalog reports
|
|
1138
|
+
"""
|
|
1139
|
+
self.method = "GET"
|
|
1140
|
+
self.endpoint = f"{ENDPOINTS['relationship']['get'].format(guid=args['--guid'])}/impact"
|
|
1141
|
+
self.params = {
|
|
1142
|
+
**get_api_version_params("datamap"),
|
|
1143
|
+
"direction": args.get("--direction", "DOWNSTREAM"),
|
|
1144
|
+
"depth": args.get("--depth", 5),
|
|
1145
|
+
"analysisType": args.get("--analysisType", "IMPACT"),
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
# === LEGACY COMPATIBILITY METHODS ===
|
|
1149
|
+
|
|
1150
|
+
@decorator
|
|
1151
|
+
def relationshipReadByGuid(self, args):
|
|
1152
|
+
"""
|
|
1153
|
+
Retrieve relationship information.
|
|
1154
|
+
|
|
1155
|
+
Retrieves detailed information about the specified relationship.
|
|
1156
|
+
Returns complete relationship metadata and properties.
|
|
1157
|
+
|
|
1158
|
+
Args:
|
|
1159
|
+
args: Dictionary of operation arguments.
|
|
1160
|
+
Contains operation-specific parameters.
|
|
1161
|
+
See method implementation for details.
|
|
1162
|
+
|
|
1163
|
+
Returns:
|
|
1164
|
+
Dictionary containing relationship information:
|
|
1165
|
+
{
|
|
1166
|
+
'guid': str, # Unique identifier
|
|
1167
|
+
'name': str, # Resource name
|
|
1168
|
+
'attributes': dict, # Resource attributes
|
|
1169
|
+
'status': str, # Resource status
|
|
1170
|
+
'updateTime': int # Last update timestamp
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
Raises:
|
|
1174
|
+
ValueError: When required parameters are missing or invalid:
|
|
1175
|
+
- Empty or None values for required fields
|
|
1176
|
+
- Invalid GUID format
|
|
1177
|
+
- Out-of-range values
|
|
1178
|
+
|
|
1179
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
1180
|
+
- DefaultAzureCredential not configured
|
|
1181
|
+
- Insufficient permissions
|
|
1182
|
+
- Expired authentication token
|
|
1183
|
+
|
|
1184
|
+
HTTPError: When Purview API returns error:
|
|
1185
|
+
- 400: Bad request (invalid parameters)
|
|
1186
|
+
- 401: Unauthorized (authentication failed)
|
|
1187
|
+
- 403: Forbidden (insufficient permissions)
|
|
1188
|
+
- 404: Resource not found
|
|
1189
|
+
- 429: Rate limit exceeded
|
|
1190
|
+
- 500: Internal server error
|
|
1191
|
+
|
|
1192
|
+
NetworkError: When network connectivity fails
|
|
1193
|
+
|
|
1194
|
+
Example:
|
|
1195
|
+
# Basic usage
|
|
1196
|
+
client = Relationship()
|
|
1197
|
+
|
|
1198
|
+
result = client.relationshipReadByGuid(args=...)
|
|
1199
|
+
print(f"Result: {result}")
|
|
1200
|
+
|
|
1201
|
+
Use Cases:
|
|
1202
|
+
- Data Discovery: Find and explore data assets
|
|
1203
|
+
- Compliance Auditing: Review metadata and classifications
|
|
1204
|
+
- Reporting: Generate catalog reports
|
|
1205
|
+
"""
|
|
1206
|
+
return self.relationshipRead(args)
|
|
1207
|
+
|
|
1208
|
+
@decorator
|
|
1209
|
+
def relationshipCreateOrUpdate(self, args):
|
|
1210
|
+
"""
|
|
1211
|
+
Create a new relationship.
|
|
1212
|
+
|
|
1213
|
+
Creates a new relationship in Microsoft Purview Relationships. Define connections between entities.
|
|
1214
|
+
Requires appropriate permissions and valid relationship definition.
|
|
1215
|
+
|
|
1216
|
+
Args:
|
|
1217
|
+
args: Dictionary of operation arguments.
|
|
1218
|
+
Contains operation-specific parameters.
|
|
1219
|
+
See method implementation for details.
|
|
1220
|
+
|
|
1221
|
+
Returns:
|
|
1222
|
+
Dictionary containing created relationship:
|
|
1223
|
+
{
|
|
1224
|
+
'guid': str, # Unique identifier
|
|
1225
|
+
'name': str, # Resource name
|
|
1226
|
+
'status': str, # Creation status
|
|
1227
|
+
'attributes': dict, # Resource attributes
|
|
1228
|
+
'createTime': int # Creation timestamp
|
|
1229
|
+
}
|
|
1230
|
+
|
|
1231
|
+
Raises:
|
|
1232
|
+
ValueError: When required parameters are missing or invalid:
|
|
1233
|
+
- Empty or None values for required fields
|
|
1234
|
+
- Invalid GUID format
|
|
1235
|
+
- Out-of-range values
|
|
1236
|
+
|
|
1237
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
1238
|
+
- DefaultAzureCredential not configured
|
|
1239
|
+
- Insufficient permissions
|
|
1240
|
+
- Expired authentication token
|
|
1241
|
+
|
|
1242
|
+
HTTPError: When Purview API returns error:
|
|
1243
|
+
- 400: Bad request (invalid parameters)
|
|
1244
|
+
- 401: Unauthorized (authentication failed)
|
|
1245
|
+
- 403: Forbidden (insufficient permissions)
|
|
1246
|
+
- 404: Resource not found
|
|
1247
|
+
- 409: Conflict (resource already exists)
|
|
1248
|
+
- 429: Rate limit exceeded
|
|
1249
|
+
- 500: Internal server error
|
|
1250
|
+
|
|
1251
|
+
NetworkError: When network connectivity fails
|
|
1252
|
+
|
|
1253
|
+
Example:
|
|
1254
|
+
# Basic usage
|
|
1255
|
+
client = Relationship()
|
|
1256
|
+
|
|
1257
|
+
result = client.relationshipCreateOrUpdate(args=...)
|
|
1258
|
+
print(f"Result: {result}")
|
|
1259
|
+
|
|
1260
|
+
# With detailed data
|
|
1261
|
+
data = {
|
|
1262
|
+
'name': 'My Resource',
|
|
1263
|
+
'description': 'Resource description',
|
|
1264
|
+
'attributes': {
|
|
1265
|
+
'key1': 'value1',
|
|
1266
|
+
'key2': 'value2'
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
result = client.relationshipCreateOrUpdate(data)
|
|
1271
|
+
print(f"Created/Updated: {result['guid']}")
|
|
1272
|
+
|
|
1273
|
+
Use Cases:
|
|
1274
|
+
- Data Onboarding: Register new data sources in catalog
|
|
1275
|
+
- Metadata Management: Add descriptive metadata to assets
|
|
1276
|
+
- Automation: Programmatically populate catalog
|
|
1277
|
+
"""
|
|
1278
|
+
payload = get_json(args, "--payloadFile")
|
|
1279
|
+
if payload.get("guid"):
|
|
1280
|
+
return self.relationshipUpdate(args)
|
|
1281
|
+
else:
|
|
1282
|
+
return self.relationshipCreate(args)
|
|
1283
|
+
|
|
1284
|
+
@decorator
|
|
1285
|
+
def relationshipPut(self, args):
|
|
1286
|
+
"""
|
|
1287
|
+
Update an existing relationship.
|
|
1288
|
+
|
|
1289
|
+
Updates an existing relationship with new values.
|
|
1290
|
+
Only specified fields are modified; others remain unchanged.
|
|
1291
|
+
|
|
1292
|
+
Args:
|
|
1293
|
+
args: Dictionary of operation arguments.
|
|
1294
|
+
Contains operation-specific parameters.
|
|
1295
|
+
See method implementation for details.
|
|
1296
|
+
|
|
1297
|
+
Returns:
|
|
1298
|
+
Dictionary containing updated relationship:
|
|
1299
|
+
{
|
|
1300
|
+
'guid': str, # Unique identifier
|
|
1301
|
+
'attributes': dict, # Updated attributes
|
|
1302
|
+
'updateTime': int # Update timestamp
|
|
1303
|
+
}
|
|
1304
|
+
|
|
1305
|
+
Raises:
|
|
1306
|
+
ValueError: When required parameters are missing or invalid:
|
|
1307
|
+
- Empty or None values for required fields
|
|
1308
|
+
- Invalid GUID format
|
|
1309
|
+
- Out-of-range values
|
|
1310
|
+
|
|
1311
|
+
AuthenticationError: When Azure credentials are invalid:
|
|
1312
|
+
- DefaultAzureCredential not configured
|
|
1313
|
+
- Insufficient permissions
|
|
1314
|
+
- Expired authentication token
|
|
1315
|
+
|
|
1316
|
+
HTTPError: When Purview API returns error:
|
|
1317
|
+
- 400: Bad request (invalid parameters)
|
|
1318
|
+
- 401: Unauthorized (authentication failed)
|
|
1319
|
+
- 403: Forbidden (insufficient permissions)
|
|
1320
|
+
- 404: Resource not found
|
|
1321
|
+
- 429: Rate limit exceeded
|
|
1322
|
+
- 500: Internal server error
|
|
1323
|
+
|
|
1324
|
+
NetworkError: When network connectivity fails
|
|
1325
|
+
|
|
1326
|
+
Example:
|
|
1327
|
+
# Basic usage
|
|
1328
|
+
client = Relationship()
|
|
1329
|
+
|
|
1330
|
+
result = client.relationshipPut(args=...)
|
|
1331
|
+
print(f"Result: {result}")
|
|
1332
|
+
|
|
1333
|
+
# With detailed data
|
|
1334
|
+
data = {
|
|
1335
|
+
'name': 'My Resource',
|
|
1336
|
+
'description': 'Resource description',
|
|
1337
|
+
'attributes': {
|
|
1338
|
+
'key1': 'value1',
|
|
1339
|
+
'key2': 'value2'
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
result = client.relationshipPut(data)
|
|
1344
|
+
print(f"Created/Updated: {result['guid']}")
|
|
1345
|
+
|
|
1346
|
+
Use Cases:
|
|
1347
|
+
- Metadata Enrichment: Update descriptions and tags
|
|
1348
|
+
- Ownership Changes: Reassign data ownership
|
|
1349
|
+
- Classification: Apply or modify data classifications
|
|
1350
|
+
"""
|
|
1351
|
+
return self.relationshipUpdate(args)
|