pyegeria 0.7.16__py3-none-any.whl → 0.7.17__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.
@@ -52,7 +52,7 @@ from examples.widgets.tech.list_relationship_types import display_relationship_t
52
52
  from examples.widgets.tech.list_tech_templates import display_templates_spec
53
53
  from examples.widgets.tech.list_valid_metadata_values import display_metadata_values
54
54
  from examples.widgets.tech.list_elements import list_elements
55
- from examples.widgets.tech.list_related_elements import display_related_elements
55
+ from examples.widgets.tech.list_related_specification import display_related_specification
56
56
 
57
57
 
58
58
  @tui()
@@ -277,15 +277,13 @@ def show_registered_services(ctx, services):
277
277
  display_registered_svcs(services, c.view_server, c.view_server_url,
278
278
  c.userid, c.password, c.jupyter, c.width)
279
279
 
280
- @show.command('related-elements')
280
+ @show.command('related-specifications')
281
281
  @click.pass_context
282
282
  @click.argument('element-guid')
283
- @click.option('--rel-type',default = 'SpecificationPropertyAssignment',
284
- help="Relationship type to find related elements of")
285
- @click.option('--om_type', default = None, help="Optional Open Metadata Type to filter by.")
286
- def show_related_elements(ctx, element_guid, rel_type, om_type):
283
+ def show_related_specifications(ctx, element_guid):
284
+ """List specifications related to the given Element"""
287
285
  c = ctx.obj
