pyegeria 5.4.7__py3-none-any.whl → 5.4.7.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.
@@ -3,7 +3,6 @@ This file contains product manager commands for processing Egeria Markdown
3
3
  """
4
4
  import json
5
5
  import os
6
- import sys
7
6
  from typing import Optional
8
7
 
9
8
  from loguru import logger
@@ -12,13 +11,12 @@ from rich.console import Console
12
11
  from rich.markdown import Markdown
13
12
 
14
13
  from md_processing.md_processing_utils.common_md_proc_utils import (parse_upsert_command, parse_view_command)
15
- from md_processing.md_processing_utils.common_md_utils import update_element_dictionary, set_update_body, \
16
- set_element_status_request_body, set_element_prop_body, set_delete_request_body, set_rel_request_body, set_peer_gov_def_request_body, \
17
- set_rel_request_body, set_create_body, set_object_classifications, set_product_body
18
-
14
+ from md_processing.md_processing_utils.common_md_utils import update_element_dictionary, set_update_body, \
15
+ set_element_prop_body, set_delete_request_body, set_rel_request_body, set_create_body, set_object_classifications, \
16
+ set_product_body
19
17
  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, to_pascal_case, PyegeriaException, print_basic_exception, print_exception_table
18
+ from md_processing.md_processing_utils.md_processing_constants import (load_commands)
19
+ from pyegeria import DEBUG_LEVEL, body_slimmer, PyegeriaException, print_basic_exception, print_exception_table
22
20
  from pyegeria.egeria_tech_client import EgeriaTech
23
21
  from pyegeria.utils import make_format_set_name_from_type
24
22
 
@@ -53,7 +51,7 @@ console = Console(width=int(200))
53
51
  #
54
52
  @logger.catch
55
53
  def add_member_to_collections(egeria_client: EgeriaTech, collection_list: list, display_name: str,
56
- guid: str) -> None:
54
+ guid: str) -> None:
57
55
  """
58
56
  Add member to data dictionaries and data specifications.
