pyegeria 0.6.4__py3-none-any.whl → 0.6.5__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.
@@ -0,0 +1,109 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ SPDX-License-Identifier: Apache-2.0
4
+ Copyright Contributors to the ODPi Egeria project.
5
+
6
+ A simple viewer for collections - provide the root and we display the hierarchy
7
+
8
+ """
9
+
10
+ import argparse
11
+ import os
12
+ from rich import print
13
+ from rich.panel import Panel
14
+ from rich.prompt import Prompt
15
+ from rich.text import Text
16
+ from rich.tree import Tree
17
+
18
+ from pyegeria import ProjectManager, UserNotAuthorizedException, PropertyServerException, InvalidParameterException
19
+ from pyegeria._exceptions import (
20
+ print_exception_response,
21
+ )
22
+
23
+ disable_ssl_warnings = True
24
+ EGERIA_METADATA_STORE = os.environ.get("EGERIA_METADATA_STORE", "active-metadata-store")
25
+ EGERIA_KAFKA_ENDPOINT = os.environ.get('KAFKA_ENDPOINT', 'localhost:9092')
26
+ EGERIA_PLATFORM_URL = os.environ.get('EGERIA_PLATFORM_URL', 'https://localhost:9443')
27
+ EGERIA_VIEW_SERVER = os.environ.get('VIEW_SERVER', 'view-server')
28
+ EGERIA_VIEW_SERVER_URL = os.environ.get('EGERIA_VIEW_SERVER_URL', 'https://localhost:9443')
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
+ def project_structure_viewer(root: str, server_name: str, platform_url: str, user: str, user_password: str,
38
+ jupyter:bool=EGERIA_JUPYTER, width:int = EGERIA_WIDTH):
39
+ """ A simple collection viewer"""
40
+ def walk_project_hierarchy(project_client: ProjectManager, root_project_name: str, tree: Tree) -> None:
41
+ """Recursively build a Tree with collection contents."""
42
+ project = project_client.get_projects_by_name(root_project_name)
43
+ if type(project) is list:
44
+ root_guid = project['elementHeader']['guid']
45
+ proj_props = project['properties']
46
+ proj_props_md = ""
47
+ for key in proj_props.keys():
48
+ proj_props_md += f"* {key}: {proj_props[key]}\n"
49
+
50
+ t = tree.add()
51
+
52
+
53
+ members = project_client.get_member_list(root_collection_name)
54
+ if members:
55
+ for member in members:
56
+ style = "bold white on black"
57
+ text_collection_name = Text(f"[bold white on black]Name: {member['name']}", style=style)
58
+ text_qualified_name = Text(f"* QualifiedName: {member['qualifiedName']}")
59
+ text_guid = Text(f"* GUID: {member['guid']}", "green")
60
+ text_collection_type = Text(f"* Collection Type: {member['collectionType']}")
61
+ text_description = Text(f"* Description: {member['description']}")
62
+ p = Panel.fit(f"{text_collection_name}[green]\n{text_qualified_name}\n{text_guid}\n"
63
+ f"{text_collection_type}\n{text_description}")
64
+ tt = tree.add(p, style=style)
65
+
66
+ children = collection_client.get_collection_members(member['guid'])
67
+ if type(children) is list:
68
+ branch = tt.add(f"[bold magenta on black]Members", style=style, guide_style=style)
69
+ walk_collection_hierarchy(collection_client, member['qualifiedName'], branch),
70
+ else:
71
+ tt = tree.add(f"[bold magenta on black]No collections match {root_collection_name}")
72
+ try:
73
+ tree = Tree(f"[bold bright green on black]{root}",guide_style="bold bright_blue")
74
+ p_client = ProjectManager(server_name, platform_url,
75
+ user_id=user)
76
+
77
+ token = p_client.create_egeria_bearer_token(user, user_password)
78
+ walk_project_hierarchy(p_client, root, tree)
79
+ print(tree)
80
+
81
+ except (
82
+ InvalidParameterException,
83
+ PropertyServerException,
84
+ UserNotAuthorizedException
85
+ ) as e:
86
+ print_exception_response(e)
87
+
88
+
89
+ def main():
90
+ parser = argparse.ArgumentParser()
91
+
92
+ parser.add_argument("--server", help="Name of the server to display status for")
93
+ parser.add_argument("--url", help="URL Platform to connect to")
94
+ parser.add_argument("--userid", help="User Id")
95
+ parser.add_argument("--password", help="User Password")
96
+ args = parser.parse_args()
97
+
98
+ server = args.server if args.server is not None else EGERIA_VIEW_SERVER
99
+ url = args.url if args.url is not None else EGERIA_PLATFORM_URL
100
+ userid = args.userid if args.userid is not None else EGERIA_USER
101
+ user_pass = args.password if args.password is not None else EGERIA_USER_PASSWORD
102
+
103
+ try:
104
+ root_project = Prompt.ask("Enter the Root Project to start from:", default="Sustainability Campaign")
105
+ project_structure_viewer(root_project, server, url, userid, user_pass)
106
+ except (KeyboardInterrupt):
107
+ pass
108
+ if __name__ == "__main__":
109
+ main()
@@ -0,0 +1,176 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ SPDX-License-Identifier: Apache-2.0
4
+ Copyright Contributors to the ODPi Egeria project.
5
+
6
+ List certification types
7
+
8
+
9
+ A simple display for certification types
10
+ """
11
+ import argparse
12
+ import os
13
+ import sys
14
+ import time
15
+ import json
16
+
17
+ from rich import box
18
+ from rich.console import Console
19
+ from rich.prompt import Prompt
20
+ from rich.markdown import Markdown
21
+ from rich.table import Table
22
+
23
+ from pyegeria import (
24
+ InvalidParameterException,
25
+ PropertyServerException,
26
+ UserNotAuthorizedException,
27
+ print_exception_response,
28
+ AssetCatalog,
29
+ ClassificationManager
30
+ )
31
+ EGERIA_METADATA_STORE = os.environ.get("EGERIA_METADATA_STORE", "active-metadata-store")
32
+ EGERIA_KAFKA_ENDPOINT = os.environ.get('KAFKA_ENDPOINT', 'localhost:9092')
33
+ EGERIA_PLATFORM_URL = os.environ.get('EGERIA_PLATFORM_URL', 'https://localhost:9443')
34
+ EGERIA_VIEW_SERVER = os.environ.get('VIEW_SERVER', 'view-server')
35
+ EGERIA_VIEW_SERVER_URL = os.environ.get('EGERIA_VIEW_SERVER_URL', 'https://localhost:9443')
36
+ EGERIA_INTEGRATION_DAEMON = os.environ.get('INTEGRATION_DAEMON', 'integration-daemon')
37
+ EGERIA_ADMIN_USER = os.environ.get('ADMIN_USER', 'garygeeke')
38
+ EGERIA_ADMIN_PASSWORD = os.environ.get('ADMIN_PASSWORD', 'secret')
39
+ EGERIA_USER = os.environ.get('EGERIA_USER', 'erinoverview')
40
+ EGERIA_USER_PASSWORD = os.environ.get('EGERIA_USER_PASSWORD', 'secret')
41
+ EGERIA_JUPYTER = bool(os.environ.get('EGERIA_JUPYTER', 'False'))
42
+ EGERIA_WIDTH = int(os.environ.get('EGERIA_WIDTH', '200'))
43
+
44
+
45
+ disable_ssl_warnings = True
46
+
47
+
48
+ def display_certifications(search_string: str, server: str, url: str, username: str, user_password: str, time_out: int = 60,
49
+ jupyter: bool = EGERIA_JUPYTER, width: int = EGERIA_WIDTH):
50
+ console = Console(width=width, force_terminal=not jupyter, soft_wrap=True)
51
+ if (search_string is None) or ((len(search_string) < 3)) and (search_string != '*'):
52
+ raise ValueError("Invalid Search String - must be greater than four characters long")
53
+ g_client = ClassificationManager(server, url, user_id=username,user_pwd=user_password )
54
+ token = g_client.create_egeria_bearer_token(username, user_password)
55
+
56
+
57
+ def generate_table(search_string:str = None) -> Table:
58
+ """Make a new table."""
59
+ table = Table(
60
+ title=f"Certifications Types @ {time.asctime()}",
61
+ header_style="white on dark_blue",
62
+ style="bold white on black",
63
+ row_styles=["bold white on black"],
64
+ title_style="bold white on black",
65
+ caption_style="white on black",
66
+ show_lines=True,
67
+ box=box.ROUNDED,
68
+ caption=f"View Server '{server}' @ Platform - {url}",
69
+ expand=True
70
+ )
71
+ table.add_column("Title", max_width=15)
72
+ table.add_column('summary')
73
+ table.add_column("domainID")
74
+ table.add_column("Unique Name")
75
+ table.add_column("Scope")
76
+ # table.add_column("Qualified Name",max_width=15)
77
+ table.add_column("Description")
78
+ table.add_column("Details")
79
+ table.add_column("Related Elements")
80
+
81
+
82
+ certs = g_client.get_elements(search_string, page_size=100, time_out=time_out)
83
+ if type(certs) is str:
84
+ return table
85
+
86
+ for element in certs:
87
+ properties = element['properties']
88
+ summary = properties.get('summary',"---")
89
+ domain = properties.get("domainIdentifier",'---')
90
+ unique_name = properties.get('qualifiedName','---')
91
+ scope = properties.get('scope','---')
92
+ description = properties.get('description','---')
93
+ details = properties.get('details','---')
94
+ title = properties.get('title','---')
95
+ cert_guid = element['elementHeader']['guid']
96
+
97
+ related = g_client.get_all_related_elements(cert_guid)
98
+ if (len(related) > 0) and (type(related) is list):
99
+ rel_md = ''
100
+ for rel in related:
101
+ rel_type = rel['relationshipHeader']['type']['typeName']
102
+ rel_element_props = rel['relatedElement']['properties']
103
+ rel_el_md = f"* Rel Type: {rel_type}\n"
104
+ for key in rel_element_props.keys():
105
+ rel_el_md += f"* {key}: {rel_element_props[key]}\n"
106
+ rel_md += f"----\n{rel_el_md}\n"
107
+ else:
108
+ rel_md = '---'
109
+
110
+ # match_tab = Table(expand=True)
111
+ # match_tab.add_column("Type Name")
112
+ # match_tab.add_column("GUID", no_wrap=True, width=36)
113
+ # match_tab.add_column("Properties")
114
+ #
115
+ # for match in nested:
116
+ # match_type_name = match['type']['typeName']
117
+ # matching_guid = match['guid']
118
+ # match_props = match['properties']
119
+ # match_details_md = ""
120
+ # for key in match_props.keys():
121
+ # match_details_md += f"* {key}: {match_props[key]}\n"
122
+ # match_details_out = Markdown(match_details_md)
123
+ # match_tab.add_row(match_type_name, matching_guid, match_details_out)
124
+
125
+
126
+ table.add_row(
127
+ title, summary, domain, unique_name,scope,description,details, rel_md
128
+ )
129
+
130
+ g_client.close_session()
131
+
132
+ return table
133
+
134
+ try:
135
+ # with Live(generate_table(), refresh_per_second=4, screen=True) as live:
136
+ # while True:
137
+ # time.sleep(2)
138
+ # live.update(generate_table())
139
+
140
+ with console.pager(styles=True):
141
+ console.print(generate_table(search_string), soft_wrap=True)
142
+
143
+
144
+ except (InvalidParameterException, PropertyServerException, UserNotAuthorizedException) as e:
145
+ console.print_exception()
146
+ sys.exit(1)
147
+
148
+ except ValueError as e:
149
+ console.print(f"\n\n====> Invalid Search String - must be greater than four characters long")
150
+ sys.exit(1)
151
+
152
+
153
+ def main():
154
+ parser = argparse.ArgumentParser()
155
+ parser.add_argument("--server", help="Name of the server to display status for")
156
+ parser.add_argument("--url", help="URL Platform to connect to")
157
+ parser.add_argument("--userid", help="User Id")
158
+ parser.add_argument("--password", help="User Password")
159
+ parser.add_argument("--time_out", help="Time Out")
160
+
161
+ args = parser.parse_args()
162
+
163
+ server = args.server if args.server is not None else EGERIA_VIEW_SERVER
164
+ url = args.url if args.url is not None else EGERIA_PLATFORM_URL
165
+ userid = args.userid if args.userid is not None else EGERIA_USER
166
+ user_pass = args.password if args.password is not None else EGERIA_USER_PASSWORD
167
+ time_out = args.time_out if args.time_out is not None else 60
168
+ try:
169
+ # search_string = Prompt.ask("Enter an asset search string:", default="*")
170
+ search_string = 'CertificationType'
171
+ display_certifications(search_string, server, url, userid, user_pass, time_out)
172
+ except(KeyboardInterrupt):
173
+ pass
174
+
175
+ if __name__ == "__main__":
176
+ main()
@@ -26,7 +26,7 @@ from pyegeria import (
26
26
  UserNotAuthorizedException,
27
27
  print_exception_response,
28
28
  )
