pyegeria 5.4.0.22__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.
Files changed (130) hide show
  1. commands/cat/.DS_Store +0 -0
  2. commands/cat/.env +8 -0
  3. commands/cat/debug_log +2046 -465
  4. commands/cat/debug_log.2025-08-15_09-14-07_444802.zip +0 -0
  5. commands/cat/debug_log.2025-08-16_10-21-59_388912.zip +0 -0
  6. commands/cat/debug_log.log +0 -0
  7. commands/cat/dr_egeria_md.py +16 -3
  8. commands/cat/list_collections.py +15 -6
  9. commands/cat/list_format_set.py +90 -85
  10. commands/cli/debug_log.log +0 -0
  11. commands/ops/logs/pyegeria.log +0 -0
  12. md_processing/.DS_Store +0 -0
  13. md_processing/__init__.py +5 -3
  14. md_processing/data/commands.json +8310 -903
  15. md_processing/dr-egeria-outbox/Collections-2025-08-12-13-30-37.md +163 -0
  16. md_processing/dr-egeria-outbox/Collections-2025-08-12-13-35-58.md +474 -0
  17. md_processing/dr_egeria_inbox/Derive-Dr-Gov-Defs.md +8 -0
  18. md_processing/dr_egeria_inbox/Dr.Egeria Templates.md +873 -0
  19. md_processing/dr_egeria_inbox/arch_test.md +57 -0
  20. md_processing/dr_egeria_inbox/archive/dr_egeria_intro.md +254 -0
  21. md_processing/dr_egeria_inbox/archive/dr_egeria_intro_more_terms.md +696 -0
  22. md_processing/dr_egeria_inbox/archive/dr_egeria_intro_part1.md +254 -0
  23. md_processing/dr_egeria_inbox/archive/dr_egeria_intro_part2.md +298 -0
  24. md_processing/dr_egeria_inbox/archive/dr_egeria_intro_part3.md +608 -0
  25. md_processing/dr_egeria_inbox/archive/dr_egeria_intro_part4.md +94 -0
  26. md_processing/dr_egeria_inbox/archive/freddie_intro.md +284 -0
  27. md_processing/dr_egeria_inbox/archive/freddie_intro_orig.md +275 -0
  28. md_processing/dr_egeria_inbox/archive/test-term.md +110 -0
  29. md_processing/dr_egeria_inbox/cat_test.md +100 -0
  30. md_processing/dr_egeria_inbox/collections.md +39 -0
  31. md_processing/dr_egeria_inbox/data_designer_debug.log +6 -0
  32. md_processing/dr_egeria_inbox/data_designer_out.md +60 -0
  33. md_processing/dr_egeria_inbox/data_designer_search_test.md +11 -0
  34. md_processing/dr_egeria_inbox/data_field.md +54 -0
  35. md_processing/dr_egeria_inbox/data_spec.md +77 -0
  36. md_processing/dr_egeria_inbox/data_spec_test.md +2406 -0
  37. md_processing/dr_egeria_inbox/data_test.md +179 -0
  38. md_processing/dr_egeria_inbox/data_test2.md +429 -0
  39. md_processing/dr_egeria_inbox/data_test3.md +462 -0
  40. md_processing/dr_egeria_inbox/dr_egeria_data_designer_1.md +124 -0
  41. md_processing/dr_egeria_inbox/dr_egeria_intro_categories.md +168 -0
  42. md_processing/dr_egeria_inbox/dr_egeria_intro_part1.md +280 -0
  43. md_processing/dr_egeria_inbox/dr_egeria_intro_part2.md +313 -0
  44. md_processing/dr_egeria_inbox/dr_egeria_intro_part3.md +1073 -0
  45. md_processing/dr_egeria_inbox/dr_egeria_isc1.md +44 -0
  46. md_processing/dr_egeria_inbox/generated_help_report.md +9 -0
  47. md_processing/dr_egeria_inbox/glossary_list.md +5 -0
  48. md_processing/dr_egeria_inbox/glossary_search_test.md +40 -0
  49. md_processing/dr_egeria_inbox/glossary_test1.md +324 -0
  50. md_processing/dr_egeria_inbox/gov_def.md +482 -0
  51. md_processing/dr_egeria_inbox/gov_def2.md +447 -0
  52. md_processing/dr_egeria_inbox/img.png +0 -0
  53. md_processing/dr_egeria_inbox/product.md +162 -0
  54. md_processing/dr_egeria_inbox/rel.md +8 -0
  55. md_processing/dr_egeria_inbox/sb.md +119 -0
  56. md_processing/dr_egeria_inbox/solution-components.md +136 -0
  57. md_processing/dr_egeria_inbox/solution_blueprints.md +118 -0
  58. md_processing/dr_egeria_inbox/synonym_test.md +42 -0
  59. md_processing/dr_egeria_inbox/t2.md +268 -0
  60. md_processing/dr_egeria_outbox/.obsidian/app.json +1 -0
  61. md_processing/dr_egeria_outbox/.obsidian/appearance.json +1 -0
  62. md_processing/dr_egeria_outbox/.obsidian/community-plugins.json +6 -0
  63. md_processing/dr_egeria_outbox/.obsidian/core-plugins.json +31 -0
  64. md_processing/dr_egeria_outbox/.obsidian/plugins/calendar/data.json +10 -0
  65. md_processing/dr_egeria_outbox/.obsidian/plugins/calendar/main.js +4459 -0
  66. md_processing/dr_egeria_outbox/.obsidian/plugins/calendar/manifest.json +10 -0
  67. md_processing/dr_egeria_outbox/.obsidian/plugins/obsidian-kanban/data.json +3 -0
  68. md_processing/dr_egeria_outbox/.obsidian/plugins/obsidian-kanban/main.js +153 -0
  69. md_processing/dr_egeria_outbox/.obsidian/plugins/obsidian-kanban/manifest.json +11 -0
  70. md_processing/dr_egeria_outbox/.obsidian/plugins/obsidian-kanban/styles.css +1 -0
  71. md_processing/dr_egeria_outbox/.obsidian/plugins/obsidian-tasks-plugin/main.js +500 -0
  72. md_processing/dr_egeria_outbox/.obsidian/plugins/obsidian-tasks-plugin/manifest.json +12 -0
  73. md_processing/dr_egeria_outbox/.obsidian/plugins/obsidian-tasks-plugin/styles.css +1 -0
  74. md_processing/dr_egeria_outbox/.obsidian/plugins/templater-obsidian/main.js +37 -0
  75. md_processing/dr_egeria_outbox/.obsidian/plugins/templater-obsidian/manifest.json +11 -0
  76. md_processing/dr_egeria_outbox/.obsidian/plugins/templater-obsidian/styles.css +220 -0
  77. md_processing/dr_egeria_outbox/.obsidian/types.json +28 -0
  78. md_processing/dr_egeria_outbox/.obsidian/workspace.json +220 -0
  79. md_processing/dr_egeria_outbox/Untitled.canvas +1 -0
  80. md_processing/dr_egeria_outbox/monday/processed-2025-07-14 12:38-data_designer_out.md +663 -0
  81. md_processing/dr_egeria_outbox/monday/processed-2025-07-21 10:52-generated_help_report.md +2744 -0
  82. md_processing/dr_egeria_outbox/monday/processed-2025-07-21 18:38-collections.md +62 -0
  83. md_processing/dr_egeria_outbox/monday/processed-2025-08-01 11:34-gov_def.md +444 -0
  84. md_processing/dr_egeria_outbox/monday/processed-2025-08-17 21:04-product.md +97 -0
  85. md_processing/dr_egeria_outbox/sunday/processed-2025-07-20 14:55-product.md +77 -0
  86. md_processing/dr_egeria_outbox/sunday/processed-2025-07-20 15:05-product.md +75 -0
  87. md_processing/dr_egeria_outbox/sunday/processed-2025-07-20 15:11-product.md +74 -0
  88. md_processing/dr_egeria_outbox/sunday/processed-2025-07-20 20:40-collections.md +49 -0
  89. md_processing/dr_egeria_outbox/thursday/processed-2025-07-17 15:00-Derive-Dr-Gov-Defs.md +719 -0
  90. md_processing/dr_egeria_outbox/thursday/processed-2025-07-17 20:13-Derive-Dr-Gov-Defs.md +41 -0
  91. md_processing/dr_egeria_outbox/thursday/processed-2025-07-17 20:14-Derive-Dr-Gov-Defs.md +33 -0
  92. md_processing/dr_egeria_outbox/thursday/processed-2025-07-17 20:50-Derive-Dr-Gov-Defs.md +192 -0
  93. md_processing/dr_egeria_outbox/thursday/processed-2025-07-17 22:08-gov_def2.md +486 -0
  94. md_processing/dr_egeria_outbox/thursday/processed-2025-07-17 22:10-gov_def2.md +486 -0
  95. md_processing/dr_egeria_outbox/thursday/processed-2025-07-18 08:53-gov_def2.md +486 -0
  96. md_processing/dr_egeria_outbox/thursday/processed-2025-07-18 08:54-gov_def2.md +486 -0
  97. md_processing/dr_egeria_outbox/thursday/processed-2025-07-18 09:03-gov_def2.md +486 -0
  98. md_processing/dr_egeria_outbox/thursday/processed-2025-07-18 09:06-gov_def2.md +486 -0
  99. md_processing/dr_egeria_outbox/thursday/processed-2025-07-18 09:10-gov_def2.md +486 -0
  100. md_processing/dr_egeria_outbox/tuesday/processed-2025-07-16 19:15-gov_def2.md +527 -0
  101. md_processing/dr_egeria_outbox/tuesday/processed-2025-07-17 12:08-gov_def2.md +527 -0
  102. md_processing/dr_egeria_outbox/tuesday/processed-2025-07-17 14:27-gov_def2.md +485 -0
  103. md_processing/md_commands/governance_officer_commands.py +291 -150
  104. md_processing/md_commands/product_manager_commands.py +309 -401
  105. md_processing/md_processing_utils/common_md_proc_utils.py +110 -7
  106. md_processing/md_processing_utils/common_md_utils.py +112 -26
  107. md_processing/md_processing_utils/debug_log.log +0 -0
  108. md_processing/md_processing_utils/md_processing_constants.py +8 -5
  109. md_processing/md_processing_utils/solution_architect_log.log +0 -0
  110. pyegeria/.DS_Store +0 -0
  111. pyegeria/__init__.py +3 -3
  112. pyegeria/_client_new.py +48 -51
  113. pyegeria/_exceptions_new.py +6 -0
  114. pyegeria/_output_format_models.py +22 -17
  115. pyegeria/_output_formats.py +122 -34
  116. pyegeria/collection_manager.py +154 -50
  117. pyegeria/collection_manager_omvs.py +47 -18
  118. pyegeria/egeria_cat_client.py +1 -1
  119. pyegeria/egeria_client.py +6 -0
  120. pyegeria/egeria_tech_client.py +6 -1
  121. pyegeria/governance_officer.py +2513 -0
  122. pyegeria/load_config.py +1 -1
  123. pyegeria/models.py +48 -5
  124. pyegeria/output_formatter.py +298 -79
  125. pyegeria/utils.py +1 -1
  126. {pyegeria-5.4.0.22.dist-info → pyegeria-5.4.0.24.dist-info}/METADATA +1 -1
  127. {pyegeria-5.4.0.22.dist-info → pyegeria-5.4.0.24.dist-info}/RECORD +130 -30
  128. {pyegeria-5.4.0.22.dist-info → pyegeria-5.4.0.24.dist-info}/LICENSE +0 -0
  129. {pyegeria-5.4.0.22.dist-info → pyegeria-5.4.0.24.dist-info}/WHEEL +0 -0
  130. {pyegeria-5.4.0.22.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: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
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[str]:
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
- 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, category
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 glossary-related attributes.
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
- 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)
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
- display_name = attributes['Display Name'].get('value', None)
110
-
111
- replace_all_props = not attributes.get('Merge Update', {}).get('value', True)
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
- 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')
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
- 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
247
+ # Singularize the selected word
248
+ singular_word = inflector.singular_noun(word_to_singularize) or word_to_singularize
180
249
 
181
- except Exception as e:
182
- logger.error(f"Error performing {command}: {e}")
183
- return None
184
- else:
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 process_gov_def_link_detach_command(egeria_client: EgeriaTech, txt: str,
191
- directive: str = "display") -> Optional[str]:
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 definition2 is not None
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
- logger.success(f"===> Detached segment with {label} from `{definition1}`to {definition2}\n")
252
- out = parsed_output['display'].replace('Unlink', 'Link', 1)
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
- return (out)
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
- 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)
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
- else:
269
- body = set_peer_gov_def_request_body(object_type, attributes)
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
- 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
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
- except Exception as e:
280
- logger.error(f"Error performing {command}: {e}")
281
- return None
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
- directive: str = "display") -> Optional[str]:
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 = set_update_body(object_type, attr)
475
+ body = set_find_body(object_type, attr)
335
476
 
336
477
  struct = egeria_client.find_governance_definitions(search_string,
337
- body = body,
338
- output_format=output_format)
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
- directive: str = "display") -> Optional[str]:
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 = body, output_format=output_format)
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
-