59
57
  """
@@ -61,8 +59,8 @@ def add_member_to_collections(egeria_client: EgeriaTech, collection_list: list,
61
59
  "class": "NewRelationshipRequestBody", "properties": {
62
60
  "class": "CollectionMembershipProperties", "membershipRationale": "User Specified",
63
61
  "notes": "Added by Dr.Egeria"
64
- }
65
62
  }
63
+ }
66
64
  try:
67
65
  if collection_list is not None:
68
66
  for collection in collection_list:
@@ -79,7 +77,7 @@ def add_member_to_collections(egeria_client: EgeriaTech, collection_list: list,
79
77
 
80
78
  @logger.catch
81
79
  def remove_member_from_collections(egeria_client: EgeriaTech, collection_list: list, display_name: str,
82
- guid: str) -> None:
80
+ guid: str) -> None:
83
81
  try:
84
82
  for collection in collection_list:
85
83
  egeria_client.remove_from_collection(collection, guid)
@@ -174,8 +172,6 @@ def process_collection_upsert_command(egeria_client: EgeriaTech, txt: str, direc
174
172
 
175
173
  guid = parsed_output.get('guid', None)
176
174
 
177
-
178
-
179
175
  logger.debug(json.dumps(parsed_output, indent=4))
180
176
 
181
177
  attributes = parsed_output['attributes']
@@ -211,7 +207,6 @@ def process_collection_upsert_command(egeria_client: EgeriaTech, txt: str, direc
211
207
  elif directive == "process":
212
208
  try:
213
209
 
214
-
215
210
  if object_action == "Update":
216
211
  if not exists:
217
212
  msg = (f" Element `{display_name}` does not exist! Updating result document with Create "
@@ -235,8 +230,8 @@ def process_collection_upsert_command(egeria_client: EgeriaTech, txt: str, direc
235
230
  logger.success(f"Updated {object_type} `{display_name}` with GUID {guid}\n\n___")
236
231
  update_element_dictionary(qualified_name, {
237
232
  'guid': guid, 'display_name': display_name
238
- })
239
- return egeria_client.get_collection_by_guid(guid, element_type= obj,
233
+ })
234
+ return egeria_client.get_collection_by_guid(guid, element_type=obj,
240
235
  output_format='MD', output_format_set=output_set)
241
236
 
242
237
 
@@ -248,27 +243,29 @@ def process_collection_upsert_command(egeria_client: EgeriaTech, txt: str, direc
248
243
  return update_a_command(txt, object_action, object_type, qualified_name, guid)
249
244
 
250
245
  else:
251
- body = set_create_body(object_type,attributes)
246
+ body = set_create_body(object_type, attributes)
252
247
 
253
248
  # if this is a root or folder (maybe more in the future), then make sure that the classification is set.
254
- body["initialClassifications"] = set_object_classifications(object_type, attributes, ["Folder", "Root Collection"])
249
+ body["initialClassifications"] = set_object_classifications(object_type, attributes,
250
+ ["Folder", "Root Collection"])
255
251
  body["properties"] = set_element_prop_body(obj, qualified_name, attributes)
256
252
  parent_guid = body.get('parentGuid', None)
257
253
  if parent_guid:
258
254
  body['parentRelationshipTypeName'] = "CollectionMembership"
259
255
  body['parentAtEnd1'] = True
260
256
 
261
- guid = egeria_client.create_collection(body = body)
257
+ guid = egeria_client.create_collection(body=body)
262
258
  if guid:
263
259
  update_element_dictionary(qualified_name, {
264
260
  'guid': guid, 'display_name': display_name
265
- })
261
+ })
266
262
  msg = f"\nCreated Element `{display_name}` with GUID {guid}\n\n___"
267
- # todo - add the source member asset to the product manager
268
- # create_elem_from_template
269
- # add this guid to the product collection
263
+ # todo - add the source member asset to the product manager
264
+ # create_elem_from_template
265
+ # add this guid to the product collection
270
266
  logger.success(msg)
271
- return egeria_client.get_collection_by_guid(guid, obj, output_format='MD', output_format_set=output_set)
267
+ return egeria_client.get_collection_by_guid(guid, obj, output_format='MD',
268
+ output_format_set=output_set)
272
269
  else:
273
270
  msg = f"Failed to create element `{display_name}` with GUID {guid}\n\n___"
274
271
  logger.error(msg)
@@ -283,6 +280,7 @@ def process_collection_upsert_command(egeria_client: EgeriaTech, txt: str, direc
283
280
  else:
284
281
  return None
285
282
 
283
+
286
284
  @logger.catch
287
285
  def process_digital_product_upsert_command(egeria_client: EgeriaTech, txt: str,
288
286
  directive: str = "display") -> Optional[str]:
@@ -307,7 +305,6 @@ def process_digital_product_upsert_command(egeria_client: EgeriaTech, txt: str,
307
305
  qualified_name = parsed_output.get('qualified_name', None)
308
306
  guid = parsed_output.get('guid', None)
309
307
 
310
-
311
308
  print(Markdown(parsed_output['display']))
312
309
 
313
310
  logger.debug(json.dumps(parsed_output, indent=4))
@@ -315,8 +312,8 @@ def process_digital_product_upsert_command(egeria_client: EgeriaTech, txt: str,
315
312
  attributes = parsed_output['attributes']
316
313
 
317
314
  display_name = attributes['Display Name'].get('value', None)
318
- product_manager = attributes.get('Product Manager',{}).get('value', None)
319
- product_status = attributes.get('Product Status',{}).get('value', None)
315
+ product_manager = attributes.get('Product Manager', {}).get('value', None)
316
+ product_status = attributes.get('Product Status', {}).get('value', None)
320
317
  output_set = make_format_set_name_from_type(object_type)
321
318
 
322
319
  if directive == "display":
@@ -354,11 +351,10 @@ def process_digital_product_upsert_command(egeria_client: EgeriaTech, txt: str,
354
351
  # if product_status:
355
352
  # egeria_client.update_digital_product_status(guid, product_status)
356
353
 
357
-
358
354
  logger.success(f"Updated {object_type} `{display_name}` with GUID {guid}\n\n___")
359
355
  update_element_dictionary(qualified_name, {
360
356
  'guid': guid, 'display_name': display_name
361
- })
357
+ })
362
358
  return egeria_client.get_collection_by_guid(guid, element_type='Digital Product',
363
359
  output_format='MD', output_format_set=output_set)
364
360
 
@@ -380,7 +376,7 @@ def process_digital_product_upsert_command(egeria_client: EgeriaTech, txt: str,
380
376
  if guid:
381
377
  update_element_dictionary(qualified_name, {
382
378
  'guid': guid, 'display_name': display_name
383
- })
379
+ })
384
380
  # Todo: Add product manager link later? Agreements?
385
381
 
386
382
  msg = f"Created Element `{display_name}` with GUID {guid}\n\n___"
@@ -587,7 +583,7 @@ def process_agreement_upsert_command(egeria_client: EgeriaTech, txt: str, direct
587
583
  logger.success(f"Updated {object_type} `{display_name}` with GUID {guid}\n\n___")
588
584
  update_element_dictionary(qualified_name, {
589
585
  'guid': guid, 'display_name': display_name
590
- })
586
+ })
591
587
  return egeria_client.get_collection_by_guid(guid, element_type='Data Specification',
592
588
  output_format='MD', output_format_set=output_set)
593
589
 
@@ -611,10 +607,11 @@ def process_agreement_upsert_command(egeria_client: EgeriaTech, txt: str, direct
611
607
  if guid:
612
608
  update_element_dictionary(qualified_name, {
613
609
  'guid': guid, 'display_name': display_name
614
- })
610
+ })
615
611
  msg = f"Created Element `{display_name}` with GUID {guid}\n\n___"
616
612
  logger.success(msg)
617
- return egeria_client.get_collection_by_guid(guid, obj, output_format='MD', output_format_set=output_set)
613
+ return egeria_client.get_collection_by_guid(guid, obj, output_format='MD',
614
+ output_format_set=output_set)
618
615
  else:
619
616
  msg = f"Failed to create element `{display_name}` with GUID {guid}\n\n___"
620
617
  logger.error(msg)
@@ -630,9 +627,9 @@ def process_agreement_upsert_command(egeria_client: EgeriaTech, txt: str, direct
630
627
  return None
631
628
 
632
629
 
633
-
634
630
  @logger.catch
635
- def process_csv_element_upsert_command(egeria_client: EgeriaTech, txt: str, directive: str = "display") -> Optional[str]:
631
+ def process_csv_element_upsert_command(egeria_client: EgeriaTech, txt: str, directive: str = "display") -> Optional[
632
+ str]:
636
633
  """