29
- from pyegeria import ProjectManager
29
+ from pyegeria import ProjectManager, ClassificationManager
30
30
 
31
31
  EGERIA_METADATA_STORE = os.environ.get("EGERIA_METADATA_STORE", "active-metadata-store")
32
32
  EGERIA_KAFKA_ENDPOINT = os.environ.get('KAFKA_ENDPOINT', 'localhost:9092')
@@ -48,6 +48,7 @@ def display_project_list(project_name: str, server: str, url: str,
48
48
  width: int = EGERIA_WIDTH):
49
49
  p_client = ProjectManager(server, url, user_id=username)
50
50
  token = p_client.create_egeria_bearer_token(username, user_pass)
51
+ c_client = ClassificationManager(server, url, token)
51
52
 
52
53
  def generate_table(project_name: str) -> Table:
53
54
  """Make a new table."""
@@ -60,7 +61,7 @@ def display_project_list(project_name: str, server: str, url: str,
60
61
  expand=True
61
62
  )
62
63
 
63
- table.add_column("Display Name")
64
+ table.add_column("Project Name")
64
65
  table.add_column("Description")
65
66
 
66
67
  table.add_column("Classifications")
@@ -112,11 +113,24 @@ def display_project_list(project_name: str, server: str, url: str,
112
113
  if additional_properties is not None:
113
114
  props = json.dumps(additional_properties)
114
115
 
116
+ governed_by = c_client.get_related_elements(guid,'GovernedBy')
117
+ if type(governed_by) is list:
118
+ for gov in governed_by:
119
+ rel_guid = gov['relatedElement']['elementHeader']['guid']
120
+ rel_title = gov['relatedElement']['properties'].get('title','---')
121
+ certified_partner= f"{rel_title}: \n"
122
+ certified = c_client.get_related_elements(rel_guid, "Certification")
123
+ if type(certified) is list:
124
+ for rel_elem in certified:
125
+ p_name = rel_elem['relatedElement']['properties']['name']
126
+ certified_partner += f"* {p_name}\n"
127
+ else:
128
+ certified_partner = "---"
115
129
 
116
130
 
117
131
  table.add_row(
118
132
  name, description, classification, qualified_name, identifier, phase, health, status, start,
119
- end, '---')
133
+ end, certified_partner)
120
134
 
