pyegeria 0.3.3__py3-none-any.whl → 0.3.4__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/automated_curation_omvs.py +15 -10
- pyegeria/core_omag_server_config.py +14 -21
- pyegeria/full_omag_server_config.py +0 -1
- pyegeria/glossary_omvs.py +14 -2
- pyegeria/gov_engine.py +1 -8
- pyegeria/governance_author.py +2 -0
- pyegeria/my_profile_omvs.py +1 -1
- pyegeria/platform_services.py +2 -39
- pyegeria/registered_info.py +3 -1
- pyegeria/server_operations.py +2 -2
- pyegeria-0.3.4.data/scripts/engine_action_status.py +145 -0
- pyegeria-0.3.4.data/scripts/find_todos.py +152 -0
- pyegeria-0.3.4.data/scripts/glossary_view.py +135 -0
- pyegeria-0.3.4.data/scripts/gov_engine_status.py +120 -0
- pyegeria-0.3.4.data/scripts/integration_daemon_status.py +130 -0
- pyegeria-0.3.4.data/scripts/list_asset_types.py +114 -0
- pyegeria-0.3.4.data/scripts/multi-server_status.py +123 -0
- pyegeria-0.3.4.data/scripts/my_todos.py +162 -0
- pyegeria-0.3.4.data/scripts/open_todos.py +140 -0
- pyegeria-0.3.4.data/scripts/server_status.py +105 -0
- pyegeria-0.3.4.data/scripts/server_status_widget.py +93 -0
- pyegeria-0.3.4.data/scripts/view_my_profile.py +140 -0
- {pyegeria-0.3.3.dist-info → pyegeria-0.3.4.dist-info}/METADATA +1 -1
- pyegeria-0.3.4.dist-info/RECORD +34 -0
- pyegeria-0.3.3.dist-info/RECORD +0 -22
- {pyegeria-0.3.3.dist-info → pyegeria-0.3.4.dist-info}/LICENSE +0 -0
- {pyegeria-0.3.3.dist-info → pyegeria-0.3.4.dist-info}/WHEEL +0 -0
- {pyegeria-0.3.3.dist-info → pyegeria-0.3.4.dist-info}/top_level.txt +0 -0
@@ -19,16 +19,21 @@ from ._validators import validate_name, validate_guid, validate_search_string
|
|
19
19
|
|
20
20
|
class AutomatedCuration(Client):
|
21
21
|
""" Set up and maintain automation services in Egeria.
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
22
|
+
|
23
|
+
Attributes:
|
24
|
+
server_name : str
|
25
|
+
The name of the View Server to use.
|
26
|
+
platform_url : str
|
27
|
+
URL of the server platform to connect to
|
28
|
+
user_id : str
|
29
|
+
The identity of the user calling the method - this sets a default optionally used by the methods
|
30
|
+
when the user doesn't pass the user_id on a method call.
|
31
|
+
user_pwd: str
|
32
|
+
The password associated with the user_id. Defaults to None
|
33
|
+
verify_flag: bool
|
34
|
+
Flag to indicate if SSL Certificates should be verified in the HTTP requests.
|
35
|
+
Defaults to False.
|
36
|
+
|
32
37
|
"""
|
33
38
|
|
34
39
|
def __init__(
|
@@ -24,31 +24,24 @@ from pyegeria._validators import (
|
|
24
24
|
class CoreServerConfig(Client):
|
25
25
|
"""
|
26
26
|
CoreServerConfig is a class that extends the Client class. It provides methods to configure and interact with access
|
27
|
-
|
27
|
+
services in the OMAG server.
|
28
28
|
|
29
|
-
|
29
|
+
Attributes:
|
30
30
|
|
31
|
-
|
32
|
-
|
31
|
+
server_name: str
|
32
|
+
The name of the OMAG server to configure.
|
33
|
+
platform_url : str
|
34
|
+
URL of the server platform to connect to
|
35
|
+
user_id : str
|
36
|
+
The identity of the user calling the method - this sets a default optionally used by the methods
|
37
|
+
when the user doesn't pass the user_id on a method call.
|
38
|
+
user_pwd: str
|
39
|
+
The password associated with the user_id. Defaults to None
|
40
|
+
verify_flag: bool
|
41
|
+
Flag to indicate if SSL Certificates should be verified in the HTTP requests.
|
42
|
+
Defaults to False.
|
33
43
|
|
34
|
-
- get_configured_access_services(server_name: str = None) -> dict:
|
35
|
-
Returns the list of access services that are configured for this server.
|
36
44
|
|
37
|
-
- configure_all_access_services(server_name: str = None) -> None:
|
38
|
-
Enables all access services that are registered with this server platform.
|
39
|
-
|
40
|
-
- configure_all_access_services_no_topics(server_name: str = None) -> None:
|
41
|
-
Configures all access services for the specified server with no cohort/Event Bus.
|
42
|
-
|
43
|
-
- clear_all_access_services(server_name: str = None) -> None:
|
44
|
-
Disables the access services. This removes all configuration for the access services and disables the
|
45
|
-
enterprise repository services.
|
46
|
-
|
47
|
-
- get_access_service_config(access_service_name: str, server_name: str = None) -> dict:
|
48
|
-
Retrieves the config for an access service.
|
49
|
-
|
50
|
-
- configure_access_service(access_service_name: str, server_name: str = None) -> None:
|
51
|
-
Enables a single access service.
|
52
45
|
"""
|
53
46
|
|
54
47
|
def __init__(
|
pyegeria/glossary_omvs.py
CHANGED
@@ -26,8 +26,20 @@ class GlossaryBrowser(Client):
|
|
26
26
|
GlossaryBrowser is a class that extends the Client class. It provides methods to search and retrieve glossaries,
|
27
27
|
terms and categories.
|
28
28
|
|
29
|
-
|
30
|
-
|
29
|
+
Attributes:
|
30
|
+
|
31
|
+
server_name: str
|
32
|
+
The name of the View Server to connect to.
|
33
|
+
platform_url : str
|
34
|
+
URL of the server platform to connect to
|
35
|
+
user_id : str
|
36
|
+
The identity of the user calling the method - this sets a default optionally used by the methods
|
37
|
+
when the user doesn't pass the user_id on a method call.
|
38
|
+
user_pwd: str
|
39
|
+
The password associated with the user_id. Defaults to None
|
40
|
+
verify_flag: bool
|
41
|
+
Flag to indicate if SSL Certificates should be verified in the HTTP requests.
|
42
|
+
Defaults to False.
|
31
43
|
|
32
44
|
"""
|
33
45
|
|
pyegeria/gov_engine.py
CHANGED
@@ -33,7 +33,7 @@ class GovEng(Client):
|
|
33
33
|
|
34
34
|
Attributes:
|
35
35
|
server_name: str
|
36
|
-
Name of the server to
|
36
|
+
Name of the server to use.
|
37
37
|
platform_url : str
|
38
38
|
URL of the server platform to connect to
|
39
39
|
user_id : str
|
@@ -45,13 +45,6 @@ class GovEng(Client):
|
|
45
45
|
Set true for SSL verification to be enabled, false for disabled. Default behaviour set by the
|
46
46
|
enable_ssl_check attribute from _globals.py
|
47
47
|
|
48
|
-
Methods:
|
49
|
-
__init__(self,
|
50
|
-
platform_url: str,
|
51
|
-
end_user_id: str,
|
52
|
-
)
|
53
|
-
Initializes the connection - throwing an exception if there is a problem
|
54
|
-
|
55
48
|
"""
|
56
49
|
|
57
50
|
def __init__(
|
pyegeria/governance_author.py
CHANGED
pyegeria/my_profile_omvs.py
CHANGED
pyegeria/platform_services.py
CHANGED
@@ -30,7 +30,8 @@ class Platform(Client):
|
|
30
30
|
Client to operate Egeria Platforms - inherits from Server Ops
|
31
31
|
|
32
32
|
Attributes:
|
33
|
-
|
33
|
+
server_name: str
|
34
|
+
Name of the server to use.
|
34
35
|
platform_url : str
|
35
36
|
URL of the server platform to connect to
|
36
37
|
user_id : str
|
@@ -42,44 +43,6 @@ class Platform(Client):
|
|
42
43
|
Flag to indicate if SSL Certificates should be verified in the HTTP requests.
|
43
44
|
Defaults to False.
|
44
45
|
|
45
|
-
Methods:
|
46
|
-
__init__(self, platform_url: str, end_user_id: str)
|
47
|
-
Initializes the connection - throwing an exception if there is a problem
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
get_platform_origin() -> str
|
52
|
-
|
53
|
-
activate_server_stored_config(server: str = None, timeout: int = 30) -> None
|
54
|
-
|
55
|
-
activate_server_supplied_config(config_body: str, server: str = None, timeout: int = 30) -> None
|
56
|
-
|
57
|
-
get_active_server_instance_status(server: str = None)-> dict | str
|
58
|
-
|
59
|
-
get_known_servers() -> list[str] | str
|
60
|
-
|
61
|
-
is_server_known(server: str = None) -> bool
|
62
|
-
|
63
|
-
is_server_configured(server: str = None) -> bool
|
64
|
-
|
65
|
-
check_server_active(server: str = None)
|
66
|
-
|
67
|
-
get_active_server_list() -> dict | str
|
68
|
-
|
69
|
-
shutdown_platform() -> None:
|
70
|
-
|
71
|
-
shutdown_server(server: str = None) -> None:
|
72
|
-
|
73
|
-
shutdown_unregister_servers() -> None
|
74
|
-
|
75
|
-
shutdown_all_servers() -> None
|
76
|
-
|
77
|
-
activate_server_if_down(server: str) -> bool
|
78
|
-
|
79
|
-
activate_servers_on_platform(server_list: str) -> bool
|
80
|
-
|
81
|
-
activate_platform(self, platform_name: str, hosted_server_names: [str], timeout:int = 60) -> None
|
82
|
-
|
83
46
|
"""
|
84
47
|
|
85
48
|
admin_command_root: str
|
pyegeria/registered_info.py
CHANGED
@@ -27,6 +27,8 @@ class RegisteredInfo(Client):
|
|
27
27
|
|
28
28
|
Attributes:
|
29
29
|
----------
|
30
|
+
server_name: str
|
31
|
+
Name of the server to use.
|
30
32
|
platform_url : str
|
31
33
|
URL of the server platform to connect to
|
32
34
|
user_id : str
|
@@ -55,11 +57,11 @@ class RegisteredInfo(Client):
|
|
55
57
|
|
56
58
|
def __init__(
|
57
59
|
self,
|
60
|
+
server_name: str,
|
58
61
|
platform_url: str,
|
59
62
|
user_id: str,
|
60
63
|
user_pwd: str = None,
|
61
64
|
verify_flag: bool = False,
|
62
|
-
server_name: str = None
|
63
65
|
):
|
64
66
|
if server_name is None:
|
65
67
|
server_name = "NA"
|
pyegeria/server_operations.py
CHANGED
@@ -19,7 +19,8 @@ class ServerOps(Platform):
|
|
19
19
|
Client to issue operations on a running OMAG server.
|
20
20
|
|
21
21
|
Attributes:
|
22
|
-
|
22
|
+
server_name: str
|
23
|
+
Name of the server to use.
|
23
24
|
platform_url : str
|
24
25
|
URL of the server platform to connect to
|
25
26
|
user_id : str
|
@@ -31,7 +32,6 @@ class ServerOps(Platform):
|
|
31
32
|
Flag to indicate if SSL Certificates should be verified in the HTTP requests.
|
32
33
|
Defaults to False.
|
33
34
|
|
34
|
-
Methods:
|
35
35
|
|
36
36
|
"""
|
37
37
|
def __init__(
|
@@ -0,0 +1,145 @@
|
|
1
|
+
#!python
|
2
|
+
"""
|
3
|
+
SPDX-License-Identifier: Apache-2.0
|
4
|
+
Copyright Contributors to the ODPi Egeria project.
|
5
|
+
|
6
|
+
Unit tests for the Utils helper functions using the Pytest framework.
|
7
|
+
|
8
|
+
|
9
|
+
A simple status display for Engine Actions
|
10
|
+
"""
|
11
|
+
|
12
|
+
import argparse
|
13
|
+
import json
|
14
|
+
import time
|
15
|
+
|
16
|
+
from rich import box
|
17
|
+
from rich.live import Live
|
18
|
+
from rich.table import Table
|
19
|
+
from rich import console
|
20
|
+
|
21
|
+
from pyegeria import (
|
22
|
+
InvalidParameterException,
|
23
|
+
PropertyServerException,
|
24
|
+
UserNotAuthorizedException,
|
25
|
+
print_exception_response,
|
26
|
+
)
|
27
|
+
from pyegeria import GovEng, AutomatedCuration
|
28
|
+
|
29
|
+
disable_ssl_warnings = True
|
30
|
+
|
31
|
+
good_platform1_url = "https://127.0.0.1:9443"
|
32
|
+
good_platform2_url = "https://egeria.pdr-associates.com:7443"
|
33
|
+
bad_platform1_url = "https://localhost:9443"
|
34
|
+
|
35
|
+
# good_platform1_url = "https://127.0.0.1:30080"
|
36
|
+
# good_platform2_url = "https://127.0.0.1:30081"
|
37
|
+
# bad_platform1_url = "https://localhost:9443"
|
38
|
+
|
39
|
+
good_user_1 = "garygeeke"
|
40
|
+
good_user_2 = "erinoverview"
|
41
|
+
bad_user_1 = "eviledna"
|
42
|
+
bad_user_2 = ""
|
43
|
+
|
44
|
+
good_server_1 = "active-metadata-store"
|
45
|
+
good_server_2 = "simple-metadata-store"
|
46
|
+
good_server_3 = "view-server"
|
47
|
+
good_server_4 = "engine-host"
|
48
|
+
bad_server_1 = "coco"
|
49
|
+
bad_server_2 = ""
|
50
|
+
|
51
|
+
|
52
|
+
def display_status_engine_actions(server: str = good_server_3, url: str = good_platform1_url, user: str = good_user_1):
|
53
|
+
g_client = AutomatedCuration(server, url, user, user_pwd="secret")
|
54
|
+
|
55
|
+
def generate_table() -> Table:
|
56
|
+
"""Make a new table."""
|
57
|
+
table = Table(
|
58
|
+
title=f"Engine Action Status for Platform {good_platform1_url} @ {time.asctime()}",
|
59
|
+
# style = "black on grey66",
|
60
|
+
header_style="white on dark_blue",
|
61
|
+
show_lines=True,
|
62
|
+
box=box.ROUNDED,
|
63
|
+
caption=f"Engine Status for Server '{server}' @ Platform - {url}",
|
64
|
+
expand=True
|
65
|
+
)
|
66
|
+
table.add_column("Requested Time")
|
67
|
+
table.add_column("Start Time")
|
68
|
+
|
69
|
+
table.add_column("Engine Name")
|
70
|
+
table.add_column("Request Type")
|
71
|
+
table.add_column("Action Status")
|
72
|
+
table.add_column("Target Element")
|
73
|
+
table.add_column("Completion Time")
|
74
|
+
table.add_column("Process Name")
|
75
|
+
table.add_column("Completion Message")
|
76
|
+
|
77
|
+
token = g_client.create_egeria_bearer_token()
|
78
|
+
action_status = g_client.get_engine_actions()
|
79
|
+
if action_status is None:
|
80
|
+
requested_time = " "
|
81
|
+
start_time = " "
|
82
|
+
completion_time = " "
|
83
|
+
engine_name = " "
|
84
|
+
request_type = " "
|
85
|
+
action_status = " "
|
86
|
+
target_element = " "
|
87
|
+
process_name = " "
|
88
|
+
completion_message = " "
|
89
|
+
else:
|
90
|
+
for action in action_status:
|
91
|
+
requested_time = action["requestedTime"]
|
92
|
+
start_time = action.get("startTime", " ")
|
93
|
+
completion_time = action.get("completionTime", " ")
|
94
|
+
|
95
|
+
engine_name = action["governanceEngineName"]
|
96
|
+
request_type = action["requestType"]
|
97
|
+
|
98
|
+
if action["actionStatus"] in ("REQUESTED", "APPROVED", "WAITING", "ACTIVATING"):
|
99
|
+
action_status = f"[yellow]{action['actionStatus']}"
|
100
|
+
elif action["actionStatus"] in ("IN_PROGRESS", "ACTIONED"):
|
101
|
+
action_status = f"[green]{action['actionStatus']}"
|
102
|
+
else:
|
103
|
+
action_status = f"[red]{action['actionStatus']}"
|
104
|
+
|
105
|
+
target= action.get("actionTargetElements","Empty")
|
106
|
+
if type(target) is list:
|
107
|
+
target_element = json.dumps(target[0]["targetElement"]["elementProperties"]["propertiesAsStrings"])
|
108
|
+
else:
|
109
|
+
target_element = " "
|
110
|
+
|
111
|
+
process_name = action.get("processName", " ")
|
112
|
+
completion_message = action.get("completionMessage", " ")
|
113
|
+
|
114
|
+
table.add_row(
|
115
|
+
requested_time, start_time, engine_name, request_type,
|
116
|
+
action_status, target_element, completion_time, process_name, completion_message
|
117
|
+
)
|
118
|
+
|
119
|
+
# g_client.close_session()
|
120
|
+
return table
|
121
|
+
|
122
|
+
try:
|
123
|
+
with Live(generate_table(), refresh_per_second=4, screen=True) as live:
|
124
|
+
while True:
|
125
|
+
time.sleep(2)
|
126
|
+
live.update(generate_table())
|
127
|
+
live.console.pager()
|
128
|
+
|
129
|
+
except (InvalidParameterException, PropertyServerException, UserNotAuthorizedException) as e:
|
130
|
+
print_exception_response(e)
|
131
|
+
assert e.related_http_code != "200", "Invalid parameters"
|
132
|
+
|
133
|
+
|
134
|
+
if __name__ == "__main__":
|
135
|
+
parser = argparse.ArgumentParser()
|
136
|
+
parser.add_argument("--server", help="Name of the server to display status for")
|
137
|
+
parser.add_argument("--url", help="URL Platform to connect to")
|
138
|
+
parser.add_argument("--userid", help="User Id")
|
139
|
+
args = parser.parse_args()
|
140
|
+
|
141
|
+
server = args.server if args.server is not None else "view-server"
|
142
|
+
url = args.url if args.url is not None else "https://localhost:9443"
|
143
|
+
userid = args.userid if args.userid is not None else 'garygeeke'
|
144
|
+
print(f"Starting display_status_engine_actions with {server}, {url}, {userid}")
|
145
|
+
display_status_engine_actions(server=server, url=url, user=userid)
|
@@ -0,0 +1,152 @@
|
|
1
|
+
#!python
|
2
|
+
"""
|
3
|
+
SPDX-Lic
|
4
|
+
ense-Identifier: Apache-2.0
|
5
|
+
Copyright Contributors to the ODPi Egeria project.
|
6
|
+
|
7
|
+
Unit tests for the Utils helper functions using the Pytest framework.
|
8
|
+
|
9
|
+
|
10
|
+
A simple display for glossary terms
|
11
|
+
"""
|
12
|
+
|
13
|
+
import time
|
14
|
+
import json
|
15
|
+
import argparse
|
16
|
+
from pyegeria import (
|
17
|
+
InvalidParameterException,
|
18
|
+
PropertyServerException,
|
19
|
+
UserNotAuthorizedException,
|
20
|
+
print_exception_response,
|
21
|
+
)
|
22
|
+
from rich.table import Table
|
23
|
+
from rich.live import Live
|
24
|
+
from rich import box
|
25
|
+
from rich.prompt import Prompt
|
26
|
+
from rich.tree import Tree
|
27
|
+
from rich import print
|
28
|
+
from rich.console import Console
|
29
|
+
from pyegeria.my_profile_omvs import MyProfile
|
30
|
+
|
31
|
+
from pyegeria.server_operations import ServerOps
|
32
|
+
from pyegeria.gov_engine import GovEng
|
33
|
+
from pyegeria.glossary_omvs import GlossaryBrowser
|
34
|
+
disable_ssl_warnings = True
|
35
|
+
|
36
|
+
good_platform1_url = "https://127.0.0.1:9443"
|
37
|
+
good_platform2_url = "https://egeria.pdr-associates.com:7443"
|
38
|
+
bad_platform1_url = "https://localhost:9443"
|
39
|
+
|
40
|
+
# good_platform1_url = "https://127.0.0.1:30080"
|
41
|
+
# good_platform2_url = "https://127.0.0.1:30081"
|
42
|
+
# bad_platform1_url = "https://localhost:9443"
|
43
|
+
|
44
|
+
good_user_1 = "garygeeke"
|
45
|
+
good_user_2 = "erinoverview"
|
46
|
+
bad_user_1 = "eviledna"
|
47
|
+
bad_user_2 = ""
|
48
|
+
|
49
|
+
good_server_1 = "active-metadata-store"
|
50
|
+
good_server_2 = "simple-metadata-store"
|
51
|
+
good_server_3 = "view-server"
|
52
|
+
good_server_4 = "engine-host"
|
53
|
+
bad_server_1 = "coco"
|
54
|
+
bad_server_2 = ""
|
55
|
+
|
56
|
+
|
57
|
+
def display_to_dos(search_string: str, guid: str=None, server: str = good_server_3, url: str = good_platform1_url, username: str = good_user_2):
|
58
|
+
|
59
|
+
m_client = MyProfile(server, url, user_id=username)
|
60
|
+
token = m_client.create_egeria_bearer_token(username, "secret")
|
61
|
+
|
62
|
+
def generate_table(search_string:str = '*') -> Table:
|
63
|
+
"""Make a new table."""
|
64
|
+
table = Table(
|
65
|
+
title=f"Open ToDos for Platform {good_platform1_url} @ {time.asctime()}",
|
66
|
+
# style = "black on grey66",
|
67
|
+
header_style="white on dark_blue",
|
68
|
+
show_lines=True,
|
69
|
+
box=box.ROUNDED,
|
70
|
+
caption=f"ToDos for Server '{server}' @ Platform - {url}",
|
71
|
+
expand=True
|
72
|
+
)
|
73
|
+
|
74
|
+
table.add_column("Name")
|
75
|
+
table.add_column("Type Name")
|
76
|
+
|
77
|
+
table.add_column("Created")
|
78
|
+
table.add_column("Priority")
|
79
|
+
table.add_column("Due")
|
80
|
+
table.add_column("Completion")
|
81
|
+
table.add_column("Status")
|
82
|
+
table.add_column("Sponsor")
|
83
|
+
|
84
|
+
todo_items = m_client.find_to_do("*", starts_with=True)
|
85
|
+
|
86
|
+
if todo_items is None:
|
87
|
+
name = " "
|
88
|
+
type_name = " "
|
89
|
+
created = " "
|
90
|
+
priority = " "
|
91
|
+
due = " "
|
92
|
+
completed = " "
|
93
|
+
status = " "
|
94
|
+
sponsor = " "
|
95
|
+
else:
|
96
|
+
for item in todo_items:
|
97
|
+
props = item["properties"]
|
98
|
+
name = props["name"]
|
99
|
+
type_name = props.get("toDoType", " ")
|
100
|
+
created = props.get("creationTime", " ")
|
101
|
+
priority = str(props.get("priority", " "))
|
102
|
+
due = props.get("dueTime", " ")
|
103
|
+
completed = props.get("completionTime", " ")
|
104
|
+
status = props.get("status")
|
105
|
+
# assigned_actors = item["assignedActors"]
|
106
|
+
# sponsor = assigned_actors[0].get("uniqueName", " ")
|
107
|
+
sponsor = "erinoverview"
|
108
|
+
if status in ("WAITING", "OPEN"):
|
109
|
+
status = f"[yellow]{status}"
|
110
|
+
elif status in ("INPROGRESS", "COMPLETE"):
|
111
|
+
status = f"[green]{status}"
|
112
|
+
else:
|
113
|
+
status = f"[red]{status}"
|
114
|
+
|
115
|
+
table.add_row(
|
116
|
+
name, type_name, created, priority, due, completed, status, sponsor
|
117
|
+
)
|
118
|
+
|
119
|
+
m_client.close_session()
|
120
|
+
return table
|
121
|
+
|
122
|
+
try:
|
123
|
+
# with Live(generate_table(), refresh_per_second=4, screen=True) as live:
|
124
|
+
# while True:
|
125
|
+
# time.sleep(2)
|
126
|
+
# live.update(generate_table())
|
127
|
+
console = Console()
|
128
|
+
with console.pager():
|
129
|
+
console.print(generate_table(search_string))
|
130
|
+
|
131
|
+
|
132
|
+
except (InvalidParameterException, PropertyServerException, UserNotAuthorizedException) as e:
|
133
|
+
print_exception_response(e)
|
134
|
+
assert e.related_http_code != "200", "Invalid parameters"
|
135
|
+
|
136
|
+
if __name__ == "__main__":
|
137
|
+
sus_guid = "f9b78b26-6025-43fa-9299-a905cc6d1575"
|
138
|
+
parser = argparse.ArgumentParser()
|
139
|
+
parser.add_argument("--server", help="Name of the server to display status for")
|
140
|
+
parser.add_argument("--url", help="URL Platform to connect to")
|
141
|
+
parser.add_argument("--userid", help="User Id")
|
142
|
+
# parser.add_argument("--sponsor", help="Name of sponsor to search")
|
143
|
+
args = parser.parse_args()
|
144
|
+
|
145
|
+
server = args.server if args.server is not None else "view-server"
|
146
|
+
url = args.url if args.url is not None else "https://localhost:9443"
|
147
|
+
userid = args.userid if args.userid is not None else 'erinoverview'
|
148
|
+
# guid = args.guid if args.guid is not None else None
|
149
|
+
guid = None
|
150
|
+
|
151
|
+
search_string = Prompt.ask("Enter the ToDo you are searching for:", default="*")
|
152
|
+
display_to_dos(search_string, guid,server, url, userid)
|
@@ -0,0 +1,135 @@
|
|
1
|
+
#!python
|
2
|
+
"""
|
3
|
+
SPDX-License-Identifier: Apache-2.0
|
4
|
+
Copyright Contributors to the ODPi Egeria project.
|
5
|
+
|
6
|
+
Unit tests for the Utils helper functions using the Pytest framework.
|
7
|
+
|
8
|
+
|
9
|
+
A simple display for glossary terms
|
10
|
+
"""
|
11
|
+
|
12
|
+
import time
|
13
|
+
import json
|
14
|
+
import argparse
|
15
|
+
from pyegeria import (
|
16
|
+
InvalidParameterException,
|
17
|
+
PropertyServerException,
|
18
|
+
UserNotAuthorizedException,
|
19
|
+
print_exception_response,
|
20
|
+
)
|
21
|
+
from rich.table import Table
|
22
|
+
from rich.live import Live
|
23
|
+
from rich import box
|
24
|
+
from rich.prompt import Prompt
|
25
|
+
from rich.tree import Tree
|
26
|
+
from rich import print
|
27
|
+
from rich.console import Console
|
28
|
+
|
29
|
+
|
30
|
+
from pyegeria.server_operations import ServerOps
|
31
|
+
from pyegeria.gov_engine import GovEng
|
32
|
+
from pyegeria.glossary_omvs import GlossaryBrowser
|
33
|
+
disable_ssl_warnings = True
|
34
|
+
|
35
|
+
good_platform1_url = "https://127.0.0.1:9443"
|
36
|
+
good_platform2_url = "https://egeria.pdr-associates.com:7443"
|
37
|
+
bad_platform1_url = "https://localhost:9443"
|
38
|
+
|
39
|
+
# good_platform1_url = "https://127.0.0.1:30080"
|
40
|
+
# good_platform2_url = "https://127.0.0.1:30081"
|
41
|
+
# bad_platform1_url = "https://localhost:9443"
|
42
|
+
|
43
|
+
good_user_1 = "garygeeke"
|
44
|
+
good_user_2 = "erinoverview"
|
45
|
+
bad_user_1 = "eviledna"
|
46
|
+
bad_user_2 = ""
|
47
|
+
|
48
|
+
good_server_1 = "active-metadata-store"
|
49
|
+
good_server_2 = "simple-metadata-store"
|
50
|
+
good_server_3 = "view-server"
|
51
|
+
good_server_4 = "engine-host"
|
52
|
+
bad_server_1 = "coco"
|
53
|
+
bad_server_2 = ""
|
54
|
+
|
55
|
+
|
56
|
+
def display_glossary_terms(search_string: str, guid: str=None, server: str = good_server_3, url: str = good_platform1_url, username: str = good_user_2):
|
57
|
+
|
58
|
+
g_client = GlossaryBrowser(server, url)
|
59
|
+
token = g_client.create_egeria_bearer_token(username, "secret")
|
60
|
+
|
61
|
+
|
62
|
+
def generate_table(search_string:str = '*') -> Table:
|
63
|
+
"""Make a new table."""
|
64
|
+
table = Table(
|
65
|
+
title=f"Glossary Definitions for Terms like {search_string} @ {time.asctime()}",
|
66
|
+
# style = "black on grey66",
|
67
|
+
header_style="white on dark_blue",
|
68
|
+
show_lines=True,
|
69
|
+
box=box.ROUNDED,
|
70
|
+
caption=f"Glossary View Server '{server}' @ Platform - {url}",
|
71
|
+
expand=True
|
72
|
+
)
|
73
|
+
table.add_column("Display Name")
|
74
|
+
table.add_column("Qualified Name")
|
75
|
+
|
76
|
+
table.add_column("Abbreviation")
|
77
|
+
table.add_column("Summary")
|
78
|
+
table.add_column("Description")
|
79
|
+
|
80
|
+
terms = g_client.find_glossary_terms(search_string, guid, starts_with=True,
|
81
|
+
ends_with=False, status_filter=[], page_size=500)
|
82
|
+
if type(terms) is str:
|
83
|
+
return table
|
84
|
+
|
85
|
+
for term in terms:
|
86
|
+
props = term.get("glossaryTermProperties","None")
|
87
|
+
if props == "None":
|
88
|
+
return table
|
89
|
+
|
90
|
+
display_name = props["displayName"]
|
91
|
+
qualified_name = props["qualifiedName"]
|
92
|
+
abbrev = props.get("abbreviation"," ")
|
93
|
+
summary = props.get("summary", " ")
|
94
|
+
description = props.get("description", " ")
|
95
|
+
|
96
|
+
|
97
|
+
table.add_row(
|
98
|
+
display_name,qualified_name, abbrev, summary, description
|
99
|
+
)
|
100
|
+
|
101
|
+
g_client.close_session()
|
102
|
+
return table
|
103
|
+
|
104
|
+
try:
|
105
|
+
# with Live(generate_table(), refresh_per_second=4, screen=True) as live:
|
106
|
+
# while True:
|
107
|
+
# time.sleep(2)
|
108
|
+
# live.update(generate_table())
|
109
|
+
console = Console()
|
110
|
+
with console.pager():
|
111
|
+
console.print(generate_table(search_string))
|
112
|
+
|
113
|
+
|
114
|
+
except (InvalidParameterException, PropertyServerException, UserNotAuthorizedException) as e:
|
115
|
+
print_exception_response(e)
|
116
|
+
assert e.related_http_code != "200", "Invalid parameters"
|
117
|
+
|
118
|
+
if __name__ == "__main__":
|
119
|
+
sus_guid = "f9b78b26-6025-43fa-9299-a905cc6d1575"
|
120
|
+
parser = argparse.ArgumentParser()
|
121
|
+
parser.add_argument("--server", help="Name of the server to display status for")
|
122
|
+
parser.add_argument("--url", help="URL Platform to connect to")
|
123
|
+
parser.add_argument("--userid", help="User Id")
|
124
|
+
parser.add_argument("--guid", help="GUID of glossary to search")
|
125
|
+
parser.add_argument("--sustainability", help="Set True for Sustainability Glossary")
|
126
|
+
args = parser.parse_args()
|
127
|
+
|
128
|
+
server = args.server if args.server is not None else "view-server"
|
129
|
+
url = args.url if args.url is not None else "https://localhost:9443"
|
130
|
+
userid = args.userid if args.userid is not None else 'garygeeke'
|
131
|
+
guid = args.guid if args.guid is not None else None
|
132
|
+
guid = sus_guid if args.sustainability else None
|
133
|
+
|
134
|
+
search_string = Prompt.ask("Enter the term you are searching for:", default="*")
|
135
|
+
display_glossary_terms(search_string, guid,server, url, userid)
|