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,533 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Manage Purview glossaries, categories, and terms using modular Click-based commands.
|
|
3
|
+
|
|
4
|
+
Usage:
|
|
5
|
+
glossary create Create a new glossary
|
|
6
|
+
glossary create-categories Create multiple glossary categories
|
|
7
|
+
glossary create-category Create a glossary category
|
|
8
|
+
glossary create-term Create a glossary term
|
|
9
|
+
glossary create-terms Create multiple glossary terms
|
|
10
|
+
glossary delete Delete a glossary
|
|
11
|
+
glossary delete-category Delete a glossary category
|
|
12
|
+
glossary delete-term Delete a glossary term
|
|
13
|
+
glossary put Update a glossary
|
|
14
|
+
glossary put-category Update a glossary category
|
|
15
|
+
glossary put-term Update a glossary term
|
|
16
|
+
glossary read or list Read glossaries
|
|
17
|
+
glossary read-categories Read glossary categories
|
|
18
|
+
glossary read-category Read a glossary category
|
|
19
|
+
glossary read-term Read a glossary term
|
|
20
|
+
glossary read-terms Read all terms in a glossary
|
|
21
|
+
glossary list-terms List all terms in a glossary (alias)
|
|
22
|
+
glossary --help Show this help message and exit
|
|
23
|
+
|
|
24
|
+
Options:
|
|
25
|
+
-h --help Show this help message and exit
|
|
26
|
+
"""
|
|
27
|
+
import click
|
|
28
|
+
import json
|
|
29
|
+
from rich.console import Console
|
|
30
|
+
from purviewcli.client._glossary import Glossary
|
|
31
|
+
|
|
32
|
+
console = Console()
|
|
33
|
+
|
|
34
|
+
@click.group()
|
|
35
|
+
def glossary():
|
|
36
|
+
"""Manage Purview glossaries, categories, and terms
|
|
37
|
+
"""
|
|
38
|
+
pass
|
|
39
|
+
|
|
40
|
+
# === CREATE OPERATIONS ===
|
|
41
|
+
|
|
42
|
+
@glossary.command()
|
|
43
|
+
@click.option('--payload-file', required=True, type=click.Path(exists=True), help='Path to JSON file with glossary data')
|
|
44
|
+
def create(payload_file):
|
|
45
|
+
"""Create a new glossary"""
|
|
46
|
+
try:
|
|
47
|
+
client = Glossary()
|
|
48
|
+
args = {'--payloadFile': payload_file}
|
|
49
|
+
result = client.glossaryCreate(args)
|
|
50
|
+
console.print(json.dumps(result, indent=2))
|
|
51
|
+
except Exception as e:
|
|
52
|
+
console.print(f"[red][X] Error: {e}[/red]")
|
|
53
|
+
|
|
54
|
+
@glossary.command()
|
|
55
|
+
@click.option('--payload-file', required=True, type=click.Path(exists=True), help='Path to JSON file with categories data')
|
|
56
|
+
def create_categories(payload_file):
|
|
57
|
+
"""Create multiple glossary categories"""
|
|
58
|
+
try:
|
|
59
|
+
client = Glossary()
|
|
60
|
+
args = {'--payloadFile': payload_file}
|
|
61
|
+
result = client.glossaryCreateCategories(args)
|
|
62
|
+
console.print(json.dumps(result, indent=2))
|
|
63
|
+
except Exception as e:
|
|
64
|
+
console.print(f"[red][X] Error: {e}[/red]")
|
|
65
|
+
|
|
66
|
+
@glossary.command()
|
|
67
|
+
@click.option('--payload-file', required=True, type=click.Path(exists=True), help='Path to JSON file with category data')
|
|
68
|
+
def create_category(payload_file):
|
|
69
|
+
"""Create a single glossary category"""
|
|
70
|
+
try:
|
|
71
|
+
client = Glossary()
|
|
72
|
+
args = {'--payloadFile': payload_file}
|
|
73
|
+
result = client.glossaryCreateCategory(args)
|
|
74
|
+
console.print(json.dumps(result, indent=2))
|
|
75
|
+
except Exception as e:
|
|
76
|
+
console.print(f"[red][X] Error: {e}[/red]")
|
|
77
|
+
|
|
78
|
+
@glossary.command()
|
|
79
|
+
@click.option('--payload-file', required=True, type=click.Path(exists=True), help='Path to JSON file with term data')
|
|
80
|
+
@click.option('--include-term-hierarchy', is_flag=True, help='Include term hierarchy in creation')
|
|
81
|
+
def create_term(payload_file, include_term_hierarchy):
|
|
82
|
+
"""Create a single glossary term"""
|
|
83
|
+
try:
|
|
84
|
+
client = Glossary()
|
|
85
|
+
args = {'--payloadFile': payload_file, '--includeTermHierarchy': include_term_hierarchy}
|
|
86
|
+
result = client.glossaryCreateTerm(args)
|
|
87
|
+
console.print(json.dumps(result, indent=2))
|
|
88
|
+
except Exception as e:
|
|
89
|
+
console.print(f"[red][X] Error: {e}[/red]")
|
|
90
|
+
|
|
91
|
+
@glossary.command()
|
|
92
|
+
@click.option('--payload-file', required=True, type=click.Path(exists=True), help='Path to JSON file with terms data')
|
|
93
|
+
@click.option('--include-term-hierarchy', is_flag=True, help='Include term hierarchy in creation')
|
|
94
|
+
def create_terms(payload_file, include_term_hierarchy):
|
|
95
|
+
"""Create multiple glossary terms"""
|
|
96
|
+
try:
|
|
97
|
+
client = Glossary()
|
|
98
|
+
args = {'--payloadFile': payload_file, '--includeTermHierarchy': include_term_hierarchy}
|
|
99
|
+
result = client.glossaryCreateTerms(args)
|
|
100
|
+
console.print(json.dumps(result, indent=2))
|
|
101
|
+
except Exception as e:
|
|
102
|
+
console.print(f"[red][X] Error: {e}[/red]")
|
|
103
|
+
|
|
104
|
+
# === DELETE OPERATIONS ===
|
|
105
|
+
|
|
106
|
+
@glossary.command()
|
|
107
|
+
@click.option('--glossary-guid', required=True, help='The globally unique identifier for glossary')
|
|
108
|
+
def delete(glossary_guid):
|
|
109
|
+
"""Delete a glossary"""
|
|
110
|
+
try:
|
|
111
|
+
client = Glossary()
|
|
112
|
+
args = {'--glossaryGuid': glossary_guid}
|
|
113
|
+
result = client.glossaryDelete(args)
|
|
114
|
+
console.print(json.dumps(result, indent=2))
|
|
115
|
+
except Exception as e:
|
|
116
|
+
console.print(f"[red][X] Error: {e}[/red]")
|
|
117
|
+
|
|
118
|
+
@glossary.command()
|
|
119
|
+
@click.option('--category-guid', required=True, help='The globally unique identifier of the category')
|
|
120
|
+
def delete_category(category_guid):
|
|
121
|
+
"""Delete a glossary category"""
|
|
122
|
+
try:
|
|
123
|
+
client = Glossary()
|
|
124
|
+
args = {'--categoryGuid': category_guid}
|
|
125
|
+
result = client.glossaryDeleteCategory(args)
|
|
126
|
+
console.print(json.dumps(result, indent=2))
|
|
127
|
+
except Exception as e:
|
|
128
|
+
console.print(f"[red][X] Error: {e}[/red]")
|
|
129
|
+
|
|
130
|
+
@glossary.command()
|
|
131
|
+
@click.option('--term-guid', required=True, help='The globally unique identifier for glossary term')
|
|
132
|
+
def delete_term(term_guid):
|
|
133
|
+
"""Delete a glossary term"""
|
|
134
|
+
try:
|
|
135
|
+
client = Glossary()
|
|
136
|
+
args = {'--termGuid': term_guid}
|
|
137
|
+
result = client.glossaryDeleteTerm(args)
|
|
138
|
+
console.print(json.dumps(result, indent=2))
|
|
139
|
+
except Exception as e:
|
|
140
|
+
console.print(f"[red][X] Error: {e}[/red]")
|
|
141
|
+
|
|
142
|
+
# === PUT OPERATIONS ===
|
|
143
|
+
|
|
144
|
+
@glossary.command()
|
|
145
|
+
@click.option('--glossary-guid', required=True, help='The globally unique identifier for glossary')
|
|
146
|
+
@click.option('--payload-file', required=True, type=click.Path(exists=True), help='Path to JSON file with updated glossary data')
|
|
147
|
+
def put(glossary_guid, payload_file):
|
|
148
|
+
"""Update a glossary"""
|
|
149
|
+
try:
|
|
150
|
+
client = Glossary()
|
|
151
|
+
args = {'--glossaryGuid': glossary_guid, '--payloadFile': payload_file}
|
|
152
|
+
result = client.glossaryPut(args)
|
|
153
|
+
console.print(json.dumps(result, indent=2))
|
|
154
|
+
except Exception as e:
|
|
155
|
+
console.print(f"[red][X] Error: {e}[/red]")
|
|
156
|
+
|
|
157
|
+
@glossary.command()
|
|
158
|
+
@click.option('--category-guid', required=True, help='The globally unique identifier of the category')
|
|
159
|
+
@click.option('--payload-file', required=True, type=click.Path(exists=True), help='Path to JSON file with updated category data')
|
|
160
|
+
def put_category(category_guid, payload_file):
|
|
161
|
+
"""Update a glossary category"""
|
|
162
|
+
try:
|
|
163
|
+
client = Glossary()
|
|
164
|
+
args = {'--categoryGuid': category_guid, '--payloadFile': payload_file}
|
|
165
|
+
result = client.glossaryPutCategory(args)
|
|
166
|
+
console.print(json.dumps(result, indent=2))
|
|
167
|
+
except Exception as e:
|
|
168
|
+
console.print(f"[red][X] Error: {e}[/red]")
|
|
169
|
+
|
|
170
|
+
@glossary.command()
|
|
171
|
+
@click.option('--category-guid', required=True, help='The globally unique identifier of the category')
|
|
172
|
+
@click.option('--payload-file', required=True, type=click.Path(exists=True), help='Path to JSON file with partial updated category data')
|
|
173
|
+
def put_category_partial(category_guid, payload_file):
|
|
174
|
+
"""Partially update a glossary category"""
|
|
175
|
+
try:
|
|
176
|
+
client = Glossary()
|
|
177
|
+
args = {'--categoryGuid': category_guid, '--payloadFile': payload_file}
|
|
178
|
+
result = client.glossaryPutCategoryPartial(args)
|
|
179
|
+
console.print(json.dumps(result, indent=2))
|
|
180
|
+
except Exception as e:
|
|
181
|
+
console.print(f"[red][X] Error: {e}[/red]")
|
|
182
|
+
|
|
183
|
+
@glossary.command()
|
|
184
|
+
@click.option('--glossary-guid', required=True, help='The globally unique identifier for glossary')
|
|
185
|
+
@click.option('--payload-file', required=True, type=click.Path(exists=True), help='Path to JSON file with partial updated glossary data')
|
|
186
|
+
@click.option('--include-term-hierarchy', is_flag=True, help='Include term hierarchy in update')
|
|
187
|
+
def put_partial(glossary_guid, payload_file, include_term_hierarchy):
|
|
188
|
+
"""Partially update a glossary"""
|
|
189
|
+
try:
|
|
190
|
+
client = Glossary()
|
|
191
|
+
args = {'--glossaryGuid': glossary_guid, '--payloadFile': payload_file, '--includeTermHierarchy': include_term_hierarchy}
|
|
192
|
+
result = client.glossaryPutPartial(args)
|
|
193
|
+
console.print(json.dumps(result, indent=2))
|
|
194
|
+
except Exception as e:
|
|
195
|
+
console.print(f"[red][X] Error: {e}[/red]")
|
|
196
|
+
|
|
197
|
+
@glossary.command()
|
|
198
|
+
@click.option('--term-guid', required=True, help='The globally unique identifier for glossary term')
|
|
199
|
+
@click.option('--payload-file', required=True, type=click.Path(exists=True), help='Path to JSON file with updated term data')
|
|
200
|
+
@click.option('--include-term-hierarchy', is_flag=True, help='Include term hierarchy in update')
|
|
201
|
+
def put_term(term_guid, payload_file, include_term_hierarchy):
|
|
202
|
+
"""Update a glossary term"""
|
|
203
|
+
try:
|
|
204
|
+
client = Glossary()
|
|
205
|
+
args = {'--termGuid': term_guid, '--payloadFile': payload_file, '--includeTermHierarchy': include_term_hierarchy}
|
|
206
|
+
result = client.glossaryPutTerm(args)
|
|
207
|
+
console.print(json.dumps(result, indent=2))
|
|
208
|
+
except Exception as e:
|
|
209
|
+
console.print(f"[red][X] Error: {e}[/red]")
|
|
210
|
+
|
|
211
|
+
@glossary.command()
|
|
212
|
+
@click.option('--term-guid', required=True, help='The globally unique identifier for glossary term')
|
|
213
|
+
@click.option('--payload-file', required=True, type=click.Path(exists=True), help='Path to JSON file with partial updated term data')
|
|
214
|
+
@click.option('--include-term-hierarchy', is_flag=True, help='Include term hierarchy in update')
|
|
215
|
+
def put_term_partial(term_guid, payload_file, include_term_hierarchy):
|
|
216
|
+
"""Partially update a glossary term"""
|
|
217
|
+
try:
|
|
218
|
+
client = Glossary()
|
|
219
|
+
args = {'--termGuid': term_guid, '--payloadFile': payload_file, '--includeTermHierarchy': include_term_hierarchy}
|
|
220
|
+
result = client.glossaryPutTermPartial(args)
|
|
221
|
+
console.print(json.dumps(result, indent=2))
|
|
222
|
+
except Exception as e:
|
|
223
|
+
console.print(f"[red][X] Error: {e}[/red]")
|
|
224
|
+
|
|
225
|
+
@glossary.command()
|
|
226
|
+
@click.option('--term-guid', required=True, help='The globally unique identifier for glossary term')
|
|
227
|
+
@click.option('--payload-file', required=True, type=click.Path(exists=True), help='Path to JSON file with terms assigned entities data')
|
|
228
|
+
def put_terms_assigned_entities(term_guid, payload_file):
|
|
229
|
+
"""Assign entities to a glossary term"""
|
|
230
|
+
try:
|
|
231
|
+
client = Glossary()
|
|
232
|
+
args = {'--termGuid': term_guid, '--payloadFile': payload_file}
|
|
233
|
+
result = client.glossaryPutTermsAssignedEntities(args)
|
|
234
|
+
console.print(json.dumps(result, indent=2))
|
|
235
|
+
except Exception as e:
|
|
236
|
+
console.print(f"[red][X] Error: {e}[/red]")
|
|
237
|
+
|
|
238
|
+
# === READ OPERATIONS ===
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
def _read_glossaries_impl(glossary_guid, limit, offset, sort, ignore_terms_and_categories):
|
|
242
|
+
try:
|
|
243
|
+
client = Glossary()
|
|
244
|
+
args = {
|
|
245
|
+
'--glossaryGuid': glossary_guid,
|
|
246
|
+
'--limit': limit,
|
|
247
|
+
'--offset': offset,
|
|
248
|
+
'--sort': sort,
|
|
249
|
+
'--ignoreTermsAndCategories': ignore_terms_and_categories
|
|
250
|
+
}
|
|
251
|
+
result = client.glossaryRead(args)
|
|
252
|
+
console.print(json.dumps(result, indent=2))
|
|
253
|
+
except Exception as e:
|
|
254
|
+
console.print(f"[red][X] Error: {e}[/red]")
|
|
255
|
+
|
|
256
|
+
@glossary.command(name="read", help="Read glossaries and list all glossaries")
|
|
257
|
+
@click.option("--glossary-guid", help="The globally unique identifier for glossary")
|
|
258
|
+
@click.option("--limit", type=int, default=1000, help="The page size - by default there is no paging")
|
|
259
|
+
@click.option("--offset", type=int, default=0, help="Offset for pagination purpose")
|
|
260
|
+
@click.option("--sort", default="ASC", help="Sort order: ASC or DESC")
|
|
261
|
+
@click.option("--ignore-terms-and-categories", is_flag=True, help="Whether to ignore terms and categories")
|
|
262
|
+
def read(glossary_guid, limit, offset, sort, ignore_terms_and_categories):
|
|
263
|
+
"""Read glossaries"""
|
|
264
|
+
_read_glossaries_impl(glossary_guid, limit, offset, sort, ignore_terms_and_categories)
|
|
265
|
+
|
|
266
|
+
@glossary.command(name="list", help="List all glossaries")
|
|
267
|
+
@click.option("--limit", type=int, default=1000, help="The page size - by default there is no paging")
|
|
268
|
+
@click.option("--offset", type=int, default=0, help="Offset for pagination purpose")
|
|
269
|
+
@click.option("--sort", default="ASC", help="Sort order: ASC or DESC")
|
|
270
|
+
@click.option("--ignore-terms-and-categories", is_flag=True, help="Whether to ignore terms and categories")
|
|
271
|
+
def list_glossaries(limit, offset, sort, ignore_terms_and_categories):
|
|
272
|
+
"""List all glossaries (alias for 'read')"""
|
|
273
|
+
_read_glossaries_impl('', limit, offset, sort, ignore_terms_and_categories)
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
@glossary.command()
|
|
277
|
+
@click.option('--glossary-guid', help='The globally unique identifier for glossary')
|
|
278
|
+
@click.option('--limit', type=int, default=1000, help='The page size - by default there is no paging')
|
|
279
|
+
@click.option('--offset', type=int, default=0, help='Offset for pagination purpose')
|
|
280
|
+
@click.option('--sort', default='ASC', help='Sort order: ASC or DESC')
|
|
281
|
+
def read_categories(glossary_guid, limit, offset, sort):
|
|
282
|
+
"""Read glossary categories"""
|
|
283
|
+
try:
|
|
284
|
+
client = Glossary()
|
|
285
|
+
args = {'--glossaryGuid': glossary_guid, '--limit': limit, '--offset': offset, '--sort': sort}
|
|
286
|
+
result = client.glossaryReadCategories(args)
|
|
287
|
+
console.print(json.dumps(result, indent=2))
|
|
288
|
+
except Exception as e:
|
|
289
|
+
console.print(f"[red][X] Error: {e}[/red]")
|
|
290
|
+
|
|
291
|
+
@glossary.command()
|
|
292
|
+
@click.option('--glossary-guid', help='The globally unique identifier for glossary')
|
|
293
|
+
@click.option('--limit', type=int, default=1000, help='The page size - by default there is no paging')
|
|
294
|
+
@click.option('--offset', type=int, default=0, help='Offset for pagination purpose')
|
|
295
|
+
@click.option('--sort', default='ASC', help='Sort order: ASC or DESC')
|
|
296
|
+
def read_categories_headers(glossary_guid, limit, offset, sort):
|
|
297
|
+
"""Read glossary categories headers"""
|
|
298
|
+
try:
|
|
299
|
+
client = Glossary()
|
|
300
|
+
args = {'--glossaryGuid': glossary_guid, '--limit': limit, '--offset': offset, '--sort': sort}
|
|
301
|
+
result = client.glossaryReadCategoriesHeaders(args)
|
|
302
|
+
console.print(json.dumps(result, indent=2))
|
|
303
|
+
except Exception as e:
|
|
304
|
+
console.print(f"[red][X] Error: {e}[/red]")
|
|
305
|
+
|
|
306
|
+
@glossary.command()
|
|
307
|
+
@click.option('--category-guid', help='The globally unique identifier of the category')
|
|
308
|
+
@click.option('--limit', type=int, default=1000, help='The page size - by default there is no paging')
|
|
309
|
+
@click.option('--offset', type=int, default=0, help='Offset for pagination purpose')
|
|
310
|
+
@click.option('--sort', default='ASC', help='Sort order: ASC or DESC')
|
|
311
|
+
def read_category(category_guid, limit, offset, sort):
|
|
312
|
+
"""Read a glossary category"""
|
|
313
|
+
try:
|
|
314
|
+
client = Glossary()
|
|
315
|
+
args = {'--categoryGuid': category_guid, '--limit': limit, '--offset': offset, '--sort': sort}
|
|
316
|
+
result = client.glossaryReadCategory(args)
|
|
317
|
+
console.print(json.dumps(result, indent=2))
|
|
318
|
+
except Exception as e:
|
|
319
|
+
console.print(f"[red][X] Error: {e}[/red]")
|
|
320
|
+
|
|
321
|
+
@glossary.command()
|
|
322
|
+
@click.option('--category-guid', help='The globally unique identifier of the category')
|
|
323
|
+
def read_category_related(category_guid):
|
|
324
|
+
"""Read related terms of a glossary category"""
|
|
325
|
+
try:
|
|
326
|
+
client = Glossary()
|
|
327
|
+
args = {'--categoryGuid': category_guid}
|
|
328
|
+
result = client.glossaryReadCategoryRelated(args)
|
|
329
|
+
console.print(json.dumps(result, indent=2))
|
|
330
|
+
except Exception as e:
|
|
331
|
+
console.print(f"[red][X] Error: {e}[/red]")
|
|
332
|
+
|
|
333
|
+
@glossary.command()
|
|
334
|
+
@click.option('--category-guid', help='The globally unique identifier of the category')
|
|
335
|
+
@click.option('--limit', type=int, default=1000, help='The page size - by default there is no paging')
|
|
336
|
+
@click.option('--offset', type=int, default=0, help='Offset for pagination purpose')
|
|
337
|
+
@click.option('--sort', default='ASC', help='Sort order: ASC or DESC')
|
|
338
|
+
def read_category_terms(category_guid, limit, offset, sort):
|
|
339
|
+
"""Read terms of a glossary category"""
|
|
340
|
+
try:
|
|
341
|
+
client = Glossary()
|
|
342
|
+
args = {'--categoryGuid': category_guid, '--limit': limit, '--offset': offset, '--sort': sort}
|
|
343
|
+
result = client.glossaryReadCategoryTerms(args)
|
|
344
|
+
console.print(json.dumps(result, indent=2))
|
|
345
|
+
except Exception as e:
|
|
346
|
+
console.print(f"[red][X] Error: {e}[/red]")
|
|
347
|
+
|
|
348
|
+
@glossary.command()
|
|
349
|
+
@click.option('--glossary-guid', help='The globally unique identifier for glossary')
|
|
350
|
+
@click.option('--include-term-hierarchy', is_flag=True, help='Include term hierarchy in retrieval')
|
|
351
|
+
def read_detailed(glossary_guid, include_term_hierarchy):
|
|
352
|
+
"""Read detailed information of a glossary"""
|
|
353
|
+
try:
|
|
354
|
+
client = Glossary()
|
|
355
|
+
args = {'--glossaryGuid': glossary_guid, '--includeTermHierarchy': include_term_hierarchy}
|
|
356
|
+
result = client.glossaryReadDetailed(args)
|
|
357
|
+
console.print(json.dumps(result, indent=2))
|
|
358
|
+
except Exception as e:
|
|
359
|
+
console.print(f"[red][X] Error: {e}[/red]")
|
|
360
|
+
|
|
361
|
+
@glossary.command()
|
|
362
|
+
@click.option('--term-guid', help='The globally unique identifier for glossary term')
|
|
363
|
+
@click.option('--include-term-hierarchy', is_flag=True, help='Include term hierarchy in retrieval')
|
|
364
|
+
def read_term(term_guid, include_term_hierarchy):
|
|
365
|
+
"""Read a glossary term"""
|
|
366
|
+
try:
|
|
367
|
+
client = Glossary()
|
|
368
|
+
args = {'--termGuid': term_guid, '--includeTermHierarchy': include_term_hierarchy}
|
|
369
|
+
result = client.glossaryReadTerm(args)
|
|
370
|
+
console.print(json.dumps(result, indent=2))
|
|
371
|
+
except Exception as e:
|
|
372
|
+
console.print(f"[red][X] Error: {e}[/red]")
|
|
373
|
+
|
|
374
|
+
@glossary.command()
|
|
375
|
+
@click.option('--glossary-guid', help='The globally unique identifier for glossary')
|
|
376
|
+
@click.option('--limit', type=int, default=1000, help='The page size - by default there is no paging')
|
|
377
|
+
@click.option('--offset', type=int, default=0, help='Offset for pagination purpose')
|
|
378
|
+
@click.option('--sort', default='ASC', help='Sort order: ASC or DESC')
|
|
379
|
+
@click.option('--ext-info', is_flag=True, help='Include extended information')
|
|
380
|
+
@click.option('--include-term-hierarchy', is_flag=True, help='Include term hierarchy in retrieval')
|
|
381
|
+
def read_terms(glossary_guid, limit, offset, sort, ext_info, include_term_hierarchy):
|
|
382
|
+
"""Read glossary terms"""
|
|
383
|
+
try:
|
|
384
|
+
client = Glossary()
|
|
385
|
+
args = {'--glossaryGuid': glossary_guid, '--limit': limit, '--offset': offset, '--sort': sort, '--extInfo': ext_info, '--includeTermHierarchy': include_term_hierarchy}
|
|
386
|
+
result = client.glossaryReadTerms(args)
|
|
387
|
+
console.print(json.dumps(result, indent=2))
|
|
388
|
+
except Exception as e:
|
|
389
|
+
console.print(f"[red][X] Error: {e}[/red]")
|
|
390
|
+
|
|
391
|
+
@glossary.command(name="list-terms", help="List all terms in a glossary (alias for read-terms)")
|
|
392
|
+
@click.option('--glossary-guid', help='The globally unique identifier for glossary')
|
|
393
|
+
@click.option('--limit', type=int, default=1000, help='The page size - by default there is no paging')
|
|
394
|
+
@click.option('--offset', type=int, default=0, help='Offset for pagination purpose')
|
|
395
|
+
@click.option('--sort', default='ASC', help='Sort order: ASC or DESC')
|
|
396
|
+
@click.option('--ext-info', is_flag=True, help='Include extended information')
|
|
397
|
+
@click.option('--include-term-hierarchy', is_flag=True, help='Include term hierarchy in retrieval')
|
|
398
|
+
def list_terms(glossary_guid, limit, offset, sort, ext_info, include_term_hierarchy):
|
|
399
|
+
"""List all terms in a glossary (user-friendly alias for read-terms)"""
|
|
400
|
+
try:
|
|
401
|
+
client = Glossary()
|
|
402
|
+
args = {'--glossaryGuid': glossary_guid, '--limit': limit, '--offset': offset, '--sort': sort, '--extInfo': ext_info, '--includeTermHierarchy': include_term_hierarchy}
|
|
403
|
+
result = client.glossaryReadTerms(args)
|
|
404
|
+
console.print(json.dumps(result, indent=2))
|
|
405
|
+
except Exception as e:
|
|
406
|
+
console.print(f"[red][X] Error: {e}[/red]")
|
|
407
|
+
|
|
408
|
+
@glossary.command()
|
|
409
|
+
@click.option('--term-guid', help='The globally unique identifier for glossary term')
|
|
410
|
+
@click.option('--limit', type=int, default=1000, help='The page size - by default there is no paging')
|
|
411
|
+
@click.option('--offset', type=int, default=0, help='Offset for pagination purpose')
|
|
412
|
+
@click.option('--sort', default='ASC', help='Sort order: ASC or DESC')
|
|
413
|
+
def read_terms_assigned_entities(term_guid, limit, offset, sort):
|
|
414
|
+
"""Read assigned entities of a glossary term"""
|
|
415
|
+
try:
|
|
416
|
+
client = Glossary()
|
|
417
|
+
args = {'--termGuid': term_guid, '--limit': limit, '--offset': offset, '--sort': sort}
|
|
418
|
+
result = client.glossaryReadTermsAssignedEntities(args)
|
|
419
|
+
console.print(json.dumps(result, indent=2))
|
|
420
|
+
except Exception as e:
|
|
421
|
+
console.print(f"[red][X] Error: {e}[/red]")
|
|
422
|
+
|
|
423
|
+
@glossary.command()
|
|
424
|
+
@click.option('--glossary-guid', help='The globally unique identifier for glossary')
|
|
425
|
+
@click.option('--limit', type=int, default=1000, help='The page size - by default there is no paging')
|
|
426
|
+
@click.option('--offset', type=int, default=0, help='Offset for pagination purpose')
|
|
427
|
+
@click.option('--sort', default='ASC', help='Sort order: ASC or DESC')
|
|
428
|
+
def read_terms_headers(glossary_guid, limit, offset, sort):
|
|
429
|
+
"""Read glossary terms headers"""
|
|
430
|
+
try:
|
|
431
|
+
client = Glossary()
|
|
432
|
+
args = {'--glossaryGuid': glossary_guid, '--limit': limit, '--offset': offset, '--sort': sort}
|
|
433
|
+
result = client.glossaryReadTermsHeaders(args)
|
|
434
|
+
console.print(json.dumps(result, indent=2))
|
|
435
|
+
except Exception as e:
|
|
436
|
+
console.print(f"[red][X] Error: {e}[/red]")
|
|
437
|
+
|
|
438
|
+
@glossary.command()
|
|
439
|
+
@click.option('--operation-guid', help='The globally unique identifier for async operation/job')
|
|
440
|
+
def read_terms_import(operation_guid):
|
|
441
|
+
"""Read the result of a terms import operation"""
|
|
442
|
+
try:
|
|
443
|
+
client = Glossary()
|
|
444
|
+
args = {'--operationGuid': operation_guid}
|
|
445
|
+
result = client.glossaryReadTermsImport(args)
|
|
446
|
+
console.print(json.dumps(result, indent=2))
|
|
447
|
+
except Exception as e:
|
|
448
|
+
console.print(f"[red][X] Error: {e}[/red]")
|
|
449
|
+
|
|
450
|
+
@glossary.command()
|
|
451
|
+
@click.option('--term-guid', help='The globally unique identifier for glossary term')
|
|
452
|
+
@click.option('--limit', type=int, default=1000, help='The page size - by default there is no paging')
|
|
453
|
+
@click.option('--offset', type=int, default=0, help='Offset for pagination purpose')
|
|
454
|
+
@click.option('--sort', default='ASC', help='Sort order: ASC or DESC')
|
|
455
|
+
def read_terms_related(term_guid, limit, offset, sort):
|
|
456
|
+
"""Read related terms of a glossary term"""
|
|
457
|
+
try:
|
|
458
|
+
client = Glossary()
|
|
459
|
+
args = {'--termGuid': term_guid, '--limit': limit, '--offset': offset, '--sort': sort}
|
|
460
|
+
result = client.glossaryReadTermsRelated(args)
|
|
461
|
+
console.print(json.dumps(result, indent=2))
|
|
462
|
+
except Exception as e:
|
|
463
|
+
console.print(f"[red][X] Error: {e}[/red]")
|
|
464
|
+
|
|
465
|
+
@glossary.command(name="import-terms")
|
|
466
|
+
@click.option('--csv-file', required=False, type=click.Path(exists=True), help='CSV file with glossary terms')
|
|
467
|
+
@click.option('--json-file', required=False, type=click.Path(exists=True), help='JSON file with glossary terms')
|
|
468
|
+
@click.option('--glossary-guid', required=True, help='The globally unique identifier for glossary')
|
|
469
|
+
@click.option('--include-term-hierarchy', is_flag=True, help='Include term hierarchy in creation')
|
|
470
|
+
def import_terms_csv(csv_file, json_file, glossary_guid, include_term_hierarchy):
|
|
471
|
+
"""Import glossary terms from a CSV or JSON file."""
|
|
472
|
+
try:
|
|
473
|
+
if not csv_file and not json_file:
|
|
474
|
+
console.print("[red]Error: Either --csv-file or --json-file must be provided[/red]")
|
|
475
|
+
return
|
|
476
|
+
|
|
477
|
+
if csv_file and json_file:
|
|
478
|
+
console.print("[red]Error: Provide either --csv-file or --json-file, not both[/red]")
|
|
479
|
+
return
|
|
480
|
+
|
|
481
|
+
from purviewcli.client._glossary import Glossary
|
|
482
|
+
client = Glossary()
|
|
483
|
+
|
|
484
|
+
if csv_file:
|
|
485
|
+
# For CSV files, we need to read and convert to the expected format
|
|
486
|
+
# The Purview API expects a specific JSON structure for import
|
|
487
|
+
console.print(f"[yellow]Note: CSV import requires conversion to JSON format[/yellow]")
|
|
488
|
+
console.print(f"[yellow]Processing CSV file: {csv_file}[/yellow]")
|
|
489
|
+
|
|
490
|
+
import csv
|
|
491
|
+
import json
|
|
492
|
+
|
|
493
|
+
terms = []
|
|
494
|
+
with open(csv_file, 'r', encoding='utf-8') as f:
|
|
495
|
+
reader = csv.DictReader(f)
|
|
496
|
+
for row in reader:
|
|
497
|
+
term = {
|
|
498
|
+
"name": row.get("name", ""),
|
|
499
|
+
"definition": row.get("definition", ""),
|
|
500
|
+
"status": row.get("status", "Draft"),
|
|
501
|
+
"nickName": row.get("nickName", ""),
|
|
502
|
+
"abbreviation": row.get("abbreviation", "")
|
|
503
|
+
}
|
|
504
|
+
# Remove empty values
|
|
505
|
+
term = {k: v for k, v in term.items() if v}
|
|
506
|
+
terms.append(term)
|
|
507
|
+
|
|
508
|
+
args = {
|
|
509
|
+
'--payloadFile': None, # We'll set payload directly
|
|
510
|
+
'--glossaryGuid': glossary_guid,
|
|
511
|
+
'--includeTermHierarchy': include_term_hierarchy
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
# Set the payload directly on the client
|
|
515
|
+
client.glossaryImportTerms(args)
|
|
516
|
+
client.payload = terms
|
|
517
|
+
result = client.call_api()
|
|
518
|
+
|
|
519
|
+
else:
|
|
520
|
+
# For JSON files, use the existing method
|
|
521
|
+
args = {
|
|
522
|
+
'--payloadFile': json_file,
|
|
523
|
+
'--glossaryGuid': glossary_guid,
|
|
524
|
+
'--includeTermHierarchy': include_term_hierarchy
|
|
525
|
+
}
|
|
526
|
+
result = client.glossaryImportTerms(args)
|
|
527
|
+
|
|
528
|
+
console.print(json.dumps({'status': 'success', 'result': str(result)}, indent=2))
|
|
529
|
+
except Exception as e:
|
|
530
|
+
console.print(f"[red]Error importing glossary terms from CSV: {e}[/red]")
|
|
531
|
+
|
|
532
|
+
# Make the glossary group available for import
|
|
533
|
+
__all__ = ['glossary']
|