121
135
  p_client.close_session()
122
136
  return table
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyegeria
3
- Version: 0.6.4
3
+ Version: 0.6.5
4
4
  Summary: A python client for Egeria
5
5
  Home-page: https://github.com/odpi/egeria-python
6
6
  License: Apache 2.0
@@ -4,11 +4,13 @@ examples/widgets/cat/README.md,sha256=-aaAnIT2fcfU63vajgB-RzQk4l4yFdhkyVfSaTPiqR
4
4
  examples/widgets/cat/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  examples/widgets/cat/get_asset_graph.py,sha256=Q23n_svJBii58hgaMPLpliN8wqKl4yhnhCCk2IU2nvM,11168
6
6
  examples/widgets/cat/get_collection.py,sha256=DBZ5-XkoYsz4WmMSPz0Ao0wz3DlAUQve89KI26-44nc,4613
7
+ examples/widgets/cat/get_project_structure.py,sha256=IA5PtZn6IzhVF0J6vzCasKPqu6Y1dY7CHkzo6VvqedA,4962
7
8
  examples/widgets/cat/get_tech_type_elements.py,sha256=SvnDWfBIA1NzpkKZj4-ZapIeM2SEhe5jJt7rTkvTzaA,6129
8
9
  examples/widgets/cat/get_tech_type_template.py,sha256=gMFVcgCIm09GQu1Vsc5ZUVH9XLhItAG1eVGZJrcnHeQ,6174
