pyegeria 5.4.8.6__py3-none-any.whl → 5.4.8.8__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- examples/Coco_config/README.md +19 -0
- examples/Coco_config/__init__.py +4 -0
- examples/Coco_config/config_cocoMDS1.py +108 -0
- examples/Coco_config/config_cocoMDS2.py +126 -0
- examples/Coco_config/config_cocoMDS3.py +109 -0
- examples/Coco_config/config_cocoMDS4.py +91 -0
- examples/Coco_config/config_cocoMDS5.py +116 -0
- examples/Coco_config/config_cocoMDS6.py +114 -0
- examples/Coco_config/config_cocoMDSx.py +119 -0
- examples/Coco_config/config_cocoView1.py +155 -0
- examples/Coco_config/config_coco_core.py +255 -0
- examples/Coco_config/config_coco_datalake.py +450 -0
- examples/Coco_config/config_exchangeDL01.py +106 -0
- examples/Coco_config/config_governDL01.py +80 -0
- examples/Coco_config/config_monitorDev01.py +60 -0
- examples/Coco_config/config_monitorGov01.py +194 -0
- examples/Coco_config/globals.py +154 -0
- examples/GeoSpatial Products Example.py +535 -0
- examples/Jupyter Notebooks/P-egeria-server-config.ipynb +2137 -0
- examples/Jupyter Notebooks/README.md +2 -0
- examples/Jupyter Notebooks/common/P-environment-check.ipynb +115 -0
- examples/Jupyter Notebooks/common/__init__.py +14 -0
- examples/Jupyter Notebooks/common/common-functions.ipynb +4694 -0
- examples/Jupyter Notebooks/common/environment-check.ipynb +53 -0
- examples/Jupyter Notebooks/common/globals.ipynb +184 -0
- examples/Jupyter Notebooks/common/globals.py +154 -0
- examples/Jupyter Notebooks/common/orig_globals.py +152 -0
- examples/format_sets/all_format_sets.json +910 -0
- examples/format_sets/custom_format_sets.json +268 -0
- examples/format_sets/subset_format_sets.json +187 -0
- examples/format_sets_save_load_example.py +294 -0
- examples/output_formats_example.py +193 -0
- md_processing/__init__.py +6 -0
- md_processing/data/commands.json +30640 -59579
- md_processing/dr_egeria.py +18 -0
- md_processing/md_commands/feedback_commands.py +763 -0
- md_processing/md_commands/project_commands.py +1 -1
- md_processing/md_processing_utils/md_processing_constants.py +134 -4
- pyegeria/__init__.py +1 -1
- pyegeria/_client_new.py +109 -12
- pyegeria/_globals.py +3 -2
- pyegeria/base_report_formats.py +17 -0
- pyegeria/format_set_executor.py +5 -2
- {pyegeria-5.4.8.6.dist-info → pyegeria-5.4.8.8.dist-info}/METADATA +1 -1
- {pyegeria-5.4.8.6.dist-info → pyegeria-5.4.8.8.dist-info}/RECORD +49 -16
- {pyegeria-5.4.8.6.dist-info → pyegeria-5.4.8.8.dist-info}/top_level.txt +1 -0
- {pyegeria-5.4.8.6.dist-info → pyegeria-5.4.8.8.dist-info}/WHEEL +0 -0
- {pyegeria-5.4.8.6.dist-info → pyegeria-5.4.8.8.dist-info}/entry_points.txt +0 -0
- {pyegeria-5.4.8.6.dist-info → pyegeria-5.4.8.8.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,763 @@
|
|
|
1
|
+
"""
|
|
2
|
+
This file contains feedback-related object_action functions for processing Egeria Markdown
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
import os
|
|
7
|
+
import re
|
|
8
|
+
from typing import List, Optional
|
|
9
|
+
|
|
10
|
+
from inflect import engine
|
|
11
|
+
from loguru import logger
|
|
12
|
+
from pydantic import ValidationError
|
|
13
|
+
from rich import print
|
|
14
|
+
from rich.console import Console
|
|
15
|
+
from rich.markdown import Markdown
|
|
16
|
+
|
|
17
|
+
from md_processing.md_processing_utils.common_md_proc_utils import (parse_upsert_command, parse_view_command,
|
|
18
|
+
sync_collection_memberships)
|
|
19
|
+
from md_processing.md_processing_utils.common_md_utils import update_element_dictionary, set_update_body, \
|
|
20
|
+
set_element_status_request_body, set_element_prop_body, set_delete_request_body, set_rel_request_body, \
|
|
21
|
+
set_peer_gov_def_request_body, \
|
|
22
|
+
set_rel_request_body, set_create_body, set_object_classifications, set_product_body, set_rel_request_body_for_type
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
from pyegeria import DEBUG_LEVEL, body_slimmer, to_pascal_case, PyegeriaException, print_basic_exception, \
|
|
26
|
+
print_exception_table, print_validation_error, COMMENT_TYPES
|
|
27
|
+
from pyegeria.egeria_tech_client import EgeriaTech
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
from md_processing.md_processing_utils.common_md_utils import (debug_level, print_msg, set_debug_level,
|
|
32
|
+
get_element_dictionary, update_element_dictionary,
|
|
33
|
+
)
|
|
34
|
+
from md_processing.md_processing_utils.extraction_utils import (extract_command_plus, extract_command,
|
|
35
|
+
process_simple_attribute, process_element_identifiers,
|
|
36
|
+
update_a_command, extract_attribute,
|
|
37
|
+
get_element_by_name, process_name_list)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
from pyegeria.egeria_tech_client import EgeriaTech
|
|
41
|
+
from pyegeria.utils import make_format_set_name_from_type, body_slimmer
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def process_add_comment_command(egeria_client: EgeriaTech, txt: str, directive: str = "display") -> Optional[str]:
|
|
46
|
+
"""
|
|
47
|
+
Processes a comment create or update object_action by extracting key attributes such as
|
|
48
|
+
from the given text. If the Parent Comment is provided, then this comment will be a `reply` and the `Associated Element`
|
|
49
|
+
will be ignored. One of `Associated Element` and `Parent Comment` must be provided.
|
|
50
|
+
|
|
51
|
+
:param txt: A string representing the input cell to be processed for
|
|
52
|
+
extracting glossary-related attributes.
|
|
53
|
+
:param directive: an optional string indicating the directive to be used - display, validate or execute
|
|
54
|
+
:return: A string summarizing the outcome of the processing.
|
|
55
|
+
"""
|
|
56
|
+
|
|
57
|
+
command, object_type, object_action = extract_command_plus(txt)
|
|
58
|
+
print(Markdown(f"# {command}\n"))
|
|
59
|
+
|
|
60
|
+
parsed_output = parse_upsert_command(egeria_client, object_type, object_action, txt, directive)
|
|
61
|
+
if not parsed_output:
|
|
62
|
+
logger.error(f"No output for `{object_action}`")
|
|
63
|
+
return None
|
|
64
|
+
|
|
65
|
+
attributes = parsed_output['attributes']
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
qualified_name = parsed_output.get('qualified_name', None)
|
|
70
|
+
guid = parsed_output.get('guid', None)
|
|
71
|
+
|
|
72
|
+
print(Markdown(parsed_output['display']))
|
|
73
|
+
|
|
74
|
+
logger.debug(json.dumps(parsed_output, indent=4))
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
display_name = attributes['Display Name'].get('value', None)
|
|
79
|
+
associated_element = attributes.get('Associated Element', {}).get('value', None)
|
|
80
|
+
associated_element_guid = attributes.get('Associated Element', {}).get('guid', None)
|
|
81
|
+
description = attributes.get('Comment Text', {}).get('value', None)
|
|
82
|
+
comment_type = attributes.get('Comment Type', {}).get('value', None)
|
|
83
|
+
parent_comment = attributes.get('Parent Comment', {}).get('value', None)
|
|
84
|
+
parent_comment_guid = attributes.get('Parent Comment', {}).get('guid', None)
|
|
85
|
+
|
|
86
|
+
if associated_element_guid is None and parent_comment_guid is None:
|
|
87
|
+
valid = False
|
|
88
|
+
msg = f"Validation failed for {command} - One of `Associated Element` or `Parent Comment` must be specified\n"
|
|
89
|
+
logger.error(msg)
|
|
90
|
+
print(msg)
|
|
91
|
+
else:
|
|
92
|
+
if description:
|
|
93
|
+
valid = True
|
|
94
|
+
exists = True
|
|
95
|
+
#
|
|
96
|
+
|
|
97
|
+
if directive == "display":
|
|
98
|
+
return None
|
|
99
|
+
elif directive == "validate":
|
|
100
|
+
if valid:
|
|
101
|
+
print(Markdown(f"==> Validation of {command} completed successfully!\n"))
|
|
102
|
+
else:
|
|
103
|
+
msg = f"Validation failed for object_action `{command}`\n"
|
|
104
|
+
return valid
|
|
105
|
+
|
|
106
|
+
elif directive == "process":
|
|
107
|
+
try:
|
|
108
|
+
|
|
109
|
+
obj = "Comment"
|
|
110
|
+
if comment_type not in COMMENT_TYPES:
|
|
111
|
+
raise ValueError(f"Invalid comment type: {comment_type}")
|
|
112
|
+
target_guid = parent_comment_guid if parent_comment_guid else associated_element_guid
|
|
113
|
+
if qualified_name is None:
|
|
114
|
+
qualified_name = egeria_client.make_feedback_qn("Comment",target_guid,display_name)
|
|
115
|
+
# Set the property body for a glossary collection
|
|
116
|
+
#
|
|
117
|
+
prop_body = {
|
|
118
|
+
"class": "CommentProperties",
|
|
119
|
+
"qualifiedName": qualified_name,
|
|
120
|
+
"description": description,
|
|
121
|
+
"commentType": comment_type
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if object_action == "Update":
|
|
125
|
+
if not exists:
|
|
126
|
+
msg = (f" Element `{display_name}` does not exist! Updating result document with Create "
|
|
127
|
+
f"{object_action}\n")
|
|
128
|
+
logger.error(msg)
|
|
129
|
+
return update_a_command(txt, object_action, object_type, qualified_name, guid)
|
|
130
|
+
elif not valid:
|
|
131
|
+
msg = (" The input data is invalid and cannot be processed. \nPlease review")
|
|
132
|
+
logger.error(msg)
|
|
133
|
+
print(Markdown(f"==> Validation of {command} failed!!\n"))
|
|
134
|
+
print(Markdown(msg))
|
|
135
|
+
return None
|
|
136
|
+
else:
|
|
137
|
+
print(Markdown(
|
|
138
|
+
f"==> Validation of {command} completed successfully! Proceeding to apply the changes.\n"))
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
body = set_update_body(obj, attributes)
|
|
142
|
+
body['properties'] = prop_body
|
|
143
|
+
|
|
144
|
+
egeria_client.update_comment(guid, body)
|
|
145
|
+
|
|
146
|
+
logger.success(f"Updated {object_type} `{display_name}` with GUID {guid}\n\n___")
|
|
147
|
+
update_element_dictionary(qualified_name, {
|
|
148
|
+
'guid': guid, 'display_name': display_name
|
|
149
|
+
})
|
|
150
|
+
return egeria_client.get_comment_by_guid(guid, element_type='Comment',
|
|
151
|
+
output_format='MD', report_spec = "Comments-DrE")
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
elif object_action == "Create":
|
|
155
|
+
if valid is False and exists:
|
|
156
|
+
msg = (f"Project `{display_name}` already exists and result document updated changing "
|
|
157
|
+
f"`Create` to `Update` in processed output\n\n___")
|
|
158
|
+
logger.error(msg)
|
|
159
|
+
return update_a_command(txt, object_action, object_type, qualified_name, guid)
|
|
160
|
+
elif not valid:
|
|
161
|
+
msg = ("The input data is invalid and cannot be processed. \nPlease review")
|
|
162
|
+
logger.error(msg)
|
|
163
|
+
print(Markdown(f"==> Validation of {command} failed!!\n"))
|
|
164
|
+
print(Markdown(msg))
|
|
165
|
+
return None
|
|
166
|
+
|
|
167
|
+
else:
|
|
168
|
+
body = set_create_body(object_type,attributes)
|
|
169
|
+
body['class'] = "NewAttachmentRequestBody"
|
|
170
|
+
body["properties"] = prop_body
|
|
171
|
+
slim_body = body_slimmer(body)
|
|
172
|
+
if parent_comment_guid:
|
|
173
|
+
guid = egeria_client.add_comment_reply(element_guid = parent_comment_guid, body = slim_body)
|
|
174
|
+
else:
|
|
175
|
+
guid = egeria_client.add_comment_to_element(element_guid = associated_element_guid, body =slim_body)
|
|
176
|
+
|
|
177
|
+
if guid:
|
|
178
|
+
update_element_dictionary(qualified_name, {
|
|
179
|
+
'guid': guid, 'display_name': display_name
|
|
180
|
+
})
|
|
181
|
+
msg = f"Created Element `{display_name}` with GUID {guid}\n\n___"
|
|
182
|
+
logger.success(msg)
|
|
183
|
+
print(Markdown(msg))
|
|
184
|
+
return egeria_client.get_comment_by_guid(guid, output_format='MD', report_spec = "Comments-DrE")
|
|
185
|
+
else:
|
|
186
|
+
msg = f"Failed to create element `{display_name}` with GUID {guid}\n\n___"
|
|
187
|
+
logger.error(msg)
|
|
188
|
+
return None
|
|
189
|
+
|
|
190
|
+
except PyegeriaException as e:
|
|
191
|
+
logger.error(f"Pyegeria error performing {command}: {e}")
|
|
192
|
+
print_basic_exception(e)
|
|
193
|
+
return None
|
|
194
|
+
except Exception as e:
|
|
195
|
+
logger.error(f"Error performing {command}: {e}")
|
|
196
|
+
else:
|
|
197
|
+
return None
|
|
198
|
+
|
|
199
|
+
def process_upsert_note_log_command(egeria_client: EgeriaTech, txt: str, directive: str = "display") -> Optional[str]:
|
|
200
|
+
"""
|
|
201
|
+
Processes a noteLog create or update object_action by extracting key attributes from the given text and applying
|
|
202
|
+
this using the pyegeria function.
|
|
203
|
+
|
|
204
|
+
:param txt: A string representing the input cell to be processed for
|
|
205
|
+
extracting glossary-related attributes.
|
|
206
|
+
:param directive: an optional string indicating the directive to be used - display, validate or execute
|
|
207
|
+
:return: A string summarizing the outcome of the processing.
|
|
208
|
+
"""
|
|
209
|
+
|
|
210
|
+
command, object_type, object_action = extract_command_plus(txt)
|
|
211
|
+
print(Markdown(f"# {command}\n"))
|
|
212
|
+
|
|
213
|
+
parsed_output = parse_upsert_command(egeria_client, object_type, object_action, txt, directive)
|
|
214
|
+
if not parsed_output:
|
|
215
|
+
logger.error(f"No output for `{object_action}`")
|
|
216
|
+
return None
|
|
217
|
+
|
|
218
|
+
valid = parsed_output['valid']
|
|
219
|
+
exists = parsed_output['exists']
|
|
220
|
+
|
|
221
|
+
qualified_name = parsed_output.get('qualified_name', None)
|
|
222
|
+
guid = parsed_output.get('guid', None)
|
|
223
|
+
|
|
224
|
+
print(Markdown(parsed_output['display']))
|
|
225
|
+
|
|
226
|
+
logger.debug(json.dumps(parsed_output, indent=4))
|
|
227
|
+
|
|
228
|
+
attributes = parsed_output['attributes']
|
|
229
|
+
|
|
230
|
+
display_name = attributes['Display Name'].get('value', None)
|
|
231
|
+
description = attributes['Description'].get('value', None)
|
|
232
|
+
associated_element = attributes.get('Associated Element', {}).get('value', None)
|
|
233
|
+
associated_element_guid = attributes.get('Associated Element', {}).get('guid', None)
|
|
234
|
+
#
|
|
235
|
+
|
|
236
|
+
if directive == "display":
|
|
237
|
+
return None
|
|
238
|
+
elif directive == "validate":
|
|
239
|
+
if valid:
|
|
240
|
+
print(Markdown(f"==> Validation of {command} completed successfully!\n"))
|
|
241
|
+
else:
|
|
242
|
+
msg = f"Validation failed for object_action `{command}`\n"
|
|
243
|
+
return valid
|
|
244
|
+
|
|
245
|
+
elif directive == "process":
|
|
246
|
+
try:
|
|
247
|
+
obj = "NoteLog"
|
|
248
|
+
|
|
249
|
+
# Set the property body for a glossary collection
|
|
250
|
+
#
|
|
251
|
+
prop_body = set_element_prop_body(obj, qualified_name, attributes)
|
|
252
|
+
|
|
253
|
+
if object_action == "Update":
|
|
254
|
+
if not exists:
|
|
255
|
+
msg = (f" Element `{display_name}` does not exist! Updating result document with Create "
|
|
256
|
+
f"{object_action}\n")
|
|
257
|
+
logger.error(msg)
|
|
258
|
+
return update_a_command(txt, object_action, object_type, qualified_name, guid)
|
|
259
|
+
elif not valid:
|
|
260
|
+
msg = (" The input data is invalid and cannot be processed. \nPlease review")
|
|
261
|
+
logger.error(msg)
|
|
262
|
+
print(Markdown(f"==> Validation of {command} failed!!\n"))
|
|
263
|
+
print(Markdown(msg))
|
|
264
|
+
return None
|
|
265
|
+
else:
|
|
266
|
+
print(Markdown(
|
|
267
|
+
f"==> Validation of {command} completed successfully! Proceeding to apply the changes.\n"))
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
body = set_update_body(obj, attributes)
|
|
271
|
+
body['properties'] = prop_body
|
|
272
|
+
|
|
273
|
+
egeria_client.update_note_log(associated_element_guid, body)
|
|
274
|
+
|
|
275
|
+
logger.success(f"Updated {object_type} `{display_name}` with GUID {guid}\n\n___")
|
|
276
|
+
update_element_dictionary(qualified_name, {
|
|
277
|
+
'guid': guid, 'display_name': display_name
|
|
278
|
+
})
|
|
279
|
+
return egeria_client.get_note_logs_by_name(filter = qualified_name, element_type="NoteLog",
|
|
280
|
+
output_format='MD', report_spec = "NoteLog-DrE")
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
elif object_action == "Create":
|
|
284
|
+
if valid is False and exists:
|
|
285
|
+
msg = (f"NoteLog `{display_name}` already exists and result document updated changing "
|
|
286
|
+
f"`Create` to `Update` in processed output\n\n___")
|
|
287
|
+
logger.error(msg)
|
|
288
|
+
return update_a_command(txt, object_action, object_type, qualified_name, guid)
|
|
289
|
+
elif not valid:
|
|
290
|
+
msg = ("The input data is invalid and cannot be processed. \nPlease review")
|
|
291
|
+
logger.error(msg)
|
|
292
|
+
print(Markdown(f"==> Validation of {command} failed!!\n"))
|
|
293
|
+
print(Markdown(msg))
|
|
294
|
+
return None
|
|
295
|
+
|
|
296
|
+
else:
|
|
297
|
+
body = set_create_body(object_type,attributes)
|
|
298
|
+
|
|
299
|
+
body["properties"] = prop_body
|
|
300
|
+
slim_body = body_slimmer(body)
|
|
301
|
+
guid = egeria_client.create_note_log(associated_element_guid, slim_body)
|
|
302
|
+
if guid:
|
|
303
|
+
update_element_dictionary(qualified_name, {
|
|
304
|
+
'guid': guid, 'display_name': display_name
|
|
305
|
+
})
|
|
306
|
+
msg = f"Created Element `{display_name}` with GUID {guid}\n\n___"
|
|
307
|
+
logger.success(msg)
|
|
308
|
+
return egeria_client.get_note_logs_by_name(filter = qualified_name, element_type="NoteLog",
|
|
309
|
+
output_format='MD', report_spec = "NoteLog-DrE")
|
|
310
|
+
else:
|
|
311
|
+
msg = f"Failed to create element `{display_name}` with GUID {guid}\n\n___"
|
|
312
|
+
logger.error(msg)
|
|
313
|
+
return None
|
|
314
|
+
|
|
315
|
+
except PyegeriaException as e:
|
|
316
|
+
logger.error(f"Pyegeria error performing {command}: {e}")
|
|
317
|
+
print_basic_exception(e)
|
|
318
|
+
return None
|
|
319
|
+
except Exception as e:
|
|
320
|
+
logger.error(f"Error performing {command}: {e}")
|
|
321
|
+
else:
|
|
322
|
+
return None
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
def process_upsert_note_command(egeria_client: EgeriaTech, txt: str, directive: str = "display") -> Optional[str]:
|
|
326
|
+
"""
|
|
327
|
+
Processes a NoteLog Note request to create or update object_action from the given text.
|
|
328
|
+
|
|
329
|
+
:param txt: A string representing the input cell to be processed for
|
|
330
|
+
extracting glossary-related attributes.
|
|
331
|
+
:param directive: an optional string indicating the directive to be used - display, validate or execute
|
|
332
|
+
:return: A string summarizing the outcome of the processing.
|
|
333
|
+
"""
|
|
334
|
+
|
|
335
|
+
command, object_type, object_action = extract_command_plus(txt)
|
|
336
|
+
print(Markdown(f"# {command}\n"))
|
|
337
|
+
|
|
338
|
+
parsed_output = parse_upsert_command(egeria_client, object_type, object_action, txt, directive)
|
|
339
|
+
if not parsed_output:
|
|
340
|
+
logger.error(f"No output for `{object_action}`")
|
|
341
|
+
return None
|
|
342
|
+
|
|
343
|
+
valid = parsed_output['valid']
|
|
344
|
+
exists = parsed_output['exists']
|
|
345
|
+
|
|
346
|
+
qualified_name = parsed_output.get('qualified_name', None)
|
|
347
|
+
guid = parsed_output.get('guid', None)
|
|
348
|
+
|
|
349
|
+
print(Markdown(parsed_output['display']))
|
|
350
|
+
|
|
351
|
+
logger.debug(json.dumps(parsed_output, indent=4))
|
|
352
|
+
|
|
353
|
+
attributes = parsed_output['attributes']
|
|
354
|
+
|
|
355
|
+
display_name = attributes['Display Name'].get('value', None)
|
|
356
|
+
note_log = attributes.get('Note Log',{}).get('value', {})
|
|
357
|
+
note_log_guid = attributes.get('Note Log',{}).get('guid', None)
|
|
358
|
+
#
|
|
359
|
+
|
|
360
|
+
if directive == "display":
|
|
361
|
+
return None
|
|
362
|
+
elif directive == "validate":
|
|
363
|
+
if valid:
|
|
364
|
+
print(Markdown(f"==> Validation of {command} completed successfully!\n"))
|
|
365
|
+
else:
|
|
366
|
+
msg = f"Validation failed for object_action `{command}`\n"
|
|
367
|
+
return valid
|
|
368
|
+
|
|
369
|
+
elif directive == "process":
|
|
370
|
+
try:
|
|
371
|
+
obj = "Notification"
|
|
372
|
+
|
|
373
|
+
# Set the property body for a glossary collection
|
|
374
|
+
#
|
|
375
|
+
prop_body = set_element_prop_body(obj, qualified_name, attributes)
|
|
376
|
+
|
|
377
|
+
if object_action == "Update":
|
|
378
|
+
if not exists:
|
|
379
|
+
msg = (f" Element `{display_name}` does not exist! Updating result document with Create "
|
|
380
|
+
f"{object_action}\n")
|
|
381
|
+
logger.error(msg)
|
|
382
|
+
return update_a_command(txt, object_action, object_type, qualified_name, guid)
|
|
383
|
+
elif not valid:
|
|
384
|
+
msg = (" The input data is invalid and cannot be processed. \nPlease review")
|
|
385
|
+
logger.error(msg)
|
|
386
|
+
print(Markdown(f"==> Validation of {command} failed!!\n"))
|
|
387
|
+
print(Markdown(msg))
|
|
388
|
+
return None
|
|
389
|
+
else:
|
|
390
|
+
print(Markdown(
|
|
391
|
+
f"==> Validation of {command} completed successfully! Proceeding to apply the changes.\n"))
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
body = set_update_body(obj, attributes)
|
|
395
|
+
body['properties'] = prop_body
|
|
396
|
+
slim_body = body_slimmer(body)
|
|
397
|
+
egeria_client.update_note(guid, slim_body)
|
|
398
|
+
|
|
399
|
+
|
|
400
|
+
logger.success(f"Updated {object_type} `{display_name}` with GUID {guid}\n\n___")
|
|
401
|
+
update_element_dictionary(qualified_name, {
|
|
402
|
+
'guid': guid, 'display_name': display_name
|
|
403
|
+
})
|
|
404
|
+
return egeria_client.get_note_by_guid(guid, output_format='MD', report_spec = "Note-DrE")
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
elif object_action == "Create":
|
|
408
|
+
if valid is False and exists:
|
|
409
|
+
msg = (f"Project `{display_name}` already exists and result document updated changing "
|
|
410
|
+
f"`Create` to `Update` in processed output\n\n___")
|
|
411
|
+
logger.error(msg)
|
|
412
|
+
return update_a_command(txt, object_action, object_type, qualified_name, guid)
|
|
413
|
+
elif not valid:
|
|
414
|
+
msg = ("The input data is invalid and cannot be processed. \nPlease review")
|
|
415
|
+
logger.error(msg)
|
|
416
|
+
print(Markdown(f"==> Validation of {command} failed!!\n"))
|
|
417
|
+
print(Markdown(msg))
|
|
418
|
+
return None
|
|
419
|
+
|
|
420
|
+
else:
|
|
421
|
+
body = set_create_body(object_type,attributes)
|
|
422
|
+
|
|
423
|
+
body["properties"] = prop_body
|
|
424
|
+
slim_body = body_slimmer(body)
|
|
425
|
+
guid = egeria_client.create_project(body = slim_body)
|
|
426
|
+
if guid:
|
|
427
|
+
update_element_dictionary(qualified_name, {
|
|
428
|
+
'guid': guid, 'display_name': display_name
|
|
429
|
+
})
|
|
430
|
+
msg = f"Created Element `{display_name}` with GUID {guid}\n\n___"
|
|
431
|
+
logger.success(msg)
|
|
432
|
+
return egeria_client.get_note_by_guid(guid, output_format='MD', report_spec = "Note-DrE")
|
|
433
|
+
else:
|
|
434
|
+
msg = f"Failed to create element `{display_name}` with GUID {guid}\n\n___"
|
|
435
|
+
logger.error(msg)
|
|
436
|
+
return None
|
|
437
|
+
|
|
438
|
+
except PyegeriaException as e:
|
|
439
|
+
logger.error(f"Pyegeria error performing {command}: {e}")
|
|
440
|
+
print_basic_exception(e)
|
|
441
|
+
return None
|
|
442
|
+
except Exception as e:
|
|
443
|
+
logger.error(f"Error performing {command}: {e}")
|
|
444
|
+
else:
|
|
445
|
+
return None
|
|
446
|
+
|
|
447
|
+
def process_attach_note_log_command(egeria_client: EgeriaTech, txt: str, directive: str = "display") -> Optional[str]:
|
|
448
|
+
|
|
449
|
+
# """ Set one project to manage another."""
|
|
450
|
+
#
|
|
451
|
+
command, object_type, object_action = extract_command_plus(txt)
|
|
452
|
+
print(Markdown(f"# {command}\n"))
|
|
453
|
+
|
|
454
|
+
parsed_output = parse_view_command(egeria_client, object_type, object_action,
|
|
455
|
+
txt, directive)
|
|
456
|
+
|
|
457
|
+
if not parsed_output:
|
|
458
|
+
logger.error(f"No output for `{object_action}`")
|
|
459
|
+
print(Markdown("## Parsing failed"))
|
|
460
|
+
return None
|
|
461
|
+
|
|
462
|
+
print(Markdown(parsed_output['display']))
|
|
463
|
+
|
|
464
|
+
logger.debug(json.dumps(parsed_output, indent=4))
|
|
465
|
+
|
|
466
|
+
attributes = parsed_output['attributes']
|
|
467
|
+
|
|
468
|
+
parent_project_guid = attributes.get('Parent Project', {}).get('guid', None)
|
|
469
|
+
child_project_guid = attributes.get('Child Project', {}).get('guid', None)
|
|
470
|
+
label = attributes.get('Link Label', {}).get('value', "")
|
|
471
|
+
|
|
472
|
+
valid = parsed_output['valid']
|
|
473
|
+
exists = parent_project_guid is not None and child_project_guid is not None
|
|
474
|
+
|
|
475
|
+
if directive == "display":
|
|
476
|
+
|
|
477
|
+
return None
|
|
478
|
+
elif directive == "validate":
|
|
479
|
+
if valid:
|
|
480
|
+
print(Markdown(f"==> Validation of {command} completed successfully!\n"))
|
|
481
|
+
else:
|
|
482
|
+
msg = f"Validation failed for object_action `{command}`\n"
|
|
483
|
+
logger.error(msg)
|
|
484
|
+
print(Markdown(f"==> Validation of {command} failed!!\n"))
|
|
485
|
+
return valid
|
|
486
|
+
|
|
487
|
+
elif directive == "process":
|
|
488
|
+
|
|
489
|
+
|
|
490
|
+
try:
|
|
491
|
+
if object_action == "Detach":
|
|
492
|
+
if not exists:
|
|
493
|
+
msg = (f" Link `{label}` does not exist! Updating result document with Link "
|
|
494
|
+
f"object_action\n")
|
|
495
|
+
logger.error(msg)
|
|
496
|
+
out = parsed_output['display'].replace('Link', 'Detach', 1)
|
|
497
|
+
return out
|
|
498
|
+
elif not valid:
|
|
499
|
+
return None
|
|
500
|
+
else:
|
|
501
|
+
print(Markdown(
|
|
502
|
+
f"==> Validation of {command} completed successfully! Proceeding to apply the changes.\n"))
|
|
503
|
+
body = set_delete_request_body(object_type, attributes)
|
|
504
|
+
|
|
505
|
+
egeria_client.clear_project_hierarchy(child_project_guid, parent_project_guid,body)
|
|
506
|
+
|
|
507
|
+
logger.success(f"===> Detached segment with {label} from `{child_project_guid}`to {parent_project_guid}\n")
|
|
508
|
+
out = parsed_output['display'].replace('Unlink', 'Link', 1)
|
|
509
|
+
|
|
510
|
+
return (out)
|
|
511
|
+
|
|
512
|
+
|
|
513
|
+
elif object_action == "Link":
|
|
514
|
+
if valid is False and exists:
|
|
515
|
+
msg = (f"--> Link called `{label}` already exists and result document updated changing "
|
|
516
|
+
f"`Link` to `Detach` in processed output\n")
|
|
517
|
+
logger.error(msg)
|
|
518
|
+
|
|
519
|
+
elif valid is False:
|
|
520
|
+
msg = f"==>{object_type} Link with label `{label}` is not valid and can't be created"
|
|
521
|
+
logger.error(msg)
|
|
522
|
+
return
|
|
523
|
+
|
|
524
|
+
else:
|
|
525
|
+
body = set_rel_request_body_for_type("ProjectHierarchy", attributes)
|
|
526
|
+
|
|
527
|
+
egeria_client.set_project_hierarchy(project_guid =child_project_guid,
|
|
528
|
+
parent_project_guid = parent_project_guid)
|
|
529
|
+
# body=body_slimmer(body))
|
|
530
|
+
msg = f"==>Created {object_type} link named `{label}`\n"
|
|
531
|
+
logger.success(msg)
|
|
532
|
+
out = parsed_output['display'].replace('Link', 'Detach', 1)
|
|
533
|
+
return out
|
|
534
|
+
|
|
535
|
+
except ValidationError as e:
|
|
536
|
+
print_validation_error(e)
|
|
537
|
+
logger.error(f"Validation Error performing {command}: {e}")
|
|
538
|
+
return None
|
|
539
|
+
except PyegeriaException as e:
|
|
540
|
+
print_basic_exception(e)
|
|
541
|
+
logger.error(f"PyegeriaException occurred: {e}")
|
|
542
|
+
return None
|
|
543
|
+
|
|
544
|
+
except Exception as e:
|
|
545
|
+
logger.error(f"Error performing {command}: {e}")
|
|
546
|
+
return None
|
|
547
|
+
else:
|
|
548
|
+
return None
|
|
549
|
+
|
|
550
|
+
def process_upsert_informal_tag_command(egeria_client: EgeriaTech, txt: str, directive: str = "display") -> Optional[str]:
|
|
551
|
+
"""
|
|
552
|
+
Processes a informal tag create or update object_action by extracting key attributes such as
|
|
553
|
+
from the given text.
|
|
554
|
+
|
|
555
|
+
:param txt: A string representing the input cell to be processed for
|
|
556
|
+
extracting glossary-related attributes.
|
|
557
|
+
:param directive: an optional string indicating the directive to be used - display, validate or execute
|
|
558
|
+
:return: A string summarizing the outcome of the processing.
|
|
559
|
+
"""
|
|
560
|
+
|
|
561
|
+
command, object_type, object_action = extract_command_plus(txt)
|
|
562
|
+
print(Markdown(f"# {command}\n"))
|
|
563
|
+
|
|
564
|
+
parsed_output = parse_upsert_command(egeria_client, object_type, object_action, txt, directive)
|
|
565
|
+
if not parsed_output:
|
|
566
|
+
logger.error(f"No output for `{object_action}`")
|
|
567
|
+
return None
|
|
568
|
+
|
|
569
|
+
valid = parsed_output['valid']
|
|
570
|
+
exists = parsed_output['exists']
|
|
571
|
+
|
|
572
|
+
qualified_name = parsed_output.get('qualified_name', None)
|
|
573
|
+
guid = parsed_output.get('guid', None)
|
|
574
|
+
|
|
575
|
+
print(Markdown(parsed_output['display']))
|
|
576
|
+
|
|
577
|
+
logger.debug(json.dumps(parsed_output, indent=4))
|
|
578
|
+
|
|
579
|
+
attributes = parsed_output['attributes']
|
|
580
|
+
|
|
581
|
+
display_name = attributes['Display Name'].get('value', None)
|
|
582
|
+
description = attributes['Description'].get('value', None)
|
|
583
|
+
#
|
|
584
|
+
|
|
585
|
+
if directive == "display":
|
|
586
|
+
return None
|
|
587
|
+
elif directive == "validate":
|
|
588
|
+
if valid:
|
|
589
|
+
print(Markdown(f"==> Validation of {command} completed successfully!\n"))
|
|
590
|
+
else:
|
|
591
|
+
msg = f"Validation failed for object_action `{command}`\n"
|
|
592
|
+
return valid
|
|
593
|
+
|
|
594
|
+
elif directive == "process":
|
|
595
|
+
try:
|
|
596
|
+
obj = "InformalTag"
|
|
597
|
+
|
|
598
|
+
# Set the property body for a glossary collection
|
|
599
|
+
#
|
|
600
|
+
prop_body = set_element_prop_body(obj, qualified_name, attributes)
|
|
601
|
+
|
|
602
|
+
if object_action == "Update":
|
|
603
|
+
if not exists:
|
|
604
|
+
msg = (f" Element `{display_name}` does not exist! Updating result document with Create "
|
|
605
|
+
f"{object_action}\n")
|
|
606
|
+
logger.error(msg)
|
|
607
|
+
return update_a_command(txt, object_action, object_type, qualified_name, guid)
|
|
608
|
+
elif not valid:
|
|
609
|
+
msg = (" The input data is invalid and cannot be processed. \nPlease review")
|
|
610
|
+
logger.error(msg)
|
|
611
|
+
print(Markdown(f"==> Validation of {command} failed!!\n"))
|
|
612
|
+
print(Markdown(msg))
|
|
613
|
+
return None
|
|
614
|
+
else:
|
|
615
|
+
print(Markdown(
|
|
616
|
+
f"==> Validation of {command} completed successfully! Proceeding to apply the changes.\n"))
|
|
617
|
+
|
|
618
|
+
egeria_client.update_informal_tag(guid, description)
|
|
619
|
+
|
|
620
|
+
logger.success(f"Updated {object_type} `{display_name}` with GUID {guid}\n\n___")
|
|
621
|
+
update_element_dictionary(qualified_name, {
|
|
622
|
+
'guid': guid, 'display_name': display_name
|
|
623
|
+
})
|
|
624
|
+
return egeria_client.get_tag_by_guid(guid, element_type='InformalTag',
|
|
625
|
+
output_format='MD', report_spec = "Informal-Tag-DrE")
|
|
626
|
+
|
|
627
|
+
|
|
628
|
+
elif object_action == "Create":
|
|
629
|
+
if valid is False and exists:
|
|
630
|
+
msg = (f"Project `{display_name}` already exists and result document updated changing "
|
|
631
|
+
f"`Create` to `Update` in processed output\n\n___")
|
|
632
|
+
logger.error(msg)
|
|
633
|
+
return update_a_command(txt, object_action, object_type, qualified_name, guid)
|
|
634
|
+
elif not valid:
|
|
635
|
+
msg = ("The input data is invalid and cannot be processed. \nPlease review")
|
|
636
|
+
logger.error(msg)
|
|
637
|
+
print(Markdown(f"==> Validation of {command} failed!!\n"))
|
|
638
|
+
print(Markdown(msg))
|
|
639
|
+
return None
|
|
640
|
+
|
|
641
|
+
else:
|
|
642
|
+
|
|
643
|
+
guid = egeria_client.create_informal_tag(display_name, description)
|
|
644
|
+
if guid:
|
|
645
|
+
update_element_dictionary(qualified_name, {
|
|
646
|
+
'guid': guid, 'display_name': display_name
|
|
647
|
+
})
|
|
648
|
+
msg = f"Created Element `{display_name}` with GUID {guid}\n\n___"
|
|
649
|
+
logger.success(msg)
|
|
650
|
+
return egeria_client.get_informal_tag_by_guid(guid, output_format='MD', report_spec = "Informal-Tag-DrE")
|
|
651
|
+
else:
|
|
652
|
+
msg = f"Failed to create element `{display_name}` with GUID {guid}\n\n___"
|
|
653
|
+
logger.error(msg)
|
|
654
|
+
return None
|
|
655
|
+
|
|
656
|
+
except PyegeriaException as e:
|
|
657
|
+
logger.error(f"Pyegeria error performing {command}: {e}")
|
|
658
|
+
print_basic_exception(e)
|
|
659
|
+
return None
|
|
660
|
+
except Exception as e:
|
|
661
|
+
logger.error(f"Error performing {command}: {e}")
|
|
662
|
+
else:
|
|
663
|
+
return None
|
|
664
|
+
|
|
665
|
+
|
|
666
|
+
def process_tag_element_command(egeria_client: EgeriaTech, txt: str, directive: str = "display") -> Optional[str]:
|
|
667
|
+
|
|
668
|
+
# """ Tag an Element with the specified Informal Tag."""
|
|
669
|
+
#
|
|
670
|
+
command, object_type, object_action = extract_command_plus(txt)
|
|
671
|
+
print(Markdown(f"# {command}\n"))
|
|
672
|
+
|
|
673
|
+
parsed_output = parse_view_command(egeria_client, object_type, object_action,
|
|
674
|
+
txt, directive)
|
|
675
|
+
tag_id = parsed_output['attributes']['Tag ID'].get('value', None)
|
|
676
|
+
tag_guid = parsed_output['attributes']['Tag ID'].get('guid', None)
|
|
677
|
+
element_id = parsed_output['attributes']['Element ID'].get('value', None)
|
|
678
|
+
element_guid = parsed_output['attributes']['Element ID'].get('guid', None)
|
|
679
|
+
|
|
680
|
+
if not parsed_output:
|
|
681
|
+
logger.error(f"No output for `{object_action}`")
|
|
682
|
+
print(Markdown("## Parsing failed"))
|
|
683
|
+
return None
|
|
684
|
+
|
|
685
|
+
print(Markdown(parsed_output['display']))
|
|
686
|
+
|
|
687
|
+
logger.debug(json.dumps(parsed_output, indent=4))
|
|
688
|
+
|
|
689
|
+
valid = parsed_output['valid']
|
|
690
|
+
exists = tag_guid is not None and element_guid is not None
|
|
691
|
+
|
|
692
|
+
if directive == "display":
|
|
693
|
+
|
|
694
|
+
return None
|
|
695
|
+
elif directive == "validate":
|
|
696
|
+
if valid:
|
|
697
|
+
print(Markdown(f"==> Validation of {command} completed successfully!\n"))
|
|
698
|
+
else:
|
|
699
|
+
msg = f"Validation failed for object_action `{command}`\n"
|
|
700
|
+
logger.error(msg)
|
|
701
|
+
print(Markdown(f"==> Validation of {command} failed!!\n"))
|
|
702
|
+
return valid
|
|
703
|
+
|
|
704
|
+
elif directive == "process":
|
|
705
|
+
|
|
706
|
+
try:
|
|
707
|
+
if object_action == "Detach":
|
|
708
|
+
if not exists:
|
|
709
|
+
msg = (f" The tag or element do not exist! Updating result document with Link "
|
|
710
|
+
f"object_action\n")
|
|
711
|
+
logger.error(msg)
|
|
712
|
+
out = parsed_output['display'].replace('Link', 'Detach', 1)
|
|
713
|
+
return out
|
|
714
|
+
elif not valid:
|
|
715
|
+
return None
|
|
716
|
+
else:
|
|
717
|
+
print(Markdown(
|
|
718
|
+
f"==> Validation of {command} completed successfully! Proceeding to apply the changes.\n"))
|
|
719
|
+
|
|
720
|
+
egeria_client.remove_tag_from_element(element_guid, tag_guid)
|
|
721
|
+
|
|
722
|
+
logger.success(f"===> Detached tab {tag_id} from `{element_id}`\n")
|
|
723
|
+
out = parsed_output['display'].replace('Unlink', 'Link', 1)
|
|
724
|
+
|
|
725
|
+
return (out)
|
|
726
|
+
|
|
727
|
+
|
|
728
|
+
elif object_action == "Link":
|
|
729
|
+
if valid is False and exists:
|
|
730
|
+
msg = ("--> Link already exists and result document updated changing "
|
|
731
|
+
"`Link` to `Detach` in processed output\n")
|
|
732
|
+
logger.error(msg)
|
|
733
|
+
|
|
734
|
+
elif valid is False:
|
|
735
|
+
msg = f"==>{object_type} Add link request is not valid and can't be created"
|
|
736
|
+
logger.error(msg)
|
|
737
|
+
return
|
|
738
|
+
|
|
739
|
+
else:
|
|
740
|
+
egeria_client.add_tag_to_element(element_guid =element_guid,
|
|
741
|
+
tag_guid = tag_guid)
|
|
742
|
+
|
|
743
|
+
msg = f"==>Created {object_type} link \n"
|
|
744
|
+
logger.success(msg)
|
|
745
|
+
out = parsed_output['display'].replace('Link', 'Detach', 1)
|
|
746
|
+
return out
|
|
747
|
+
|
|
748
|
+
except ValidationError as e:
|
|
749
|
+
print_validation_error(e)
|
|
750
|
+
logger.error(f"Validation Error performing {command}: {e}")
|
|
751
|
+
return None
|
|
752
|
+
except PyegeriaException as e:
|
|
753
|
+
print_basic_exception(e)
|
|
754
|
+
logger.error(f"PyegeriaException occurred: {e}")
|
|
755
|
+
return None
|
|
756
|
+
|
|
757
|
+
except Exception as e:
|
|
758
|
+
logger.error(f"Error performing {command}: {e}")
|
|
759
|
+
return None
|
|
760
|
+
else:
|
|
761
|
+
return None
|
|
762
|
+
|
|
763
|
+
|