pyegeria 5.4.0.dev13__py3-none-any.whl → 5.4.0.1__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/__init__.py +1 -17
- commands/cat/debug_log +2802 -2
- commands/cat/debug_log.2025-07-15_14-28-38_087378.zip +0 -0
- commands/cat/debug_log.2025-07-16_15-48-50_037087.zip +0 -0
- commands/cat/dr_egeria_md.py +30 -6
- md_processing/__init__.py +16 -3
- md_processing/data/commands.json +18541 -171
- md_processing/dr_egeria_outbox-pycharm/.obsidian/app.json +1 -0
- md_processing/dr_egeria_outbox-pycharm/.obsidian/appearance.json +1 -0
- md_processing/dr_egeria_outbox-pycharm/.obsidian/core-plugins.json +31 -0
- md_processing/dr_egeria_outbox-pycharm/.obsidian/workspace.json +177 -0
- md_processing/dr_egeria_outbox-pycharm/monday/processed-2025-07-14 12:38-data_designer_out.md +663 -0
- md_processing/dr_egeria_outbox-pycharm/thursday/processed-2025-07-17 15:00-Derive-Dr-Gov-Defs.md +719 -0
- md_processing/dr_egeria_outbox-pycharm/thursday/processed-2025-07-17 20:13-Derive-Dr-Gov-Defs.md +41 -0
- md_processing/dr_egeria_outbox-pycharm/thursday/processed-2025-07-17 20:14-Derive-Dr-Gov-Defs.md +33 -0
- md_processing/dr_egeria_outbox-pycharm/thursday/processed-2025-07-17 20:50-Derive-Dr-Gov-Defs.md +192 -0
- md_processing/dr_egeria_outbox-pycharm/tuesday/processed-2025-07-16 19:15-gov_def2.md +527 -0
- md_processing/dr_egeria_outbox-pycharm/tuesday/processed-2025-07-17 12:08-gov_def2.md +527 -0
- md_processing/dr_egeria_outbox-pycharm/tuesday/processed-2025-07-17 14:27-gov_def2.md +474 -0
- md_processing/family_docs/Data Designer/Create_Data_Class.md +164 -0
- md_processing/family_docs/Data Designer/Create_Data_Dictionary.md +30 -0
- md_processing/family_docs/Data Designer/Create_Data_Field.md +162 -0
- md_processing/family_docs/Data Designer/Create_Data_Specification.md +36 -0
- md_processing/family_docs/Data Designer/Create_Data_Structure.md +38 -0
- md_processing/family_docs/Data Designer/View_Data_Classes.md +78 -0
- md_processing/family_docs/Data Designer/View_Data_Dictionaries.md +78 -0
- md_processing/family_docs/Data Designer/View_Data_Fields.md +78 -0
- md_processing/family_docs/Data Designer/View_Data_Specifications.md +78 -0
- md_processing/family_docs/Data Designer/View_Data_Structures.md +78 -0
- md_processing/family_docs/Data Designer.md +842 -0
- md_processing/family_docs/Digital Product Manager/Add_Member->Collection.md +42 -0
- md_processing/family_docs/Digital Product Manager/Attach_Collection->Resource.md +36 -0
- md_processing/family_docs/Digital Product Manager/Create_Agreement.md +96 -0
- md_processing/family_docs/Digital Product Manager/Create_Data_Sharing_Agreement.md +72 -0
- md_processing/family_docs/Digital Product Manager/Create_DigitalSubscription.md +102 -0
- md_processing/family_docs/Digital Product Manager/Create_Digital_Product.md +134 -0
- md_processing/family_docs/Digital Product Manager/Link_Agreement_Items.md +60 -0
- md_processing/family_docs/Digital Product Manager/Link_Contracts.md +26 -0
- md_processing/family_docs/Digital Product Manager/Link_Digital_Product_-_Digital_Product.md +30 -0
- md_processing/family_docs/Digital Product Manager/Link_Subscribers.md +48 -0
- md_processing/family_docs/Digital Product Manager.md +668 -0
- md_processing/family_docs/Glossary/Attach_Category_Parent.md +18 -0
- md_processing/family_docs/Glossary/Attach_Term-Term_Relationship.md +26 -0
- md_processing/family_docs/Glossary/Create_Category.md +38 -0
- md_processing/family_docs/Glossary/Create_Glossary.md +42 -0
- md_processing/family_docs/Glossary/Create_Term.md +70 -0
- md_processing/family_docs/Glossary.md +206 -0
- md_processing/family_docs/Governance Officer/Create_Business_Imperative.md +106 -0
- md_processing/family_docs/Governance Officer/Create_Certification_Type.md +112 -0
- md_processing/family_docs/Governance Officer/Create_Governance_Approach.md +114 -0
- md_processing/family_docs/Governance Officer/Create_Governance_Obligation.md +114 -0
- md_processing/family_docs/Governance Officer/Create_Governance_Principle.md +114 -0
- md_processing/family_docs/Governance Officer/Create_Governance_Procedure.md +128 -0
- md_processing/family_docs/Governance Officer/Create_Governance_Process.md +122 -0
- md_processing/family_docs/Governance Officer/Create_Governance_Processing_Purpose.md +106 -0
- md_processing/family_docs/Governance Officer/Create_Governance_Responsibility.md +122 -0
- md_processing/family_docs/Governance Officer/Create_Governance_Rule.md +122 -0
- md_processing/family_docs/Governance Officer/Create_Governance_Strategy.md +106 -0
- md_processing/family_docs/Governance Officer/Create_License_Type.md +112 -0
- md_processing/family_docs/Governance Officer/Create_Naming_Standard_Rule.md +122 -0
- md_processing/family_docs/Governance Officer/Create_Regulation_Article.md +106 -0
- md_processing/family_docs/Governance Officer/Create_Regulation_Definition.md +118 -0
- md_processing/family_docs/Governance Officer/Create_Security_Access_Control.md +114 -0
- md_processing/family_docs/Governance Officer/Create_Security_Group.md +120 -0
- md_processing/family_docs/Governance Officer/Create_Service_Level_Objectives.md +122 -0
- md_processing/family_docs/Governance Officer/Create_Threat_Definition.md +106 -0
- md_processing/family_docs/Governance Officer/Link_Governance_Controls.md +32 -0
- md_processing/family_docs/Governance Officer/Link_Governance_Drivers.md +32 -0
- md_processing/family_docs/Governance Officer/Link_Governance_Policies.md +32 -0
- md_processing/family_docs/Governance Officer/View_Governance_Definitions.md +82 -0
- md_processing/family_docs/Governance Officer.md +2412 -0
- md_processing/family_docs/Solution Architect/Create_Information_Supply_Chain.md +70 -0
- md_processing/family_docs/Solution Architect/Create_Solution_Blueprint.md +44 -0
- md_processing/family_docs/Solution Architect/Create_Solution_Component.md +96 -0
- md_processing/family_docs/Solution Architect/Create_Solution_Role.md +66 -0
- md_processing/family_docs/Solution Architect/Link_Information_Supply_Chain_Peers.md +32 -0
- md_processing/family_docs/Solution Architect/Link_Solution_Component_Peers.md +32 -0
- md_processing/family_docs/Solution Architect/View_Information_Supply_Chains.md +32 -0
- md_processing/family_docs/Solution Architect/View_Solution_Blueprints.md +32 -0
- md_processing/family_docs/Solution Architect/View_Solution_Components.md +32 -0
- md_processing/family_docs/Solution Architect/View_Solution_Roles.md +32 -0
- md_processing/family_docs/Solution Architect.md +490 -0
- md_processing/md_commands/data_designer_commands.py +9 -10
- md_processing/md_commands/glossary_commands.py +16 -2
- md_processing/md_commands/governance_officer_commands.py +420 -0
- md_processing/md_commands/product_manager_commands.py +186 -752
- md_processing/md_commands/project_commands.py +5 -2
- md_processing/md_commands/solution_architect_commands.py +9 -8
- md_processing/md_processing_utils/common_md_proc_utils.py +15 -10
- md_processing/md_processing_utils/common_md_utils.py +194 -2
- md_processing/md_processing_utils/debug_log +574 -0
- md_processing/md_processing_utils/dr-egeria-help-2025-07-17T17:22:09.md +2065 -0
- md_processing/md_processing_utils/extraction_utils.py +1 -1
- md_processing/md_processing_utils/generate_dr_help.py +20 -5
- md_processing/md_processing_utils/generate_md_cmd_templates.py +143 -0
- md_processing/md_processing_utils/md_processing_constants.py +56 -4
- pyegeria/governance_officer_omvs.py +14 -99
- pyegeria/output_formatter.py +3 -2
- pyegeria/utils.py +7 -0
- {pyegeria-5.4.0.dev13.dist-info → pyegeria-5.4.0.1.dist-info}/METADATA +2 -1
- {pyegeria-5.4.0.dev13.dist-info → pyegeria-5.4.0.1.dist-info}/RECORD +104 -30
- commands/cat/debug_log.2025-07-01_15-22-20_102237.zip +0 -0
- commands/cat/debug_log.2025-07-04_15-43-28_460900.zip +0 -0
- commands/cat/debug_log.2025-07-06_20-48-04_338314.zip +0 -0
- commands/cat/debug_log.2025-07-09_10-17-09_526262.zip +0 -0
- commands/cat/debug_log.2025-07-10_10-25-47_958331.zip +0 -0
- pyegeria/m_test.py +0 -118
- {pyegeria-5.4.0.dev13.dist-info → pyegeria-5.4.0.1.dist-info}/LICENSE +0 -0
- {pyegeria-5.4.0.dev13.dist-info → pyegeria-5.4.0.1.dist-info}/WHEEL +0 -0
- {pyegeria-5.4.0.dev13.dist-info → pyegeria-5.4.0.1.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,420 @@
|
|
1
|
+
"""
|
2
|
+
This file contains term-related object_action functions for processing Egeria Markdown
|
3
|
+
"""
|
4
|
+
import json
|
5
|
+
import os
|
6
|
+
import sys
|
7
|
+
|
8
|
+
from typing import Optional
|
9
|
+
|
10
|
+
from loguru import logger
|
11
|
+
from rich import print
|
12
|
+
from rich.console import Console
|
13
|
+
from rich.markdown import Markdown
|
14
|
+
|
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
|
+
GERIA_METADATA_STORE = os.environ.get("EGERIA_METADATA_STORE", "active-metadata-store")
|
25
|
+
EGERIA_KAFKA_ENDPOINT = os.environ.get("KAFKA_ENDPOINT", "localhost:9092")
|
26
|
+
EGERIA_PLATFORM_URL = os.environ.get("EGERIA_PLATFORM_URL", "https://localhost:9443")
|
27
|
+
EGERIA_VIEW_SERVER = os.environ.get("EGERIA_VIEW_SERVER", "view-server")
|
28
|
+
EGERIA_VIEW_SERVER_URL = os.environ.get("EGERIA_VIEW_SERVER_URL", "https://localhost:9443")
|
29
|
+
EGERIA_INTEGRATION_DAEMON = os.environ.get("EGERIA_INTEGRATION_DAEMON", "integration-daemon")
|
30
|
+
EGERIA_INTEGRATION_DAEMON_URL = os.environ.get("EGERIA_INTEGRATION_DAEMON_URL", "https://localhost:9443")
|
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_WIDTH = os.environ.get("EGERIA_WIDTH", 220)
|
36
|
+
EGERIA_JUPYTER = os.environ.get("EGERIA_JUPYTER", False)
|
37
|
+
EGERIA_HOME_GLOSSARY_GUID = os.environ.get("EGERIA_HOME_GLOSSARY_GUID", None)
|
38
|
+
EGERIA_GLOSSARY_PATH = os.environ.get("EGERIA_GLOSSARY_PATH", None)
|
39
|
+
EGERIA_ROOT_PATH = os.environ.get("EGERIA_ROOT_PATH", "../../")
|
40
|
+
EGERIA_INBOX_PATH = os.environ.get("EGERIA_INBOX_PATH", "md_processing/dr_egeria_inbox")
|
41
|
+
EGERIA_OUTBOX_PATH = os.environ.get("EGERIA_OUTBOX_PATH", "md_processing/dr_egeria_outbox")
|
42
|
+
|
43
|
+
GENERAL_GOVERNANCE_DEFINITIONS = ["Business Imperative", "Regulation Article", "Threat", "Governance Principle",
|
44
|
+
"Governance Obligation", "Governance Approach", "Governance Processing Purpose"]
|
45
|
+
|
46
|
+
GOVERNANCE_CONTROLS = ["Governance Rule", "Service Level Objective", "Governance Process",
|
47
|
+
"Governance Responsibility", "Governance Procedure", "Security Access Control"]
|
48
|
+
|
49
|
+
load_commands('commands.json')
|
50
|
+
debug_level = DEBUG_LEVEL
|
51
|
+
|
52
|
+
console = Console(width=int(200))
|
53
|
+
setup_log()
|
54
|
+
|
55
|
+
#
|
56
|
+
# Helper functions for the governance officer commands
|
57
|
+
#
|
58
|
+
|
59
|
+
@logger.catch
|
60
|
+
def sync_gov_rel_elements(egeria_client: EgeriaTech, object_action:str, object_type:str, guid:str, qualified_name:str, attributes: dict):
|
61
|
+
# TODO: when the next release is available, I should be able to more easily get the asis elements - so will
|
62
|
+
# TODO: hold off on implementing replace all
|
63
|
+
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)
|
67
|
+
|
68
|
+
if merge_update or object_action == "Create":
|
69
|
+
if to_be_supports_policies:
|
70
|
+
for policy in to_be_supports_policies:
|
71
|
+
egeria_client.attach_supporting_definitions(policy, "GovernanceImplementation",guid)
|
72
|
+
print(f"Added `{policy}` to `{guid}`")
|
73
|
+
elif to_be_governance_drivers:
|
74
|
+
for policy in to_be_governance_drivers:
|
75
|
+
egeria_client.attach_supporting_definitions(policy, "GovernanceResponse",guid)
|
76
|
+
print(f"Added `{policy}` to `{guid}`")
|
77
|
+
except Exception as ex:
|
78
|
+
print(ex)
|
79
|
+
|
80
|
+
@logger.catch
|
81
|
+
def process_gov_definition_upsert_command(egeria_client: EgeriaTech, txt: str, directive: str = "display") -> Optional[str]:
|
82
|
+
"""
|
83
|
+
Processes a data specification create or update object_action by extracting key attributes such as
|
84
|
+
spec name, parent_guid, parent_relationship_type, parent_at_end_1, collection_type
|
85
|
+
|
86
|
+
:param txt: A string representing the input cell to be processed for
|
87
|
+
extracting glossary-related attributes.
|
88
|
+
:param directive: an optional string indicating the directive to be used - display, validate or execute
|
89
|
+
:return: A string summarizing the outcome of the processing.
|
90
|
+
"""
|
91
|
+
|
92
|
+
command, object_type, object_action = extract_command_plus(txt)
|
93
|
+
print(Markdown(f"# {command}\n"))
|
94
|
+
parsed_output = parse_upsert_command(egeria_client, object_type, object_action, txt, directive)
|
95
|
+
|
96
|
+
|
97
|
+
valid = parsed_output['valid']
|
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)
|
102
|
+
|
103
|
+
print(Markdown(parsed_output['display']))
|
104
|
+
|
105
|
+
logger.debug(json.dumps(parsed_output, indent=4))
|
106
|
+
|
107
|
+
attributes = parsed_output['attributes']
|
108
|
+
|
109
|
+
display_name = attributes['Display Name'].get('value', None)
|
110
|
+
|
111
|
+
replace_all_props = not attributes.get('Merge Update', {}).get('value', True)
|
112
|
+
|
113
|
+
|
114
|
+
if directive == "display":
|
115
|
+
|
116
|
+
return None
|
117
|
+
elif directive == "validate":
|
118
|
+
if valid:
|
119
|
+
print(Markdown(f"==> Validation of {command} completed successfully!\n"))
|
120
|
+
else:
|
121
|
+
msg = f"Validation failed for object_action `{command}`\n"
|
122
|
+
return valid
|
123
|
+
|
124
|
+
elif directive == "process":
|
125
|
+
|
126
|
+
try:
|
127
|
+
if object_action == "Update":
|
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')
|
148
|
+
|
149
|
+
|
150
|
+
elif object_action == "Create":
|
151
|
+
if valid is False and exists:
|
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
|
180
|
+
|
181
|
+
except Exception as e:
|
182
|
+
logger.error(f"Error performing {command}: {e}")
|
183
|
+
return None
|
184
|
+
else:
|
185
|
+
return None
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
@logger.catch
|
190
|
+
def process_gov_def_link_detach_command(egeria_client: EgeriaTech, txt: str,
|
191
|
+
directive: str = "display") -> Optional[str]:
|
192
|
+
"""
|
193
|
+
Processes a link or unlink command to associate or break up peer governance definitions.
|
194
|
+
|
195
|
+
:param txt: A string representing the input cell to be processed for
|
196
|
+
extracting blueprint-related attributes.
|
197
|
+
:param directive: an optional string indicating the directive to be used - display, validate or execute
|
198
|
+
:return: A string summarizing the outcome of the processing.
|
199
|
+
"""
|
200
|
+
command, object_type, object_action = extract_command_plus(txt)
|
201
|
+
print(Markdown(f"# {command}\n"))
|
202
|
+
|
203
|
+
parsed_output = parse_view_command(egeria_client, object_type, object_action, txt, directive)
|
204
|
+
|
205
|
+
print(Markdown(parsed_output['display']))
|
206
|
+
|
207
|
+
logger.debug(json.dumps(parsed_output, indent=4))
|
208
|
+
|
209
|
+
attributes = parsed_output['attributes']
|
210
|
+
|
211
|
+
definition1 = attributes.get('Definition 1', {}).get('guid', None)
|
212
|
+
definition2 = attributes.get('Definition 2', {}).get('guid', None)
|
213
|
+
label = attributes.get('Link Label', {}).get('value', None)
|
214
|
+
description = attributes.get('Description', {}).get('value', None)
|
215
|
+
|
216
|
+
valid = parsed_output['valid']
|
217
|
+
exists = definition1 is not None and definition2 is not None
|
218
|
+
|
219
|
+
|
220
|
+
if directive == "display":
|
221
|
+
|
222
|
+
return None
|
223
|
+
elif directive == "validate":
|
224
|
+
if valid:
|
225
|
+
print(Markdown(f"==> Validation of {command} completed successfully!\n"))
|
226
|
+
else:
|
227
|
+
msg = f"Validation failed for object_action `{command}`\n"
|
228
|
+
return valid
|
229
|
+
|
230
|
+
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
|
+
|
251
|
+
logger.success(f"===> Detached segment with {label} from `{definition1}`to {definition2}\n")
|
252
|
+
out = parsed_output['display'].replace('Unlink', 'Link', 1)
|
253
|
+
|
254
|
+
return (out)
|
255
|
+
|
256
|
+
|
257
|
+
elif object_action == "Link":
|
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)
|
262
|
+
|
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
|
+
|
268
|
+
else:
|
269
|
+
body = set_peer_gov_def_request_body(object_type, attributes)
|
270
|
+
|
271
|
+
egeria_client.link_peer_definitions(definition1, gov_peer_relationship_type,
|
272
|
+
definition2, body)
|
273
|
+
msg = f"==>Created {object_type} link named `{label}`\n"
|
274
|
+
logger.success(msg)
|
275
|
+
out = parsed_output['display'].replace('Link', 'Detach', 1)
|
276
|
+
return out
|
277
|
+
|
278
|
+
|
279
|
+
except Exception as e:
|
280
|
+
logger.error(f"Error performing {command}: {e}")
|
281
|
+
return None
|
282
|
+
else:
|
283
|
+
return None
|
284
|
+
|
285
|
+
|
286
|
+
@logger.catch
|
287
|
+
def process_gov_definition_list_command(egeria_client: EgeriaTech, txt: str,
|
288
|
+
directive: str = "display") -> Optional[str]:
|
289
|
+
"""
|
290
|
+
Processes a Governance Definition list object_action by extracting key attributes such as
|
291
|
+
search string from the given text.
|
292
|
+
|
293
|
+
:param txt: A string representing the input cell to be processed for
|
294
|
+
extracting term-related attributes.
|
295
|
+
:param directive: an optional string indicating the directive to be used - display, validate or execute
|
296
|
+
:return: A string summarizing the outcome of the processing.
|
297
|
+
"""
|
298
|
+
command, object_type, object_action = extract_command_plus(txt)
|
299
|
+
print(Markdown(f"# {command}\n"))
|
300
|
+
|
301
|
+
parsed_output = parse_view_command(egeria_client, object_type, object_action, txt, directive)
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
valid = parsed_output['valid']
|
306
|
+
print(Markdown(f"Performing {command}"))
|
307
|
+
print(Markdown(parsed_output['display']))
|
308
|
+
|
309
|
+
attr = parsed_output.get('attributes',{})
|
310
|
+
|
311
|
+
search_string = attr.get('Search String', {}).get('value', '*')
|
312
|
+
output_format = attr.get('Output Format', {}).get('value', 'LIST')
|
313
|
+
detailed = attr.get('Detailed', {}).get('value', False)
|
314
|
+
|
315
|
+
|
316
|
+
if directive == "display":
|
317
|
+
return None
|
318
|
+
elif directive == "validate":
|
319
|
+
if valid:
|
320
|
+
print(Markdown(f"==> Validation of {command} completed successfully!\n"))
|
321
|
+
else:
|
322
|
+
msg = f"Validation failed for object_action `{command}`\n"
|
323
|
+
logger.error(msg)
|
324
|
+
return valid
|
325
|
+
|
326
|
+
elif directive == "process":
|
327
|
+
try:
|
328
|
+
if not valid: # First validate the command before we process it
|
329
|
+
msg = f"Validation failed for {object_action} `{object_type}`\n"
|
330
|
+
logger.error(msg)
|
331
|
+
return None
|
332
|
+
|
333
|
+
list_md = f"\n# `{object_type}` with filter: `{search_string}`\n\n"
|
334
|
+
body = set_update_body(object_type, attr)
|
335
|
+
|
336
|
+
struct = egeria_client.find_governance_definitions(search_string,
|
337
|
+
body = body,
|
338
|
+
output_format=output_format)
|
339
|
+
if output_format.upper() == "DICT":
|
340
|
+
list_md += f"```\n{json.dumps(struct, indent=4)}\n```\n"
|
341
|
+
else:
|
342
|
+
list_md += struct
|
343
|
+
logger.info(f"Wrote `{object_type}` for search string: `{search_string}`")
|
344
|
+
|
345
|
+
return list_md
|
346
|
+
|
347
|
+
except Exception as e:
|
348
|
+
logger.error(f"Error performing {command}: {e}")
|
349
|
+
console.print_exception(show_locals=True)
|
350
|
+
return None
|
351
|
+
else:
|
352
|
+
return None
|
353
|
+
|
354
|
+
@logger.catch
|
355
|
+
def process_gov_def_context_command(egeria_client: EgeriaTech, txt: str,
|
356
|
+
directive: str = "display") -> Optional[str]:
|
357
|
+
"""
|
358
|
+
Retrieves the context graph for a governance definition.
|
359
|
+
|
360
|
+
:param txt: A string representing the input cell to be processed for
|
361
|
+
extracting term-related attributes.
|
362
|
+
:param directive: an optional string indicating the directive to be used - display, validate or execute
|
363
|
+
:return: A string summarizing the outcome of the processing.
|
364
|
+
"""
|
365
|
+
command, object_type, object_action = extract_command_plus(txt)
|
366
|
+
print(Markdown(f"# {command}\n"))
|
367
|
+
|
368
|
+
parsed_output = parse_view_command(egeria_client, object_type, object_action, txt, directive)
|
369
|
+
|
370
|
+
valid = parsed_output['valid']
|
371
|
+
exists = parsed_output['exists']
|
372
|
+
qualified_name = parsed_output.get('qualified_name', None)
|
373
|
+
display_name = parsed_output.get('display_name', None)
|
374
|
+
guid = parsed_output.get('guid', None)
|
375
|
+
|
376
|
+
print(Markdown(parsed_output['display']))
|
377
|
+
|
378
|
+
attr = parsed_output.get('attributes',{})
|
379
|
+
|
380
|
+
output_format = attr.get('Output Format', {}).get('value', 'LIST')
|
381
|
+
detailed = attr.get('Detailed', {}).get('value', False)
|
382
|
+
|
383
|
+
|
384
|
+
if directive == "display":
|
385
|
+
return None
|
386
|
+
elif directive == "validate":
|
387
|
+
if valid:
|
388
|
+
print(Markdown(f"==> Validation of {command} completed successfully!\n"))
|
389
|
+
else:
|
390
|
+
msg = f"Validation failed for object_action `{command}`\n"
|
391
|
+
logger.error(msg)
|
392
|
+
return valid
|
393
|
+
|
394
|
+
elif directive == "process":
|
395
|
+
try:
|
396
|
+
if not valid: # First validate the command before we process it
|
397
|
+
msg = f"Validation failed for {object_action} `{object_type}`\n"
|
398
|
+
logger.error(msg)
|
399
|
+
return None
|
400
|
+
|
401
|
+
list_md = f"\n# `{object_type}` with Qualified Name: `{qualified_name}`\n\n"
|
402
|
+
body = set_update_body(object_type, attr)
|
403
|
+
|
404
|
+
struct = egeria_client.get_gov_def_in_context(guid, body = body, output_format=output_format)
|
405
|
+
if output_format.upper() == "DICT":
|
406
|
+
list_md += f"```\n{json.dumps(struct, indent=4)}\n```\n"
|
407
|
+
else:
|
408
|
+
list_md += struct
|
409
|
+
logger.info(f"Wrote `{object_type}` graph for : `{qualified_name}`")
|
410
|
+
|
411
|
+
return list_md
|
412
|
+
|
413
|
+
except Exception as e:
|
414
|
+
logger.error(f"Error performing {command}: {e}")
|
415
|
+
console.print_exception(show_locals=True)
|
416
|
+
return None
|
417
|
+
else:
|
418
|
+
return None
|
419
|
+
|
420
|
+
|