9
10
  examples/widgets/cat/list_assets.py,sha256=imVun2GB3zoEjaQxKJVGcalI7yZv5Dg_ksb7tYCIVLE,6476
11
+ examples/widgets/cat/list_cert_types.py,sha256=6FmVoNVKz6TRaxQ0XR8IySRCvwKV03wOoY_bSwLgFdU,7005
10
12
  examples/widgets/cat/list_glossary.py,sha256=zljSzVKYysFZVmVhHJt0fYFDmAG9azIphOs4MOIfA7g,5395
11
- examples/widgets/cat/list_projects.py,sha256=pFXjP_OjfLqR0hQuJl90u8Y7T0Z0YdVZazrcUwPVGaE,6510
13
+ examples/widgets/cat/list_projects.py,sha256=jP6HoVqGi-w4R1itgdAW1zamPLsgkvjvh8reRj0v10Q,7432
12
14
  examples/widgets/cat/list_tech_types.py,sha256=20T4v6L5qeebSsaL1nGkFMDAIsy2W3A3SMm1RcgFoh0,4609
13
15
  examples/widgets/cat/list_todos.py,sha256=wD9HevGcc4G_bxV25VUz1rRssdZHE33mF5zmJ6Lprt8,5522
14
16
  examples/widgets/cli/__init__.py,sha256=6d_R0KZBNnJy9EBz9J2xvGFlx-3j_ZPqPCxKgdvYeDQ,291