637
634
  Processes a create CSV element command by extracting key attributes and calling the pyegeria
638
635
  api that creates a csv element from template.
@@ -697,21 +694,22 @@ def process_csv_element_upsert_command(egeria_client: EgeriaTech, txt: str, dire
697
694
 
698
695
  else:
699
696
  guid = egeria_client.get_create_csv_data_file_element_from_template(
700
- file_name, file_type, file_path, version_identifier, file_encoding, file_extension, file_system_name, description)
697
+ file_name, file_type, file_path, version_identifier, file_encoding, file_extension,
698
+ file_system_name, description)
701
699
 
702
700
  if guid:
703
701
  update_element_dictionary(qualified_name, {
704
702
  'guid': guid, 'display_name': display_name
705
- })
703
+ })
706
704
  msg = f"Created Element `{display_name}` with GUID {guid}\n\n___"
707
705
  logger.success(msg)
708
706
  output_md = (f"# Create CSV File\n\n## Display Name:\n\n {display_name}\n\n"
709
- f"## File Type:\n\n {file_type}\n\n## File Path:\n\n {file_path}\n\n"
710
- f"## File Encoding:\n\n {file_encoding}\n\n## File Extension:\n\n {file_extension}\n\n"
711
- f"## File System Name:\n\n {file_system_name}\n\n## Version Identifier:\n\n {version_identifier}\n\n"
712
- f"## Description:\n\n {description}\n\n"
713
- f"## Qualified Name\n\n {qualified_name}\n\n"
714
- f"## GUID:\n\n {guid}\n\n"
707
+ f"## File Type:\n\n {file_type}\n\n## File Path:\n\n {file_path}\n\n"
708
+ f"## File Encoding:\n\n {file_encoding}\n\n## File Extension:\n\n {file_extension}\n\n"
709
+ f"## File System Name:\n\n {file_system_name}\n\n## Version Identifier:\n\n {version_identifier}\n\n"
710
+ f"## Description:\n\n {description}\n\n"
711
+ f"## Qualified Name\n\n {qualified_name}\n\n"
712
+ f"## GUID:\n\n {guid}\n\n"
715
713
  )
716
714
  return output_md
717
715
  else:
@@ -732,7 +730,6 @@ def process_csv_element_upsert_command(egeria_client: EgeriaTech, txt: str, dire
732
730
  return None
733
731
 
734
732
 
735
-
736
733
  def process_link_agreement_item_command(egeria_client: EgeriaTech, txt: str,
737
734
  directive: str = "display") -> Optional[str]:
738
735
  """
@@ -753,16 +750,15 @@ def process_link_agreement_item_command(egeria_client: EgeriaTech, txt: str,
753
750
  logger.debug(json.dumps(parsed_output, indent=4))
754
751
 
755
752
  attributes = parsed_output['attributes']
756
- agreement = attributes.get('Agreement Name',{}).get('value', None)
753
+ agreement = attributes.get('Agreement Name', {}).get('value', None)
757
754
  agreement_guid = attributes.get('Agreement Name', {}).get('guid', None)
758
- item = attributes.get('Item Name',{}).get('value', None)
755
+ item = attributes.get('Item Name', {}).get('value', None)
759
756
  item_guid = attributes.get('Item Name', {}).get('guid', None)
760
757
  label = attributes.get('Link Label', {}).get('value', None)
761
758
  description = attributes.get('Description', {}).get('value', None)
762
759
 
763
760
  valid = parsed_output['valid']
764
- exists = agreement_guid is not None and item_guid is not None
765
-
761
+ exists = agreement_guid is not None and item_guid is not None
766
762
 
767
763
  if directive == "display":
768
764
 
@@ -791,7 +787,7 @@ def process_link_agreement_item_command(egeria_client: EgeriaTech, txt: str,
791
787
  f"==> Validation of {command} completed successfully! Proceeding to apply the changes.\n"))
792
788
  body = set_delete_request_body(object_type, attributes)
793
789
 
794
- egeria_client.detach_agreement_item(agreement_guid, item_guid,body)
790
+ egeria_client.detach_agreement_item(agreement_guid, item_guid, body)
795
791
 
796
792
  logger.success(f"===> Detached agreement item `{item}` from agreement `{agreement}`\n")
797
793
  out = parsed_output['display'].replace('Unlink', 'Link', 1)
@@ -813,21 +809,21 @@ def process_link_agreement_item_command(egeria_client: EgeriaTech, txt: str,
813
809
  body = set_rel_request_body(object_type, attributes)
814
810
  item_props = {
815
811
  "class": "AgreementItemProperties",
816
- "agreementItemId": attributes.get("Agreement Item Id",{}).get("value", None),
817
- "agreementItemTypeName": attributes.get("Agreement Item Type",{}).get("value", None),
818
- "agreementStart": attributes.get("Agreement Start",{}).get("value", None),
819
- "agreementEnd": attributes.get("Agreement End",{}).get("value", None),
820
- "restrictions": attributes.get("Restrictions",{}).get("value", None),
821
- "obligations": attributes.get("Obligations",{}).get("value", None),
822
- "entitlements": attributes.get("Entitlements",{}).get("value", None),
823
- "usageMeasurements": attributes.get("Usage Measurements",{}).get("value", None),
824
- "effectiveFrom": attributes.get("Effective From",{}).get("value", None),
825
- "effectiveTo": attributes.get("Effective To",{}).get("value", None)
812
+ "agreementItemId": attributes.get("Agreement Item Id", {}).get("value", None),
813
+ "agreementItemTypeName": attributes.get("Agreement Item Type", {}).get("value", None),
814
+ "agreementStart": attributes.get("Agreement Start", {}).get("value", None),
815
+ "agreementEnd": attributes.get("Agreement End", {}).get("value", None),
816
+ "restrictions": attributes.get("Restrictions", {}).get("value", None),
817
+ "obligations": attributes.get("Obligations", {}).get("value", None),
818
+ "entitlements": attributes.get("Entitlements", {}).get("value", None),
819
+ "usageMeasurements": attributes.get("Usage Measurements", {}).get("value", None),
820
+ "effectiveFrom": attributes.get("Effective From", {}).get("value", None),
821
+ "effectiveTo": attributes.get("Effective To", {}).get("value", None)
826
822
 
827
823
  }
828
824
  body['properties'] = item_props
829
825
  egeria_client.link_agreement_item(agreement_guid,
830
- item_guid, body)
826
+ item_guid, body)
831
827
  msg = f"==>Linked {object_type} `{agreement} to item {item}\n"
832
828
  logger.success(msg)
833
829
  out = parsed_output['display'].replace('Link', 'Detach', 1)
@@ -840,8 +836,9 @@ def process_link_agreement_item_command(egeria_client: EgeriaTech, txt: str,
840
836
  else:
841
837
  return None
842
838
 
839
+
843
840
  def process_add_to_collection_command(egeria_client: EgeriaTech, txt: str,
844
- directive: str = "display") -> Optional[str]:
841
+ directive: str = "display") -> Optional[str]:
845
842
  """
846
843
  Processes a link or unlink command to add or remove a member to/from a collection..
847
844
 
@@ -860,9 +857,9 @@ def process_add_to_collection_command(egeria_client: EgeriaTech, txt: str,
860
857
  logger.debug(json.dumps(parsed_output, indent=4))
861
858
 
862
859
  attributes = parsed_output['attributes']
863
- element_guid = attributes.get('Element Id',{}).get('guid', None)
860
+ element_guid = attributes.get('Element Id', {}).get('guid', None)
864
861
  collection_guid = attributes.get('Collection Id', {}).get('guid', None)
865
- membership_rationale = attributes.get('Membership Rationale',{}).get('value', None)
862
+ membership_rationale = attributes.get('Membership Rationale', {}).get('value', None)
866
863
  expression = attributes.get('Expression', {}).get('value', None)
867
864
  confidence = attributes.get('Confidence', {}).get('value', None)
868
865
  membership_status = attributes.get('Membership Status', {}).get('value', None)
@@ -875,7 +872,6 @@ def process_add_to_collection_command(egeria_client: EgeriaTech, txt: str,
875
872
  glossary_term = attributes.get('Glossary Term', {}).get('value', None)
876
873
  journal_entry = attributes.get('Journal Entry', {}).get('value', None)
877
874
 
878
-
879
875
  valid = parsed_output['valid']
880
876
  # exists = agreement_guid is not None and item_guid is not None
881
877
  exists = collection_guid is not None and element_guid is not None
@@ -892,7 +888,7 @@ def process_add_to_collection_command(egeria_client: EgeriaTech, txt: str,
892
888
 
893
889
  elif directive == "process":
894
890
  prop_body = {
895
- "class" : "CollectionMembershipProperties",
891
+ "class": "CollectionMembershipProperties",
896
892
  "membershipRationale": membership_rationale,
897
893
  "expression": expression,
898
894
  "membershipStatus": membership_status,
@@ -903,10 +899,10 @@ def process_add_to_collection_command(egeria_client: EgeriaTech, txt: str,
903
899
  "stewardPropertyName": steward_property_name,
904
900
  "source": source,
905
901
  "notes": notes,
906
- }
902
+ }
907
903
  label = "Add Member"
908
904
  try:
909
- if object_action in["Detach", "Unlink", "Remove"]:
905
+ if object_action in ["Detach", "Unlink", "Remove"]:
910
906
  if not exists:
911
907
  msg = (f" Link `{label}` does not exist! Updating result document with Link "
912
908
  f"object_action\n")
@@ -920,7 +916,7 @@ def process_add_to_collection_command(egeria_client: EgeriaTech, txt: str,
920
916
  f"==> Validation of {command} completed successfully! Proceeding to apply the changes.\n"))
921
917
  body = set_delete_request_body(object_type, attributes)
922
918
 
923
- egeria_client.remove_from_collection(collection_guid, element_guid,body)
919
+ egeria_client.remove_from_collection(collection_guid, element_guid, body)
924
920
 
925
921
  logger.success(f"===> Detached element `{element_guid}` from collection `{collection_guid}`\n")
926
922
  out = parsed_output['display'].replace('Unlink', 'Link', 1)
@@ -948,7 +944,7 @@ def process_add_to_collection_command(egeria_client: EgeriaTech, txt: str,
948
944
  body['properties'] = prop_body
949
945
  body = body_slimmer(body)
950
946
  egeria_client.add_to_collection(collection_guid,
951
- element_guid, body)
947
+ element_guid, body)
952
948
  msg = f"==>Linked `{element_guid}` to collection `{collection_guid}` \n"
953
949
  logger.success(msg)
954
950
  out = parsed_output['display'].replace('Link', 'Detach', 1)
@@ -961,8 +957,9 @@ def process_add_to_collection_command(egeria_client: EgeriaTech, txt: str,
961
957
  else:
962
958
  return None
963
959
 
960
+
964
961
  def process_product_dependency_command(egeria_client: EgeriaTech, txt: str,
965
- directive: str = "display") -> Optional[str]:
962
+ directive: str = "display") -> Optional[str]:
966
963
  """
967
964
  Processes a link or unlink command to associate or break up a dependency between digital products..
968
965
 
@@ -983,15 +980,13 @@ def process_product_dependency_command(egeria_client: EgeriaTech, txt: str,
983
980
  attributes = parsed_output['attributes']
984
981
  digital_product1_guid = attributes.get('Digital Product 1', None)
985
982
  digital_product2_guid = attributes.get('Digital Product 2', None)
986
- label = attributes.get('Label',{}).get('value', None)
983
+ label = attributes.get('Label', {}).get('value', None)
987
984
  description = attributes.get('Description', {}).get('value', None)
988
985
  effective_from = attributes.get('Effective From', {}).get('value', None)
989
986
  effective_to = attributes.get('Effective To', {}).get('value', None)
990
987
 
991
-
992
988
  valid = parsed_output['valid']
993
- exists = agreement_guid is not None and item_guid is not None
994
-
989
+ exists = digital_product1_guid is not None and digital_product2_guid is not None
995
990
 
996
991
  if directive == "display":
997
992
 
@@ -1005,12 +1000,12 @@ def process_product_dependency_command(egeria_client: EgeriaTech, txt: str,
1005
1000
 
1006
1001
  elif directive == "process":
1007
1002
  prop_body = {
1008
- "class" : "DigitalProductDependencyProperties",
1003
+ "class": "DigitalProductDependencyProperties",
1009
1004
  "label": label,
1010
1005
  "description": description,
1011
1006
  "effectiveFrom": effective_from,
1012
1007
  "effectiveTo": effective_to
1013
- }
1008
+ }
1014
1009
 
1015
1010
  try:
1016
1011
  if object_action == "Detach":
@@ -1027,9 +1022,10 @@ def process_product_dependency_command(egeria_client: EgeriaTech, txt: str,
1027
1022
  f"==> Validation of {command} completed successfully! Proceeding to apply the changes.\n"))
1028
1023
  body = set_delete_request_body(object_type, attributes)
1029
1024
 
1030
- egeria_client.detach_digital_product_dependency(digital_product1_guid, digital_product2_guid,body)
1025
+ egeria_client.detach_digital_product_dependency(digital_product1_guid, digital_product2_guid, body)
1031
1026
 
1032
- logger.success(f"===> Detached dependency between products `{digital_product1_guid}` and `{digital_product2_guid}`\n")
1027
+ logger.success(
1028
+ f"===> Detached dependency between products `{digital_product1_guid}` and `{digital_product2_guid}`\n")
1033
1029
  out = parsed_output['display'].replace('Unlink', 'Link', 1)
1034
1030
 
1035
1031
  return (out)
@@ -1050,7 +1046,7 @@ def process_product_dependency_command(egeria_client: EgeriaTech, txt: str,
1050
1046
 
1051
1047
  body['properties'] = prop_body
1052
1048
  egeria_client.link_digital_product_dependency(digital_product1_guid,
1053
- digital_product2_guid, body)
1049
+ digital_product2_guid, body)
1054
1050
  msg = f"==>Linked dependency from digital product `{digital_product1_guid}` to product `{digital_product2_guid}` \n"
1055
1051
  logger.success(msg)
1056
1052
  out = parsed_output['display'].replace('Link', 'Detach', 1)
@@ -1063,8 +1059,9 @@ def process_product_dependency_command(egeria_client: EgeriaTech, txt: str,
1063
1059
  else:
1064
1060
  return None
1065
1061
 
1062
+
1066
1063
  def process_attach_collection_command(egeria_client: EgeriaTech, txt: str,
1067
- directive: str = "display") -> Optional[str]:
1064
+ directive: str = "display") -> Optional[str]:
1068
1065
  """
1069
1066
  Processes a link or unlink command to attach a collection to a resources.
1070
1067
 
@@ -1091,10 +1088,8 @@ def process_attach_collection_command(egeria_client: EgeriaTech, txt: str,
1091
1088
  effective_from = attributes.get('Effective From', {}).get('value', None)
1092
1089
  effective_to = attributes.get('Effective To', {}).get('value', None)
1093
1090
 
1094
-
1095
1091
  valid = parsed_output['valid']
1096
- exists = agreement_guid is not None and item_guid is not None
1097
-
1092
+ exists = collection_guid is not None and resource_guid is not None
1098
1093
 
1099
1094
  if directive == "display":
1100
1095
 
@@ -1108,18 +1103,18 @@ def process_attach_collection_command(egeria_client: EgeriaTech, txt: str,
1108
1103
 
1109
1104
  elif directive == "process":
1110
1105
  prop_body = {
1111
- "class" : "ResourceListProperties",
1106
+ "class": "ResourceListProperties",
1112
1107
  "resourceUse": resource_use,
1113
1108
  "resourceDescription": resource_description,
1114
1109
  "resourceProperties": resource_properties,
1115
1110
  "effectiveFrom": effective_from,
1116
1111
  "effectiveTo": effective_to
1117
- }
1112
+ }
1118
1113
 
1119
1114
  try:
1120
1115
  if object_action == "Detach":
1121
1116
  if not exists:
1122
- msg = (f" Link `{label}` does not exist! Updating result document with Link "
1117
+ msg = (f" Link `Attach Resource to Collection` does not exist! Updating result document with Link "
1123
1118
  f"object_action\n")
1124
1119
  logger.error(msg)
1125
1120
  out = parsed_output['display'].replace('Link', 'Detach', 1)
@@ -1131,21 +1126,23 @@ def process_attach_collection_command(egeria_client: EgeriaTech, txt: str,
1131
1126
  f"==> Validation of {command} completed successfully! Proceeding to apply the changes.\n"))
1132
1127
  body = set_delete_request_body(object_type, attributes)
1133
1128
 
1134
- egeria_client.detach_collection(resource_guid, collection_guid,body)
1129
+ egeria_client.detach_collection(resource_guid, collection_guid, body)
1135
1130
 
1136
- logger.success(f"===> Detached linkage between resource `{resource_guid}` and collection`{collection_guid}`\n")
1131
+ logger.success(
1132
+ f"===> Detached linkage between resource `{resource_guid}` and collection`{collection_guid}`\n")
1137
1133
  out = parsed_output['display'].replace('Unlink', 'Link', 1)
1138
1134
 
1139
1135
  return (out)
1140
1136
 
1141
1137
  elif object_action == "Link":
1142
1138
  if valid is False and exists:
1143
- msg = (f"--> Link called `{label}` already exists and result document updated changing "
1144
- f"`Link` to `Detach` in processed output\n")
1139
+ msg = (
1140
+ f"--> Link called `Attach Resource to Collection` already exists and result document updated changing "
1141
+ f"`Link` to `Detach` in processed output\n")
1145
1142
  logger.error(msg)
1146
1143
 
1147
1144
  elif valid is False:
1148
- msg = f"==>{object_type} Link with label `{label}` is not valid and can't be created"
1145
+ msg = f"==>{object_type} Link with label `Attach Resource to Collection` is not valid and can't be created"
1149
1146
  logger.error(msg)
1150
1147
  return
1151
1148
 
@@ -1154,7 +1151,7 @@ def process_attach_collection_command(egeria_client: EgeriaTech, txt: str,
1154
1151
 
1155
1152
  body['properties'] = prop_body
1156
1153
  egeria_client.attach_collection(resource_guid,
1157
- collection_guid, body)
1154
+ collection_guid, body)
1158
1155
  msg = f"==>Attached collection `{collection_guid}` to resource `{resource_guid}` \n"
1159
1156
  logger.success(msg)
1160
1157
  out = parsed_output['display'].replace('Link', 'Detach', 1)
@@ -1167,8 +1164,9 @@ def process_attach_collection_command(egeria_client: EgeriaTech, txt: str,
1167
1164
  else:
1168
1165
  return None
1169
1166
 
1167
+
1170
1168
  def process_attach_subscriber_command(egeria_client: EgeriaTech, txt: str,
1171
- directive: str = "display") -> Optional[str]:
1169
+ directive: str = "display") -> Optional[str]:
1172
1170
  """
1173
1171
  Processes a link or unlink command to attach a subscriber to a subscription.
1174
1172
 
@@ -1194,7 +1192,7 @@ def process_attach_subscriber_command(egeria_client: EgeriaTech, txt: str,
1194
1192
  subscription_guid = attributes.get('Subscription', {}).get('guid', None)
1195
1193
 
1196
1194
  valid = parsed_output['valid']
1197
-
1195
+ exists = subscriber_guid is not None and subscription_guid is not None
1198
1196
  if directive == "display":
1199
1197
 
1200
1198
  return None
@@ -1208,7 +1206,7 @@ def process_attach_subscriber_command(egeria_client: EgeriaTech, txt: str,
1208
1206
  elif directive == "process":
1209
1207
  prop_body = {
1210
1208
  "class": "DigitalSubscriberProperties",
1211
- "subscriberId": attributes.get('Subscriber Id', {}).get('value', None),
1209
+ "subscriberId": attributes.get('Subscriber Id', {}).get('value', None),
1212
1210
  "effectiveFrom": attributes.get('Effective From', {}).get('value', None),
1213
1211
  "effectiveTo": attributes.get('Effective To', {}).get('value', None),
1214
1212
  }
@@ -1216,8 +1214,9 @@ def process_attach_subscriber_command(egeria_client: EgeriaTech, txt: str,
1216
1214
  try:
1217
1215
  if object_action == "Detach":
1218
1216
  if not exists:
1219
- msg = (f" Link `{label}` does not exist! Updating result document with Link "
1220
- f"object_action\n")
1217
+ msg = (
1218
+ f" Link `Attach Subscriber to Subscription` does not exist! Updating result document with Link "
1219
+ f"object_action\n")
1221
1220
  logger.error(msg)
1222
1221
  out = parsed_output['display'].replace('Link', 'Detach', 1)
1223
1222
  return out
@@ -1228,17 +1227,19 @@ def process_attach_subscriber_command(egeria_client: EgeriaTech, txt: str,
1228
1227
  f"==> Validation of {command} completed successfully! Proceeding to apply the changes.\n"))
1229
1228
  body = set_delete_request_body(object_type, attributes)
1230
1229
 
1231
- egeria_client.detach_subscriber(subscriber_guid, subscription_guid,body)
1230
+ egeria_client.detach_subscriber(subscriber_guid, subscription_guid, body)
1232
1231
 
1233
- logger.success(f"===> Detached linkage between subscriber `{subscriber_guid}` and subscription`{subscription_guid}`\n")
1232
+ logger.success(
1233
+ f"===> Detached linkage between subscriber `{subscriber_guid}` and subscription`{subscription_guid}`\n")
1234
1234
  out = parsed_output['display'].replace('Unlink', 'Link', 1)
1235
1235
 
1236
1236
  return (out)
1237
1237
 
1238
1238
  elif object_action == "Link":
1239
1239
  if valid is False and exists:
1240
- msg = (f"--> Link called `{label}` already exists and result document updated changing "
1241
- f"`Link` to `Detach` in processed output\n")
1240
+ msg = (
1241
+ f"--> Link called `Attach Subscriber to Subscription` already exists and result document updated changing "
1242
+ f"`Link` to `Detach` in processed output\n")
1242
1243
  logger.error(msg)
1243
1244
 
1244
1245
  elif valid is False:
@@ -1251,7 +1252,7 @@ def process_attach_subscriber_command(egeria_client: EgeriaTech, txt: str,
1251
1252
 
1252
1253
  body['properties'] = prop_body
1253
1254
  egeria_client.link_subscriber(subscriber_guid,
1254
- subscription_guid, body)
1255
+ subscription_guid, body)
1255
1256
  msg = f"==>Attached subscriber `{subscriber_guid}` to subscription `{subscriber_guid}` \n"
1256
1257
  logger.success(msg)
1257
1258
  out = parsed_output['display'].replace('Link', 'Detach', 1)
@@ -1263,4 +1264,3 @@ def process_attach_subscriber_command(egeria_client: EgeriaTech, txt: str,
1263
1264
  return None
1264
1265
  else:
1265
1266
  return None
1266
-
pyegeria/__init__.py CHANGED
@@ -68,7 +68,8 @@ from .x_action_author_omvs import ActionAuthor
68
68
  from .template_manager_omvs import TemplateManager
69
69
  from .data_designer import DataDesigner
70
70
  from ._output_formats import select_output_format_set
71
- from .mcp_adapter import list_reports, describe_report, run_report
71
+ from .mcp_adapter import list_reports, describe_report, run_report, _async_run_report, _execute_egeria_call_blocking
72
+
72
73
  #
73
74
  global template_guids, integration_guids
74
75