288
- display_related_elements(element_guid,rel_type,om_type, c.view_server, c.view_server_url,
286
+ display_related_specification(element_guid, c.view_server, c.view_server_url,
289
287
  c.userid, c.password, c.jupyter, c.width)
290
288
 
291
289
 
@@ -23,7 +23,7 @@ from examples.widgets.tech.list_tech_templates import display_templates_spec
23
23
  from examples.widgets.tech.list_valid_metadata_values import display_metadata_values
24
24
  from examples.widgets.cat.get_tech_type_template import template_viewer
25
25
  from examples.widgets.tech.list_elements import list_elements
26
- from examples.widgets.tech.list_related_elements import display_related_elements
26
+ from examples.widgets.tech.list_related_specification import display_related_specification
27
27
 
28
28
 
29
29
 
@@ -217,15 +217,13 @@ def get_element_info(ctx, om_type):
217
217
  list_elements(om_type, c.view_server, c.view_server_url,
218
218
  c.userid, c.password, c.jupyter, c.width)
219
219
 
220
- @show.command('related-elements')
220
+ @show.command('related-specifications')
221
221
  @click.pass_context
222
222
  @click.argument('element-guid')
223
- @click.option('--rel-type',default = 'SpecificationPropertyAssignment',
224
- help="Relationship type to find related elements of")
225
- @click.option('--om_type', default = None, help="Optional Open Metadata Type to filter by.")
226
- def show_related_elements(ctx, element_guid, rel_type, om_type):
223
+ def show_related_specifications(ctx, element_guid):
224
+ """List specifications related to the given Element"""
227
225
  c = ctx.obj
228
- display_related_elements(element_guid,rel_type,om_type, c.view_server, c.view_server_url,
226
+ display_related_specification(element_guid,c.view_server, c.view_server_url,
229
227
  c.userid, c.password, c.jupyter, c.width)
230
228
 
231
229
  #
@@ -0,0 +1,144 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ SPDX-License-Identifier: Apache-2.0
4
+ Copyright Contributors to the ODPi Egeria project.
5
+
6
+ List elements related to given element guid by the specified relationship type. Optionally filter by a specified
7
+ open metadata type.
8
+
9
+ """
10
+ import argparse
11
+ import os
12
+ import sys
13
+ import time
14
+
15
+ from rich import box
16
+ from rich.console import Console
17
+ from rich.markdown import Markdown
18
+ from rich.prompt import Prompt
19
+ from rich.table import Table
20
+
21
+ from pyegeria import (InvalidParameterException, PropertyServerException, UserNotAuthorizedException,
22
+ print_exception_response, ClassificationManager)
23
+
24
+ console = Console()
25
+ EGERIA_METADATA_STORE = os.environ.get("EGERIA_METADATA_STORE", "active-metadata-store")
26
+ EGERIA_KAFKA_ENDPOINT = os.environ.get('KAFKA_ENDPOINT', 'localhost:9092')
27
+ EGERIA_PLATFORM_URL = os.environ.get('EGERIA_PLATFORM_URL', 'https://localhost:9443')
28
+ EGERIA_VIEW_SERVER = os.environ.get('VIEW_SERVER', 'view-server')
29
+ EGERIA_VIEW_SERVER_URL = os.environ.get('EGERIA_VIEW_SERVER_URL', 'https://localhost:9443')
30
+ EGERIA_INTEGRATION_DAEMON = os.environ.get('INTEGRATION_DAEMON', 'integration-daemon')
31
+ EGERIA_ADMIN_USER = os.environ.get('ADMIN_USER', 'garygeeke')
32
+ EGERIA_ADMIN_PASSWORD = os.environ.get('ADMIN_PASSWORD', 'secret')
33
+ EGERIA_USER = os.environ.get('EGERIA_USER', 'erinoverview')
34
+ EGERIA_USER_PASSWORD = os.environ.get('EGERIA_USER_PASSWORD', 'secret')
35
+ EGERIA_JUPYTER = bool(os.environ.get('EGERIA_JUPYTER', 'False'))
36
+ EGERIA_WIDTH = int(os.environ.get('EGERIA_WIDTH', '200'))
37
+
38
+
39
+ def display_related_specification(element_guid: str, server: str, url: str, username: str, password: str,
40
+ jupyter: bool = EGERIA_JUPYTER, width: int = EGERIA_WIDTH):
41
+ c_client = ClassificationManager(server, url, user_id=username, user_pwd=password)
42
+ token = c_client.create_egeria_bearer_token()
43
+ rel_el = c_client.get_related_elements(element_guid, 'SpecificationPropertyAssignment', None)
44
+
45
+ if type(rel_el) is str:
46
+ print(f"\n\nWas not able list related specifications for {element_guid}\n\n")
47
+ sys.exit(0)
48
+
49
+ related_elements: dict = {}
50
+
51
+ def generate_table() -> Table:
52
+ """Make a new table."""
53
+ table = Table(title=f"Specifications related to: {element_guid} @ {time.asctime()}",
54
+ style="bold bright_white on black", row_styles=["bold bright_white on black"],
55
+ header_style="white on dark_blue", title_style="bold bright_white on black", caption_style="white on black",
56
+ show_lines=True, box=box.ROUNDED, caption=f"Elements from Server '{server}' @ Platform - {url}",
57
+ expand=True, # width=500
58
+ )
59
+
60
+ table.add_column("Name", justify='center', style="bold bright_white")
61
+ table.add_column("Specification", justify='center', style="bold bright_white")
62
+
63
+ for element in rel_el:
64
+ relationship_props = element["relationshipProperties"]['propertyType']
65
+ related_elements[relationship_props] = []
66
+
67
+ for element in rel_el:
68
+ relationship_props = element["relationshipProperties"]['propertyType']
69
+
70
+ rel_element = element['relatedElement']
71
+ el = rel_element["properties"]
72
+ re: dict = {}
73
+
74
+ re['case'] = el.get("isCaseSensitive", '---')
75
+ re['name'] = el.get("preferredValue", '---')
76
+ re['description'] = el.get("description", '---')
77
+ add = el.get("additionalProperties", '---')
78
+ if type(add) is str:
79
+ re['additional'] = add
80
+ else:
81
+ add_md = ""
82
+ for k in add.keys():
83
+ add_md += f"* {k}: {add[k]}\n"
84
+ re['additional'] = Markdown(add_md)
85
+
86
+ related_elements[relationship_props].append(re)
87
+
88
+ for kind in related_elements.keys():
89
+
90
+ spec_table = Table(expand=False, show_lines=True)
91
+ spec_table.add_column('Name')
92
+ spec_table.add_column('Case Sensitive?')
93
+ spec_table.add_column('Description')
94
+ spec_table.add_column('Additional Properties')
95
+
96
+ for spec_row in related_elements[kind]:
97
+ name = spec_row['name']
98
+ case = spec_row['case']
99
+ desc = spec_row['description']
100
+ additional_props = spec_row['additional']
101
+ spec_table.add_row(name, case, desc, additional_props)
102
+
103
+ table.add_row(kind, spec_table)
104
+
105
+ return table
106
+
107
+ try:
108
+ console = Console(width=width, force_terminal=not jupyter)
109
+
110
+ with console.pager(styles=True):
111
+ console.print(generate_table())
112
+
113
+ except (InvalidParameterException, PropertyServerException, UserNotAuthorizedException) as e:
114
+ print_exception_response(e)
115
+ assert e.related_http_code != "200", "Invalid parameters"
116
+ finally:
117
+ c_client.close_session()
118
+
119
+
120
+ def main():
121
+ parser = argparse.ArgumentParser()
122
+ parser.add_argument("--server", help="Name of the server to display status for")
123
+ parser.add_argument("--url", help="URL Platform to connect to")
124
+ parser.add_argument("--userid", help="User Id")
125
+ parser.add_argument("--password", help="Password")
126
+
127
+ args = parser.parse_args()
128
+
129
+ server = args.server if args.server is not None else EGERIA_VIEW_SERVER
130
+ url = args.url if args.url is not None else EGERIA_PLATFORM_URL
131
+ userid = args.userid if args.userid is not None else EGERIA_USER
132
+ password = args.password if args.password is not None else EGERIA_USER_PASSWORD
133
+ guid = None
134
+
135
+ try:
136
+ element_guid = Prompt.ask("Enter an Element GUID find relationships for")
137
+
138
+ display_related_specification(element_guid, server, url, userid, password)
139
+ except(KeyboardInterrupt):
140
+ pass
141
+
142
+
143
+ if __name__ == "__main__":
144
+ main()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyegeria
3
- Version: 0.7.16
3
+ Version: 0.7.17
4
4
  Summary: A python client for Egeria
5
5
  Home-page: https://github.com/odpi/egeria-python
6
6
  License: Apache 2.0
@@ -15,11 +15,11 @@ examples/widgets/cat/list_relationships.py,sha256=lRfnsMUc0KN6Gb3qJoHjAwYGrcvTk3
15
15
  examples/widgets/cat/list_tech_types.py,sha256=20T4v6L5qeebSsaL1nGkFMDAIsy2W3A3SMm1RcgFoh0,4609
16
16
  examples/widgets/cat/list_todos.py,sha256=wD9HevGcc4G_bxV25VUz1rRssdZHE33mF5zmJ6Lprt8,5522
17
17
  examples/widgets/cli/__init__.py,sha256=6d_R0KZBNnJy9EBz9J2xvGFlx-3j_ZPqPCxKgdvYeDQ,291
18
- examples/widgets/cli/egeria.py,sha256=lCpnsdOjg6E8vQ2DbjxkXf9Mw5h-Y2b1g0RXnYo_eRw,24623
18
+ examples/widgets/cli/egeria.py,sha256=L8VdfZcI_2ccbOIiXNeaYWXgzvG7RwS3n5AzyXNxbOU,24440
19
19
  examples/widgets/cli/egeria_cat.py,sha256=q02DByikrGY6QHPy5u-R6zVBt6-y146iecmkA3oVb4A,10826
20
20
  examples/widgets/cli/egeria_my.py,sha256=xi2j1hzNnjDruJeR1qa8K9JPDgzaL_COsMkcieT4Vo8,5653
21
21
  examples/widgets/cli/egeria_ops.py,sha256=Y2fNDFnaaMjt8vjOeUXneh4_WEyxp0ucMvIfdLn8Bik,10139
22
- examples/widgets/cli/egeria_tech.py,sha256=C16HE4d-hwcLOlSCl9QODx9PXzQ5nJu55o7lFm1ZoZk,9996
22
+ examples/widgets/cli/egeria_tech.py,sha256=tbFbJJFY6MpU6hbF9VSBLWOlaUbeUgesSFPi4wOF0_Y,9812
23
23
  examples/widgets/cli/ops_config.py,sha256=m4AfPjf-fR4EBTx8Dc2mcgrfWwAxb30YGeV-v79bg4U,1450
24
24
  examples/widgets/my/README.md,sha256=ZheFhj_VoPMhcWjW3pGchHB0vH_A9PklSmrSkzKdrcQ,844
25
25
  examples/widgets/my/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -51,10 +51,11 @@ examples/widgets/tech/get_tech_details.py,sha256=p5OgSKep3VOuuZmQXE2OSYhE-kvnI18
51
51
  examples/widgets/tech/list_asset_types.py,sha256=PHPtCXqCHhIw0K59hUvoKdybp6IKPt_9Wc0AJVDtdrg,4181
52
52
  examples/widgets/tech/list_elements.py,sha256=xQg-PGS2oORed2ATVNPZvGVCGLEUHO5rOeXvgS6pkrg,4726
53
53
  examples/widgets/tech/list_registered_services.py,sha256=TqZbT54vMGvHUAX_bovCce3A3eV_RbjSEtPP6u6ZJV0,6388
54
- examples/widgets/tech/list_related_elements.py,sha256=hDiPThI9FLI63yoWEy7j7k_zLPBSlZIXYSaixiY_YAY,5785
54
+ examples/widgets/tech/list_related_specification.py,sha256=7omZFJPndec1zCL_reO1drvE6fHi4MQJu6PpAh9FNww,5802
55
55
  examples/widgets/tech/list_relationship_types.py,sha256=0T8Sl7J3WFq_0IQLLzcL0T79pUxVENWNT95Cpjz2ukc,5633
56
56
  examples/widgets/tech/list_tech_templates.py,sha256=RiyA8a4fIL9BGeGf37Bkk471mK5ECkDJMN9QVNReC1M,6192
57
57
  examples/widgets/tech/list_valid_metadata_values.py,sha256=64z5tr-0VD-mPTFmr6FT76gj4MXJZLWTxT4oeIiUaiU,6043
58
+ examples/widgets/tech/x_list_related_elements.py,sha256=hDiPThI9FLI63yoWEy7j7k_zLPBSlZIXYSaixiY_YAY,5785
58
59
  pyegeria/Xloaded_resources_omvs.py,sha256=cseWZTIwNhkzhZ0fhujI66DslNAQcjuwsz_p1GRmSPQ,3392
59
60
  pyegeria/__init__.py,sha256=RNkQeblUJGmnCY7U8l8xMhivpVzMcXRBafxDAzxG6Lc,7714
60
61
  pyegeria/_client.py,sha256=mTK3qqaxwrwn4OiIKZkSkMVEsHPJsHxKmfz1LK_FgEg,26308
@@ -81,8 +82,8 @@ pyegeria/runtime_manager_omvs.py,sha256=oSVFeG_yBGXIvQR0EClLZqTZ6C5z5ReZzwm8cce8
81
82
  pyegeria/server_operations.py,sha256=1z2wZLdrNZG6HlswY_Eh8qI1mlcjsQ59zO-AMy9XbUU,16605
82
83
  pyegeria/utils.py,sha256=pkVmS3RrbjaS9yz7FtOCwaOfV5FMqz-__Rt5koCnd9c,5374
83
84
  pyegeria/valid_metadata_omvs.py,sha256=aisdRodIwJSkyArAzfm_sEnBELh69xE8k4Nea-vHu8M,36745
84
- pyegeria-0.7.16.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
85
- pyegeria-0.7.16.dist-info/METADATA,sha256=UrNPrPJxm58XxX7OozELahmXQGwO1xv4mX9y2P47Oa4,2775
86
- pyegeria-0.7.16.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
87
- pyegeria-0.7.16.dist-info/entry_points.txt,sha256=zCihYOoewwczEFaj8HIjQjfppnFz79m--yUSA3_Sg3k,2994
88
- pyegeria-0.7.16.dist-info/RECORD,,
85
+ pyegeria-0.7.17.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
86
+ pyegeria-0.7.17.dist-info/METADATA,sha256=2cG8Oe7rsCNDuVRh7Kq1ckSHk0e5dFtC6mvTqchIQiI,2775
87
+ pyegeria-0.7.17.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
88
+ pyegeria-0.7.17.dist-info/entry_points.txt,sha256=hnXpc9IDhQuV3fR_Ann1Cbn-IvheeRI0Fc0tRQWNamg,3004
89
+ pyegeria-0.7.17.dist-info/RECORD,,
@@ -24,7 +24,7 @@ list_integ_daemon_status=examples.widgets.ops.monitor_integ_daemon_status:main_p
24
24
  list_my_profile=examples.widgets.my.list_my_profile:main
25
25
  list_projects=examples.widgets.cat.list_projects:main
26
26
  list_registered_services=examples.widgets.tech.list_registered_services:main
27
- list_related_elements=examples.widgets.tech.list_related_elements:main
27
+ list_related_specification=examples.widgets.tech.list_related_specification:main
28
28
  list_relationship_types=examples.widgets.tech.list_relationship_types:main
29
29
  list_relationships=examples.widgets.cat.list_relationships:main
30
30
  list_tech_templates=examples.widgets.tech.list_tech_templates:main