pyegeria 5.4.0.dev14__py3-none-any.whl → 5.4.0.2__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 (43) hide show
  1. commands/cat/__init__.py +1 -17
  2. commands/cat/dr_egeria_md.py +6 -4
  3. commands/cat/list_collections.py +46 -36
  4. md_processing/__init__.py +5 -2
  5. md_processing/data/commands-working.json +34850 -0
  6. md_processing/data/commands.json +1750 -530
  7. md_processing/md_commands/product_manager_commands.py +171 -220
  8. md_processing/md_processing_utils/common_md_proc_utils.py +9 -0
  9. md_processing/md_processing_utils/common_md_utils.py +15 -2
  10. md_processing/md_processing_utils/md_processing_constants.py +44 -6
  11. pyegeria/__init__.py +8 -4
  12. pyegeria/_client.py +2 -1
  13. pyegeria/_client_new.py +688 -0
  14. pyegeria/_exceptions_new.py +364 -0
  15. pyegeria/_globals.py +3 -1
  16. pyegeria/_output_formats.py +196 -0
  17. pyegeria/_validators.py +72 -199
  18. pyegeria/collection_manager_omvs.py +602 -324
  19. pyegeria/data_designer_omvs.py +251 -203
  20. pyegeria/load_config.py +206 -0
  21. pyegeria/logging_configuration.py +204 -0
  22. pyegeria/output_formatter.py +162 -31
  23. pyegeria/utils.py +99 -61
  24. {pyegeria-5.4.0.dev14.dist-info → pyegeria-5.4.0.2.dist-info}/METADATA +4 -1
  25. {pyegeria-5.4.0.dev14.dist-info → pyegeria-5.4.0.2.dist-info}/RECORD +28 -37
  26. commands/cat/debug_log +0 -2806
  27. commands/cat/debug_log.2025-07-15_14-28-38_087378.zip +0 -0
  28. commands/cat/debug_log.2025-07-16_15-48-50_037087.zip +0 -0
  29. md_processing/dr_egeria_outbox-pycharm/.obsidian/app.json +0 -1
  30. md_processing/dr_egeria_outbox-pycharm/.obsidian/appearance.json +0 -1
  31. md_processing/dr_egeria_outbox-pycharm/.obsidian/core-plugins.json +0 -31
  32. md_processing/dr_egeria_outbox-pycharm/.obsidian/workspace.json +0 -177
  33. md_processing/dr_egeria_outbox-pycharm/monday/processed-2025-07-14 12:38-data_designer_out.md +0 -663
  34. md_processing/dr_egeria_outbox-pycharm/thursday/processed-2025-07-17 15:00-Derive-Dr-Gov-Defs.md +0 -719
  35. md_processing/dr_egeria_outbox-pycharm/thursday/processed-2025-07-17 20:13-Derive-Dr-Gov-Defs.md +0 -41
  36. md_processing/dr_egeria_outbox-pycharm/thursday/processed-2025-07-17 20:14-Derive-Dr-Gov-Defs.md +0 -33
  37. md_processing/dr_egeria_outbox-pycharm/thursday/processed-2025-07-17 20:50-Derive-Dr-Gov-Defs.md +0 -192
  38. md_processing/dr_egeria_outbox-pycharm/tuesday/processed-2025-07-16 19:15-gov_def2.md +0 -527
  39. md_processing/dr_egeria_outbox-pycharm/tuesday/processed-2025-07-17 12:08-gov_def2.md +0 -527
  40. md_processing/dr_egeria_outbox-pycharm/tuesday/processed-2025-07-17 14:27-gov_def2.md +0 -474
  41. {pyegeria-5.4.0.dev14.dist-info → pyegeria-5.4.0.2.dist-info}/LICENSE +0 -0
  42. {pyegeria-5.4.0.dev14.dist-info → pyegeria-5.4.0.2.dist-info}/WHEEL +0 -0
  43. {pyegeria-5.4.0.dev14.dist-info → pyegeria-5.4.0.2.dist-info}/entry_points.txt +0 -0
@@ -14,10 +14,10 @@ from rich.markdown import Markdown
14
14
  from md_processing.md_processing_utils.common_md_proc_utils import (parse_upsert_command, parse_view_command)
15
15
  from md_processing.md_processing_utils.common_md_utils import update_element_dictionary, setup_log, set_update_body, \
16
16
  set_element_status_request_body, set_prop_body, set_metadata_source_request_body, set_peer_gov_def_request_body, \
17
- set_rel_request_body
17
+ set_rel_request_body, set_create_body, set_collection_classifications, set_collection_property_body
18
18
  from md_processing.md_processing_utils.extraction_utils import (extract_command_plus, update_a_command)
19
19
  from md_processing.md_processing_utils.md_processing_constants import (load_commands, ERROR)
