pyegeria 0.7.27__py3-none-any.whl → 0.7.29__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.
- examples/widgets/cat/get_tech_type_elements.py +70 -54
- examples/widgets/cat/list_glossary.py +55 -25
- examples/widgets/cat/list_projects.py +71 -35
- examples/widgets/cat/list_user_ids.py +57 -40
- examples/widgets/cli/egeria.py +658 -267
- examples/widgets/ops/monitor_engine_activity.py +70 -30
- examples/widgets/ops/monitor_gov_eng_status.py +49 -24
- examples/widgets/ops/monitor_integ_daemon_status.py +100 -38
- {pyegeria-0.7.27.dist-info → pyegeria-0.7.29.dist-info}/METADATA +1 -1
- {pyegeria-0.7.27.dist-info → pyegeria-0.7.29.dist-info}/RECORD +13 -13
- {pyegeria-0.7.27.dist-info → pyegeria-0.7.29.dist-info}/LICENSE +0 -0
- {pyegeria-0.7.27.dist-info → pyegeria-0.7.29.dist-info}/WHEEL +0 -0
- {pyegeria-0.7.27.dist-info → pyegeria-0.7.29.dist-info}/entry_points.txt +0 -0
@@ -18,7 +18,7 @@ from pyegeria import (
|
|
18
18
|
PropertyServerException,
|
19
19
|
UserNotAuthorizedException,
|
20
20
|
print_exception_response,
|
21
|
-
AutomatedCuration
|
21
|
+
AutomatedCuration,
|
22
22
|
)
|
23
23
|
from rich.table import Table
|
24
24
|
from rich.live import Live
|
@@ -31,17 +31,19 @@ from rich.text import Text
|
|
31
31
|
from rich import print
|
32
32
|
|
33
33
|
EGERIA_METADATA_STORE = os.environ.get("EGERIA_METADATA_STORE", "active-metadata-store")
|
34
|
-
EGERIA_KAFKA_ENDPOINT = os.environ.get(
|
35
|
-
EGERIA_PLATFORM_URL = os.environ.get(
|
36
|
-
EGERIA_VIEW_SERVER = os.environ.get(
|
37
|
-
EGERIA_VIEW_SERVER_URL = os.environ.get(
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
34
|
+
EGERIA_KAFKA_ENDPOINT = os.environ.get("KAFKA_ENDPOINT", "localhost:9092")
|
35
|
+
EGERIA_PLATFORM_URL = os.environ.get("EGERIA_PLATFORM_URL", "https://localhost:9443")
|
36
|
+
EGERIA_VIEW_SERVER = os.environ.get("VIEW_SERVER", "view-server")
|
37
|
+
EGERIA_VIEW_SERVER_URL = os.environ.get(
|
38
|
+
"EGERIA_VIEW_SERVER_URL", "https://localhost:9443"
|
39
|
+
)
|
40
|
+
EGERIA_INTEGRATION_DAEMON = os.environ.get("INTEGRATION_DAEMON", "integration-daemon")
|
41
|
+
EGERIA_ADMIN_USER = os.environ.get("ADMIN_USER", "garygeeke")
|
42
|
+
EGERIA_ADMIN_PASSWORD = os.environ.get("ADMIN_PASSWORD", "secret")
|
43
|
+
EGERIA_USER = os.environ.get("EGERIA_USER", "erinoverview")
|
44
|
+
EGERIA_USER_PASSWORD = os.environ.get("EGERIA_USER_PASSWORD", "secret")
|
45
|
+
EGERIA_JUPYTER = bool(os.environ.get("EGERIA_JUPYTER", "False"))
|
46
|
+
EGERIA_WIDTH = int(os.environ.get("EGERIA_WIDTH", "200"))
|
45
47
|
|
46
48
|
|
47
49
|
disable_ssl_warnings = True
|
@@ -49,12 +51,18 @@ console = Console(width=200)
|
|
49
51
|
|
50
52
|
guid_list = []
|
51
53
|
|
52
|
-
def tech_viewer(tech_name: str, server_name:str, platform_url:str, user:str, user_pass:str,
|
53
|
-
jupyter:bool=EGERIA_JUPYTER, width:int=EGERIA_WIDTH):
|
54
54
|
|
55
|
+
def tech_viewer(
|
56
|
+
tech_name: str,
|
57
|
+
server_name: str,
|
58
|
+
platform_url: str,
|
59
|
+
user: str,
|
60
|
+
user_pass: str,
|
61
|
+
jupyter: bool = EGERIA_JUPYTER,
|
62
|
+
width: int = EGERIA_WIDTH,
|
63
|
+
):
|
55
64
|
def build_classifications(classification: dict) -> Markdown:
|
56
|
-
|
57
|
-
class_md = ("\n")
|
65
|
+
class_md = "\n"
|
58
66
|
for c in classification:
|
59
67
|
c_type = c["classificationName"]
|
60
68
|
if c_type == "Anchors":
|
@@ -72,56 +80,62 @@ def tech_viewer(tech_name: str, server_name:str, platform_url:str, user:str, use
|
|
72
80
|
return output
|
73
81
|
|
74
82
|
try:
|
75
|
-
|
76
83
|
console = Console(width=width, force_terminal=not jupyter)
|
77
84
|
|
78
|
-
|
79
|
-
a_client = AutomatedCuration(server_name, platform_url,
|
80
|
-
user_id=user)
|
85
|
+
a_client = AutomatedCuration(server_name, platform_url, user_id=user)
|
81
86
|
|
82
87
|
token = a_client.create_egeria_bearer_token(user, user_pass)
|
83
|
-
tech_elements = a_client.get_technology_type_elements(
|
88
|
+
tech_elements = a_client.get_technology_type_elements(
|
89
|
+
tech_name, get_templates=False
|
90
|
+
)
|
84
91
|
if type(tech_elements) is str:
|
85
92
|
console.print(f"No elements found for {tech_name}")
|
86
93
|
sys.exit(1)
|
87
|
-
|
88
|
-
|
94
|
+
|
95
|
+
tree = Tree(
|
96
|
+
f"Deployed Technology Type: {tech_name}",
|
97
|
+
style="bold bright_white on black",
|
98
|
+
guide_style="bold bright_blue",
|
99
|
+
)
|
100
|
+
note: str = " "
|
89
101
|
for element in tech_elements:
|
90
|
-
header = element[
|
102
|
+
header = element["elementHeader"]
|
91
103
|
tech_type = header["type"]["typeName"]
|
92
|
-
tech_collection = header["origin"][
|
93
|
-
tech_created_by = header[
|
94
|
-
tech_created_at = header[
|
95
|
-
tech_guid = header[
|
96
|
-
tech_classifications = header[
|
104
|
+
tech_collection = header["origin"]["homeMetadataCollectionName"]
|
105
|
+
tech_created_by = header["versions"]["createdBy"]
|
106
|
+
tech_created_at = header["versions"]["createTime"]
|
107
|
+
tech_guid = header["guid"]
|
108
|
+
tech_classifications = header["classifications"]
|
97
109
|
class_md = build_classifications(tech_classifications)
|
98
110
|
|
99
|
-
referenceables = element[
|
100
|
-
tech_qualified_name = referenceables[
|
101
|
-
extended = referenceables[
|
102
|
-
ex_md:str = ""
|
111
|
+
referenceables = element["referenceableProperties"]
|
112
|
+
tech_qualified_name = referenceables["qualifiedName"]
|
113
|
+
extended = referenceables["extendedProperties"]
|
114
|
+
ex_md: str = ""
|
103
115
|
for key, value in extended.items():
|
104
116
|
ex_md += f"* {key}: {value}\n"
|
105
117
|
|
106
|
-
note = (
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
118
|
+
note = (
|
119
|
+
f"* Qualified Name: {tech_qualified_name}\n"
|
120
|
+
f"* GUID: {tech_guid}\n"
|
121
|
+
f"* Created by: {tech_created_by}\n"
|
122
|
+
f"* Created at: {tech_created_at}\n"
|
123
|
+
f"* Home Collection: {tech_collection}\n"
|
124
|
+
f"{class_md}\n"
|
125
|
+
f"{ex_md}\n"
|
126
|
+
)
|
127
|
+
|
128
|
+
interfaces = extended.get("connectorInterfaces", None)
|
116
129
|
if interfaces is not None:
|
117
|
-
interface_type_name = interfaces[
|
118
|
-
interface_array_cnt = interfaces[
|
130
|
+
interface_type_name = interfaces["typeName"]
|
131
|
+
interface_array_cnt = interfaces["arrayCount"]
|
119
132
|
note += f"* Interface Type: {interface_type_name}\n"
|
120
133
|
for i in range(0, int(interface_array_cnt)):
|
121
|
-
note += (
|
122
|
-
|
123
|
-
|
124
|
-
|
134
|
+
note += (
|
135
|
+
f"\t* Type: {interfaces['arrayValues']['propertyValueMap'][str(i)]['typeName']}"
|
136
|
+
f"\tName: {interfaces['arrayValues']['propertiesAsStrings'][str(i)]}\n"
|
137
|
+
)
|
138
|
+
note_md = Panel.fit(Markdown(note), style="bold bright_white")
|
125
139
|
t = tree.add(note_md)
|
126
140
|
|
127
141
|
print(tree)
|
@@ -129,7 +143,7 @@ def tech_viewer(tech_name: str, server_name:str, platform_url:str, user:str, use
|
|
129
143
|
except (
|
130
144
|
InvalidParameterException,
|
131
145
|
PropertyServerException,
|
132
|
-
UserNotAuthorizedException
|
146
|
+
UserNotAuthorizedException,
|
133
147
|
) as e:
|
134
148
|
print_exception_response(e)
|
135
149
|
|
@@ -148,11 +162,13 @@ def main():
|
|
148
162
|
userid = args.userid if args.userid is not None else EGERIA_USER
|
149
163
|
user_pass = args.password if args.password is not None else EGERIA_USER_PASSWORD
|
150
164
|
try:
|
151
|
-
tech_name = Prompt.ask(
|
152
|
-
|
153
|
-
|
165
|
+
tech_name = Prompt.ask(
|
166
|
+
"Enter the Asset Name to view:", default="Apache Kafka Server"
|
167
|
+
)
|
168
|
+
tech_viewer(tech_name, server, url, userid, user_pass)
|
169
|
+
except KeyboardInterrupt:
|
154
170
|
pass
|
155
171
|
|
156
172
|
|
157
173
|
if __name__ == "__main__":
|
158
|
-
main()
|
174
|
+
main()
|
@@ -28,25 +28,35 @@ from pyegeria.glossary_browser_omvs import GlossaryBrowser
|
|
28
28
|
disable_ssl_warnings = True
|
29
29
|
|
30
30
|
EGERIA_METADATA_STORE = os.environ.get("EGERIA_METADATA_STORE", "active-metadata-store")
|
31
|
-
EGERIA_KAFKA_ENDPOINT = os.environ.get(
|
32
|
-
EGERIA_PLATFORM_URL = os.environ.get(
|
33
|
-
EGERIA_VIEW_SERVER = os.environ.get(
|
34
|
-
EGERIA_VIEW_SERVER_URL = os.environ.get(
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
31
|
+
EGERIA_KAFKA_ENDPOINT = os.environ.get("KAFKA_ENDPOINT", "localhost:9092")
|
32
|
+
EGERIA_PLATFORM_URL = os.environ.get("EGERIA_PLATFORM_URL", "https://localhost:9443")
|
33
|
+
EGERIA_VIEW_SERVER = os.environ.get("VIEW_SERVER", "view-server")
|
34
|
+
EGERIA_VIEW_SERVER_URL = os.environ.get(
|
35
|
+
"EGERIA_VIEW_SERVER_URL", "https://localhost:9443"
|
36
|
+
)
|
37
|
+
EGERIA_INTEGRATION_DAEMON = os.environ.get("INTEGRATION_DAEMON", "integration-daemon")
|
38
|
+
EGERIA_ADMIN_USER = os.environ.get("ADMIN_USER", "garygeeke")
|
39
|
+
EGERIA_ADMIN_PASSWORD = os.environ.get("ADMIN_PASSWORD", "secret")
|
40
|
+
EGERIA_USER = os.environ.get("EGERIA_USER", "erinoverview")
|
41
|
+
EGERIA_USER_PASSWORD = os.environ.get("EGERIA_USER_PASSWORD", "secret")
|
42
|
+
EGERIA_JUPYTER = bool(os.environ.get("EGERIA_JUPYTER", "False"))
|
43
|
+
EGERIA_WIDTH = int(os.environ.get("EGERIA_WIDTH", "200"))
|
44
|
+
|
45
|
+
|
46
|
+
def display_glossary_terms(
|
47
|
+
search_string: str,
|
48
|
+
guid: str,
|
49
|
+
server: str,
|
50
|
+
url: str,
|
51
|
+
username: str,
|
52
|
+
user_password: str,
|
53
|
+
jupyter: bool = EGERIA_JUPYTER,
|
54
|
+
width: int = EGERIA_WIDTH,
|
55
|
+
):
|
46
56
|
g_client = GlossaryBrowser(server, url)
|
47
57
|
token = g_client.create_egeria_bearer_token(username, user_password)
|
48
58
|
|
49
|
-
def generate_table(search_string: str =
|
59
|
+
def generate_table(search_string: str = "*") -> Table:
|
50
60
|
"""Make a new table."""
|
51
61
|
table = Table(
|
52
62
|
title=f"Glossary Definitions for Terms like {search_string} @ {time.asctime()}",
|
@@ -58,7 +68,7 @@ def display_glossary_terms(search_string: str, guid: str, server: str, url: str,
|
|
58
68
|
show_lines=True,
|
59
69
|
box=box.ROUNDED,
|
60
70
|
caption=f"Glossary View Server '{server}' @ Platform - {url}",
|
61
|
-
expand=True
|
71
|
+
expand=True,
|
62
72
|
)
|
63
73
|
table.add_column("Display Name")
|
64
74
|
table.add_column("Qualified Name")
|
@@ -67,13 +77,23 @@ def display_glossary_terms(search_string: str, guid: str, server: str, url: str,
|
|
67
77
|
table.add_column("Summary")
|
68
78
|
table.add_column("Description")
|
69
79
|
|
70
|
-
terms = g_client.find_glossary_terms(
|
71
|
-
|
80
|
+
terms = g_client.find_glossary_terms(
|
81
|
+
search_string,
|
82
|
+
guid,
|
83
|
+
starts_with=False,
|
84
|
+
ends_with=False,
|
85
|
+
status_filter=[],
|
86
|
+
page_size=500,
|
87
|
+
)
|
88
|
+
|
89
|
+
sorted_terms = sorted(
|
90
|
+
terms, key=lambda k: k["glossaryTermProperties"]["displayName"]
|
91
|
+
)
|
72
92
|
style = "bright_white on black"
|
73
93
|
if type(terms) is str:
|
74
94
|
return table
|
75
95
|
|
76
|
-
for term in
|
96
|
+
for term in sorted_terms:
|
77
97
|
props = term.get("glossaryTermProperties", "None")
|
78
98
|
if props == "None":
|
79
99
|
return table
|
@@ -85,7 +105,12 @@ def display_glossary_terms(search_string: str, guid: str, server: str, url: str,
|
|
85
105
|
description = Text(props.get("description", " "), style=style)
|
86
106
|
|
87
107
|
table.add_row(
|
88
|
-
display_name,
|
108
|
+
display_name,
|
109
|
+
qualified_name,
|
110
|
+
abbrev,
|
111
|
+
summary,
|
112
|
+
description,
|
113
|
+
style="bold white on black",
|
89
114
|
)
|
90
115
|
|
91
116
|
g_client.close_session()
|
@@ -96,12 +121,17 @@ def display_glossary_terms(search_string: str, guid: str, server: str, url: str,
|
|
96
121
|
# while True:
|
97
122
|
# time.sleep(2)
|
98
123
|
# live.update(generate_table(search_string))
|
99
|
-
console = Console(
|
124
|
+
console = Console(
|
125
|
+
style="bold bright_white on black", width=width, force_terminal=not jupyter
|
126
|
+
)
|
100
127
|
with console.pager(styles=True):
|
101
128
|
console.print(generate_table(search_string))
|
102
129
|
|
103
|
-
|
104
|
-
|
130
|
+
except (
|
131
|
+
InvalidParameterException,
|
132
|
+
PropertyServerException,
|
133
|
+
UserNotAuthorizedException,
|
134
|
+
) as e:
|
105
135
|
console.print_exception()
|
106
136
|
|
107
137
|
|
@@ -126,7 +156,7 @@ def main():
|
|
126
156
|
try:
|
127
157
|
search_string = Prompt.ask("Enter the term you are searching for:", default="*")
|
128
158
|
display_glossary_terms(search_string, guid, server, url, userid, user_pass)
|
129
|
-
except
|
159
|
+
except KeyboardInterrupt:
|
130
160
|
pass
|
131
161
|
|
132
162
|
|
@@ -29,23 +29,34 @@ from pyegeria import (
|
|
29
29
|
from pyegeria import ProjectManager, ClassificationManager
|
30
30
|
|
31
31
|
EGERIA_METADATA_STORE = os.environ.get("EGERIA_METADATA_STORE", "active-metadata-store")
|
32
|
-
EGERIA_KAFKA_ENDPOINT = os.environ.get(
|
33
|
-
EGERIA_PLATFORM_URL = os.environ.get(
|
34
|
-
EGERIA_VIEW_SERVER = os.environ.get(
|
35
|
-
EGERIA_VIEW_SERVER_URL = os.environ.get(
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
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_ADMIN_USER = os.environ.get("ADMIN_USER", "garygeeke")
|
43
|
+
EGERIA_ADMIN_PASSWORD = os.environ.get("ADMIN_PASSWORD", "secret")
|
44
|
+
EGERIA_USER = os.environ.get("EGERIA_USER", "erinoverview")
|
45
|
+
EGERIA_USER_PASSWORD = os.environ.get("EGERIA_USER_PASSWORD", "secret")
|
46
|
+
EGERIA_JUPYTER = bool(os.environ.get("EGERIA_JUPYTER", "False"))
|
47
|
+
EGERIA_WIDTH = int(os.environ.get("EGERIA_WIDTH", "200"))
|
48
|
+
|
49
|
+
|
50
|
+
def display_project_list(
|
51
|
+
project_name: str,
|
52
|
+
server: str,
|
53
|
+
url: str,
|
54
|
+
username: str,
|
55
|
+
user_pass: str,
|
56
|
+
save_output: bool,
|
57
|
+
jupyter: bool = EGERIA_JUPYTER,
|
58
|
+
width: int = EGERIA_WIDTH,
|
59
|
+
):
|
49
60
|
p_client = ProjectManager(server, url, user_id=username)
|
50
61
|
token = p_client.create_egeria_bearer_token(username, user_pass)
|
51
62
|
c_client = ClassificationManager(server, url, token)
|
@@ -58,7 +69,7 @@ def display_project_list(project_name: str, server: str, url: str,
|
|
58
69
|
show_lines=True,
|
59
70
|
box=box.ROUNDED,
|
60
71
|
caption=f"Project list for Server '{server}' @ Platform - {url}",
|
61
|
-
expand=True
|
72
|
+
expand=True,
|
62
73
|
)
|
63
74
|
|
64
75
|
table.add_column("Project Name")
|
@@ -74,7 +85,6 @@ def display_project_list(project_name: str, server: str, url: str,
|
|
74
85
|
table.add_column("End Date")
|
75
86
|
table.add_column("Contracts")
|
76
87
|
|
77
|
-
|
78
88
|
projects = p_client.find_projects(project_name)
|
79
89
|
|
80
90
|
if projects is None:
|
@@ -92,12 +102,16 @@ def display_project_list(project_name: str, server: str, url: str,
|
|
92
102
|
elif type(projects) == str:
|
93
103
|
raise ValueError("-->This is not a known project")
|
94
104
|
else:
|
95
|
-
|
105
|
+
sorted_projects = sorted(
|
106
|
+
projects, key=lambda k: k["properties"].get("name", "---")
|
107
|
+
)
|
108
|
+
|
109
|
+
for project in sorted_projects:
|
96
110
|
classification = ""
|
97
|
-
guid = project[
|
111
|
+
guid = project["elementHeader"]["guid"]
|
98
112
|
props = project["properties"]
|
99
113
|
name = props.get("name", "None")
|
100
|
-
p_class = project[
|
114
|
+
p_class = project["elementHeader"].get("classifications")
|
101
115
|
if p_class:
|
102
116
|
for classif in p_class:
|
103
117
|
classification += f"* {classif.get('classificationName')}\n"
|
@@ -109,28 +123,43 @@ def display_project_list(project_name: str, server: str, url: str,
|
|
109
123
|
description = props.get("description", " ")
|
110
124
|
start = props.get("startDate", " ")[0:10]
|
111
125
|
end = props.get("plannedEndDate", " ")
|
112
|
-
additional_properties = project.get(
|
126
|
+
additional_properties = project.get("additionalProperties")
|
113
127
|
if additional_properties is not None:
|
114
128
|
props = json.dumps(additional_properties)
|
115
129
|
|
116
|
-
governed_by = c_client.get_related_elements(guid,
|
130
|
+
governed_by = c_client.get_related_elements(guid, "GovernedBy")
|
117
131
|
if type(governed_by) is list:
|
118
132
|
for gov in governed_by:
|
119
|
-
rel_guid = gov[
|
120
|
-
rel_title = gov[
|
121
|
-
|
122
|
-
|
133
|
+
rel_guid = gov["relatedElement"]["elementHeader"]["guid"]
|
134
|
+
rel_title = gov["relatedElement"]["properties"].get(
|
135
|
+
"title", "---"
|
136
|
+
)
|
137
|
+
certified_partner = f"{rel_title}: \n"
|
138
|
+
certified = c_client.get_related_elements(
|
139
|
+
rel_guid, "Certification"
|
140
|
+
)
|
123
141
|
if type(certified) is list:
|
124
|
-
|
125
|
-
p_name = rel_elem[
|
142
|
+
for rel_elem in certified:
|
143
|
+
p_name = rel_elem["relatedElement"]["properties"][
|
144
|
+
"name"
|
145
|
+
]
|
126
146
|
certified_partner += f"* {p_name}\n"
|
127
147
|
else:
|
128
148
|
certified_partner = "---"
|
129
149
|
|
130
|
-
|
131
150
|
table.add_row(
|
132
|
-
name,
|
133
|
-
|
151
|
+
name,
|
152
|
+
description,
|
153
|
+
classification,
|
154
|
+
qualified_name,
|
155
|
+
identifier,
|
156
|
+
phase,
|
157
|
+
health,
|
158
|
+
status,
|
159
|
+
start,
|
160
|
+
end,
|
161
|
+
certified_partner,
|
162
|
+
)
|
134
163
|
|
135
164
|
p_client.close_session()
|
136
165
|
return table
|
@@ -140,13 +169,20 @@ def display_project_list(project_name: str, server: str, url: str,
|
|
140
169
|
# while True:
|
141
170
|
# time.sleep(2)
|
142
171
|
# live.update(generate_table())
|
143
|
-
console = Console(
|
172
|
+
console = Console(
|
173
|
+
record=True, width=width, force_terminal=not jupyter, soft_wrap=True
|
174
|
+
)
|
144
175
|
with console.pager():
|
145
176
|
console.print(generate_table(project_name), soft_wrap=True)
|
146
177
|
if save_output:
|
147
178
|
console.save_html("projects.html")
|
148
179
|
|
149
|
-
except (
|
180
|
+
except (
|
181
|
+
InvalidParameterException,
|
182
|
+
PropertyServerException,
|
183
|
+
UserNotAuthorizedException,
|
184
|
+
ValueError,
|
185
|
+
) as e:
|
150
186
|
if type(e) is str:
|
151
187
|
print(e)
|
152
188
|
else:
|
@@ -14,33 +14,38 @@ from pyegeria import (
|
|
14
14
|
PropertyServerException,
|
15
15
|
UserNotAuthorizedException,
|
16
16
|
print_exception_response,
|
17
|
-
|
17
|
+
ClassificationManager,
|
18
18
|
)
|
19
19
|
|
20
20
|
|
21
21
|
console = Console()
|
22
22
|
EGERIA_METADATA_STORE = os.environ.get("EGERIA_METADATA_STORE", "active-metadata-store")
|
23
|
-
EGERIA_KAFKA_ENDPOINT = os.environ.get(
|
24
|
-
EGERIA_PLATFORM_URL = os.environ.get(
|
25
|
-
EGERIA_VIEW_SERVER = os.environ.get(
|
26
|
-
EGERIA_VIEW_SERVER_URL = os.environ.get(
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
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("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 list_user_ids(
|
39
|
+
server: str,
|
40
|
+
url: str,
|
41
|
+
username: str,
|
42
|
+
password: str,
|
43
|
+
jupyter: bool = EGERIA_JUPYTER,
|
44
|
+
width: int = EGERIA_WIDTH,
|
39
45
|
):
|
40
|
-
|
41
46
|
c_client = ClassificationManager(server, url, user_id=username, user_pwd=password)
|
42
47
|
token = c_client.create_egeria_bearer_token()
|
43
|
-
elements = c_client.get_elements(
|
48
|
+
elements = c_client.get_elements("UserIdentity")
|
44
49
|
|
45
50
|
def generate_table() -> Table:
|
46
51
|
"""Make a new table."""
|
@@ -61,27 +66,38 @@ def list_user_ids(server: str,
|
|
61
66
|
table.add_column("Job Title")
|
62
67
|
table.add_column("UserId")
|
63
68
|
table.add_column("Created")
|
64
|
-
table.add_column("GUID", width
|
69
|
+
table.add_column("GUID", width=38, no_wrap=True)
|
65
70
|
table.add_column("Qualified Name")
|
66
71
|
|
67
|
-
|
68
72
|
if type(elements) is list:
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
73
|
+
sorted_elements = sorted(
|
74
|
+
elements, key=lambda i: i["properties"].get("userId", "---")
|
75
|
+
)
|
76
|
+
for element in sorted_elements:
|
77
|
+
header = element["elementHeader"]
|
78
|
+
el_q_name = element["properties"].get("qualifiedName", "---")
|
79
|
+
el_create_time = header["versions"]["createTime"][:-10]
|
80
|
+
el_guid = header["guid"]
|
81
|
+
el_user_id = element["properties"].get("userId", "---")
|
82
|
+
full_name = ""
|
83
|
+
job = ""
|
84
|
+
|
85
|
+
profile = c_client.get_related_elements(el_guid, "ProfileIdentity")
|
79
86
|
if type(profile) is list:
|
80
87
|
for rel in profile:
|
81
|
-
full_name = rel[
|
82
|
-
|
83
|
-
|
84
|
-
|
88
|
+
full_name = rel["relatedElement"]["properties"].get(
|
89
|
+
"fullName", "---"
|
90
|
+
)
|
91
|
+
job = rel["relatedElement"]["properties"].get("jobTitle", "---")
|
92
|
+
|
93
|
+
table.add_row(
|
94
|
+
full_name,
|
95
|
+
job,
|
96
|
+
el_user_id,
|
97
|
+
el_create_time,
|
98
|
+
el_guid,
|
99
|
+
el_q_name,
|
100
|
+
)
|
85
101
|
|
86
102
|
return table
|
87
103
|
else:
|
@@ -94,7 +110,11 @@ def list_user_ids(server: str,
|
|
94
110
|
with console.pager(styles=True):
|
95
111
|
console.print(generate_table())
|
96
112
|
|
97
|
-
except (
|
113
|
+
except (
|
114
|
+
InvalidParameterException,
|
115
|
+
PropertyServerException,
|
116
|
+
UserNotAuthorizedException,
|
117
|
+
) as e:
|
98
118
|
print_exception_response(e)
|
99
119
|
print("Perhaps the type name isn't known")
|
100
120
|
finally:
|
@@ -117,12 +137,9 @@ def main():
|
|
117
137
|
|
118
138
|
try:
|
119
139
|
list_user_ids(server, url, userid, password)
|
120
|
-
except
|
140
|
+
except KeyboardInterrupt:
|
121
141
|
pass
|
122
142
|
|
123
143
|
|
124
144
|
if __name__ == "__main__":
|
125
145
|
main()
|
126
|
-
|
127
|
-
|
128
|
-
|