pyegeria 1.5.1.0.16__py3-none-any.whl → 1.5.1.0.19__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.
@@ -114,15 +114,6 @@ def list_deployed_database_schemas(
114
114
  continue
115
115
 
116
116
  el_name = element["properties"].get("name", "---")
117
- # el_type = header["type"]["typeName"]
118
- # el_home = header["origin"]["homeMetadataCollectionName"]
119
- # el_create_time = header["versions"]["createTime"][:-10]
120
- # el_created_by = header["versions"]["createdBy"]
121
- # el_created_md = (
122
- # f"* **Created By**: {el_created_by}\n"
123
- # f"* **Created Time**: {el_create_time}"
124
- # )
125
- # el_created_out = Markdown(el_created_md)
126
117
 
127
118
  el_guid = header["guid"]
128
119
 
@@ -148,9 +139,6 @@ def list_deployed_database_schemas(
148
139
 
149
140
  # get the schema properties
150
141
  el_props_md = make_prop_md(element["properties"])
151
- # el_props_md = ""
152
- # for prop in element["properties"].keys():
153
- # el_props_md += f"* **{prop}**: {element['properties'][prop]}\n"
154
142
 
155
143
  # Now get property facets related to us
156
144
  el_facets = c_client.get_related_elements(
@@ -189,7 +177,7 @@ def list_deployed_database_schemas(
189
177
  # spacer = "---\n"
190
178
  # elif count > len_els:
191
179
  # spacer = ""
192
- rel_el_md = f"{rel_el_md}\n* **{rel_type}**:\n\t{rel_guid}\n{props_md}{spacer}"
180
+ # rel_el_md = f"{rel_el_md}\n* **{rel_type}**:\n\t{rel_guid}\n{props_md}{spacer}"
193
181
  if count == len_els:
194
182
  rel_el_md = rel_el_md[:-4]
195
183
  rel_el_out = Markdown(rel_el_md)
commands/cli/egeria.py CHANGED
@@ -32,7 +32,7 @@ from commands.my.list_my_profile import display_my_profile
32
32
  from commands.my.list_my_roles import display_my_roles
33
33
  from commands.my.monitor_my_todos import display_my_todos
34
34
  from commands.my.monitor_open_todos import display_todos
35
- from commands.cat.old_list_deployed_database_schemas import (
35
+ from commands.cat.list_deployed_database_schemas import (
36
36
  list_deployed_database_schemas,
37
37
  )
38
38
  from commands.cat.list_deployed_catalogs import list_deployed_catalogs
@@ -16,6 +16,9 @@ from rich import box
16
16
  from rich.console import Console
17
17
  from rich.live import Live
18
18
  from rich.table import Table
19
+ import nest_asyncio
20
+ from typing import Union
21
+ from textual.widgets import DataTable
19
22
 
20
23
  from pyegeria import EgeriaTech, AutomatedCuration
21
24
  from pyegeria._exceptions import (
@@ -44,6 +47,7 @@ EGERIA_WIDTH = int(os.environ.get("EGERIA_WIDTH", "200"))
44
47
  disable_ssl_warnings = True
45
48
 
46
49
 
50
+
47
51
  def display_integration_daemon_status(
48
52
  integ_server: str = EGERIA_INTEGRATION_DAEMON,
49
53
  integ_url: str = EGERIA_INTEGRATION_DAEMON_URL,
@@ -0,0 +1,292 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ SPDX-License-Identifier: Apache-2.0
4
+ Copyright Contributors to the ODPi Egeria project.
5
+
6
+
7
+ A simple status display for the Integration Daemon.
8
+
9
+
10
+ """
11
+ import argparse
12
+ import os
13
+ import time
14
+
15
+ from rich import box
16
+ from rich.console import Console
17
+ from rich.live import Live
18
+ from rich.table import Table
19
+ import nest_asyncio
20
+ from typing import Union
21
+ from textual.widgets import DataTable
22
+
23
+ from pyegeria import EgeriaTech, AutomatedCuration
24
+ from pyegeria._exceptions import (
25
+ InvalidParameterException,
26
+ PropertyServerException,
27
+ UserNotAuthorizedException,
28
+ print_exception_response,
29
+ )
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(
36
+ "EGERIA_VIEW_SERVER_URL", "https://localhost:9443"
37
+ )
38
+ EGERIA_INTEGRATION_DAEMON = os.environ.get("INTEGRATION_DAEMON", "integration-daemon")
39
+ EGERIA_INTEGRATION_DAEMON_URL = os.environ.get(
40
+ "EGERIA_INTEGRATION_DAEMON_URL", "https://localhost:9443"
41
+ )
42
+ EGERIA_USER = os.environ.get("EGERIA_USER", "erinoverview")
43
+ EGERIA_USER_PASSWORD = os.environ.get("EGERIA_USER_PASSWORD", "secret")
44
+ EGERIA_JUPYTER = bool(os.environ.get("EGERIA_JUPYTER", "False"))
45
+ EGERIA_WIDTH = int(os.environ.get("EGERIA_WIDTH", "200"))
46
+
47
+ disable_ssl_warnings = True
48
+
49
+
50
+ def add_row(
51
+ table: Union[Table, DataTable],
52
+ connector_name: str,
53
+ connector_status: str,
54
+ last_refresh_time: str,
55
+ refresh_interval: str,
56
+ targets_out,
57
+ exception_msg,
58
+ ) -> Table | DataTable:
59
+ table.add_row(
60
+ connector_name,
61
+ connector_status,
62
+ last_refresh_time,
63
+ refresh_interval,
64
+ targets_out,
65
+ exception_msg,
66
+ )
67
+ return table
68
+
69
+
70
+ def display_integration_daemon_status(
71
+ integ_server: str = EGERIA_INTEGRATION_DAEMON,
72
+ integ_url: str = EGERIA_INTEGRATION_DAEMON_URL,
73
+ view_server: str = EGERIA_VIEW_SERVER,
74
+ view_url: str = EGERIA_VIEW_SERVER_URL,
75
+ user: str = EGERIA_USER,
76
+ user_pass: str = EGERIA_USER_PASSWORD,
77
+ paging: bool = True,
78
+ jupyter: bool = EGERIA_JUPYTER,
79
+ width: int = EGERIA_WIDTH,
80
+ sort: bool = True,
81
+ data_table: bool = False,
82
+ ) -> Table | DataTable:
83
+ s_client = EgeriaTech(view_server, view_url, user, user_pass)
84
+ nest_asyncio.apply()
85
+
86
+ def generate_table() -> Table:
87
+ """Make a new table."""
88
+
89
+ if data_table:
90
+ table = DataTable()
91
+ table.add_columns(
92
+ "Connector Name",
93
+ "Status",
94
+ "Last Refresh Time",
95
+ "Min Refresh (Mins)",
96
+ "Target Element",
97
+ "Exception Message",
98
+ )
99
+ else:
100
+ table = Table(
101
+ title=f"Integration Daemon Status @ {time.asctime()}",
102
+ style="bold white on black",
103
+ row_styles=["bold white on black"],
104
+ header_style="white on dark_blue",
105
+ title_style="bold white on black",
106
+ caption_style="white on black",
107
+ show_lines=True,
108
+ box=box.ROUNDED,
109
+ caption=f"Integration Daemon Status for Server '{integ_server}' @ Platform - {integ_url}",
110
+ expand=True,
111
+ )
112
+ table.add_column("Connector Name", min_width=15)
113
+ table.add_column("Status", max_width=6)
114
+ table.add_column("Last Refresh Time", min_width=12)
115
+ table.add_column("Min Refresh (mins)", max_width=6)
116
+ table.add_column("Target Element", min_width=20)
117
+ table.add_column("Exception Message", min_width=10)
118
+
119
+ # Now get the integration connector report
120
+ token = s_client.create_egeria_bearer_token()
121
+ daemon_status = s_client.get_server_report(None, integ_server)
122
+
123
+ reports = daemon_status["integrationConnectorReports"]
124
+ if sort is True:
125
+ connector_reports = sorted(
126
+ reports, key=lambda x: x.get("connectorName", "---")
127
+ )
128
+ else:
129
+ connector_reports = reports
130
+
131
+ for connector in connector_reports:
132
+ connector_name = connector.get("connectorName", "---")
133
+ connector_status = connector.get("connectorStatus", "---")
134
+ connector_guid = connector.get("connectorGUID", "---")
135
+ last_refresh_time = connector.get("lastRefreshTime", "---")[:-10]
136
+ refresh_interval = str(connector.get("minMinutesBetweenRefresh", "---"))
137
+ exception_msg = " "
138
+ if connector_guid != "---":
139
+ targets = s_client.get_catalog_targets(connector_guid)
140
+ tgt_tab = Table()
141
+ tgt_tab.add_column("Target")
142
+ tgt_tab.add_column("UniqueName")
143
+ tgt_tab.add_column("Relationship GUID", no_wrap=True)
144
+
145
+ if type(targets) == list:
146
+ targets_md = True
147
+ for target in targets:
148
+ t_name = target["catalogTargetName"]
149
+ # t_sync = target["permittedSynchronization"]
150
+ t_unique_name = target["catalogTargetElement"]["uniqueName"]
151
+ t_rel_guid = target["relationshipGUID"]
152
+ # targets_m += f"* Target Name: __{t_name}__\n* Sync: {t_sync}\n* Unique Name: {t_unique_name}\n\n"
153
+ tgt_tab.add_row(t_name, t_unique_name, t_rel_guid)
154
+ # targets_md = Markdown(targets_m)
155
+ else:
156
+ targets_md = False
157
+ else:
158
+ targets_md = False
159
+ if targets_md is False:
160
+ targets_out = ""
161
+ else:
162
+ targets_out = tgt_tab
163
+
164
+ if connector_status in ("RUNNING", "REFRESHING", "WAITING"):
165
+ connector_status = f"[green]{connector_status}"
166
+ elif connector_status in ("INITIALIZE FAILED", "CONFIG_FAILED", "FAILED"):
167
+ connector_status = f"[red]{connector_status}"
168
+ else:
169
+ connector_status = f"[yellow]{connector_status}"
170
+
171
+ add_row(
172
+ table,
173
+ connector_name,
174
+ connector_status,
175
+ last_refresh_time,
176
+ refresh_interval,
177
+ targets_out,
178
+ exception_msg,
179
+ )
180
+ return table
181
+
182
+ try:
183
+ if paging is True:
184
+ console = Console(width=width, force_terminal=not jupyter)
185
+ with console.pager():
186
+ console.print(generate_table())
187
+ else:
188
+ with Live(
189
+ generate_table(),
190
+ refresh_per_second=1,
191
+ screen=True,
192
+ vertical_overflow="visible",
193
+ ) as live:
194
+ while True:
195
+ time.sleep(2)
196
+ live.update(generate_table())
197
+
198
+ except (
199
+ InvalidParameterException,
200
+ PropertyServerException,
201
+ UserNotAuthorizedException,
202
+ ) as e:
203
+ print_exception_response(e)
204
+
205
+ except KeyboardInterrupt:
206
+ pass
207
+
208
+ finally:
209
+ s_client.close_session()
210
+
211
+
212
+ def main_live():
213
+ parser = argparse.ArgumentParser()
214
+ parser.add_argument(
215
+ "--integ_server", help="Name of the integration server to display status for"
216
+ )
217
+ parser.add_argument("--integ_url", help="URL Platform to connect to")
218
+ parser.add_argument("--view_server", help="Name of the view server to use")
219
+ parser.add_argument("--view_url", help="view server URL Platform to connect to")
220
+ parser.add_argument("--userid", help="User Id")
221
+ parser.add_argument("--password", help="User Password")
222
+ args = parser.parse_args()
223
+
224
+ integ_server = (
225
+ args.integ_server
226
+ if args.integ_server is not None
227
+ else EGERIA_INTEGRATION_DAEMON
228
+ )
229
+ integ_url = (
230
+ args.integ_url if args.integ_url is not None else EGERIA_INTEGRATION_DAEMON_URL
231
+ )
232
+ view_server = (
233
+ args.view_server if args.view_server is not None else EGERIA_VIEW_SERVER
234
+ )
235
+ view_url = args.view_url if args.view_url is not None else EGERIA_VIEW_SERVER_URL
236
+ userid = args.userid if args.userid is not None else EGERIA_USER
237
+ user_pass = args.password if args.password is not None else EGERIA_USER_PASSWORD
238
+ display_integration_daemon_status(
239
+ integ_server=integ_server,
240
+ integ_url=integ_url,
241
+ view_server=view_server,
242
+ view_url=view_url,
243
+ user=userid,
244
+ user_pass=user_pass,
245
+ paging=False,
246
+ data_table=False,
247
+ )
248
+
249
+
250
+ def main_paging():
251
+ parser = argparse.ArgumentParser()
252
+ parser.add_argument(
253
+ "--integ_server", help="Name of the integration server to display status for"
254
+ )
255
+ parser.add_argument("--integ_url", help="URL Platform to connect to")
256
+ parser.add_argument("--view_server", help="Name of the view server to use")
257
+ parser.add_argument("--view_url", help="view server URL Platform to connect to")
258
+ parser.add_argument("--userid", help="User Id")
259
+ parser.add_argument("--password", help="User Password")
260
+ args = parser.parse_args()
261
+
262
+ integ_server = (
263
+ args.integ_server
264
+ if args.integ_server is not None
265
+ else EGERIA_INTEGRATION_DAEMON
266
+ )
267
+ integ_url = (
268
+ args.integ_url if args.integ_url is not None else EGERIA_INTEGRATION_DAEMON_URL
269
+ )
270
+ view_server = (
271
+ args.view_server if args.view_server is not None else EGERIA_VIEW_SERVER
272
+ )
273
+ view_url = args.view_url if args.view_url is not None else EGERIA_VIEW_SERVER_URL
274
+ userid = args.userid if args.userid is not None else EGERIA_USER
275
+ user_pass = args.password if args.password is not None else EGERIA_USER_PASSWORD
276
+ display_integration_daemon_status(
277
+ integ_server=integ_server,
278
+ integ_url=integ_url,
279
+ view_server=view_server,
280
+ view_url=view_url,
281
+ user=userid,
282
+ user_pass=user_pass,
283
+ paging=True,
284
+ data_table=False,
285
+ )
286
+
287
+
288
+ if __name__ == "__main__":
289
+ main_live()
290
+
291
+ if __name__ == "__main_paging__":
292
+ main_paging()
@@ -0,0 +1,173 @@
1
+ """This creates a templates guid file from the core metadata archive"""
2
+ from rich.markdown import Markdown
3
+ from rich.prompt import Prompt
4
+ import os
5
+ from pyegeria import AutomatedCuration, _client
6
+ from datetime import datetime
7
+ import argparse
8
+ import time
9
+ import sys
10
+ from rich import box
11
+ from rich.console import Console
12
+ from rich.table import Table
13
+ import asyncio
14
+ import nest_asyncio
15
+ from typing import Union
16
+
17
+ from pyegeria import (
18
+ InvalidParameterException,
19
+ PropertyServerException,
20
+ UserNotAuthorizedException,
21
+ print_exception_response,
22
+ RegisteredInfo
23
+ )
24
+ from textual.widgets import DataTable
25
+
26
+ console = Console()
27
+ EGERIA_METADATA_STORE = os.environ.get("EGERIA_METADATA_STORE", "active-metadata-store")
28
+ EGERIA_KAFKA_ENDPOINT = os.environ.get('KAFKA_ENDPOINT', 'localhost:9092')
29
+ EGERIA_PLATFORM_URL = os.environ.get('EGERIA_PLATFORM_URL', 'https://localhost:9443')
30
+ EGERIA_VIEW_SERVER = os.environ.get('VIEW_SERVER', 'view-server')
31
+ EGERIA_VIEW_SERVER_URL = os.environ.get('EGERIA_VIEW_SERVER_URL', 'https://localhost:9443')
32
+ EGERIA_INTEGRATION_DAEMON = os.environ.get('INTEGRATION_DAEMON', 'integration-daemon')
33
+ EGERIA_ADMIN_USER = os.environ.get('ADMIN_USER', 'garygeeke')
34
+ EGERIA_ADMIN_PASSWORD = os.environ.get('ADMIN_PASSWORD', 'secret')
35
+ EGERIA_USER = os.environ.get('EGERIA_USER', 'erinoverview')
36
+ EGERIA_USER_PASSWORD = os.environ.get('EGERIA_USER_PASSWORD', 'secret')
37
+ EGERIA_JUPYTER = bool(os.environ.get('EGERIA_JUPYTER', 'False'))
38
+ EGERIA_WIDTH = int(os.environ.get('EGERIA_WIDTH', '200'))
39
+
40
+ def add_row(table: Union[Table,DataTable], name: str, template_name:str, template_guid: str,
41
+ placeholder_table: Table) -> Table | DataTable:
42
+ if isinstance(table, Table):
43
+ table.add_row(name, template_name, template_guid, placeholder_table)
44
+ elif isinstance(table, DataTable):
45
+ table.add_row(name, template_name, template_guid, placeholder_table)
46
+
47
+ return table
48
+
49
+ def display_templates_spec(search_string:str, server: str,
50
+ url: str, username: str, password: str, jupyter:bool=EGERIA_JUPYTER,
51
+ width:int = EGERIA_WIDTH, data_table: bool = False
52
+ )-> Table | DataTable:
53
+
54
+ a_client = AutomatedCuration(server, url, username)
55
+ nest_asyncio.apply()
56
+ token = a_client.create_egeria_bearer_token(username, password)
57
+ tech_list = a_client.find_technology_types(search_string, page_size=0)
58
+
59
+ def generate_table(data_table: bool) -> Table | DataTable:
60
+ """Make a new table."""
61
+ if data_table:
62
+ table = DataTable()
63
+ table.add_columns("Name", "Template Name", "Template GUID", "Placeholders")
64
+ else:
65
+ table = Table(
66
+ title=f"Technology Templates for: {url} @ {time.asctime()}",
67
+ style="bold bright_white on black",
68
+ row_styles=["bold bright_white on black"],
69
+ header_style="white on dark_blue",
70
+ title_style="bold bright_white on black",
71
+ caption_style="white on black",
72
+ show_lines=True,
73
+ box=box.ROUNDED,
74
+ caption=f"Templates from Server '{server}' @ Platform - {url}",
75
+ expand=True,
76
+ # width=500
77
+ )
78
+
79
+ table.add_column("Name", width=20)
80
+ table.add_column("Template Name", width=20)
81
+ table.add_column("Template GUID", width = 38,no_wrap=True)
82
+ table.add_column("Placeholders")
83
+
84
+
85
+ if type(tech_list) is list:
86
+ for item in tech_list:
87
+ if 'deployedImplementationType' not in item['qualifiedName']:
88
+ continue
89
+ placeholder_table = Table(expand=False, show_lines=True)
90
+ placeholder_table.add_column("Name", width = 20,no_wrap=True)
91
+ placeholder_table.add_column("Type", width = 10)
92
+ placeholder_table.add_column("Required", width = 10)
93
+ placeholder_table.add_column("Example", width = 20)
94
+ placeholder_table.add_column("Description", width = 40)
95
+
96
+
97
+ name = item.get("name", "none")
98
+
99
+ details = a_client.get_technology_type_detail(name)
100
+ if type(details) is str:
101
+ console.log(f"Missing details for - {name}: {details}")
102
+ continue
103
+
104
+ templates = details.get("catalogTemplates", "Not Found")
105
+ if type(templates) is not str:
106
+ for template in templates:
107
+ template_name = template.get("name", None)
108
+
109
+ template_name = f"{name}_Template" if template_name is None else template_name
110
+
111
+ specification = template["specification"]["placeholderProperty"]
112
+ template_guid = template["relatedElement"]["guid"]
113
+
114
+ for placeholder in specification:
115
+ placeholder_data_type = placeholder["dataType"]
116
+ placeholder_description = placeholder["description"]
117
+ placeholder_name = placeholder["placeholderPropertyName"]
118
+ placeholder_required = placeholder["required"]
119
+ placeholder_example = placeholder.get("example", None)
120
+ placeholder_table.add_row(placeholder_name, placeholder_data_type, placeholder_required,
121
+ placeholder_example, placeholder_description,)
122
+
123
+ # table.add_row(name, template_name, template_guid, placeholder_table)
124
+ table = add_row(table, name, template_name, template_guid, placeholder_table)
125
+
126
+ return table
127
+ else:
128
+ print("Unknown technology type")
129
+ sys.exit(1)
130
+
131
+ try:
132
+ if data_table:
133
+ return generate_table(data_table)
134
+ else:
135
+ console = Console(width=width, force_terminal=not jupyter)
136
+
137
+ with console.pager(styles=True):
138
+ console.print(generate_table(data_table))
139
+
140
+ except (InvalidParameterException, PropertyServerException, UserNotAuthorizedException) as e:
141
+ print_exception_response(e)
142
+ assert e.related_http_code != "200", "Invalid parameters"
143
+ finally:
144
+ a_client.close_session()
145
+
146
+
147
+ def main():
148
+ parser = argparse.ArgumentParser()
149
+ parser.add_argument("--server", help="Name of the server to display status for")
150
+ parser.add_argument("--url", help="URL Platform to connect to")
151
+ parser.add_argument("--userid", help="User Id")
152
+ parser.add_argument("--password", help="Password")
153
+
154
+ args = parser.parse_args()
155
+
156
+ server = args.server if args.server is not None else EGERIA_VIEW_SERVER
157
+ url = args.url if args.url is not None else EGERIA_PLATFORM_URL
158
+ userid = args.userid if args.userid is not None else EGERIA_USER
159
+ password = args.password if args.password is not None else EGERIA_USER_PASSWORD
160
+ guid = None
161
+
162
+ try:
163
+ search_string = Prompt.ask("Enter the technology you are searching for:", default="*")
164
+ display_templates_spec(search_string, server, url, userid, password,data_table=False)
165
+ except(KeyboardInterrupt):
166
+ pass
167
+
168
+
169
+ if __name__ == "__main__":
170
+ main()
171
+
172
+
173
+