20
- from pyegeria import DEBUG_LEVEL, body_slimmer
20
+ from pyegeria import DEBUG_LEVEL, body_slimmer, to_pascal_case
21
21
  from pyegeria.egeria_tech_client import EgeriaTech
22
22
 
23
23
  GERIA_METADATA_STORE = os.environ.get("EGERIA_METADATA_STORE", "active-metadata-store")
@@ -409,6 +409,143 @@ def sync_data_class_rel_elements(egeria_client: EgeriaTech, containing_data_clas
409
409
  # Product Manager Commands
410
410
  #
411
411
 
412
+ @logger.catch
413
+ def process_collection_upsert_command(egeria_client: EgeriaTech, txt: str, directive: str = "display") -> Optional[str]:
414
+ """
415
+ Processes a digital product create or update object_action by extracting key attributes such as
416
+ spec name, parent_guid, parent_relationship_type, parent_at_end_1, collection_type
417
+
418
+ :param txt: A string representing the input cell to be processed for
419
+ extracting glossary-related attributes.
420
+ :param directive: an optional string indicating the directive to be used - display, validate or execute
421
+ :return: A string summarizing the outcome of the processing.
422
+ """
423
+
424
+ command, object_type, object_action = extract_command_plus(txt)
425
+ print(Markdown(f"# {command}\n"))
426
+
427
+ parsed_output = parse_upsert_command(egeria_client, object_type, object_action, txt, directive)
428
+ if not parsed_output:
429
+ logger.error(f"No output for `{object_action}`")
430
+ return None
431
+
432
+ valid = parsed_output['valid']
433
+ exists = parsed_output['exists']
434
+
435
+ qualified_name = parsed_output.get('qualified_name', None)
436
+ guid = parsed_output.get('guid', None)
437
+
438
+ print(Markdown(parsed_output['display']))
439
+
440
+ logger.debug(json.dumps(parsed_output, indent=4))
441
+
442
+ attributes = parsed_output['attributes']
443
+
444
+ display_name = attributes['Display Name'].get('value', None)
445
+ description = attributes.get('Description',{}).get('value', None)
446
+ user_defined_status = attributes.get('User Defined Status',{}).get('value', None)
447
+
448
+ collection_classification = attributes.get('Collection Classification', {}).get('value', None)
449
+
450
+ current_version = attributes.get('Version Identifier',{}).get('value', None)
451
+
452
+ # status = attributes.get('Status',{}).get('value', "ACTIVE")
453
+
454
+ anchor_guid = attributes.get('Anchor ID', {}).get('guid', None)
455
+ parent_guid = attributes.get('Parent ID', {}).get('guid', None)
456
+ parent_relationship_type_name = attributes.get('Parent Relationship Type Name', {}).get('value', None)
457
+ parent_relationship_type_name = attributes.get('Parent Relationship Type Name', {}).get('value',"CollectionMembership")
458
+ parent_at_end1 = attributes.get('Parent at End1', {}).get('value', True)
459
+ anchor_scope_guid = attributes.get('Anchor Scope GUID', {}).get('value', None)
460
+ is_own_anchor = attributes.get('Is Own Anchor', {}).get('value', True)
461
+ if parent_guid is None:
462
+ is_own_anchor = True
463
+
464
+
465
+ additional_prop = attributes.get('Additional Properties', {}).get('value', None)
466
+ additional_properties = json.loads(additional_prop) if additional_prop is not None else None
467
+ extended_prop = attributes.get('Extended Properties', {}).get('value', None)
468
+ extended_properties = json.loads(extended_prop) if extended_prop is not None else None
469
+ external_source_guid = attributes.get('External Source Name', {}).get('guid', None)
470
+ external_source_name = attributes.get('External Source Name', {}).get('value', None)
471
+ effective_time = attributes.get('Effective Time', {}).get('value', None)
472
+ for_lineage = attributes.get('For Lineage', {}).get('value', None)
473
+ for_duplicate_processing = attributes.get('For Duplicate Processing', {}).get('value', None)
474
+
475
+ replace_all_props = not attributes.get('Merge Update', {}).get('value', True)
476
+
477
+ if directive == "display":
478
+
479
+ return None
480
+ elif directive == "validate":
481
+ if valid:
482
+ print(Markdown(f"==> Validation of {command} completed successfully!\n"))
483
+ else:
484
+ msg = f"Validation failed for object_action `{command}`\n"
485
+ return valid
486
+
487
+ elif directive == "process":
488
+ try:
489
+ if object_action == "Update":
490
+ if not exists:
491
+ msg = (f" Element `{display_name}` does not exist! Updating result document with Create "
492
+ f"object_action\n")
493
+ logger.error(msg)
494
+ return update_a_command(txt, object_action, object_type, qualified_name, guid)
495
+ elif not valid:
496
+ return None
497
+ else:
498
+ print(Markdown(
499
+ f"==> Validation of {command} completed successfully! Proceeding to apply the changes.\n"))
500
+ prop_body = set_collection_property_body(object_type,qualified_name,attributes)
501
+
502
+ body = set_update_body(object_type, attributes)
503
+ body['properties'] = set_collection_property_body(object_type,qualified_name,attributes)
504
+
505
+ egeria_client.update_collection_w_body(guid, body)
506
+ # egeria_client.update_collection_status(guid, status)
507
+
508
+ logger.success(f"Updated {object_type} `{display_name}` with GUID {guid}\n\n___")
509
+ update_element_dictionary(qualified_name, {
510
+ 'guid': guid, 'display_name': display_name
511
+ })
512
+ return egeria_client.get_collection_by_guid(guid, collection_type='Data Specification',
513
+ output_format='MD')
514
+
515
+
516
+ elif object_action == "Create":
517
+ if valid is False and exists:
518
+ msg = (f" Digital Product `{display_name}` already exists and result document updated changing "
519
+ f"`Create` to `Update` in processed output\n\n___")
520
+ logger.error(msg)
521
+ return update_a_command(txt, object_action, object_type, qualified_name, guid)
522
+
523
+ else:
524
+ body = set_create_body(object_type,attributes)
525
+ body["initialClassifications"] = set_collection_classifications(object_type, attributes)
526
+ body["properties"] = set_collection_property_body(object_type, qualified_name,attributes)
527
+
528
+
529
+ guid = egeria_client.create_collection_w_body(body)
530
+ if guid:
531
+ update_element_dictionary(qualified_name, {
532
+ 'guid': guid, 'display_name': display_name
533
+ })
534
+ msg = f"Created Element `{display_name}` with GUID {guid}\n\n___"
535
+ logger.success(msg)
536
+ return egeria_client.get_collection_by_guid(guid, collection_type='Digital Product',
537
+ output_format='MD')
538
+ else:
539
+ msg = f"Failed to create element `{display_name}` with GUID {guid}\n\n___"
540
+ logger.error(msg)
541
+ return None
542
+
543
+ except Exception as e:
544
+ logger.error(f"Error performing {command}: {e}")
545
+ return None
546
+ else:
547
+ return None
548
+
412
549
  @logger.catch
413
550
  def process_digital_product_upsert_command(egeria_client: EgeriaTech, txt: str, directive: str = "display") -> Optional[str]:
414
551
  """
@@ -610,7 +747,6 @@ def process_digital_product_upsert_command(egeria_client: EgeriaTech, txt: str,
610
747
  else:
611
748
  return None
612
749
 
613
-
614
750
  @logger.catch
615
751
  def process_agreement_upsert_command(egeria_client: EgeriaTech, txt: str, directive: str = "display") -> Optional[str]:
616
752
  """
@@ -821,7 +957,6 @@ def process_link_agreement_item_command(egeria_client: EgeriaTech, txt: str,
821
957
  return valid
822
958
 
823
959
  elif directive == "process":
824
- gov_peer_relationship_type = object_type[:-1].replace(" ","") + "Link"
825
960
 
826
961
  try:
827
962
  if object_action == "Detach":
@@ -837,13 +972,26 @@ def process_link_agreement_item_command(egeria_client: EgeriaTech, txt: str,
837
972
  print(Markdown(
838
973
  f"==> Validation of {command} completed successfully! Proceeding to apply the changes.\n"))
839
974
  body = set_metadata_source_request_body(object_type, attributes)
975
+ item_props = {
976
+ "class": "AgreementItemProperties",
977
+ "agreementItemId": attributes["Agreement Item Id"],
978
+ "agreementStart": attributes["Agreement Start"],
979
+ "agreementEnd": attributes["Agreement End"],
980
+ "restrictions": attributes["Restrictions"],
981
+ "obligations": attributes["Obligations"],
982
+ "entitlements": attributes["Entitlements"],
983
+ "usageMeasurements": attributes["Usage Measurements"],
984
+ "effectiveFrom": attributes["Effective From"],
985
+ "effectiveTo": attributes["Effective To"]
840
986
 
841
- egeria_client.detach_agreement_item(agreement_guid, item_guid,body)
987
+ }
988
+ body['properties'] = item_props
989
+ egeria_client.detach_agreement_item(agreement_guid, item_guid,body)
842
990
 
843
- logger.success(f"===> Detached agreement item `{item}` from agreement `{agreement}`\n")
844
- out = parsed_output['display'].replace('Unlink', 'Link', 1)
991
+ logger.success(f"===> Detached agreement item `{item}` from agreement `{agreement}`\n")
992
+ out = parsed_output['display'].replace('Unlink', 'Link', 1)
845
993
 
846
- return (out)
994
+ return (out)
847
995
 
848
996
  elif object_action == "Link":
849
997
  if valid is False and exists:
@@ -871,6 +1019,7 @@ def process_link_agreement_item_command(egeria_client: EgeriaTech, txt: str,
871
1019
  "effectiveTo": attributes["Effective To"]
872
1020
 
873
1021
  }
1022
+ body['properties'] = item_props
874
1023
  egeria_client.link_agreement_item(agreement_guid,
875
1024
  item_guid, body)
876
1025
  msg = f"==>Linked {object_type} `{agreement} to item {item}\n"
@@ -891,8 +1040,7 @@ def process_link_agreement_item_command(egeria_client: EgeriaTech, txt: str,
891
1040
  # View commands
892
1041
  #
893
1042
  @logger.catch
894
- def process_data_collection_list_command(egeria_client: EgeriaTech, txt: str, directive: str = "display") -> Optional[
895
- str]:
1043
+ def process_collection_list_command(egeria_client: EgeriaTech, txt: str, directive: str = "display") -> Optional[str]:
896
1044
  """
897
1045
  Processes a Data Dictionary list object_action by extracting key attributes such as
898
1046
  search string from the given text.
@@ -904,30 +1052,33 @@ def process_data_collection_list_command(egeria_client: EgeriaTech, txt: str, di
904
1052
  """
905
1053
  command, object_type, object_action = extract_command_plus(txt)
906
1054
  print(Markdown(f"# {command}\n"))
907
- if object_type in ["Data Dictionary", "Data Dictionaries", "DataDict", "DataDictionary"]:
908
- col_type = "DataDictionary"
909
- elif object_type in ["Data Specification", "Data Specifications", "Data Specs"]:
910
- col_type = "DataSpec"
911
- else:
912
- col_type = "Collection"
913
1055
 
914
1056
  parsed_output = parse_view_command(egeria_client, object_type, object_action, txt, directive)
915
1057
 
916
-
1058
+ col_type = to_pascal_case(object_type) if object_type != "Collections" else None
917
1059
 
918
1060
  valid = parsed_output['valid']
919
1061
  print(Markdown(f"Performing {command}"))
920
1062
  print(Markdown(parsed_output['display']))
921
1063
 
922
1064
  attr = parsed_output.get('attributes',{})
1065
+ columns = attr.get('Columns',{}).get('value',None).replace("'", '"')
1066
+
1067
+ try:
1068
+ columns_list = json.loads(columns)
1069
+ except Exception as e:
1070
+ print(e)
1071
+ exit(1)
1072
+
923
1073
  effective_time = attr.get('effectiveTime', {}).get('value', None)
924
1074
  as_of_time = attr.get('asOfTime', {}).get('value', None)
925
1075
  for_duplicate_processing = attr.get('forDuplicateProcessing', {}).get('value', False)
926
1076
  for_lineage = attr.get('forLineage',{}).get('value', False)
927
- limit_result_by_status = attr.get('limitResultsByStatus',{}).get('value', ['ACTIVE'])
1077
+ limit_result_by_status = attr.get('limitResultsByStatus',{}).get('value', [])
928
1078
  sequencing_property = attr.get('sequencingProperty',{}).get('value',"qualifiedName" )
929
1079
  sequencing_order = attr.get('sequencingOrder',{}).get('value', "PROPERTY_ASCENDING")
930
1080
  search_string = attr.get('Search String', {}).get('value', '*')
1081
+ search_string = search_string if search_string != "*" else None
931
1082
  output_format = attr.get('Output Format', {}).get('value', 'LIST')
932
1083
  detailed = attr.get('Detailed', {}).get('value', False)
933
1084
 
@@ -961,7 +1112,8 @@ def process_data_collection_list_command(egeria_client: EgeriaTech, txt: str, di
961
1112
  "filter": search_string,
962
1113
  }
963
1114
 
964
- struct = egeria_client.find_collections_w_body(body, col_type, output_format=output_format)
1115
+ struct = egeria_client.find_collections_w_body(body, col_type,
1116
+ output_format = output_format, columns=columns_list)
965
1117
  if output_format == "DICT":
966
1118
  list_md += f"```\n{json.dumps(struct, indent=4)}\n```\n"
967
1119
  else:
@@ -977,204 +1129,3 @@ def process_data_collection_list_command(egeria_client: EgeriaTech, txt: str, di
977
1129
  else:
978
1130
  return None
979
1131
 
980
- # TODO
981
- def process_data_agreement_list_command(egeria_client: EgeriaTech, txt: str, directive: str = "display") -> Optional[
982
- str]:
983
- """
984
- Processes a Data Dictionary list object_action by extracting key attributes such as
985
- search string from the given text.
986
-
987
- :param txt: A string representing the input cell to be processed for
988
- extracting term-related attributes.
989
- :param directive: an optional string indicating the directive to be used - display, validate or execute
990
- :return: A string summarizing the outcome of the processing.
991
- """
992
- command, object_type, object_action = extract_command_plus(txt)
993
- print(Markdown(f"# {command}\n"))
994
-
995
- parsed_output = parse_view_command(egeria_client, object_type, object_action, txt, directive)
996
-
997
- attributes = parsed_output['attributes']
998
-
999
- valid = parsed_output['valid']
1000
- print(Markdown(f"Performing {command}"))
1001
- print(Markdown(parsed_output['display']))
1002
-
1003
- if directive == "display":
1004
- return None
1005
- elif directive == "validate":
1006
- if valid:
1007
- print(Markdown(f"==> Validation of {command} completed successfully!\n"))
1008
- else:
1009
- msg = f"Validation failed for object_action `{command}`\n"
1010
- logger.error(msg)
1011
- return valid
1012
-
1013
- elif directive == "process":
1014
- attributes = parsed_output['attributes']
1015
- search_string = attributes.get('Search String', {}).get('value', '*')
1016
- output_format = attributes.get('Output Format', {}).get('value', 'LIST')
1017
- detailed = attributes.get('Detailed', {}).get('value', False)
1018
-
1019
- try:
1020
- if not valid: # First validate the command before we process it
1021
- msg = f"Validation failed for {object_action} `{object_type}`\n"
1022
- logger.error(msg)
1023
- return None
1024
-
1025
- list_md = f"\n# `{object_type}` with filter: `{search_string}`\n\n"
1026
- struct = egeria_client.find_data_structures(search_string, output_format=output_format)
1027
-
1028
- if output_format == "DICT":
1029
- list_md += f"```\n{json.dumps(struct, indent=4)}\n```\n"
1030
- else:
1031
- list_md += struct
1032
- logger.info(f"Wrote `{object_type}` for search string: `{search_string}`")
1033
-
1034
- return list_md
1035
-
1036
- except Exception as e:
1037
- logger.error(f"Error performing {command}: {e}")
1038
- console.print_exception(show_locals=True)
1039
- return None
1040
- else:
1041
- return None
1042
-
1043
- # TODO
1044
- def process_subscription_list_command(egeria_client: EgeriaTech, txt: str, directive: str = "display") -> Optional[str]:
1045
- """
1046
- Processes a Data Dictionary list object_action by extracting key attributes such as
1047
- search string from the given text.
1048
-
1049
- :param txt: A string representing the input cell to be processed for
1050
- extracting term-related attributes.
1051
- :param directive: an optional string indicating the directive to be used - display, validate or execute
1052
- :return: A string summarizing the outcome of the processing.
1053
- """
1054
- command, object_type, object_action = extract_command_plus(txt)
1055
- print(Markdown(f"# {command}\n"))
1056
-
1057
- parsed_output = parse_view_command(egeria_client, object_type, object_action, txt, directive)
1058
-
1059
- attributes = parsed_output['attributes']
1060
-
1061
- valid = parsed_output['valid']
1062
- print(Markdown(f"Performing {command}"))
1063
- print(Markdown(parsed_output['display']))
1064
-
1065
- if directive == "display":
1066
- return None
1067
- elif directive == "validate":
1068
- if valid:
1069
- print(Markdown(f"==> Validation of {command} completed successfully!\n"))
1070
- else:
1071
- msg = f"Validation failed for object_action `{command}`\n"
1072
- logger.error(msg)
1073
- return valid
1074
-
1075
- elif directive == "process":
1076
- attributes = parsed_output['attributes']
1077
- search_string = attributes.get('Search String', {}).get('value', '*')
1078
- output_format = attributes.get('Output Format', {}).get('value', 'LIST')
1079
- detailed = attributes.get('Detailed', {}).get('value', False)
1080
- as_of_time = attributes.get('AsOfTime', {}).get('value', None)
1081
- effective_time = attributes.get('Effective Time', {}).get('value', None)
1082
- sort_order = attributes.get('Sort Order', {}).get('value', None)
1083
- order_property = attributes.get('Order Property', {}).get('value', None)
1084
- starts_with = attributes.get('Start With', {}).get('value', True)
1085
- ends_with = attributes.get('End With', {}).get('value', False)
1086
- ignore_case = attributes.get('Ignore Case', {}).get('value', False)
1087
- start_from = attributes.get('Start From', {}).get('value', 0)
1088
- page_size = attributes.get('Page Size', {}).get('value', None)
1089
-
1090
- try:
1091
- if not valid: # First validate the command before we process it
1092
- msg = f"Validation failed for {object_action} `{object_type}`\n"
1093
- logger.error(msg)
1094
- return None
1095
-
1096
- list_md = f"\n# `{object_type}` with filter: `{search_string}`\n\n"
1097
- body = {
1098
- "class": "FilterRequestBody", "asOfTime": as_of_time, "effectiveTime": effective_time,
1099
- "forLineage": False, "forDuplicateProcessing": False, "limitResultsByStatus": ["ACTIVE"],
1100
- "sequencingOrder": sort_order, "sequencingProperty": order_property, "filter": search_string,
1101
- }
1102
- struct = egeria_client.find_data_fields_w_body(body, start_from, page_size, starts_with, ends_with,
1103
- ignore_case, output_format)
1104
-
1105
- if output_format == "DICT":
1106
- list_md += f"```\n{json.dumps(struct, indent=4)}\n```\n"
1107
- else:
1108
- list_md += struct
1109
- logger.info(f"Wrote `{object_type}` for search string: `{search_string}`")
1110
-
1111
- return list_md
1112
-
1113
- except Exception as e:
1114
- logger.error(f"Error performing {command}: {e}")
1115
- console.print_exception(show_locals=True)
1116
- return None
1117
- else:
1118
- return None
1119
-
1120
- # TODO
1121
- def process_digital_product_list_command(egeria_client: EgeriaTech, txt: str, directive: str = "display") -> Optional[str]:
1122
- """
1123
- Processes a Data Dictionary list object_action by extracting key attributes such as
1124
- search string from the given text.
1125
-
1126
- :param txt: A string representing the input cell to be processed for
1127
- extracting term-related attributes.
1128
- :param directive: an optional string indicating the directive to be used - display, validate or execute
1129
- :return: A string summarizing the outcome of the processing.
1130
- """
1131
- command, object_type, object_action = extract_command_plus(txt)
1132
- print(Markdown(f"# {command}\n"))
1133
-
1134
- parsed_output = parse_view_command(egeria_client, object_type, object_action, txt, directive)
1135
-
1136
- attributes = parsed_output['attributes']
1137
-
1138
- valid = parsed_output['valid']
1139
- print(Markdown(f"Performing {command}"))
1140
- print(Markdown(parsed_output['display']))
1141
-
1142
- if directive == "display":
1143
- return None
1144
- elif directive == "validate":
1145
- if valid:
1146
- print(Markdown(f"==> Validation of {command} completed successfully!\n"))
1147
- else:
1148
- msg = f"Validation failed for object_action `{command}`\n"
1149
- logger.error(msg)
1150
- return valid
1151
-
1152
- elif directive == "process":
1153
- attributes = parsed_output['attributes']
1154
- search_string = attributes.get('Search String', {}).get('value', '*')
1155
- output_format = attributes.get('Output Format', {}).get('value', 'LIST')
1156
- detailed = attributes.get('Detailed', {}).get('value', False)
1157
-
1158
- try:
1159
- if not valid: # First validate the command before we process it
1160
- msg = f"Validation failed for {object_action} `{object_type}`\n"
1161
- logger.error(msg)
1162
- return None
1163
-
1164
- list_md = f"\n# `{object_type}` with filter: `{search_string}`\n\n"
1165
- struct = egeria_client.find_data_classes(search_string, output_format=output_format)
1166
-
1167
- if output_format == "DICT":
1168
- list_md += f"```\n{json.dumps(struct, indent=4)}\n```\n"
1169
- else:
1170
- list_md += struct
1171
- logger.info(f"Wrote `{object_type}` for search string: `{search_string}`")
1172
-
1173
- return list_md
1174
-
1175
- except Exception as e:
1176
- logger.error(f"Error performing {command}: {e}")
1177
- console.print_exception(show_locals=True)
1178
- return None
1179
- else:
1180
- return None
@@ -1,6 +1,7 @@
1
1
  """
2
2
  This file contains general utility functions for processing Egeria Markdown
3
3
  """
4
+ import json
4
5
  import os
5
6
  import sys
6
7
  from typing import List
@@ -175,6 +176,9 @@ def parse_upsert_command(egeria_client: EgeriaTech, object_type: str, object_act
175
176
  parsed_attributes[key] = proc_simple_attribute(txt, object_action, labels, if_missing, default_value)
176
177
  elif style == 'Bool':
177
178
  parsed_attributes[key] = proc_bool_attribute(txt, object_action, labels, if_missing, default_value)
179
+ elif style == "Dictionary List":
180
+ parsed_attributes[key] = proc_simple_attribute(txt, object_action, labels, if_missing, default_value)
181
+ parsed_attributes[key]['list'] = json.loads(parsed_attributes[key]['value'])
178
182
 
179
183
 
180
184
  elif style == 'Reference Name List':
@@ -374,6 +378,9 @@ def parse_view_command(egeria_client: EgeriaTech, object_type: str, object_actio
374
378
  parsed_attributes[key] = proc_simple_attribute(txt, object_action, labels, if_missing, default_value)
375
379
  elif style == 'Bool':
376
380
  parsed_attributes[key] = proc_bool_attribute(txt, object_action, labels, if_missing, default_value)
381
+ elif style == "Dictionary List":
382
+ parsed_attributes[key] = proc_simple_attribute(txt, object_action, labels, if_missing, default_value)
383
+ # parsed_attributes[key]['list'] = json.loads(parsed_attributes[key]['value'])
377
384
 
378
385
  elif style == 'Reference Name List':
379
386
  parsed_attributes[key] = proc_name_list(egeria_client, key, txt, labels, if_missing)
@@ -490,6 +497,8 @@ def proc_valid_value(txt: str, action: str, labels: set, valid_values: [], if_mi
490
497
  if isinstance(valid_values, str):
491
498
  # v_values = [item.strip() for item in re.split(r'[;,\n]+', valid_values)]
492
499
  v_values = split_tb_string(valid_values)
500
+ if isinstance(valid_values, list):
501
+ v_values = valid_values
493
502
  if not isinstance(v_values, list):
494
503
  msg = "Valid values list is not a list"
495
504
  logger.error(msg)
@@ -232,8 +232,8 @@ def set_create_body(object_type: str, attributes: dict)->dict:
232
232
  "parentRelationshipProperties": attributes.get('Parent Relationship Properties', {}).get('value', None),
233
233
  "parentAtEnd1": attributes.get('Parent at End1', {}).get('value', True),
234
234
  "properties": "",
235
- "initialStatus": attributes.get('Status', {}).get('value', "ACTIVE")
236
- }
235
+ "initialStatus": attributes.get('Status', {}).get('value', "ACTIVE"),
236
+ "initialClassifications": {}}
237
237
 
238
238
  return body
239
239
 
@@ -261,6 +261,8 @@ def set_prop_body(object_type: str, qualified_name: str, attributes: dict)->dict
261
261
  "displayName": attributes['Display Name'].get('value', None),
262
262
  "qualifiedName" : qualified_name,
263
263
  "description": attributes['Description'].get('value', None),
264
+ "status": attributes.get('Status', {}).get('value', "ACTIVE"),
265
+ "userDefinedStatus": attributes.get('User Defined Status', {}).get('value', None),
264
266
  "versionIdentifier": attributes.get('Version Identifier', {}).get('value', None),
265
267
  "effectiveFrom": attributes.get('Effective From', {}).get('value', None),
266
268
  "effectiveTo": attributes.get('Effective To', {}).get('value', None),
@@ -369,3 +371,14 @@ def set_element_status_request_body(object_type: str, attributes: dict)->dict:
369
371
  "forLineage": attributes.get('For Lineage', {}).get('value', False),
370
372
  "forDuplicateProcessing": attributes.get('For Duplicate Processing', {}).get('value', False)
371
373
  }
374
+ def set_collection_property_body(object_type: str, qualified_name:str, attributes: dict)->dict:
375
+ body = set_prop_body("Collection", qualified_name,attributes)
376
+ body["category"] = attributes.get('Category', {}).get('value', None)
377
+ return body
378
+
379
+ def set_collection_classifications(object_type: str, attributes: dict)->dict:
380
+ collection_classifications = attributes.get('Collection Classifications', {}).get('name_list', None)
381
+ if collection_classifications is None:
382
+ collection_classifications = object_type
383
+ body = {classification: {} for classification in collection_classifications} if collection_classifications else {}
384
+ return body
@@ -4,6 +4,7 @@ This file contains display-related constants and formatting functions for Egeria
4
4
  import importlib.resources
5
5
  import json
6
6
  import os
7
+ import inflect
7
8
 
8
9
  from rich.markdown import Markdown
9
10
 
@@ -11,6 +12,9 @@ from md_processing.md_processing_utils.message_constants import ERROR
11
12
  from pyegeria._globals import DEBUG_LEVEL
12
13
  from md_processing.md_processing_utils.message_constants import message_types, ALWAYS, ERROR, INFO, WARNING
13
14
 
15
+ inflect_engine = inflect.engine()
16
+
17
+
14
18
  EGERIA_ROOT_PATH = os.environ.get("EGERIA_ROOT_PATH", "/home/jovyan")
15
19
  EGERIA_INBOX_PATH = os.environ.get("EGERIA_INBOX_PATH", "loading-bay/dr_egeria_inbox")
16
20
 
@@ -71,6 +75,40 @@ GOV_COM_LIST = [ "Create Business Imperative", "Update Business Imperative",
71
75
  "Create Certification Type", "Update Certification Type",
72
76
  "Create License Type", "Update License Type",]
73
77
 
78
+ SIMPLE_BASE_COLLECTIONS: set = { "Collection", "Home Collection", "Digital Product", "Result Set" , "Recent Access",
79
+ "Reference List", "Work Item List", "Data Sharing Agreement", "Namespace", "Agreement",
80
+ "Digital Subscription", "Data Product", "Subscription",
81
+ "Root Collection", "Folders", "Context Event Collection", "Name Space Collection",
82
+ # "Data Specifications", "Data Specifications", "Data Specs", "Data Specs",
83
+ # "Data Dictionaries", "Data Dictionaries",
84
+ "Event Set Collection", "Naming Standard Ruleset",
85
+ }
86
+ SIMPLE_COLLECTIONS: set = set()
87
+ for element in SIMPLE_BASE_COLLECTIONS:
88
+ SIMPLE_COLLECTIONS.add(f"Create {element}")
89
+ SIMPLE_COLLECTIONS.add(f"Update {element}")
90
+ plural = inflect_engine.plural_noun(element)
91
+ SIMPLE_COLLECTIONS.add(f"Create {plural}")
92
+ SIMPLE_COLLECTIONS.add(f"Update {plural}")
93
+
94
+
95
+
96
+ COLLECTIONS_LIST = ["List Collections", "View Collections", "List Digital Products", "View Digital Products",
97
+ "List Data Products", "View Data Products",
98
+ "List Data Sharing Agreements", "View Data Sharing Agreements",
99
+ "List Agreements", "View Agreements",
100
+ "List Digital Subscriptions", "View Digital Subscriptions",
101
+ "List Subscriptions", "View Subscriptions",
102
+ "List Root Collections", "View Root Collections",
103
+ "List Data Specifications", "View Data Specifications", "List Data Specs", "View Data Specs",
104
+ "List Data Dictionaries", "View Data Dictionaries",
105
+ "List Folders", "View Folders",
106
+ "List Context Event Collections", "View Context Event Collections",
107
+ "List Name Space Collections", "View Name Space Collections",
108
+ "List Event Set Collections", "View Event Set Collections",
109
+ "List Naming Standard Rulesets", "View Naming Standard Rulesets",
110
+ ]
111
+
74
112
  command_list = ["Provenance", "Create Glossary", "Update Glossary", "Create Term", "Update Term", "List Terms",
75
113
  "List Term Details", "List Glossary Terms", "List Term History", "List Term Revision History",
76
114
  "List Term Update History", "List Glossary Structure", "List Glossaries", "List Categories",
@@ -87,13 +125,13 @@ command_list = ["Provenance", "Create Glossary", "Update Glossary", "Create Term
87
125
  "Update Term-Term Relationship", "Create Data Spec", "Create Data Specification", "Update Data Spec",
88
126
  "Update Data Specification", "Create Data Field", "Update Data Field", "Create Data Structure",
89
127
  "Update Data Structure", "Create Data Dictionary", "Update Data Dictionary", "Create Data Dict",
90
- "Update Data Dict", " View Data Dictionary", "View Data Dictionaries", "View Data Specifications",
91
- "View Data Specs", "View Data Structures", "View Data Structure", "View Data Fields", "View Data Field",
128
+ "Update Data Dict",
129
+ "View Data Structures", "View Data Structure", "View Data Fields", "View Data Field",
92
130
  "View Dataa Classes", "View Data Class", "Create Data Class", "Update Data Class",
93
131
  "Create Digital Product", "Create Data Product", "Update Digital Product", "Update Data Product",
94
132
  "Create Agreement", "Update Agreement",
95
133
  "Link Digital Products", "Link Data Products", "Detach Digital Products", "Detach Data Products",
96
- "Create Data Sharing Agreement", "Update Data Sharing Agreement",
134
+ # "Create Data Sharing Agreement", "Update Data Sharing Agreement",
97
135
  "Create Digital Subscription", "Create Product Subscription", "Update Digital Subscription", "Update Product Subscription",
98
136
  "Attach Agreement Items", "Detach Agreement Items",
99
137
  "Attach Contract", "Detach Contract",
@@ -102,9 +140,7 @@ command_list = ["Provenance", "Create Glossary", "Update Glossary", "Create Term
102
140
  "Unlink Collection From Resource", "Detach Collection From Resource",
103
141
  "Add Member to Collection", "Add Member", "Member->Collection",
104
142
  "Remove Member from Collection","Remove Member from Collection",
105
- "View Digital Products", "View Data Products", "List Data Products", "List Digtal Products",
106
- "View Agreements", "View Data Sharing Agreements", "List Agreements", "List Data Sharing Agreements",
107
- "View Subscriptions", "List Subscriptions", "View Governance Definitions", "View Gov Definitions",
143
+ "View Governance Definitions", "View Gov Definitions",
108
144
  "List Governance Definitions", "List Gov Definitions",
109
145
  "View Governance Definition Context","List Governance Definition Context",
110
146
  "View Governance Def Context", "List Governance Def Context",
@@ -135,6 +171,8 @@ command_list = ["Provenance", "Create Glossary", "Update Glossary", "Create Term
135
171
 
136
172
  command_list.extend(GOV_COM_LIST)
137
173
  command_list.extend(GOV_LINK_LIST)
174
+ command_list.extend(COLLECTIONS_LIST)
175
+ command_list.extend(SIMPLE_COLLECTIONS)
138
176
 
139
177
  pre_command = "\n---\n==> Processing object_action:"
140
178
  command_seperator = Markdown("\n---\n")