pyegeria 5.3.2__py3-none-any.whl → 5.3.3__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/.DS_Store +0 -0
- pyegeria/classification_manager_omvs.py +4 -4
- pyegeria/commands/.DS_Store +0 -0
- pyegeria/commands/cli/egeria.py +200 -65
- pyegeria/commands/cli/egeria_tech.py +249 -139
- pyegeria/commands/doc/.DS_Store +0 -0
- pyegeria/commands/doc/Visual Command Reference/.DS_Store +0 -0
- pyegeria/commands/doc/Visual Command Reference/cat/.DS_Store +0 -0
- pyegeria/commands/doc/Visual Command Reference/cat/show/.DS_Store +0 -0
- pyegeria/commands/doc/Visual Command Reference/cat/show/deployed-data/.DS_Store +0 -0
- pyegeria/commands/doc/glossary/.DS_Store +0 -0
- pyegeria/commands/doc/glossary/images/.DS_Store +0 -0
- pyegeria/commands/doc/hey_egeria: a pyegeria command line interface/.DS_Store +0 -0
- pyegeria/commands/doc/hey_egeria: a pyegeria command line interface/images/.DS_Store +0 -0
- pyegeria/commands/tech/{list_elements.py → list_all_om_type_elements.py} +1 -1
- pyegeria/commands/tech/{list_elements_x.py → list_all_om_type_elements_x.py} +1 -1
- pyegeria/commands/tech/list_elements_by_classification_by_property_value.py +186 -0
- pyegeria/commands/tech/list_elements_by_property_value.py +175 -0
- pyegeria/commands/tech/list_elements_by_property_value_x.py +196 -0
- pyegeria/commands/tech/list_related_elements_with_prop_value.py +207 -0
- pyegeria/valid_metadata_omvs.py +1 -1
- {pyegeria-5.3.2.dist-info → pyegeria-5.3.3.dist-info}/METADATA +1 -1
- {pyegeria-5.3.2.dist-info → pyegeria-5.3.3.dist-info}/RECORD +27 -12
- {pyegeria-5.3.2.dist-info → pyegeria-5.3.3.dist-info}/entry_points.txt +7 -2
- /pyegeria/commands/tech/{list_related_elements.py → list_all_related_elements.py} +0 -0
- {pyegeria-5.3.2.dist-info → pyegeria-5.3.3.dist-info}/LICENSE +0 -0
- {pyegeria-5.3.2.dist-info → pyegeria-5.3.3.dist-info}/WHEEL +0 -0
@@ -0,0 +1,175 @@
|
|
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
|
+
import argparse
|
6
|
+
import time
|
7
|
+
import sys
|
8
|
+
from rich import box
|
9
|
+
from rich.console import Console
|
10
|
+
from rich.table import Table
|
11
|
+
|
12
|
+
from pyegeria import (
|
13
|
+
InvalidParameterException,
|
14
|
+
PropertyServerException,
|
15
|
+
UserNotAuthorizedException,
|
16
|
+
print_exception_response,
|
17
|
+
EgeriaTech,
|
18
|
+
)
|
19
|
+
|
20
|
+
|
21
|
+
console = Console()
|
22
|
+
EGERIA_METADATA_STORE = os.environ.get("EGERIA_METADATA_STORE", "active-metadata-store")
|
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("EGERIA_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 find_elements_by_prop_value(
|
39
|
+
om_type: str,
|
40
|
+
property_value: str,
|
41
|
+
property_names: [str],
|
42
|
+
server: str,
|
43
|
+
url: str,
|
44
|
+
username: str,
|
45
|
+
password: str,
|
46
|
+
jupyter: bool = EGERIA_JUPYTER,
|
47
|
+
width: int = EGERIA_WIDTH,
|
48
|
+
):
|
49
|
+
c_client = EgeriaTech(server, url, user_id=username, user_pwd=password)
|
50
|
+
token = c_client.create_egeria_bearer_token()
|
51
|
+
|
52
|
+
om_typedef = c_client.get_typedef_by_name(om_type)
|
53
|
+
if type(om_typedef) is str:
|
54
|
+
print(
|
55
|
+
f"The type name '{om_type}' is not known to the Egeria platform at {url} - {server}"
|
56
|
+
)
|
57
|
+
sys.exit(1)
|
58
|
+
elements = c_client.find_elements_by_property_value(property_value, property_names,
|
59
|
+
om_type
|
60
|
+
)
|
61
|
+
|
62
|
+
def generate_table() -> Table:
|
63
|
+
"""Make a new table."""
|
64
|
+
table = Table(
|
65
|
+
caption=f"Find Metadata Elements for: {url} - {server} @ {time.asctime()}",
|
66
|
+
style="bold bright_white on black",
|
67
|
+
row_styles=["bold bright_white on black"],
|
68
|
+
header_style="white on dark_blue",
|
69
|
+
title_style="bold bright_white on black",
|
70
|
+
caption_style="white on black",
|
71
|
+
show_lines=True,
|
72
|
+
box=box.ROUNDED,
|
73
|
+
title=f"Elements for Open Metadata Type: {om_type}, property value: {property_value}, "
|
74
|
+
f"properties: {property_names}",
|
75
|
+
expand=True,
|
76
|
+
width=width,
|
77
|
+
)
|
78
|
+
|
79
|
+
table.add_column("Qualified Name")
|
80
|
+
table.add_column("Type")
|
81
|
+
table.add_column("Created")
|
82
|
+
table.add_column("Home Store")
|
83
|
+
table.add_column("GUID", width=38, no_wrap=True)
|
84
|
+
table.add_column("Properties")
|
85
|
+
table.add_column("Classifications")
|
86
|
+
|
87
|
+
if type(elements) is list:
|
88
|
+
for element in elements:
|
89
|
+
header = element["elementHeader"]
|
90
|
+
el_q_name = element["properties"].get("qualifiedName", "---")
|
91
|
+
el_type = header["type"]["typeName"]
|
92
|
+
el_home = header["origin"]["homeMetadataCollectionName"]
|
93
|
+
el_create_time = header["versions"]["createTime"][:-10]
|
94
|
+
el_guid = header["guid"]
|
95
|
+
el_class = header.get("classifications", "---")
|
96
|
+
|
97
|
+
el_props_md = ""
|
98
|
+
for prop in element["properties"].keys():
|
99
|
+
el_props_md += f"* **{prop}**: {element['properties'][prop]}\n"
|
100
|
+
el_props_out = Markdown(el_props_md)
|
101
|
+
|
102
|
+
c_md = ""
|
103
|
+
if type(el_class) is list:
|
104
|
+
for classification in el_class:
|
105
|
+
classification_name = classification.get(
|
106
|
+
"classificationName", "---"
|
107
|
+
)
|
108
|
+
c_md = f"* **{classification_name}**\n"
|
109
|
+
class_props = classification.get(
|
110
|
+
"classificationProperties", "---"
|
111
|
+
)
|
112
|
+
if type(class_props) is dict:
|
113
|
+
for prop in class_props.keys():
|
114
|
+
c_md += f" * **{prop}**: {class_props[prop]}\n"
|
115
|
+
c_md_out = Markdown(c_md)
|
116
|
+
|
117
|
+
table.add_row(
|
118
|
+
el_q_name,
|
119
|
+
el_type,
|
120
|
+
el_create_time,
|
121
|
+
el_home,
|
122
|
+
el_guid,
|
123
|
+
el_props_out,
|
124
|
+
c_md_out,
|
125
|
+
)
|
126
|
+
|
127
|
+
return table
|
128
|
+
else:
|
129
|
+
print("No instances found")
|
130
|
+
sys.exit(1)
|
131
|
+
|
132
|
+
try:
|
133
|
+
console = Console(width=width, force_terminal=not jupyter)
|
134
|
+
|
135
|
+
with console.pager(styles=True):
|
136
|
+
console.print(generate_table())
|
137
|
+
|
138
|
+
except (
|
139
|
+
InvalidParameterException,
|
140
|
+
PropertyServerException,
|
141
|
+
UserNotAuthorizedException,
|
142
|
+
) as e:
|
143
|
+
print_exception_response(e)
|
144
|
+
print("\n\nPerhaps the type name isn't known")
|
145
|
+
finally:
|
146
|
+
c_client.close_session()
|
147
|
+
|
148
|
+
|
149
|
+
def main():
|
150
|
+
parser = argparse.ArgumentParser()
|
151
|
+
parser.add_argument("--server", help="Name of the server to display status for")
|
152
|
+
parser.add_argument("--url", help="URL Platform to connect to")
|
153
|
+
parser.add_argument("--userid", help="User Id")
|
154
|
+
parser.add_argument("--password", help="Password")
|
155
|
+
|
156
|
+
args = parser.parse_args()
|
157
|
+
|
158
|
+
server = args.server if args.server is not None else EGERIA_VIEW_SERVER
|
159
|
+
url = args.url if args.url is not None else EGERIA_PLATFORM_URL
|
160
|
+
userid = args.userid if args.userid is not None else EGERIA_USER
|
161
|
+
password = args.password if args.password is not None else EGERIA_USER_PASSWORD
|
162
|
+
|
163
|
+
try:
|
164
|
+
om_type = Prompt.ask(
|
165
|
+
"Enter the Open Metadata Type to find elements of", default="GlossaryTerm"
|
166
|
+
)
|
167
|
+
property_value = Prompt.ask("Enter the property value to search for")
|
168
|
+
property_names = Prompt.ask("Enter a comma seperated list of properties to search")
|
169
|
+
find_elements_by_prop_value(om_type, property_value, [property_names], server, url, userid, password)
|
170
|
+
except KeyboardInterrupt:
|
171
|
+
pass
|
172
|
+
|
173
|
+
|
174
|
+
if __name__ == "__main__":
|
175
|
+
main()
|
@@ -0,0 +1,196 @@
|
|
1
|
+
"""List elements """
|
2
|
+
from rich.markdown import Markdown
|
3
|
+
from rich.prompt import Prompt
|
4
|
+
import os
|
5
|
+
import argparse
|
6
|
+
import time
|
7
|
+
import sys
|
8
|
+
from rich import box
|
9
|
+
from rich.console import Console
|
10
|
+
from rich.table import Table
|
11
|
+
|
12
|
+
from pyegeria import (
|
13
|
+
InvalidParameterException,
|
14
|
+
PropertyServerException,
|
15
|
+
UserNotAuthorizedException,
|
16
|
+
print_exception_response,
|
17
|
+
EgeriaTech,
|
18
|
+
)
|
19
|
+
|
20
|
+
|
21
|
+
console = Console()
|
22
|
+
EGERIA_METADATA_STORE = os.environ.get("EGERIA_METADATA_STORE", "active-metadata-store")
|
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("EGERIA_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 find_elements_by_prop_value_x(
|
39
|
+
om_type: str,
|
40
|
+
property_value: str,
|
41
|
+
property_names: [str],
|
42
|
+
server: str,
|
43
|
+
url: str,
|
44
|
+
username: str,
|
45
|
+
password: str,
|
46
|
+
jupyter: bool = EGERIA_JUPYTER,
|
47
|
+
width: int = EGERIA_WIDTH,
|
48
|
+
):
|
49
|
+
c_client = EgeriaTech(server, url, user_id=username, user_pwd=password)
|
50
|
+
token = c_client.create_egeria_bearer_token()
|
51
|
+
|
52
|
+
om_typedef = c_client.get_typedef_by_name(om_type)
|
53
|
+
if type(om_typedef) is str:
|
54
|
+
print(
|
55
|
+
f"The type name '{om_type}' is not known to the Egeria platform at {url} - {server}"
|
56
|
+
)
|
57
|
+
sys.exit(1)
|
58
|
+
elements = c_client.find_elements_by_property_value(property_value, property_names,
|
59
|
+
om_type
|
60
|
+
)
|
61
|
+
|
62
|
+
def generate_table() -> Table:
|
63
|
+
"""Make a new table."""
|
64
|
+
table = Table(
|
65
|
+
caption=f"Metadata Elements for: {url} - {server} @ {time.asctime()}",
|
66
|
+
style="bold bright_white on black",
|
67
|
+
row_styles=["bold bright_white on black"],
|
68
|
+
header_style="white on dark_blue",
|
69
|
+
title_style="bold bright_white on black",
|
70
|
+
caption_style="white on black",
|
71
|
+
show_lines=True,
|
72
|
+
box=box.ROUNDED,
|
73
|
+
title=f"Find Elements for Open Metadata Type: {om_type}, property value: {property_value}, "
|
74
|
+
f"properties: {property_names} - Extended",
|
75
|
+
expand=True,
|
76
|
+
width=width,
|
77
|
+
)
|
78
|
+
|
79
|
+
table.add_column("Qualified Name")
|
80
|
+
table.add_column("Type")
|
81
|
+
table.add_column("Created")
|
82
|
+
table.add_column("Home Store")
|
83
|
+
table.add_column("GUID", width=38, no_wrap=True)
|
84
|
+
table.add_column("Properties")
|
85
|
+
table.add_column("Feedback", min_width=30)
|
86
|
+
table.add_column("Public Comments")
|
87
|
+
|
88
|
+
if type(elements) is list:
|
89
|
+
for element in elements:
|
90
|
+
header = element["elementHeader"]
|
91
|
+
el_q_name = element["properties"].get("qualifiedName", "---")
|
92
|
+
el_type = header["type"]["typeName"]
|
93
|
+
el_home = header["origin"]["homeMetadataCollectionName"]
|
94
|
+
el_create_time = header["versions"]["createTime"][:-18]
|
95
|
+
el_guid = header["guid"]
|
96
|
+
|
97
|
+
el_props_md = ""
|
98
|
+
for prop in element["properties"].keys():
|
99
|
+
el_props_md += f"* **{prop}**: {element['properties'][prop]}\n"
|
100
|
+
|
101
|
+
el_props_out = Markdown(el_props_md)
|
102
|
+
|
103
|
+
tags = c_client.get_attached_tags(el_guid)
|
104
|
+
tags_md = "Tags:\n"
|
105
|
+
if type(tags) is list:
|
106
|
+
for tag in tags:
|
107
|
+
tags_md += (
|
108
|
+
f"* tag: {tag.get('name','')}\n"
|
109
|
+
f"\t description: {tag.get('description','---')}\n"
|
110
|
+
f"\t assigned by: {tag.get('user','---')}\n"
|
111
|
+
)
|
112
|
+
|
113
|
+
else:
|
114
|
+
tags_md = ""
|
115
|
+
|
116
|
+
likes = c_client.get_attached_likes(el_guid)
|
117
|
+
likes_md = "Likes:\b"
|
118
|
+
if type(likes) is list:
|
119
|
+
for like in likes:
|
120
|
+
likes_md += (
|
121
|
+
f"* tag: {like['name']}\n"
|
122
|
+
f"* description: {like['description']}\n"
|
123
|
+
f"* assigned by: {like['user']}\n"
|
124
|
+
f"\n"
|
125
|
+
)
|
126
|
+
|
127
|
+
else:
|
128
|
+
likes_md = ""
|
129
|
+
|
130
|
+
if len(tags_md) > 0 and len(likes_md) > 0:
|
131
|
+
feedback_out = f"{tags_md}\n --- \n{likes_md}"
|
132
|
+
else:
|
133
|
+
feedback_out = ""
|
134
|
+
|
135
|
+
comments_out = " "
|
136
|
+
|
137
|
+
table.add_row(
|
138
|
+
el_q_name,
|
139
|
+
el_type,
|
140
|
+
el_create_time,
|
141
|
+
el_home,
|
142
|
+
el_guid,
|
143
|
+
el_props_out,
|
144
|
+
feedback_out,
|
145
|
+
comments_out,
|
146
|
+
)
|
147
|
+
|
148
|
+
return table
|
149
|
+
else:
|
150
|
+
print("No instances found")
|
151
|
+
sys.exit(1)
|
152
|
+
|
153
|
+
try:
|
154
|
+
console = Console(width=width, force_terminal=not jupyter)
|
155
|
+
|
156
|
+
with console.pager(styles=True):
|
157
|
+
console.print(generate_table())
|
158
|
+
|
159
|
+
except (
|
160
|
+
InvalidParameterException,
|
161
|
+
PropertyServerException,
|
162
|
+
UserNotAuthorizedException,
|
163
|
+
) as e:
|
164
|
+
print_exception_response(e)
|
165
|
+
print("\n\nPerhaps the type name isn't known")
|
166
|
+
finally:
|
167
|
+
c_client.close_session()
|
168
|
+
|
169
|
+
|
170
|
+
def main():
|
171
|
+
parser = argparse.ArgumentParser()
|
172
|
+
parser.add_argument("--server", help="Name of the server to display status for")
|
173
|
+
parser.add_argument("--url", help="URL Platform to connect to")
|
174
|
+
parser.add_argument("--userid", help="User Id")
|
175
|
+
parser.add_argument("--password", help="Password")
|
176
|
+
|
177
|
+
args = parser.parse_args()
|
178
|
+
|
179
|
+
server = args.server if args.server is not None else EGERIA_VIEW_SERVER
|
180
|
+
url = args.url if args.url is not None else EGERIA_PLATFORM_URL
|
181
|
+
userid = args.userid if args.userid is not None else EGERIA_USER
|
182
|
+
password = args.password if args.password is not None else EGERIA_USER_PASSWORD
|
183
|
+
|
184
|
+
try:
|
185
|
+
om_type = Prompt.ask(
|
186
|
+
"Enter the Open Metadata Type to find elements of", default="GlossaryTerm"
|
187
|
+
)
|
188
|
+
property_value = Prompt.ask("Enter the property value to search for")
|
189
|
+
property_names = Prompt.ask("Enter a comma seperated list of properties to search")
|
190
|
+
find_elements_by_prop_value_x(om_type, property_value,[property_names], server, url, userid, password)
|
191
|
+
except KeyboardInterrupt:
|
192
|
+
pass
|
193
|
+
|
194
|
+
|
195
|
+
if __name__ == "__main__":
|
196
|
+
main()
|
@@ -0,0 +1,207 @@
|
|
1
|
+
"""This finds all elements related to the specified element by the specified relationship type,
|
2
|
+
that match the property value for the properties specified"""
|
3
|
+
from jedi import Project
|
4
|
+
from rich.markdown import Markdown
|
5
|
+
from rich.prompt import Prompt
|
6
|
+
import os
|
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
|
+
|
14
|
+
from pyegeria import (
|
15
|
+
InvalidParameterException,
|
16
|
+
PropertyServerException,
|
17
|
+
UserNotAuthorizedException,
|
18
|
+
print_exception_response,
|
19
|
+
EgeriaTech,
|
20
|
+
)
|
21
|
+
|
22
|
+
console = Console()
|
23
|
+
EGERIA_METADATA_STORE = os.environ.get("EGERIA_METADATA_STORE", "active-metadata-store")
|
24
|
+
EGERIA_KAFKA_ENDPOINT = os.environ.get("KAFKA_ENDPOINT", "localhost:9092")
|
25
|
+
EGERIA_PLATFORM_URL = os.environ.get("EGERIA_PLATFORM_URL", "https://localhost:9443")
|
26
|
+
EGERIA_VIEW_SERVER = os.environ.get("EGERIA_VIEW_SERVER", "view-server")
|
27
|
+
EGERIA_VIEW_SERVER_URL = os.environ.get(
|
28
|
+
"EGERIA_VIEW_SERVER_URL", "https://localhost:9443"
|
29
|
+
)
|
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", "220"))
|
37
|
+
|
38
|
+
|
39
|
+
def list_related_elements_with_prop_value(
|
40
|
+
element_guid: str,
|
41
|
+
relationship_type: str,
|
42
|
+
property_value: str,
|
43
|
+
property_names: [str],
|
44
|
+
om_type: str,
|
45
|
+
server: str,
|
46
|
+
url: str,
|
47
|
+
username: str,
|
48
|
+
password: str,
|
49
|
+
jupyter: bool = EGERIA_JUPYTER,
|
50
|
+
width: int = EGERIA_WIDTH,
|
51
|
+
):
|
52
|
+
c_client = EgeriaTech(server, url, user_id=username, user_pwd=password)
|
53
|
+
token = c_client.create_egeria_bearer_token()
|
54
|
+
|
55
|
+
if om_type is not None:
|
56
|
+
om_typedef = c_client.get_typedef_by_name(om_type)
|
57
|
+
if type(om_typedef) is str:
|
58
|
+
print(
|
59
|
+
f"The type name '{om_type}' is not known to the Egeria platform at {url} - {server}"
|
60
|
+
)
|
61
|
+
sys.exit(1)
|
62
|
+
|
63
|
+
def generate_table() -> Table:
|
64
|
+
"""Make a new table."""
|
65
|
+
table = Table(
|
66
|
+
caption=f"Metadata Elements for: {url} - {server} @ {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
|
+
title=f"Elements related to: '{element_guid}' ",
|
75
|
+
expand=True,
|
76
|
+
# width=500
|
77
|
+
)
|
78
|
+
table.add_column("Relationship GUID", width=38, no_wrap=True)
|
79
|
+
table.add_column("Rel Header", width=38, no_wrap=True)
|
80
|
+
table.add_column("Relationship Props")
|
81
|
+
table.add_column("Related GUID", width=38, no_wrap=True)
|
82
|
+
table.add_column("Properties")
|
83
|
+
table.add_column("Element Header")
|
84
|
+
|
85
|
+
elements = c_client.get_related_elements(
|
86
|
+
element_guid, relationship_type, om_type
|
87
|
+
)
|
88
|
+
|
89
|
+
if type(elements) is list:
|
90
|
+
for element in elements:
|
91
|
+
header = element["relationshipHeader"]
|
92
|
+
el_type = header["type"]["typeName"]
|
93
|
+
el_home = header["origin"]["homeMetadataCollectionName"]
|
94
|
+
el_create_time = header["versions"]["createTime"][:-10]
|
95
|
+
el_guid = header["guid"]
|
96
|
+
el_class = header.get("classifications", "---")
|
97
|
+
rel_header_md = (
|
98
|
+
f"* Type: {el_type}\n"
|
99
|
+
f"* Home: {el_home}\n"
|
100
|
+
f"* Created: {el_create_time}\n"
|
101
|
+
)
|
102
|
+
rel_header_out = Markdown(rel_header_md)
|
103
|
+
rel_props = element.get("relationshipProperties", "---")
|
104
|
+
|
105
|
+
rel_props_md = ""
|
106
|
+
if type(rel_props) is list:
|
107
|
+
for prop in rel_props.keys():
|
108
|
+
rel_props_md += (
|
109
|
+
f"* **{prop}**: {element['relationshipProperties'][prop]}\n"
|
110
|
+
)
|
111
|
+
rel_props_out = Markdown(rel_props_md)
|
112
|
+
|
113
|
+
c_md = ""
|
114
|
+
if type(el_class) is list:
|
115
|
+
for classification in el_class:
|
116
|
+
classification_name = classification.get(
|
117
|
+
"classificationName", "---"
|
118
|
+
)
|
119
|
+
c_md = f"* **{classification_name}**\n"
|
120
|
+
class_props = classification.get(
|
121
|
+
"classificationProperties", "---"
|
122
|
+
)
|
123
|
+
if type(class_props) is dict:
|
124
|
+
for prop in class_props.keys():
|
125
|
+
c_md += f" * **{prop}**: {class_props[prop]}\n"
|
126
|
+
c_md_out = Markdown(c_md)
|
127
|
+
|
128
|
+
rel_element = element["relatedElement"]
|
129
|
+
rel_el_header = rel_element["elementHeader"]
|
130
|
+
rel_type = rel_el_header["type"]["typeName"]
|
131
|
+
rel_home = rel_el_header["origin"]["homeMetadataCollectionName"]
|
132
|
+
rel_guid = rel_el_header["guid"]
|
133
|
+
|
134
|
+
rel_el_header_md = f"* Type: {rel_type}\n" f"* Home: {rel_home}\n"
|
135
|
+
rel_el_header_out = Markdown(rel_el_header_md)
|
136
|
+
|
137
|
+
rel_el_props_md = ""
|
138
|
+
for prop in rel_element["properties"].keys():
|
139
|
+
rel_el_props_md += (
|
140
|
+
f"* **{prop}**: {rel_element['properties'][prop]}\n"
|
141
|
+
)
|
142
|
+
rel_el_props_out = Markdown(rel_el_props_md)
|
143
|
+
|
144
|
+
table.add_row(
|
145
|
+
el_guid,
|
146
|
+
rel_header_out,
|
147
|
+
rel_props_out,
|
148
|
+
# el_q_name,
|
149
|
+
rel_guid,
|
150
|
+
rel_el_props_out,
|
151
|
+
rel_el_header_out,
|
152
|
+
)
|
153
|
+
|
154
|
+
return table
|
155
|
+
else:
|
156
|
+
print("No instances found")
|
157
|
+
sys.exit(1)
|
158
|
+
|
159
|
+
try:
|
160
|
+
console = Console(width=width, force_terminal=not jupyter)
|
161
|
+
|
162
|
+
with console.pager(styles=True):
|
163
|
+
console.print(generate_table())
|
164
|
+
|
165
|
+
except (
|
166
|
+
InvalidParameterException,
|
167
|
+
PropertyServerException,
|
168
|
+
UserNotAuthorizedException,
|
169
|
+
) as e:
|
170
|
+
print_exception_response(e)
|
171
|
+
print("\n\nPerhaps the type name isn't known")
|
172
|
+
finally:
|
173
|
+
c_client.close_session()
|
174
|
+
|
175
|
+
|
176
|
+
def main():
|
177
|
+
parser = argparse.ArgumentParser()
|
178
|
+
parser.add_argument("--server", help="Name of the server to display status for")
|
179
|
+
parser.add_argument("--url", help="URL Platform to connect to")
|
180
|
+
parser.add_argument("--userid", help="User Id")
|
181
|
+
parser.add_argument("--password", help="Password")
|
182
|
+
|
183
|
+
args = parser.parse_args()
|
184
|
+
|
185
|
+
server = args.server.strip() if args.server is not None else EGERIA_VIEW_SERVER
|
186
|
+
url = args.url.strip if args.url is not None else EGERIA_PLATFORM_URL
|
187
|
+
userid = args.userid.strip() if args.userid is not None else EGERIA_USER
|
188
|
+
password = args.password.strip() if args.password is not None else EGERIA_USER_PASSWORD
|
189
|
+
|
190
|
+
try:
|
191
|
+
element_guid = Prompt.ask("Guid of base element").strip()
|
192
|
+
relationship_type = Prompt.ask("Enter the relationship type to follow").strip()
|
193
|
+
property_value = Prompt.ask("Enter the property value to search for").strip()
|
194
|
+
property_names = Prompt.ask("Enter a comma seperated list of properties to search").strip()
|
195
|
+
om_type = Prompt.ask(
|
196
|
+
"Enter the Open Metadata Type to find elements of", default=None
|
197
|
+
)
|
198
|
+
om_type = om_type.strip() if type(om_type) is str else None
|
199
|
+
list_related_elements_with_prop_value(element_guid, relationship_type, property_value,
|
200
|
+
[property_names], om_type, server, url,
|
201
|
+
userid,password)
|
202
|
+
except KeyboardInterrupt:
|
203
|
+
pass
|
204
|
+
|
205
|
+
|
206
|
+
if __name__ == "__main__":
|
207
|
+
main()
|
pyegeria/valid_metadata_omvs.py
CHANGED
@@ -1809,7 +1809,7 @@ class ValidMetadataManager(Client):
|
|
1809
1809
|
return resp.json().get("typeDefs", "No TypeDefs Found")
|
1810
1810
|
|
1811
1811
|
def get_valid_classification_types(self, entity_type: str) -> list | str:
|
1812
|
-
"""Returns all the TypeDefs for
|
1812
|
+
"""Returns all the TypeDefs for classifications that can be attached to the requested entity type.
|
1813
1813
|
Async version.
|
1814
1814
|
|
1815
1815
|
Parameters
|