pyegeria 5.4.0.23__py3-none-any.whl → 5.4.0.24__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.
- commands/cat/debug_log +2046 -465
- commands/cat/debug_log.2025-08-15_09-14-07_444802.zip +0 -0
- commands/cat/debug_log.2025-08-16_10-21-59_388912.zip +0 -0
- commands/cat/dr_egeria_md.py +16 -3
- md_processing/__init__.py +5 -3
- md_processing/data/commands.json +8310 -903
- md_processing/dr_egeria_inbox/gov_def.md +76 -18
- md_processing/dr_egeria_inbox/img.png +0 -0
- md_processing/dr_egeria_inbox/product.md +132 -20
- md_processing/dr_egeria_outbox/monday/processed-2025-08-17 21:04-product.md +97 -0
- md_processing/md_commands/governance_officer_commands.py +291 -150
- md_processing/md_commands/product_manager_commands.py +309 -401
- md_processing/md_processing_utils/common_md_proc_utils.py +110 -7
- md_processing/md_processing_utils/common_md_utils.py +112 -26
- md_processing/md_processing_utils/md_processing_constants.py +8 -5
- pyegeria/__init__.py +1 -1
- pyegeria/_client_new.py +3 -2
- pyegeria/_exceptions_new.py +6 -0
- pyegeria/_output_formats.py +17 -2
- pyegeria/governance_officer.py +1 -3
- pyegeria/load_config.py +1 -1
- pyegeria/models.py +28 -1
- pyegeria/utils.py +1 -1
- {pyegeria-5.4.0.23.dist-info → pyegeria-5.4.0.24.dist-info}/METADATA +1 -1
- {pyegeria-5.4.0.23.dist-info → pyegeria-5.4.0.24.dist-info}/RECORD +28 -30
- commands/cat/logs/pyegeria.log +0 -136
- md_processing/dr_egeria_outbox/friday/processed-2025-07-18 15:00-product.md +0 -62
- md_processing/dr_egeria_outbox/friday/processed-2025-07-18 15:13-product.md +0 -62
- md_processing/dr_egeria_outbox/friday/processed-2025-07-20 13:23-product.md +0 -47
- md_processing/dr_egeria_outbox/friday/processed-2025-08-01 11:55-data_test3.md +0 -503
- md_processing/dr_egeria_outbox/processed-2025-08-03 16:05-glossary_list.md +0 -37
- {pyegeria-5.4.0.23.dist-info → pyegeria-5.4.0.24.dist-info}/LICENSE +0 -0
- {pyegeria-5.4.0.23.dist-info → pyegeria-5.4.0.24.dist-info}/WHEEL +0 -0
- {pyegeria-5.4.0.23.dist-info → pyegeria-5.4.0.24.dist-info}/entry_points.txt +0 -0
@@ -3,24 +3,28 @@ This file contains term-related object_action functions for processing Egeria Ma
|
|
3
3
|
"""
|
4
4
|
import json
|
5
5
|
import os
|
6
|
-
import sys
|
7
|
-
|
8
6
|
from typing import Optional
|
9
7
|
|
8
|
+
from inflect import engine
|
9
|
+
from jsonschema import ValidationError
|
10
10
|
from loguru import logger
|
11
|
+
from md_processing.md_processing_utils.common_md_proc_utils import (parse_upsert_command, parse_view_command,
|
12
|
+
process_output_command)
|
13
|
+
from md_processing.md_processing_utils.common_md_utils import (set_gov_prop_body,
|
14
|
+
set_update_body, set_create_body,
|
15
|
+
set_peer_gov_def_request_body, setup_log,
|
16
|
+
ALL_GOVERNANCE_DEFINITIONS, GOVERNANCE_POLICIES,
|
17
|
+
GOVERNANCE_CONTROLS, GOVERNANCE_DRIVERS,
|
18
|
+
set_find_body,
|
19
|
+
set_delete_request_body)
|
20
|
+
from md_processing.md_processing_utils.extraction_utils import (extract_command_plus, update_a_command)
|
21
|
+
from md_processing.md_processing_utils.md_processing_constants import (load_commands)
|
22
|
+
from pyegeria import DEBUG_LEVEL, body_slimmer, PyegeriaException, print_basic_exception, print_validation_error
|
23
|
+
from pyegeria.egeria_tech_client import EgeriaTech
|
11
24
|
from rich import print
|
12
25
|
from rich.console import Console
|
13
26
|
from rich.markdown import Markdown
|
14
27
|
|
15
|
-
from md_processing.md_processing_utils.common_md_proc_utils import (parse_upsert_command, parse_view_command)
|
16
|
-
from md_processing.md_processing_utils.common_md_utils import (update_element_dictionary, set_gov_prop_body, \
|
17
|
-
set_update_body, set_create_body, set_peer_gov_def_request_body, set_rel_request_body,
|
18
|
-
set_metadata_source_request_body, set_filter_request_body, setup_log)
|
19
|
-
from md_processing.md_processing_utils.extraction_utils import (extract_command_plus, update_a_command)
|
20
|
-
from md_processing.md_processing_utils.md_processing_constants import (load_commands, ERROR)
|
21
|
-
from pyegeria import DEBUG_LEVEL, body_slimmer
|
22
|
-
from pyegeria.egeria_tech_client import EgeriaTech
|
23
|
-
|
24
28
|
GERIA_METADATA_STORE = os.environ.get("EGERIA_METADATA_STORE", "active-metadata-store")
|
25
29
|
EGERIA_KAFKA_ENDPOINT = os.environ.get("KAFKA_ENDPOINT", "localhost:9092")
|
26
30
|
EGERIA_PLATFORM_URL = os.environ.get("EGERIA_PLATFORM_URL", "https://localhost:9443")
|
@@ -52,53 +56,156 @@ debug_level = DEBUG_LEVEL
|
|
52
56
|
console = Console(width=int(200))
|
53
57
|
setup_log()
|
54
58
|
|
59
|
+
|
55
60
|
#
|
56
61
|
# Helper functions for the governance officer commands
|
57
62
|
#
|
58
63
|
|
59
64
|
@logger.catch
|
60
|
-
def sync_gov_rel_elements(egeria_client: EgeriaTech, object_action:str, object_type:str, guid:
|
61
|
-
|
62
|
-
# TODO:
|
65
|
+
def sync_gov_rel_elements(egeria_client: EgeriaTech, object_action: str, object_type: str, guid: str,
|
66
|
+
qualified_name: str, attributes: dict):
|
67
|
+
# TODO: when the next release is available, I should be able to more easily get the asis elements - so will
|
68
|
+
# TODO: hold off on implementing replace all
|
63
69
|
try:
|
64
|
-
merge_update = attributes.get("Merge Update", {}).get("value",True)
|
65
|
-
to_be_supports_policies = attributes.get("Supports Policies", {}).get("guid_list",None)
|
66
|
-
to_be_governance_drivers = attributes.get("Governance Drivers", {}).get("guid_list",None)
|
70
|
+
merge_update = attributes.get("Merge Update", {}).get("value", True)
|
71
|
+
to_be_supports_policies = attributes.get("Supports Policies", {}).get("guid_list", None)
|
72
|
+
to_be_governance_drivers = attributes.get("Governance Drivers", {}).get("guid_list", None)
|
67
73
|
|
68
74
|
if merge_update or object_action == "Create":
|
69
75
|
if to_be_supports_policies:
|
70
76
|
for policy in to_be_supports_policies:
|
71
|
-
egeria_client.attach_supporting_definitions(policy, "GovernanceImplementation",guid)
|
77
|
+
egeria_client.attach_supporting_definitions(policy, "GovernanceImplementation", guid)
|
72
78
|
print(f"Added `{policy}` to `{guid}`")
|
73
79
|
elif to_be_governance_drivers:
|
74
80
|
for policy in to_be_governance_drivers:
|
75
|
-
egeria_client.attach_supporting_definitions(policy, "GovernanceResponse",guid)
|
81
|
+
egeria_client.attach_supporting_definitions(policy, "GovernanceResponse", guid)
|
76
82
|
print(f"Added `{policy}` to `{guid}`")
|
77
83
|
except Exception as ex:
|
78
84
|
print(ex)
|
79
85
|
|
86
|
+
|
80
87
|
@logger.catch
|
81
|
-
def process_gov_definition_upsert_command(egeria_client: EgeriaTech, txt: str, directive: str = "display") -> Optional[
|
88
|
+
def process_gov_definition_upsert_command(egeria_client: EgeriaTech, txt: str, directive: str = "display") -> Optional[
|
89
|
+
str]:
|
90
|
+
"""
|
91
|
+
Processes a data specification create or update object_action by extracting key attributes.
|
92
|
+
|
93
|
+
:param txt: Command details in text format.
|
94
|
+
:param directive: An optional string indicating the directive - display, validate, or process.
|
95
|
+
:return: A string summarizing the outcome, or None if no processing is needed.
|
82
96
|
"""
|
83
|
-
|
84
|
-
|
97
|
+
try:
|
98
|
+
# Extract basic command information
|
99
|
+
command, object_type, object_action = extract_command_plus(txt)
|
100
|
+
if not (command and object_type and object_action):
|
101
|
+
logger.error("Failed to parse `command`, `object_type`, or `object_action` from input text.")
|
102
|
+
return None
|
103
|
+
if object_type not in ALL_GOVERNANCE_DEFINITIONS:
|
104
|
+
logger.error(f"Invalid object type: {object_type}")
|
105
|
+
return None
|
106
|
+
# Log command details
|
107
|
+
print(Markdown(f"# {command}\n"))
|
108
|
+
|
109
|
+
# Parse command attributes
|
110
|
+
parsed_output = parse_upsert_command(egeria_client, object_type, object_action, txt, directive)
|
111
|
+
if not parsed_output or 'valid' not in parsed_output:
|
112
|
+
logger.error(f"Unable to parse command properly: {txt}")
|
113
|
+
return None
|
114
|
+
|
115
|
+
valid = parsed_output['valid']
|
116
|
+
exists = parsed_output['exists']
|
117
|
+
qualified_name = parsed_output.get('qualified_name')
|
118
|
+
display_name = parsed_output.get('attributes', {}).get('Display Name', {}).get('value')
|
119
|
+
guid = parsed_output.get('guid')
|
120
|
+
|
121
|
+
print(Markdown(parsed_output.get('display', '')))
|
122
|
+
logger.debug(json.dumps(parsed_output, indent=4))
|
123
|
+
|
124
|
+
if directive == "display":
|
125
|
+
logger.info("Directive set to display. No processing required.")
|
126
|
+
return None
|
127
|
+
|
128
|
+
elif directive == "validate":
|
129
|
+
if valid:
|
130
|
+
print(Markdown(f"==> Validation of {command} completed successfully!\n"))
|
131
|
+
else:
|
132
|
+
logger.error(f"Validation failed for `{command}`.")
|
133
|
+
return valid
|
134
|
+
|
135
|
+
elif directive == "process":
|
136
|
+
if object_action == "Update":
|
137
|
+
if not guid:
|
138
|
+
msg = (f"The `{object_type}` '{display_name}' does not yet exist.\n The result document has been "
|
139
|
+
f"updated to change `Update` to `Create` in processed output\n{'-' * 80}\n ")
|
140
|
+
logger.error(msg)
|
141
|
+
# print(msg)
|
142
|
+
return update_a_command(txt, object_action, object_type, qualified_name, guid)
|
143
|
+
|
144
|
+
if not valid:
|
145
|
+
logger.error("Invalid data for update action.")
|
146
|
+
return None
|
147
|
+
|
148
|
+
# Proceed with the update
|
149
|
+
update_body = set_update_body(object_type, parsed_output['attributes'])
|
150
|
+
update_body['properties'] = set_gov_prop_body(object_type, qualified_name, parsed_output['attributes'])
|
151
|
+
egeria_client.update_governance_definition(guid, body_slimmer(update_body))
|
152
|
+
if status := parsed_output['attributes'].get('Status', {}).get('value', None):
|
153
|
+
egeria_client.update_governance_definition_status(guid, status)
|
154
|
+
logger.success(f"Updated {object_type} `{display_name}` with GUID {guid}")
|
155
|
+
return egeria_client.get_governance_definition_by_guid(guid, output_format='MD')
|
156
|
+
|
157
|
+
elif object_action == "Create":
|
158
|
+
if valid is False and exists:
|
159
|
+
msg = (f"Failed to create `{object_type}` named `{display_name}` because it already exists.\n "
|
160
|
+
f"Result document has been updated to change `Create` to `Update` in processed o"
|
161
|
+
f"utput\n{'-' * 80}\n")
|
162
|
+
logger.error(msg)
|
163
|
+
return update_a_command(txt, object_action, object_type, qualified_name, guid)
|
164
|
+
elif valid is False:
|
165
|
+
msg = f" invalid data? - Correct and try again\n\n___"
|
166
|
+
logger.error(msg)
|
167
|
+
return None
|
168
|
+
else:
|
169
|
+
create_body = set_create_body(object_type, parsed_output['attributes'])
|
170
|
+
create_body['properties'] = set_gov_prop_body(object_type, qualified_name,
|
171
|
+
parsed_output['attributes'])
|
172
|
+
guid = egeria_client.create_governance_definition(body_slimmer(create_body))
|
173
|
+
if guid:
|
174
|
+
logger.success(f"Created {object_type} `{display_name}` with GUID {guid}")
|
175
|
+
return egeria_client.get_governance_definition_by_guid(guid, output_format='MD')
|
176
|
+
else:
|
177
|
+
logger.error(f"Failed to create {object_type} `{display_name}`.")
|
178
|
+
return None
|
179
|
+
|
180
|
+
else:
|
181
|
+
logger.error(f"Unsupported directive: {directive}")
|
182
|
+
return None
|
183
|
+
|
184
|
+
except PyegeriaException as e:
|
185
|
+
logger.error(f"PyegeriaException occurred: {e}")
|
186
|
+
print_basic_exception(e)
|
187
|
+
return None
|
188
|
+
|
189
|
+
except Exception as e:
|
190
|
+
logger.exception(f"Unexpected error: {e}")
|
191
|
+
return None
|
192
|
+
|
193
|
+
|
194
|
+
@logger.catch
|
195
|
+
def process_gov_def_link_detach_command(egeria_client: EgeriaTech, txt: str,
|
196
|
+
directive: str = "display") -> Optional[str]:
|
197
|
+
"""
|
198
|
+
Processes a link or unlink command to associate or break up peer governance definitions.
|
85
199
|
|
86
200
|
:param txt: A string representing the input cell to be processed for
|
87
|
-
extracting
|
201
|
+
extracting blueprint-related attributes.
|
88
202
|
:param directive: an optional string indicating the directive to be used - display, validate or execute
|
89
203
|
:return: A string summarizing the outcome of the processing.
|
90
204
|
"""
|
91
|
-
|
92
205
|
command, object_type, object_action = extract_command_plus(txt)
|
93
206
|
print(Markdown(f"# {command}\n"))
|
94
|
-
parsed_output = parse_upsert_command(egeria_client, object_type, object_action, txt, directive)
|
95
|
-
|
96
207
|
|
97
|
-
|
98
|
-
exists = parsed_output['exists']
|
99
|
-
qualified_name = parsed_output.get('qualified_name', None)
|
100
|
-
display_name = parsed_output.get('display_name', None)
|
101
|
-
guid = parsed_output.get('guid', None)
|
208
|
+
parsed_output = parse_view_command(egeria_client, object_type, object_action, txt, directive)
|
102
209
|
|
103
210
|
print(Markdown(parsed_output['display']))
|
104
211
|
|
@@ -106,10 +213,13 @@ def process_gov_definition_upsert_command(egeria_client: EgeriaTech, txt: str, d
|
|
106
213
|
|
107
214
|
attributes = parsed_output['attributes']
|
108
215
|
|
109
|
-
|
110
|
-
|
111
|
-
|
216
|
+
definition1 = attributes.get('Definition 1', {}).get('guid', None)
|
217
|
+
definition2 = attributes.get('Definition 2', {}).get('guid', None)
|
218
|
+
label = attributes.get('Link Label', {}).get('value', None)
|
219
|
+
description = attributes.get('Description', {}).get('value', None)
|
112
220
|
|
221
|
+
valid = parsed_output['valid']
|
222
|
+
exists = definition1 is not None and definition2 is not None
|
113
223
|
|
114
224
|
if directive == "display":
|
115
225
|
|
@@ -122,73 +232,87 @@ def process_gov_definition_upsert_command(egeria_client: EgeriaTech, txt: str, d
|
|
122
232
|
return valid
|
123
233
|
|
124
234
|
elif directive == "process":
|
235
|
+
# Initialize the inflect engine
|
236
|
+
inflector = engine()
|
125
237
|
|
126
|
-
|
127
|
-
|
128
|
-
if not exists:
|
129
|
-
msg = (f" Element `{display_name}` does not exist! Updating result document with Create "
|
130
|
-
f"object_action\n")
|
131
|
-
logger.error(msg)
|
132
|
-
return update_a_command(txt, object_action, object_type, qualified_name, guid)
|
133
|
-
elif not valid:
|
134
|
-
return None
|
135
|
-
else:
|
136
|
-
print(Markdown(
|
137
|
-
f"==> Validation of {command} completed successfully! Proceeding to apply the changes.\n"))
|
138
|
-
update_body = set_update_body(object_type, attributes)
|
139
|
-
update_body['properties'] = set_gov_prop_body(object_type, qualified_name, attributes)
|
140
|
-
|
141
|
-
egeria_client.update_governance_definition(guid, update_body, replace_all_props)
|
142
|
-
logger.success(f"Updated {object_type} `{display_name}` with GUID {guid}\n\n___")
|
143
|
-
update_element_dictionary(qualified_name, {
|
144
|
-
'guid': guid, 'display_name': display_name
|
145
|
-
})
|
146
|
-
sync_gov_rel_elements(egeria_client,object_type, object_type,guid, qualified_name, attributes)
|
147
|
-
return egeria_client.get_governance_definition_by_guid(guid, output_format='MD')
|
238
|
+
# Split the object_type into words
|
239
|
+
object_type_parts = object_type.split()
|
148
240
|
|
241
|
+
# Determine which word to singularize (third word if present, otherwise fallback to last word)
|
242
|
+
if len(object_type_parts) >= 3:
|
243
|
+
word_to_singularize = object_type_parts[2]
|
244
|
+
else:
|
245
|
+
word_to_singularize = object_type_parts[-1] # Fallback to last word
|
149
246
|
|
150
|
-
|
151
|
-
|
152
|
-
msg = (f" Data Specification `{display_name}` already exists and result document updated changing "
|
153
|
-
f"`Create` to `Update` in processed output\n\n___")
|
154
|
-
logger.error(msg)
|
155
|
-
return update_a_command(txt, object_action, object_type, qualified_name, guid)
|
156
|
-
# elif valid is False and in_data_spec_valid is False:
|
157
|
-
# msg = (f" Invalid data specification(s) `{in_data_spec_list}` "
|
158
|
-
# f" invalid data? - Correct and try again\n\n___")
|
159
|
-
# logger.error(msg)
|
160
|
-
# return None
|
161
|
-
else:
|
162
|
-
create_body = set_create_body(object_type, attributes)
|
163
|
-
create_body['properties'] = set_gov_prop_body(object_type, qualified_name,attributes)
|
164
|
-
guid = egeria_client.create_governance_definition(create_body)
|
165
|
-
if guid:
|
166
|
-
update_element_dictionary(qualified_name, {
|
167
|
-
'guid': guid, 'display_name': display_name
|
168
|
-
})
|
169
|
-
sync_gov_rel_elements(egeria_client, object_action,
|
170
|
-
object_type, guid, qualified_name,
|
171
|
-
attributes)
|
172
|
-
|
173
|
-
msg = f"Created Element `{display_name}` with GUID {guid}\n\n___"
|
174
|
-
logger.success(msg)
|
175
|
-
return egeria_client.get_governance_definition_by_guid(guid, output_format='MD')
|
176
|
-
else:
|
177
|
-
msg = f"Failed to create element `{display_name}` with GUID {guid}\n\n___"
|
178
|
-
logger.error(msg)
|
179
|
-
return None
|
247
|
+
# Singularize the selected word
|
248
|
+
singular_word = inflector.singular_noun(word_to_singularize) or word_to_singularize
|
180
249
|
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
250
|
+
# Construct gov_peer_relationship_type
|
251
|
+
gov_peer_relationship_type = f"Governance{singular_word}Link"
|
252
|
+
|
253
|
+
try:
|
254
|
+
if object_action == "Detach":
|
255
|
+
if not exists:
|
256
|
+
msg = (f" Link `{label}` does not exist! Updating result document with Link "
|
257
|
+
f"object_action\n")
|
258
|
+
logger.error(msg)
|
259
|
+
out = parsed_output['display'].replace('Link', 'Detach', 1)
|
260
|
+
return out
|
261
|
+
elif not valid:
|
262
|
+
return None
|
263
|
+
else:
|
264
|
+
print(Markdown(
|
265
|
+
f"==> Validation of {command} completed successfully! Proceeding to apply the changes.\n"))
|
266
|
+
body = set_delete_request_body(object_type, attributes)
|
267
|
+
|
268
|
+
egeria_client.detach_peer_definitions(definition1, gov_peer_relationship_type,
|
269
|
+
definition2, body)
|
270
|
+
|
271
|
+
logger.success(f"===> Detached segment with {label} from `{definition1}`to {definition2}\n")
|
272
|
+
out = parsed_output['display'].replace('Unlink', 'Link', 1)
|
273
|
+
|
274
|
+
return (out)
|
275
|
+
|
276
|
+
|
277
|
+
elif object_action == "Link":
|
278
|
+
if valid is False and exists:
|
279
|
+
msg = (f"--> Link called `{label}` already exists and result document updated changing "
|
280
|
+
f"`Link` to `Detach` in processed output\n")
|
281
|
+
logger.error(msg)
|
282
|
+
|
283
|
+
elif valid is False:
|
284
|
+
msg = f"==>{object_type} Link with label `{label}` is not valid and can't be created"
|
285
|
+
logger.error(msg)
|
286
|
+
return
|
287
|
+
|
288
|
+
else:
|
289
|
+
body = set_peer_gov_def_request_body(object_type, attributes)
|
290
|
+
egeria_client.link_peer_definitions(definition1, gov_peer_relationship_type,
|
291
|
+
definition2, body)
|
292
|
+
msg = f"==>Created {object_type} link named `{label}`\n"
|
293
|
+
logger.success(msg)
|
294
|
+
out = parsed_output['display'].replace('Link', 'Detach', 1)
|
295
|
+
return out
|
296
|
+
|
297
|
+
except ValidationError as e:
|
298
|
+
print_validation_error(e)
|
299
|
+
logger.error(f"Validation Error performing {command}: {e}")
|
300
|
+
return None
|
301
|
+
except PyegeriaException as e:
|
302
|
+
print_basic_exception(e)
|
303
|
+
logger.error(f"PyegeriaException occurred: {e}")
|
185
304
|
return None
|
186
305
|
|
306
|
+
except Exception as e:
|
307
|
+
logger.error(f"Error performing {command}: {e}")
|
308
|
+
return None
|
309
|
+
else:
|
310
|
+
return None
|
187
311
|
|
188
312
|
|
189
313
|
@logger.catch
|
190
|
-
def
|
191
|
-
|
314
|
+
def process_supporting_gov_def_link_detach_command(egeria_client: EgeriaTech, txt: str,
|
315
|
+
directive: str = "display") -> Optional[str]:
|
192
316
|
"""
|
193
317
|
Processes a link or unlink command to associate or break up peer governance definitions.
|
194
318
|
|
@@ -214,8 +338,7 @@ def process_gov_def_link_detach_command(egeria_client: EgeriaTech, txt: str,
|
|
214
338
|
description = attributes.get('Description', {}).get('value', None)
|
215
339
|
|
216
340
|
valid = parsed_output['valid']
|
217
|
-
exists = definition1 is not None and
|
218
|
-
|
341
|
+
exists = definition1 is not None and definition2 is not None
|
219
342
|
|
220
343
|
if directive == "display":
|
221
344
|
|
@@ -228,64 +351,81 @@ def process_gov_def_link_detach_command(egeria_client: EgeriaTech, txt: str,
|
|
228
351
|
return valid
|
229
352
|
|
230
353
|
elif directive == "process":
|
231
|
-
gov_peer_relationship_type = object_type[:-1].replace(" ","") + "Link"
|
232
|
-
|
233
|
-
try:
|
234
|
-
if object_action == "Detach":
|
235
|
-
if not exists:
|
236
|
-
msg = (f" Link `{label}` does not exist! Updating result document with Link "
|
237
|
-
f"object_action\n")
|
238
|
-
logger.error(msg)
|
239
|
-
out = parsed_output['display'].replace('Link', 'Detach', 1)
|
240
|
-
return out
|
241
|
-
elif not valid:
|
242
|
-
return None
|
243
|
-
else:
|
244
|
-
print(Markdown(
|
245
|
-
f"==> Validation of {command} completed successfully! Proceeding to apply the changes.\n"))
|
246
|
-
body = set_metadata_source_request_body(object_type, attributes)
|
247
|
-
|
248
|
-
egeria_client._async_detach_peer_definitions(definition1, gov_peer_relationship_type,
|
249
|
-
definition2,body)
|
250
354
|
|
251
|
-
|
252
|
-
|
355
|
+
# Construct gov_peer_relationship_type
|
356
|
+
relationship_type_name = object_type.replace(' ', '')
|
357
|
+
print(f"relationship_type_name: {relationship_type_name}")
|
358
|
+
try:
|
359
|
+
if object_action == "Detach":
|
360
|
+
if not exists:
|
361
|
+
msg = (f" Link `{label}` does not exist! Updating result document with Link "
|
362
|
+
f"object_action\n")
|
363
|
+
logger.error(msg)
|
364
|
+
out = parsed_output['display'].replace('Link', 'Detach', 1)
|
365
|
+
return out
|
366
|
+
elif not valid:
|
367
|
+
return None
|
368
|
+
else:
|
369
|
+
print(Markdown(
|
370
|
+
f"==> Validation of {command} completed successfully! Proceeding to apply the changes.\n"))
|
371
|
+
body = set_delete_request_body(object_type, attributes)
|
253
372
|
|
254
|
-
|
373
|
+
egeria_client.detach_supporting_definitions(definition1, relationship_type_name,
|
374
|
+
definition2, body)
|
255
375
|
|
376
|
+
logger.success(f"===> Detached segment with {label} from `{definition1}`to {definition2}\n")
|
377
|
+
out = parsed_output['display'].replace('Unlink', 'Link', 1)
|
256
378
|
|
257
|
-
|
258
|
-
if valid is False and exists:
|
259
|
-
msg = (f"--> Link called `{label}` already exists and result document updated changing "
|
260
|
-
f"`Link` to `Detach` in processed output\n")
|
261
|
-
logger.error(msg)
|
379
|
+
return (out)
|
262
380
|
|
263
|
-
elif valid is False:
|
264
|
-
msg = f"==>{object_type} Link with label `{label}` is not valid and can't be created"
|
265
|
-
logger.error(msg)
|
266
|
-
return
|
267
381
|
|
268
|
-
|
269
|
-
|
382
|
+
elif object_action == "Link":
|
383
|
+
if valid is False and exists:
|
384
|
+
msg = (f"--> Link called `{label}` already exists and result document updated changing "
|
385
|
+
f"`Link` to `Detach` in processed output\n")
|
386
|
+
logger.error(msg)
|
270
387
|
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
out = parsed_output['display'].replace('Link', 'Detach', 1)
|
276
|
-
return out
|
388
|
+
elif valid is False:
|
389
|
+
msg = f"==>{object_type} Link with label `{label}` is not valid and can't be created"
|
390
|
+
logger.error(msg)
|
391
|
+
return
|
277
392
|
|
393
|
+
else:
|
394
|
+
body_prop = {
|
395
|
+
"class": "SupportingDefinitionProperties",
|
396
|
+
"rationale": attributes.get('Rationale', {}).get('value', None),
|
397
|
+
"effectiveFrom": attributes.get('Effective From', {}).get('value', None),
|
398
|
+
"effectiveTo": attributes.get('Effective To', {}).get('value', None),
|
399
|
+
}
|
400
|
+
|
401
|
+
body = set_peer_gov_def_request_body(object_type, attributes)
|
402
|
+
body['properties'] = body_prop
|
403
|
+
egeria_client.attach_supporting_definitions(definition1, relationship_type_name,
|
404
|
+
definition2, body)
|
405
|
+
msg = f"==>Created {object_type} link named `{label}`\n"
|
406
|
+
logger.success(msg)
|
407
|
+
out = parsed_output['display'].replace('Link', 'Detach', 1)
|
408
|
+
return out
|
409
|
+
|
410
|
+
except ValidationError as e:
|
411
|
+
print_validation_error(e)
|
412
|
+
logger.error(f"Validation Error performing {command}: {e}")
|
413
|
+
return None
|
414
|
+
except PyegeriaException as e:
|
415
|
+
print_basic_exception(e)
|
416
|
+
logger.error(f"PyegeriaException occurred: {e}")
|
417
|
+
return None
|
278
418
|
|
279
|
-
|
280
|
-
|
281
|
-
|
419
|
+
except Exception as e:
|
420
|
+
logger.error(f"Error performing {command}: {e}")
|
421
|
+
return None
|
282
422
|
else:
|
283
423
|
return None
|
284
424
|
|
285
425
|
|
286
426
|
@logger.catch
|
287
427
|
def process_gov_definition_list_command(egeria_client: EgeriaTech, txt: str,
|
288
|
-
|
428
|
+
directive: str = "display") -> Optional[str]:
|
289
429
|
"""
|
290
430
|
Processes a Governance Definition list object_action by extracting key attributes such as
|
291
431
|
search string from the given text.
|
@@ -295,24 +435,25 @@ def process_gov_definition_list_command(egeria_client: EgeriaTech, txt: str,
|
|
295
435
|
:param directive: an optional string indicating the directive to be used - display, validate or execute
|
296
436
|
:return: A string summarizing the outcome of the processing.
|
297
437
|
"""
|
438
|
+
if True:
|
439
|
+
return process_output_command(egeria_client, txt, directive)
|
440
|
+
|
298
441
|
command, object_type, object_action = extract_command_plus(txt)
|
299
442
|
print(Markdown(f"# {command}\n"))
|
300
443
|
|
301
444
|
parsed_output = parse_view_command(egeria_client, object_type, object_action, txt, directive)
|
302
445
|
|
303
|
-
|
304
|
-
|
305
446
|
valid = parsed_output['valid']
|
306
447
|
print(Markdown(f"Performing {command}"))
|
307
448
|
print(Markdown(parsed_output['display']))
|
308
449
|
|
309
|
-
attr = parsed_output.get('attributes',{})
|
450
|
+
attr = parsed_output.get('attributes', {})
|
310
451
|
|
311
452
|
search_string = attr.get('Search String', {}).get('value', '*')
|
312
453
|
output_format = attr.get('Output Format', {}).get('value', 'LIST')
|
454
|
+
output_format_set = attr.get('Output Format Set', {}).get('value', object_type)
|
313
455
|
detailed = attr.get('Detailed', {}).get('value', False)
|
314
456
|
|
315
|
-
|
316
457
|
if directive == "display":
|
317
458
|
return None
|
318
459
|
elif directive == "validate":
|
@@ -331,11 +472,13 @@ def process_gov_definition_list_command(egeria_client: EgeriaTech, txt: str,
|
|
331
472
|
return None
|
332
473
|
|
333
474
|
list_md = f"\n# `{object_type}` with filter: `{search_string}`\n\n"
|
334
|
-
body =
|
475
|
+
body = set_find_body(object_type, attr)
|
335
476
|
|
336
477
|
struct = egeria_client.find_governance_definitions(search_string,
|
337
|
-
|
338
|
-
|
478
|
+
body=body,
|
479
|
+
output_format=output_format,
|
480
|
+
output_format_set=output_format_set,
|
481
|
+
)
|
339
482
|
if output_format.upper() == "DICT":
|
340
483
|
list_md += f"```\n{json.dumps(struct, indent=4)}\n```\n"
|
341
484
|
else:
|
@@ -351,9 +494,10 @@ def process_gov_definition_list_command(egeria_client: EgeriaTech, txt: str,
|
|
351
494
|
else:
|
352
495
|
return None
|
353
496
|
|
497
|
+
|
354
498
|
@logger.catch
|
355
499
|
def process_gov_def_context_command(egeria_client: EgeriaTech, txt: str,
|
356
|
-
|
500
|
+
directive: str = "display") -> Optional[str]:
|
357
501
|
"""
|
358
502
|
Retrieves the context graph for a governance definition.
|
359
503
|
|
@@ -375,12 +519,11 @@ def process_gov_def_context_command(egeria_client: EgeriaTech, txt: str,
|
|
375
519
|
|
376
520
|
print(Markdown(parsed_output['display']))
|
377
521
|
|
378
|
-
attr = parsed_output.get('attributes',{})
|
522
|
+
attr = parsed_output.get('attributes', {})
|
379
523
|
|
380
524
|
output_format = attr.get('Output Format', {}).get('value', 'LIST')
|
381
525
|
detailed = attr.get('Detailed', {}).get('value', False)
|
382
526
|
|
383
|
-
|
384
527
|
if directive == "display":
|
385
528
|
return None
|
386
529
|
elif directive == "validate":
|
@@ -401,7 +544,7 @@ def process_gov_def_context_command(egeria_client: EgeriaTech, txt: str,
|
|
401
544
|
list_md = f"\n# `{object_type}` with Qualified Name: `{qualified_name}`\n\n"
|
402
545
|
body = set_update_body(object_type, attr)
|
403
546
|
|
404
|
-
struct = egeria_client.get_gov_def_in_context(guid, body
|
547
|
+
struct = egeria_client.get_gov_def_in_context(guid, body=body, output_format=output_format)
|
405
548
|
if output_format.upper() == "DICT":
|
406
549
|
list_md += f"```\n{json.dumps(struct, indent=4)}\n```\n"
|
407
550
|
else:
|
@@ -416,5 +559,3 @@ def process_gov_def_context_command(egeria_client: EgeriaTech, txt: str,
|
|
416
559
|
return None
|
417
560
|
else:
|
418
561
|
return None
|
419
|
-
|
420
|
-
|