@@ -76,8 +78,8 @@ pyegeria/runtime_manager_omvs.py,sha256=oSVFeG_yBGXIvQR0EClLZqTZ6C5z5ReZzwm8cce8
76
78
  pyegeria/server_operations.py,sha256=ZX7FlJRrAC7RK4bq4wHWepEsYbbWlqkUZdsJrTplVVU,16534
77
79
  pyegeria/utils.py,sha256=pkVmS3RrbjaS9yz7FtOCwaOfV5FMqz-__Rt5koCnd9c,5374
78
80
  pyegeria/valid_metadata_omvs.py,sha256=aisdRodIwJSkyArAzfm_sEnBELh69xE8k4Nea-vHu8M,36745
79
- pyegeria-0.6.4.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
80
- pyegeria-0.6.4.dist-info/METADATA,sha256=0MjuQgAF2P8S0TonF0zw01gDKvQT9NAG1M_gx37rfZQ,2774
81
- pyegeria-0.6.4.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
82
- pyegeria-0.6.4.dist-info/entry_points.txt,sha256=Up_rwJL9Rnmsp4Lp5433ctUMb6qR9uTQc7e5tVkcXFg,2599
83
- pyegeria-0.6.4.dist-info/RECORD,,
81
+ pyegeria-0.6.5.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
82
+ pyegeria-0.6.5.dist-info/METADATA,sha256=itmo7_30ZJcfzitQ9CAgp6j-j4AmiZ8OY9za5IGbf-4,2774
83
+ pyegeria-0.6.5.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
84
+ pyegeria-0.6.5.dist-info/entry_points.txt,sha256=JZ24qmAz953R1Rw2l5PpW6O_IyIuHBz-ypZvl2mvccE,2657
85
+ pyegeria-0.6.5.dist-info/RECORD,,
@@ -13,6 +13,7 @@ hey_egeria=examples.widgets.cli.egeria:cli
13
13
  list_asset_types=examples.widgets.tech.list_asset_types:main
14
14
  list_assets=examples.widgets.cat.list_assets:main
15
15
  list_catalog_targets=examples.widgets.ops.list_catalog_targets:main
16
+ list_cert_types=examples.widgets.cat.list_cert_types:main
16
17
  list_engine_activity=examples.widgets.ops.monitor_engine_activity:main_paging
17
18
  list_glossary=examples.widgets.cat.list_glossary:main
18
19
  list_gov_eng_status=examples.widgets.ops.monitor_gov_eng_status:main_paging