pyegeria 5.3.2__py3-none-any.whl → 5.3.3__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.
- pyegeria/.DS_Store +0 -0
- pyegeria/classification_manager_omvs.py +4 -4
- pyegeria/commands/.DS_Store +0 -0
- pyegeria/commands/cli/egeria.py +200 -65
- pyegeria/commands/cli/egeria_tech.py +249 -139
- pyegeria/commands/doc/.DS_Store +0 -0
- pyegeria/commands/doc/Visual Command Reference/.DS_Store +0 -0
- pyegeria/commands/doc/Visual Command Reference/cat/.DS_Store +0 -0
- pyegeria/commands/doc/Visual Command Reference/cat/show/.DS_Store +0 -0
- pyegeria/commands/doc/Visual Command Reference/cat/show/deployed-data/.DS_Store +0 -0
- pyegeria/commands/doc/glossary/.DS_Store +0 -0
- pyegeria/commands/doc/glossary/images/.DS_Store +0 -0
- pyegeria/commands/doc/hey_egeria: a pyegeria command line interface/.DS_Store +0 -0
- pyegeria/commands/doc/hey_egeria: a pyegeria command line interface/images/.DS_Store +0 -0
- pyegeria/commands/tech/{list_elements.py → list_all_om_type_elements.py} +1 -1
- pyegeria/commands/tech/{list_elements_x.py → list_all_om_type_elements_x.py} +1 -1
- pyegeria/commands/tech/list_elements_by_classification_by_property_value.py +186 -0
- pyegeria/commands/tech/list_elements_by_property_value.py +175 -0
- pyegeria/commands/tech/list_elements_by_property_value_x.py +196 -0
- pyegeria/commands/tech/list_related_elements_with_prop_value.py +207 -0
- pyegeria/valid_metadata_omvs.py +1 -1
- {pyegeria-5.3.2.dist-info → pyegeria-5.3.3.dist-info}/METADATA +1 -1
- {pyegeria-5.3.2.dist-info → pyegeria-5.3.3.dist-info}/RECORD +27 -12
- {pyegeria-5.3.2.dist-info → pyegeria-5.3.3.dist-info}/entry_points.txt +7 -2
- /pyegeria/commands/tech/{list_related_elements.py → list_all_related_elements.py} +0 -0
- {pyegeria-5.3.2.dist-info → pyegeria-5.3.3.dist-info}/LICENSE +0 -0
- {pyegeria-5.3.2.dist-info → pyegeria-5.3.3.dist-info}/WHEEL +0 -0
@@ -20,45 +20,29 @@ from pyegeria.commands.cli.ops_config import Config
|
|
20
20
|
from pyegeria.commands.tech.get_guid_info import display_guid
|
21
21
|
from pyegeria.commands.tech.get_tech_details import tech_details_viewer
|
22
22
|
from pyegeria.commands.tech.list_asset_types import display_asset_types
|
23
|
-
from pyegeria.commands.tech.list_elements_x import list_elements_x
|
24
23
|
from pyegeria.commands.tech.list_registered_services import display_registered_svcs
|
25
24
|
from pyegeria.commands.tech.list_relationship_types import display_relationship_types
|
26
25
|
from pyegeria.commands.tech.list_tech_templates import display_templates_spec
|
27
26
|
from pyegeria.commands.tech.list_valid_metadata_values import display_metadata_values
|
28
|
-
from pyegeria.commands.tech.get_tech_type_template import template_viewer
|
29
27
|
from pyegeria.commands.tech.list_anchored_elements import display_anchored_elements
|
30
|
-
from pyegeria.commands.tech.
|
28
|
+
from pyegeria.commands.tech.list_all_om_type_elements import list_elements
|
29
|
+
from pyegeria.commands.tech.list_all_om_type_elements_x import list_elements_x
|
30
|
+
from pyegeria.commands.tech.list_elements_by_classification_by_property_value import find_elements_by_classification_by_prop_value
|
31
|
+
from pyegeria.commands.tech.list_elements_by_property_value import find_elements_by_prop_value
|
32
|
+
from pyegeria.commands.tech.list_elements_by_property_value_x import find_elements_by_prop_value_x
|
33
|
+
from pyegeria.commands.tech.list_related_elements_with_prop_value import list_related_elements_with_prop_value
|
31
34
|
|
32
35
|
from pyegeria.commands.tech.get_element_info import display_elements
|
33
36
|
from pyegeria.commands.tech.list_related_specification import (
|
34
37
|
display_related_specification,
|
35
38
|
)
|
36
|
-
from pyegeria.commands.tech.
|
39
|
+
from pyegeria.commands.tech.list_all_related_elements import list_related_elements
|
37
40
|
from pyegeria.commands.tech.list_elements_for_classification import (
|
38
41
|
list_classified_elements,
|
39
42
|
)
|
40
43
|
from pyegeria.commands.tech.list_gov_action_processes import display_gov_processes
|
41
44
|
from pyegeria.commands.tech.get_tech_type_template import template_viewer
|
42
45
|
|
43
|
-
# from pyegeria import ServerOps
|
44
|
-
|
45
|
-
|
46
|
-
# class Config(object):
|
47
|
-
# def __init__(self, server: str = None, url: str = None, userid:str = None, password:str = None,
|
48
|
-
# timeout:int = 30, paging: bool = False):
|
49
|
-
# self.server = server
|
50
|
-
# self.url = url
|
51
|
-
# self.userid = userid
|
52
|
-
# self.password = password
|
53
|
-
# self.timeout = timeout
|
54
|
-
# self.paging = paging
|
55
|
-
#
|
56
|
-
#
|
57
|
-
# pass_config = click.make_pass_decorator(Config)
|
58
|
-
|
59
|
-
|
60
|
-
# @tui
|
61
|
-
# @tui('menu', 'menu', 'A textual command line interface')
|
62
46
|
@tui()
|
63
47
|
@click.version_option("0.0.1", prog_name="egeria_ops")
|
64
48
|
@click.group()
|
@@ -229,39 +213,21 @@ def show_guid_info(ctx, guid):
|
|
229
213
|
display_guid(guid, c.server, c.url, c.userid, c.password, c.jupyter, c.width)
|
230
214
|
|
231
215
|
|
232
|
-
@show_elements.command("
|
233
|
-
@click.pass_context
|
234
|
-
@click.argument("element-guid")
|
235
|
-
def show_related_specifications(ctx, element_guid):
|
236
|
-
"""List specifications related to the given Element"""
|
237
|
-
c = ctx.obj
|
238
|
-
display_related_specification(
|
239
|
-
element_guid,
|
240
|
-
c.view_server,
|
241
|
-
c.view_server_url,
|
242
|
-
c.userid,
|
243
|
-
c.password,
|
244
|
-
c.jupyter,
|
245
|
-
c.width,
|
246
|
-
)
|
247
|
-
|
248
|
-
|
249
|
-
@show_elements.command("anchored-elements")
|
216
|
+
@show_elements.command("anchored_elements")
|
250
217
|
@click.pass_context
|
251
218
|
@click.option(
|
252
|
-
"--
|
253
|
-
default="
|
219
|
+
"--property_value",
|
220
|
+
default="DeployedDatabaseSchema",
|
254
221
|
help="value we are searching for",
|
255
222
|
)
|
256
223
|
@click.option(
|
257
224
|
"--prop-list",
|
258
|
-
default="
|
225
|
+
default="anchorTypeName",
|
259
226
|
help="List of properties we are searching",
|
260
227
|
)
|
261
228
|
def list_anchored_elements(ctx, search_string: str, prop_list: str):
|
262
|
-
"""List elements with the specified properties"""
|
229
|
+
"""List anchored elements with the specified properties"""
|
263
230
|
c = ctx.obj
|
264
|
-
# put guards around this to make it a list?
|
265
231
|
if type(prop_list) is str:
|
266
232
|
property_names = prop_list.split(",")
|
267
233
|
elif type(prop_list) is list:
|
@@ -270,10 +236,9 @@ def list_anchored_elements(ctx, search_string: str, prop_list: str):
|
|
270
236
|
property_names = []
|
271
237
|
print(f"\nError --> Invalid property list - must be a string or list")
|
272
238
|
sys.exit(4)
|
273
|
-
|
274
239
|
display_anchored_elements(
|
275
240
|
search_string,
|
276
|
-
|
241
|
+
[prop_list],
|
277
242
|
c.view_server,
|
278
243
|
c.view_server_url,
|
279
244
|
c.userid,
|
@@ -283,6 +248,208 @@ def list_anchored_elements(ctx, search_string: str, prop_list: str):
|
|
283
248
|
c.width,
|
284
249
|
)
|
285
250
|
|
251
|
+
@show_elements.command("elements-by-classification")
|
252
|
+
@click.option(
|
253
|
+
"--om-type",
|
254
|
+
default="Project",
|
255
|
+
help="Open Metadata type to filter by",
|
256
|
+
)
|
257
|
+
@click.option(
|
258
|
+
"--classification",
|
259
|
+
default="GovernanceProject",
|
260
|
+
help="Classification to filter byt",
|
261
|
+
)
|
262
|
+
@click.pass_context
|
263
|
+
def show_elements_by_classification(ctx, om_type, classification):
|
264
|
+
"""Show elements by classification"""
|
265
|
+
c = ctx.obj
|
266
|
+
list_classified_elements(
|
267
|
+
om_type,
|
268
|
+
classification,
|
269
|
+
c.view_server,
|
270
|
+
c.view_server_url,
|
271
|
+
c.userid,
|
272
|
+
c.password,
|
273
|
+
c.jupyter,
|
274
|
+
c.width,
|
275
|
+
)
|
276
|
+
|
277
|
+
@show_elements.command("elements-by-classification-by-prop-value")
|
278
|
+
@click.option(
|
279
|
+
"--classification",
|
280
|
+
default="GovernanceProject",
|
281
|
+
help="Classification to filter by",
|
282
|
+
)
|
283
|
+
@click.option(
|
284
|
+
"--property_value",
|
285
|
+
help="Property value to filter by",
|
286
|
+
)
|
287
|
+
@click.option(
|
288
|
+
"--property_names",
|
289
|
+
help="List of properties to search by",
|
290
|
+
)
|
291
|
+
@click.option(
|
292
|
+
"--om-type",
|
293
|
+
default="Project",
|
294
|
+
help="Open Metadata type to filter by",
|
295
|
+
)
|
296
|
+
@click.pass_context
|
297
|
+
def show_elements_by_classification_by_prop(ctx, classification, property_value, property_names, om_type):
|
298
|
+
"""Show elements by classification and property value"""
|
299
|
+
c = ctx.obj
|
300
|
+
find_elements_by_classification_by_prop_value(
|
301
|
+
om_type,
|
302
|
+
classification,
|
303
|
+
property_value,
|
304
|
+
[property_names],
|
305
|
+
c.view_server,
|
306
|
+
c.view_server_url,
|
307
|
+
c.userid,
|
308
|
+
c.password,
|
309
|
+
c.jupyter,
|
310
|
+
c.width,
|
311
|
+
)
|
312
|
+
|
313
|
+
@show_elements.command("elements-by-prop-value")
|
314
|
+
@click.option(
|
315
|
+
"--property_value",
|
316
|
+
help="Property value to filter by",
|
317
|
+
)
|
318
|
+
@click.option(
|
319
|
+
"--property_names",
|
320
|
+
help="List of properties to search by",
|
321
|
+
)
|
322
|
+
@click.option(
|
323
|
+
"--om-type",
|
324
|
+
default="Project",
|
325
|
+
help="Open Metadata type to filter by",
|
326
|
+
)
|
327
|
+
@click.option(
|
328
|
+
"--extended",
|
329
|
+
is_flag=True,
|
330
|
+
default=False,
|
331
|
+
help="If True, feedback information is displayed",
|
332
|
+
)
|
333
|
+
@click.pass_context
|
334
|
+
def show_elements_by_classification_by_prop(ctx,property_value, property_names, om_type, extended):
|
335
|
+
"""Show elements by classification and property value"""
|
336
|
+
c = ctx.obj
|
337
|
+
if extended:
|
338
|
+
find_elements_by_prop_value_x(
|
339
|
+
om_type,
|
340
|
+
property_value,
|
341
|
+
[property_names],
|
342
|
+
c.view_server,
|
343
|
+
c.view_server_url,
|
344
|
+
c.userid,
|
345
|
+
c.password,
|
346
|
+
c.jupyter,
|
347
|
+
c.width,
|
348
|
+
)
|
349
|
+
else:
|
350
|
+
find_elements_by_prop_value(
|
351
|
+
om_type,
|
352
|
+
property_value,
|
353
|
+
[property_names],
|
354
|
+
c.view_server,
|
355
|
+
c.view_server_url,
|
356
|
+
c.userid,
|
357
|
+
c.password,
|
358
|
+
c.jupyter,
|
359
|
+
c.width,
|
360
|
+
)
|
361
|
+
|
362
|
+
@show_elements.command("related-elements")
|
363
|
+
@click.option(
|
364
|
+
"--element-guid",
|
365
|
+
help="GUID of the Element to navigate from.",
|
366
|
+
)
|
367
|
+
@click.option(
|
368
|
+
"--om-type",
|
369
|
+
default="Project",
|
370
|
+
help="Open metadata type to filter by.",
|
371
|
+
)
|
372
|
+
@click.option(
|
373
|
+
"--rel-type",
|
374
|
+
default="Certification",
|
375
|
+
help="Relationship type to follow.",
|
376
|
+
)
|
377
|
+
@click.pass_context
|
378
|
+
def show_related_elements(ctx, element_guid, om_type, rel_type):
|
379
|
+
"""Show all elements related to specified guid"""
|
380
|
+
c = ctx.obj
|
381
|
+
list_related_elements(
|
382
|
+
element_guid,
|
383
|
+
om_type,
|
384
|
+
rel_type,
|
385
|
+
c.view_server,
|
386
|
+
c.view_server_url,
|
387
|
+
c.userid,
|
388
|
+
c.password,
|
389
|
+
c.jupyter,
|
390
|
+
c.width,
|
391
|
+
)
|
392
|
+
|
393
|
+
|
394
|
+
@show_elements.command("related-elements_by_prop")
|
395
|
+
@click.option(
|
396
|
+
"--element-guid",
|
397
|
+
help="GUID of the Element to navigate from.",
|
398
|
+
)
|
399
|
+
@click.option(
|
400
|
+
"--rel-type",
|
401
|
+
default="Certification",
|
402
|
+
help="Relationship type to follow.",
|
403
|
+
)
|
404
|
+
@click.option(
|
405
|
+
"--property_value",
|
406
|
+
help="Property value to filter by",
|
407
|
+
)
|
408
|
+
@click.option(
|
409
|
+
"--property_names",
|
410
|
+
help="List of properties to search by",
|
411
|
+
)
|
412
|
+
@click.option(
|
413
|
+
"--om-type",
|
414
|
+
default="Project",
|
415
|
+
help="Open metadata type to filter by.",
|
416
|
+
)
|
417
|
+
|
418
|
+
@click.pass_context
|
419
|
+
def show_related_elements(ctx, element_guid, rel_type, property_value, property_names, om_type):
|
420
|
+
"""Show elements related to specified guid and property value"""
|
421
|
+
c = ctx.obj
|
422
|
+
list_related_elements_with_prop_value(
|
423
|
+
element_guid,
|
424
|
+
rel_type,
|
425
|
+
property_value,
|
426
|
+
[property_names],
|
427
|
+
om_type,
|
428
|
+
c.view_server,
|
429
|
+
c.view_server_url,
|
430
|
+
c.userid,
|
431
|
+
c.password,
|
432
|
+
c.jupyter,
|
433
|
+
c.width,
|
434
|
+
)
|
435
|
+
|
436
|
+
|
437
|
+
@show_elements.command("related-specifications")
|
438
|
+
@click.pass_context
|
439
|
+
@click.argument("element-guid")
|
440
|
+
def show_related_specifications(ctx, element_guid):
|
441
|
+
"""List specifications related to the given Element"""
|
442
|
+
c = ctx.obj
|
443
|
+
display_related_specification(
|
444
|
+
element_guid,
|
445
|
+
c.view_server,
|
446
|
+
c.view_server_url,
|
447
|
+
c.userid,
|
448
|
+
c.password,
|
449
|
+
c.jupyter,
|
450
|
+
c.width,
|
451
|
+
)
|
452
|
+
|
286
453
|
|
287
454
|
@show_tech.command("tech-types")
|
288
455
|
@click.option("--search-string", default="*", help="Tech type to search for")
|
@@ -410,63 +577,6 @@ def show_relationship_types(ctx, rel_type):
|
|
410
577
|
)
|
411
578
|
|
412
579
|
|
413
|
-
@show_elements.command("elements-by-classification")
|
414
|
-
@click.option(
|
415
|
-
"--om-type",
|
416
|
-
default="Project",
|
417
|
-
help="Open Metadata type to filter by",
|
418
|
-
)
|
419
|
-
@click.option(
|
420
|
-
"--classification",
|
421
|
-
default="GovernanceProject",
|
422
|
-
help="Classification to filter byt",
|
423
|
-
)
|
424
|
-
@click.pass_context
|
425
|
-
def show_elements_by_classification(ctx, om_type, classification):
|
426
|
-
"""Show elements by classification"""
|
427
|
-
c = ctx.obj
|
428
|
-
list_classified_elements(
|
429
|
-
om_type,
|
430
|
-
classification,
|
431
|
-
c.view_server,
|
432
|
-
c.view_server_url,
|
433
|
-
c.userid,
|
434
|
-
c.password,
|
435
|
-
c.jupyter,
|
436
|
-
c.width,
|
437
|
-
)
|
438
|
-
|
439
|
-
|
440
|
-
@show_elements.command("related-elements")
|
441
|
-
@click.option(
|
442
|
-
"--element-guid",
|
443
|
-
help="GUID of the Element to navigate from.",
|
444
|
-
)
|
445
|
-
@click.option(
|
446
|
-
"--om-type",
|
447
|
-
default="Project",
|
448
|
-
help="Open metadata type to filter by.",
|
449
|
-
)
|
450
|
-
@click.option(
|
451
|
-
"--rel-type",
|
452
|
-
default="Certification",
|
453
|
-
help="Relationship type to follow.",
|
454
|
-
)
|
455
|
-
@click.pass_context
|
456
|
-
def show_related_elements(ctx, element_guid, om_type, rel_type):
|
457
|
-
"""Show information about related elements"""
|
458
|
-
c = ctx.obj
|
459
|
-
list_related_elements(
|
460
|
-
element_guid,
|
461
|
-
om_type,
|
462
|
-
rel_type,
|
463
|
-
c.view_server,
|
464
|
-
c.view_server_url,
|
465
|
-
c.userid,
|
466
|
-
c.password,
|
467
|
-
c.jupyter,
|
468
|
-
c.width,
|
469
|
-
)
|
470
580
|
|
471
581
|
|
472
582
|
@show_tech.command("tech-templates")
|
@@ -544,44 +654,12 @@ def valid_metadata_values(ctx, property, type_name):
|
|
544
654
|
)
|
545
655
|
|
546
656
|
|
547
|
-
@show_elements.command("elements")
|
548
|
-
@click.pass_context
|
549
|
-
@click.option(
|
550
|
-
"--extended",
|
551
|
-
is_flag=True,
|
552
|
-
default=False,
|
553
|
-
help="If True, feedback information is displayed",
|
554
|
-
)
|
555
|
-
@click.option("--om_type", default="Organization", help="Metadata type to query")
|
556
|
-
def list_element_info(ctx, om_type, extended):
|
557
|
-
"""Display elements of a specific Open Metadata Type"""
|
558
|
-
c = ctx.obj
|
559
|
-
if extended:
|
560
|
-
list_elements_x(
|
561
|
-
om_type,
|
562
|
-
c.view_server,
|
563
|
-
c.view_server_url,
|
564
|
-
c.userid,
|
565
|
-
c.password,
|
566
|
-
c.jupyter,
|
567
|
-
c.width,
|
568
|
-
)
|
569
|
-
else:
|
570
|
-
list_elements(
|
571
|
-
om_type,
|
572
|
-
c.view_server,
|
573
|
-
c.view_server_url,
|
574
|
-
c.userid,
|
575
|
-
c.password,
|
576
|
-
c.jupyter,
|
577
|
-
c.width,
|
578
|
-
)
|
579
657
|
|
580
658
|
|
581
659
|
@show_info.command("processes")
|
582
660
|
@click.pass_context
|
583
661
|
def list_element_info(ctx):
|
584
|
-
"""Display
|
662
|
+
"""Display processes"""
|
585
663
|
c = ctx.obj
|
586
664
|
list_elements(
|
587
665
|
"GovernanceActionProcess",
|
@@ -598,7 +676,7 @@ def list_element_info(ctx):
|
|
598
676
|
@click.pass_context
|
599
677
|
@click.option("--om_type", default="Project", help="Metadata type to query")
|
600
678
|
def get_element_info(ctx, om_type):
|
601
|
-
"""Display
|
679
|
+
"""Display graph of elements for an Open Metadata Type"""
|
602
680
|
c = ctx.obj
|
603
681
|
display_elements(
|
604
682
|
om_type,
|
@@ -610,6 +688,38 @@ def get_element_info(ctx, om_type):
|
|
610
688
|
c.width,
|
611
689
|
)
|
612
690
|
|
691
|
+
@show_elements.command("elements")
|
692
|
+
@click.pass_context
|
693
|
+
@click.option(
|
694
|
+
"--extended",
|
695
|
+
is_flag=True,
|
696
|
+
default=False,
|
697
|
+
help="If True, feedback information is displayed",
|
698
|
+
)
|
699
|
+
@click.option("--om_type", default="Organization", help="Metadata type to query")
|
700
|
+
def list_all_om_type_elements(ctx, om_type, extended):
|
701
|
+
"""Display all elements of a specific Open Metadata Type"""
|
702
|
+
c = ctx.obj
|
703
|
+
if extended:
|
704
|
+
list_elements_x(
|
705
|
+
om_type,
|
706
|
+
c.view_server,
|
707
|
+
c.view_server_url,
|
708
|
+
c.userid,
|
709
|
+
c.password,
|
710
|
+
c.jupyter,
|
711
|
+
c.width
|
712
|
+
)
|
713
|
+
else:
|
714
|
+
list_elements(
|
715
|
+
om_type,
|
716
|
+
c.view_server,
|
717
|
+
c.view_server_url,
|
718
|
+
c.userid,
|
719
|
+
c.password,
|
720
|
+
c.jupyter,
|
721
|
+
c.width
|
722
|
+
)
|
613
723
|
|
614
724
|
#
|
615
725
|
# Tell
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,186 @@
|
|
1
|
+
"""This finds all elements of a classification that match the property value for the properties specified"""
|
2
|
+
from rich.markdown import Markdown
|
3
|
+
from rich.prompt import Prompt
|
4
|
+
import os
|
5
|
+
import argparse
|
6
|
+
import time
|
7
|
+
import sys
|
8
|
+
from rich import box
|
9
|
+
from rich.console import Console
|
10
|
+
from rich.table import Table
|
11
|
+
|
12
|
+
from pyegeria import (
|
13
|
+
InvalidParameterException,
|
14
|
+
PropertyServerException,
|
15
|
+
UserNotAuthorizedException,
|
16
|
+
print_exception_response,
|
17
|
+
EgeriaTech,
|
18
|
+
)
|
19
|
+
|
20
|
+
|
21
|
+
console = Console()
|
22
|
+
EGERIA_METADATA_STORE = os.environ.get("EGERIA_METADATA_STORE", "active-metadata-store")
|
23
|
+
EGERIA_KAFKA_ENDPOINT = os.environ.get("KAFKA_ENDPOINT", "localhost:9092")
|
24
|
+
EGERIA_PLATFORM_URL = os.environ.get("EGERIA_PLATFORM_URL", "https://localhost:9443")
|
25
|
+
EGERIA_VIEW_SERVER = os.environ.get("EGERIA_VIEW_SERVER", "view-server")
|
26
|
+
EGERIA_VIEW_SERVER_URL = os.environ.get(
|
27
|
+
"EGERIA_VIEW_SERVER_URL", "https://localhost:9443"
|
28
|
+
)
|
29
|
+
EGERIA_INTEGRATION_DAEMON = os.environ.get("INTEGRATION_DAEMON", "integration-daemon")
|
30
|
+
EGERIA_ADMIN_USER = os.environ.get("ADMIN_USER", "garygeeke")
|
31
|
+
EGERIA_ADMIN_PASSWORD = os.environ.get("ADMIN_PASSWORD", "secret")
|
32
|
+
EGERIA_USER = os.environ.get("EGERIA_USER", "erinoverview")
|
33
|
+
EGERIA_USER_PASSWORD = os.environ.get("EGERIA_USER_PASSWORD", "secret")
|
34
|
+
EGERIA_JUPYTER = bool(os.environ.get("EGERIA_JUPYTER", "False"))
|
35
|
+
EGERIA_WIDTH = int(os.environ.get("EGERIA_WIDTH", "200"))
|
36
|
+
|
37
|
+
|
38
|
+
def find_elements_by_classification_by_prop_value(
|
39
|
+
om_type: str,
|
40
|
+
classification: str,
|
41
|
+
property_value: str,
|
42
|
+
property_names: [str],
|
43
|
+
server: str,
|
44
|
+
url: str,
|
45
|
+
username: str,
|
46
|
+
password: str,
|
47
|
+
jupyter: bool = EGERIA_JUPYTER,
|
48
|
+
width: int = EGERIA_WIDTH,
|
49
|
+
):
|
50
|
+
c_client = EgeriaTech(server, url, user_id=username, user_pwd=password)
|
51
|
+
token = c_client.create_egeria_bearer_token()
|
52
|
+
|
53
|
+
om_typedef = c_client.get_typedef_by_name(om_type)
|
54
|
+
if type(om_typedef) is str:
|
55
|
+
print(
|
56
|
+
f"The type name '{om_type}' is not known to the Egeria platform at {url} - {server}"
|
57
|
+
)
|
58
|
+
sys.exit(0)
|
59
|
+
|
60
|
+
class_def = c_client.get_typedef_by_name(classification)
|
61
|
+
if type(class_def) is str:
|
62
|
+
print(
|
63
|
+
f"The Classification {classification} is not known to the Egeria platform at {url} - {server}"
|
64
|
+
)
|
65
|
+
sys.exit(0)
|
66
|
+
|
67
|
+
elements = c_client.find_elements_by_classification_with_property_value(classification, property_value,
|
68
|
+
property_names, om_type)
|
69
|
+
c = classification
|
70
|
+
|
71
|
+
def generate_table() -> Table:
|
72
|
+
"""Make a new table."""
|
73
|
+
table = Table(
|
74
|
+
caption=f"Find Metadata Elements for: {url} - {server} @ {time.asctime()}",
|
75
|
+
style="bold bright_white on black",
|
76
|
+
row_styles=["bold bright_white on black"],
|
77
|
+
header_style="white on dark_blue",
|
78
|
+
title_style="bold bright_white on black",
|
79
|
+
caption_style="white on black",
|
80
|
+
show_lines=True,
|
81
|
+
box=box.ROUNDED,
|
82
|
+
title=f"Elements for Classification: {c}, Open Metadata Type: {om_type}, property value: {property_value}, "
|
83
|
+
f"properties: {property_names}",
|
84
|
+
expand=True,
|
85
|
+
width=width,
|
86
|
+
)
|
87
|
+
|
88
|
+
table.add_column("Qualified Name")
|
89
|
+
table.add_column("Type")
|
90
|
+
table.add_column("Created")
|
91
|
+
table.add_column("Home Store")
|
92
|
+
table.add_column("GUID", width=38, no_wrap=True)
|
93
|
+
table.add_column("Properties")
|
94
|
+
table.add_column("Classifications")
|
95
|
+
|
96
|
+
if type(elements) is list:
|
97
|
+
for element in elements:
|
98
|
+
header = element["elementHeader"]
|
99
|
+
el_q_name = element["properties"].get("qualifiedName", "---")
|
100
|
+
el_type = header["type"]["typeName"]
|
101
|
+
el_home = header["origin"]["homeMetadataCollectionName"]
|
102
|
+
el_create_time = header["versions"]["createTime"][:-10]
|
103
|
+
el_guid = header["guid"]
|
104
|
+
el_class = header.get("classifications", "---")
|
105
|
+
|
106
|
+
el_props_md = ""
|
107
|
+
for prop in element["properties"].keys():
|
108
|
+
el_props_md += f"* **{prop}**: {element['properties'][prop]}\n"
|
109
|
+
el_props_out = Markdown(el_props_md)
|
110
|
+
|
111
|
+
c_md = ""
|
112
|
+
if type(el_class) is list:
|
113
|
+
for classification in el_class:
|
114
|
+
classification_name = classification.get(
|
115
|
+
"classificationName", "---"
|
116
|
+
)
|
117
|
+
c_md = f"* **{classification_name}**\n"
|
118
|
+
class_props = classification.get(
|
119
|
+
"classificationProperties", "---"
|
120
|
+
)
|
121
|
+
if type(class_props) is dict:
|
122
|
+
for prop in class_props.keys():
|
123
|
+
c_md += f" * **{prop}**: {class_props[prop]}\n"
|
124
|
+
c_md_out = Markdown(c_md)
|
125
|
+
|
126
|
+
table.add_row(
|
127
|
+
el_q_name,
|
128
|
+
el_type,
|
129
|
+
el_create_time,
|
130
|
+
el_home,
|
131
|
+
el_guid,
|
132
|
+
el_props_out,
|
133
|
+
c_md_out,
|
134
|
+
)
|
135
|
+
|
136
|
+
return table
|
137
|
+
else:
|
138
|
+
print("No instances found")
|
139
|
+
sys.exit(1)
|
140
|
+
|
141
|
+
try:
|
142
|
+
console = Console(width=width, force_terminal=not jupyter)
|
143
|
+
|
144
|
+
with console.pager(styles=True):
|
145
|
+
console.print(generate_table())
|
146
|
+
|
147
|
+
except (
|
148
|
+
InvalidParameterException,
|
149
|
+
PropertyServerException,
|
150
|
+
UserNotAuthorizedException,
|
151
|
+
) as e:
|
152
|
+
print_exception_response(e)
|
153
|
+
print("\n\nPerhaps the type name isn't known")
|
154
|
+
finally:
|
155
|
+
c_client.close_session()
|
156
|
+
|
157
|
+
|
158
|
+
def main():
|
159
|
+
parser = argparse.ArgumentParser()
|
160
|
+
parser.add_argument("--server", help="Name of the server to display status for")
|
161
|
+
parser.add_argument("--url", help="URL Platform to connect to")
|
162
|
+
parser.add_argument("--userid", help="User Id")
|
163
|
+
parser.add_argument("--password", help="Password")
|
164
|
+
|
165
|
+
args = parser.parse_args()
|
166
|
+
|
167
|
+
server = args.server if args.server is not None else EGERIA_VIEW_SERVER
|
168
|
+
url = args.url if args.url is not None else EGERIA_PLATFORM_URL
|
169
|
+
userid = args.userid if args.userid is not None else EGERIA_USER
|
170
|
+
password = args.password if args.password is not None else EGERIA_USER_PASSWORD
|
171
|
+
|
172
|
+
try:
|
173
|
+
classification = Prompt.ask("Enter the Classification to filter on", default="Anchors")
|
174
|
+
om_type = Prompt.ask(
|
175
|
+
"Enter the Open Metadata Type to find elements of", default="GlossaryTerm"
|
176
|
+
)
|
177
|
+
property_value = Prompt.ask("Enter the property value to search for")
|
178
|
+
property_names = Prompt.ask("Enter a comma seperated list of properties to search")
|
179
|
+
find_elements_by_classification_by_prop_value(om_type, classification,property_value,
|
180
|
+
[property_names], server, url, userid, password)
|
181
|
+
except KeyboardInterrupt:
|
182
|
+
pass
|
183
|
+
|
184
|
+
|
185
|
+
if __name__ == "__main__":
|
186
|
+
main()
|