pyegeria 5.4.0.22__py3-none-any.whl → 5.4.0.23__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 (120) hide show
  1. commands/cat/.DS_Store +0 -0
  2. commands/cat/.env +8 -0
  3. commands/cat/debug_log.log +0 -0
  4. commands/cat/list_collections.py +15 -6
  5. commands/cat/list_format_set.py +90 -85
  6. commands/cat/logs/pyegeria.log +136 -0
  7. commands/cli/debug_log.log +0 -0
  8. commands/ops/logs/pyegeria.log +0 -0
  9. md_processing/.DS_Store +0 -0
  10. md_processing/dr-egeria-outbox/Collections-2025-08-12-13-30-37.md +163 -0
  11. md_processing/dr-egeria-outbox/Collections-2025-08-12-13-35-58.md +474 -0
  12. md_processing/dr_egeria_inbox/Derive-Dr-Gov-Defs.md +8 -0
  13. md_processing/dr_egeria_inbox/Dr.Egeria Templates.md +873 -0
  14. md_processing/dr_egeria_inbox/arch_test.md +57 -0
  15. md_processing/dr_egeria_inbox/archive/dr_egeria_intro.md +254 -0
  16. md_processing/dr_egeria_inbox/archive/dr_egeria_intro_more_terms.md +696 -0
  17. md_processing/dr_egeria_inbox/archive/dr_egeria_intro_part1.md +254 -0
  18. md_processing/dr_egeria_inbox/archive/dr_egeria_intro_part2.md +298 -0
  19. md_processing/dr_egeria_inbox/archive/dr_egeria_intro_part3.md +608 -0
  20. md_processing/dr_egeria_inbox/archive/dr_egeria_intro_part4.md +94 -0
  21. md_processing/dr_egeria_inbox/archive/freddie_intro.md +284 -0
  22. md_processing/dr_egeria_inbox/archive/freddie_intro_orig.md +275 -0
  23. md_processing/dr_egeria_inbox/archive/test-term.md +110 -0
  24. md_processing/dr_egeria_inbox/cat_test.md +100 -0
  25. md_processing/dr_egeria_inbox/collections.md +39 -0
  26. md_processing/dr_egeria_inbox/data_designer_debug.log +6 -0
  27. md_processing/dr_egeria_inbox/data_designer_out.md +60 -0
  28. md_processing/dr_egeria_inbox/data_designer_search_test.md +11 -0
  29. md_processing/dr_egeria_inbox/data_field.md +54 -0
  30. md_processing/dr_egeria_inbox/data_spec.md +77 -0
  31. md_processing/dr_egeria_inbox/data_spec_test.md +2406 -0
  32. md_processing/dr_egeria_inbox/data_test.md +179 -0
  33. md_processing/dr_egeria_inbox/data_test2.md +429 -0
  34. md_processing/dr_egeria_inbox/data_test3.md +462 -0
  35. md_processing/dr_egeria_inbox/dr_egeria_data_designer_1.md +124 -0
  36. md_processing/dr_egeria_inbox/dr_egeria_intro_categories.md +168 -0
  37. md_processing/dr_egeria_inbox/dr_egeria_intro_part1.md +280 -0
  38. md_processing/dr_egeria_inbox/dr_egeria_intro_part2.md +313 -0
  39. md_processing/dr_egeria_inbox/dr_egeria_intro_part3.md +1073 -0
  40. md_processing/dr_egeria_inbox/dr_egeria_isc1.md +44 -0
  41. md_processing/dr_egeria_inbox/generated_help_report.md +9 -0
  42. md_processing/dr_egeria_inbox/glossary_list.md +5 -0
  43. md_processing/dr_egeria_inbox/glossary_search_test.md +40 -0
  44. md_processing/dr_egeria_inbox/glossary_test1.md +324 -0
  45. md_processing/dr_egeria_inbox/gov_def.md +424 -0
  46. md_processing/dr_egeria_inbox/gov_def2.md +447 -0
  47. md_processing/dr_egeria_inbox/product.md +50 -0
  48. md_processing/dr_egeria_inbox/rel.md +8 -0
  49. md_processing/dr_egeria_inbox/sb.md +119 -0
  50. md_processing/dr_egeria_inbox/solution-components.md +136 -0
  51. md_processing/dr_egeria_inbox/solution_blueprints.md +118 -0
  52. md_processing/dr_egeria_inbox/synonym_test.md +42 -0
  53. md_processing/dr_egeria_inbox/t2.md +268 -0
  54. md_processing/dr_egeria_outbox/.obsidian/app.json +1 -0
  55. md_processing/dr_egeria_outbox/.obsidian/appearance.json +1 -0
  56. md_processing/dr_egeria_outbox/.obsidian/community-plugins.json +6 -0
  57. md_processing/dr_egeria_outbox/.obsidian/core-plugins.json +31 -0
  58. md_processing/dr_egeria_outbox/.obsidian/plugins/calendar/data.json +10 -0
  59. md_processing/dr_egeria_outbox/.obsidian/plugins/calendar/main.js +4459 -0
  60. md_processing/dr_egeria_outbox/.obsidian/plugins/calendar/manifest.json +10 -0
  61. md_processing/dr_egeria_outbox/.obsidian/plugins/obsidian-kanban/data.json +3 -0
  62. md_processing/dr_egeria_outbox/.obsidian/plugins/obsidian-kanban/main.js +153 -0
  63. md_processing/dr_egeria_outbox/.obsidian/plugins/obsidian-kanban/manifest.json +11 -0
  64. md_processing/dr_egeria_outbox/.obsidian/plugins/obsidian-kanban/styles.css +1 -0
  65. md_processing/dr_egeria_outbox/.obsidian/plugins/obsidian-tasks-plugin/main.js +500 -0
  66. md_processing/dr_egeria_outbox/.obsidian/plugins/obsidian-tasks-plugin/manifest.json +12 -0
  67. md_processing/dr_egeria_outbox/.obsidian/plugins/obsidian-tasks-plugin/styles.css +1 -0
  68. md_processing/dr_egeria_outbox/.obsidian/plugins/templater-obsidian/main.js +37 -0
  69. md_processing/dr_egeria_outbox/.obsidian/plugins/templater-obsidian/manifest.json +11 -0
  70. md_processing/dr_egeria_outbox/.obsidian/plugins/templater-obsidian/styles.css +220 -0
  71. md_processing/dr_egeria_outbox/.obsidian/types.json +28 -0
  72. md_processing/dr_egeria_outbox/.obsidian/workspace.json +220 -0
  73. md_processing/dr_egeria_outbox/Untitled.canvas +1 -0
  74. md_processing/dr_egeria_outbox/friday/processed-2025-07-18 15:00-product.md +62 -0
  75. md_processing/dr_egeria_outbox/friday/processed-2025-07-18 15:13-product.md +62 -0
  76. md_processing/dr_egeria_outbox/friday/processed-2025-07-20 13:23-product.md +47 -0
  77. md_processing/dr_egeria_outbox/friday/processed-2025-08-01 11:55-data_test3.md +503 -0
  78. md_processing/dr_egeria_outbox/monday/processed-2025-07-14 12:38-data_designer_out.md +663 -0
  79. md_processing/dr_egeria_outbox/monday/processed-2025-07-21 10:52-generated_help_report.md +2744 -0
  80. md_processing/dr_egeria_outbox/monday/processed-2025-07-21 18:38-collections.md +62 -0
  81. md_processing/dr_egeria_outbox/monday/processed-2025-08-01 11:34-gov_def.md +444 -0
  82. md_processing/dr_egeria_outbox/processed-2025-08-03 16:05-glossary_list.md +37 -0
  83. md_processing/dr_egeria_outbox/sunday/processed-2025-07-20 14:55-product.md +77 -0
  84. md_processing/dr_egeria_outbox/sunday/processed-2025-07-20 15:05-product.md +75 -0
  85. md_processing/dr_egeria_outbox/sunday/processed-2025-07-20 15:11-product.md +74 -0
  86. md_processing/dr_egeria_outbox/sunday/processed-2025-07-20 20:40-collections.md +49 -0
  87. md_processing/dr_egeria_outbox/thursday/processed-2025-07-17 15:00-Derive-Dr-Gov-Defs.md +719 -0
  88. md_processing/dr_egeria_outbox/thursday/processed-2025-07-17 20:13-Derive-Dr-Gov-Defs.md +41 -0
  89. md_processing/dr_egeria_outbox/thursday/processed-2025-07-17 20:14-Derive-Dr-Gov-Defs.md +33 -0
  90. md_processing/dr_egeria_outbox/thursday/processed-2025-07-17 20:50-Derive-Dr-Gov-Defs.md +192 -0
  91. md_processing/dr_egeria_outbox/thursday/processed-2025-07-17 22:08-gov_def2.md +486 -0
  92. md_processing/dr_egeria_outbox/thursday/processed-2025-07-17 22:10-gov_def2.md +486 -0
  93. md_processing/dr_egeria_outbox/thursday/processed-2025-07-18 08:53-gov_def2.md +486 -0
  94. md_processing/dr_egeria_outbox/thursday/processed-2025-07-18 08:54-gov_def2.md +486 -0
  95. md_processing/dr_egeria_outbox/thursday/processed-2025-07-18 09:03-gov_def2.md +486 -0
  96. md_processing/dr_egeria_outbox/thursday/processed-2025-07-18 09:06-gov_def2.md +486 -0
  97. md_processing/dr_egeria_outbox/thursday/processed-2025-07-18 09:10-gov_def2.md +486 -0
  98. md_processing/dr_egeria_outbox/tuesday/processed-2025-07-16 19:15-gov_def2.md +527 -0
  99. md_processing/dr_egeria_outbox/tuesday/processed-2025-07-17 12:08-gov_def2.md +527 -0
  100. md_processing/dr_egeria_outbox/tuesday/processed-2025-07-17 14:27-gov_def2.md +485 -0
  101. md_processing/md_processing_utils/debug_log.log +0 -0
  102. md_processing/md_processing_utils/solution_architect_log.log +0 -0
  103. pyegeria/.DS_Store +0 -0
  104. pyegeria/__init__.py +2 -2
  105. pyegeria/_client_new.py +45 -49
  106. pyegeria/_output_format_models.py +22 -17
  107. pyegeria/_output_formats.py +105 -32
  108. pyegeria/collection_manager.py +154 -50
  109. pyegeria/collection_manager_omvs.py +47 -18
  110. pyegeria/egeria_cat_client.py +1 -1
  111. pyegeria/egeria_client.py +6 -0
  112. pyegeria/egeria_tech_client.py +6 -1
  113. pyegeria/governance_officer.py +2515 -0
  114. pyegeria/models.py +22 -6
  115. pyegeria/output_formatter.py +298 -79
  116. {pyegeria-5.4.0.22.dist-info → pyegeria-5.4.0.23.dist-info}/METADATA +1 -1
  117. {pyegeria-5.4.0.22.dist-info → pyegeria-5.4.0.23.dist-info}/RECORD +120 -18
  118. {pyegeria-5.4.0.22.dist-info → pyegeria-5.4.0.23.dist-info}/LICENSE +0 -0
  119. {pyegeria-5.4.0.22.dist-info → pyegeria-5.4.0.23.dist-info}/WHEEL +0 -0
  120. {pyegeria-5.4.0.22.dist-info → pyegeria-5.4.0.23.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,2515 @@
1
+ """PDX-License-Identifier: Apache-2.0
2
+ Copyright Contributors to the ODPi Egeria project.
3
+
4
+ This module provides access to the Governance Officer OMVS module.
5
+
6
+
7
+ """
8
+
9
+ import asyncio
10
+ import os
11
+ import sys
12
+ from typing import Annotated, Literal, Union
13
+ from typing import Dict, List
14
+
15
+ from loguru import logger
16
+ from pydantic import Field
17
+
18
+ from pyegeria._client_new import Client2
19
+ from pyegeria.output_formatter import (
20
+ extract_mermaid_only,
21
+ generate_output,
22
+ _extract_referenceable_properties,
23
+ populate_columns_from_properties,
24
+ get_required_relationships,
25
+ )
26
+ from pyegeria._output_formats import select_output_format_set, get_output_format_type_match
27
+
28
+ sys.path.insert(0, os.path.abspath(os.path.dirname(__file__)))
29
+ from pyegeria._exceptions_new import PyegeriaInvalidParameterException
30
+ from pyegeria._globals import NO_GUID_RETURNED
31
+ from pyegeria.load_config import get_app_config
32
+ from pyegeria.models import (SearchStringRequestBody, FilterRequestBody, NewElementRequestBody,
33
+ ReferenceableProperties, TemplateRequestBody,
34
+ UpdateElementRequestBody, UpdateStatusRequestBody, NewRelationshipRequestBody,
35
+ DeleteRequestBody)
36
+ from pyegeria.utils import dynamic_catch
37
+
38
+ GOV_DEF_PROPERTIES_LIST = ["GovernanceDefinitionProperties", "GovernanceStrategyProperties", "RegulationProperties",
39
+ "GovernanceControlProperties", "SecurityGroupProperties", "NamingStandardRuleProperties",
40
+ "CertificationTypeProperties", "LicenseTypeProperties", "GovernanceApproachProperties",
41
+ "GovernanceStrategyProperties", "GovernanceProcessingPurposeProperties",
42
+ "BusinessImperativeProperties", "RegulationArticleProperties", "ThreatProperties",]
43
+
44
+ GOV_BASIC_TYPES = ["BusinessImperative", "RegulationArticle", "Threat", "GovernancePrinciple", "GovernanceObligation",
45
+ "GovernanceApproach", "GovernanceProcessingPurpose"]
46
+
47
+
48
+ app_settings = get_app_config()
49
+ EGERIA_LOCAL_QUALIFIER = app_settings.User_Profile.egeria_local_qualifier
50
+ DEFAULT_BODY_SKELETON = {
51
+ "effective_time": None, "limitResultsByStatus": ["ACTIVE"], "asOfTime": None, "sequencingOrder": None,
52
+ "sequencingProperty": None, "filter": None,
53
+ }
54
+
55
+
56
+ def base_path(client, view_server: str):
57
+ return f"{client.platform_url}/servers/governance-officer/api/open-metadata/metadata-explorer"
58
+
59
+
60
+ class GovernanceDefinitionProperties(ReferenceableProperties):
61
+ class_: Annotated[Literal["GovernanceDefinitionProperties"], Field(alias="class")]
62
+ identifier: str | None = None
63
+ domainIdentifier: int | None = None
64
+ summary: str | None = None
65
+ scope: str | None = None
66
+ usage: str | None = None
67
+ importance: str | None = None
68
+ implications: list[str] | None = None
69
+ outcomes: list[str] | None = None
70
+ results: list[str] | None = None
71
+ userDefinedStatus: str | None = None
72
+
73
+
74
+ class GovernanceOfficer(Client2):
75
+ """GovernanceOfficer is a class that extends the Client class. The Governance Officer OMVS provides APIs for
76
+ defining and managing governance definitions.
77
+
78
+ Attributes:
79
+
80
+ view_server: str
81
+ The name of the View Server to connect to.
82
+ platform_url : str
83
+ URL of the server platform to connect to
84
+ user_id : str
85
+ The identity of the user calling the method - this sets a
86
+ default optionally used by the methods when the user
87
+ doesn't pass the user_id on a method call.
88
+ user_pwd: str
89
+ The password associated with the user_id. Defaults to None
90
+
91
+
92
+ """
93
+
94
+ def __init__(self, view_server: str, platform_url: str, user_id: str = None, user_pwd: str = None,
95
+ token: str = None, ):
96
+ self.view_server = view_server
97
+ self.platform_url = platform_url
98
+ self.user_id = user_id
99
+ self.user_pwd = user_pwd
100
+
101
+ Client2.__init__(self, view_server, platform_url, user_id=user_id, user_pwd=user_pwd, token=token)
102
+ self.url_marker = "governance-officer"
103
+
104
+ #
105
+ # Extract properties functions
106
+ #
107
+ def _generate_governance_definition_output(self, elements: list | dict, search_string: str, element_type_name: str = None,
108
+ output_format: str = 'DICT', output_format_set: dict | str = None
109
+ ) -> str | list:
110
+ """
111
+ Generate output for governance definitions in the specified format, using output format sets.
112
+
113
+ Args:
114
+ elements: Dictionary or list of dictionaries containing governance definition elements
115
+ search_string: The search string used to find the elements
116
+ output_format: The desired output format (MD, FORM, REPORT, LIST, DICT, MERMAID, HTML)
117
+ output_format_set: Optional format set name or structure to control columns
118
+
119
+ Returns:
120
+ Formatted output as string or list of dictionaries
121
+ """
122
+ # Ensure elements handled consistently for MERMAID
123
+ if output_format == "MERMAID":
124
+ return extract_mermaid_only(elements)
125
+
126
+ entity_type = element_type_name if element_type_name else "Governance Definition"
127
+ # Resolve columns_struct via output format sets
128
+ if output_format_set:
129
+ if isinstance(output_format_set, str):
130
+ output_formats = select_output_format_set(output_format_set, output_format)
131
+ elif isinstance(output_format_set, dict):
132
+ output_formats = get_output_format_type_match(output_format_set, output_format)
133
+ else:
134
+ output_formats = None
135
+ else:
136
+ # Default to the Governance Definitions format set
137
+ output_formats = select_output_format_set("Governance Definitions", output_format)
138
+ if output_formats is None:
139
+ output_formats = select_output_format_set("Default", output_format)
140
+
141
+ logger.trace(f"Executing generate_governance_definition_output: {output_formats}")
142
+ return generate_output(
143
+ elements=elements,
144
+ search_string=search_string,
145
+ entity_type=entity_type,
146
+ output_format=output_format,
147
+ extract_properties_func=self._extract_gov_def_properties,
148
+ get_additional_props_func=None,
149
+ columns_struct=output_formats,
150
+ )
151
+
152
+ #
153
+ #
154
+ #
155
+
156
+ def _extract_gov_def_properties(self, element: dict, columns_struct: dict) -> dict:
157
+ """
158
+ Extract and populate governance definition properties into columns_struct.
159
+
160
+ This follows the columns_struct pattern: fill from element.properties (camelCase), overlay header
161
+ attributes, and derive any relationship-based columns that are explicitly requested.
162
+
163
+ Args:
164
+ element: The governance definition element
165
+ columns_struct: The columns structure to populate
166
+
167
+ Returns:
168
+ dict: columns_struct with populated 'value' fields
169
+ """
170
+ col_data = populate_columns_from_properties(element, columns_struct)
171
+ columns_list = col_data.get('formats', {}).get('columns', [])
172
+
173
+ # Header-derived values (GUID, type_name, etc.)
174
+ header_props = _extract_referenceable_properties(element)
175
+ for column in columns_list:
176
+ key = column.get('key')
177
+ if key in header_props:
178
+ column['value'] = header_props.get(key)
179
+ elif isinstance(key, str) and key.lower() == 'guid':
180
+ column['value'] = header_props.get('GUID')
181
+
182
+ # Populate requested relationship-based columns generically
183
+ col_data = get_required_relationships(element, col_data)
184
+
185
+ # Mermaid graph if requested
186
+ for column in columns_list:
187
+ if column.get('key') == 'mermaid':
188
+ column['value'] = element.get('mermaidGraph', '') or ''
189
+ break
190
+
191
+ return col_data
192
+
193
+ def _extract_gov_def_list(self, element: Union[Dict, List[Dict]]) -> List[Dict]:
194
+ """
195
+ Normalize for a list of dictionaries.
196
+ Args:
197
+ element: Dict or List
198
+
199
+ Returns:
200
+ list of Dict
201
+
202
+ """
203
+ if isinstance(element, dict):
204
+ return [self._extract_gov_def_properties(element)]
205
+ elif isinstance(element, list):
206
+ def_list = []
207
+ for i in range(len(element)):
208
+ def_list.append(self._extract_gov_def_properties(element[i]))
209
+ return def_list
210
+ else:
211
+ return []
212
+
213
+ def _extract_solution_components_properties(self, element: Union[Dict, List[Dict]]) -> dict:
214
+ """
215
+ Extract properties from a solution component element.
216
+
217
+ Args:
218
+ element: Dictionary containing element data
219
+
220
+ Returns:
221
+ Dictionary with extracted properties
222
+ """
223
+
224
+ guid = element['elementHeader'].get("guid", None)
225
+ properties = element.get('glossaryCategoryProperties', element.get('properties', {}))
226
+ display_name = properties.get("displayName", None)
227
+ description = properties.get("description", None)
228
+ component_type = properties.get("solutionComponentType", properties.get("componentType", None))
229
+ version = properties.get("version", None)
230
+ qualified_name = properties.get("qualifiedName", None)
231
+
232
+ # Extract extended properties
233
+ extended_props = properties.get("extendedProperties", None)
234
+ extended_props_md = ""
235
+ if extended_props:
236
+ for key in extended_props.keys():
237
+ extended_props_md += "{" + f" {key}: {extended_props[key]}" + " }, "
238
+
239
+ # Extract additional properties
240
+ additional_props = properties.get("additionalProperties", None)
241
+ additional_props_md = ""
242
+ if additional_props:
243
+ for key in additional_props.keys():
244
+ additional_props_md += "{" + f" {key}: {additional_props[key]}" + " }, "
245
+
246
+ # Extract blueprints
247
+ blueprints_md = ""
248
+ blueprints = element.get('blueprints', None)
249
+ if blueprints:
250
+ for blueprint in blueprints:
251
+ if 'relatedElement' in blueprint:
252
+ bp_q_name = blueprint["relatedElement"]['properties']['qualifiedName']
253
+ blueprints_md += f" {bp_q_name}, \n"
254
+ elif 'blueprint' in blueprint:
255
+ bp_prop = blueprint['blueprint']['properties']
256
+ bp_name = bp_prop.get("displayName", None)
257
+ bp_desc = bp_prop.get("description", None)
258
+ blueprints_md += "{" + f" {bp_name}:\t {bp_desc}" + " },\n"
259
+
260
+ # Extract parent components
261
+ parent_comp_md = ""
262
+ context = element.get("context", None)
263
+ if context:
264
+ parent_components = element.get('parentComponents', None)
265
+ if parent_components:
266
+ for parent_component in parent_components:
267
+ parent_comp_prop = parent_component['parentComponent']['properties']
268
+ parent_comp_name = parent_comp_prop.get("name", None)
269
+ parent_comp_desc = parent_comp_prop.get("description", None)
270
+ parent_comp_md += f" {parent_comp_name}"
271
+
272
+ # Extract sub components
273
+ sub_comp_md = ""
274
+ sub_components = element.get('subComponents', None)
275
+ if sub_components:
276
+ for sub_component in sub_components:
277
+ sub_comp_prop = sub_component['properties']
278
+ sub_comp_name = sub_comp_prop.get("displayName", None)
279
+ sub_comp_desc = sub_comp_prop.get("description", None)
280
+ sub_comp_md += f" {sub_comp_name}"
281
+
282
+ comp_graph = element.get('mermaidGraph', None)
283
+
284
+ return {
285
+ 'guid': guid, 'qualified_name': qualified_name, 'display_name': display_name, 'description': description,
286
+ 'component_type': component_type, 'version': version, 'blueprints': blueprints_md,
287
+ 'parent_components': parent_comp_md, 'sub_components': sub_comp_md,
288
+ 'additional_properties': additional_props_md, 'extended_properties': extended_props_md,
289
+ 'mermaid_graph': comp_graph
290
+ }
291
+
292
+ #
293
+ # Markdown output support
294
+ #
295
+ @dynamic_catch
296
+ async def _async_create_governance_definition(self, body: dict | NewElementRequestBody) -> str:
297
+ """ Create a governance definition. There are many kinds of governance definition and
298
+ while the overall body structure is the same, many will have different property
299
+ structures nested within them. A list is shown in the notes below.
300
+
301
+ It may be of type:
302
+ * BusinessImperative
303
+ * RegulationArticle
304
+ * Threat
305
+ * GovernancePrinciple
306
+ * GovernanceObligation
307
+ * GovernanceApproach
308
+ * GovernanceProcessingPurpose
309
+ The type is added to the "typeName" property.
310
+
311
+ Async Version.
312
+
313
+ Parameters
314
+ ----------
315
+ body: dict
316
+ A dictionary containing the definition of the governance definition to create.
317
+
318
+ Returns
319
+ -------
320
+
321
+ str - guid of the definition created.
322
+
323
+ Raises
324
+ ------
325
+ InvalidParameterException
326
+ one of the parameters is null or invalid or
327
+ PropertyServerException
328
+ There is a problem adding the element properties to the metadata repository or
329
+ UserNotAuthorizedException
330
+ the requesting user is not authorized to issue this request.
331
+
332
+ Notes
333
+ ----
334
+ Governance definitions can be simple or anchored to a parent element - Both are shown below. depending on
335
+ which structure is used for the body.
336
+
337
+ Many kinds of governance definition have additional properties added. Details are described in the UML diagrams
338
+ on the website and summarized in the table below which shows the property class name and which types
339
+ of governance definitions use it. The test_governance_officer module offers some usage examples.
340
+
341
+ Property Class Name | Definition Types
342
+ ===================================================================================
343
+ GovernanceDefinitionProperties | BusinessImperative, RegulationArticle, Threat, GovernanceProcessingPurpose,
344
+ | GovernancePrinciple, GovernanceObligation, GovernanceApproach
345
+ GovernanceStrategyProperties | GovernanceStrategy
346
+ RegulationProperties | Regulation
347
+ GovernanceControlProperties | GovernanceControl
348
+ SecurityGroupProperties | SecurityGroup
349
+ NamingStandardRuleProperties | NamingStandardRule
350
+ CertificationTypeProperties | CertificationType
351
+ LicenseTyoeProperties | LicenseType
352
+ GovernanceApproachProperties | GovernanceApproach
353
+
354
+
355
+ Generic simple governance body structure:
356
+ {
357
+ "class": "NewElementRequestBody",
358
+ "properties": {
359
+ "class" : "GovernanceDefinitionProperties",
360
+ "typeName" : "enter the type of the governance definition",
361
+ "domainIdentifier": 0,
362
+ "documentIdentifier": "add unique name here",
363
+ "title": "add short name here",
364
+ "summary": "add summary here",
365
+ "description": "add description here",
366
+ "scope": "add scope of effect for this definition",
367
+ "importance": "add importance for this definition",
368
+ "implications": [],
369
+ "outcomes": [],
370
+ "results": [],
371
+ "additionalProperties": {
372
+ "property1" : "propertyValue1",
373
+ "property2" : "propertyValue2"
374
+ }
375
+ },
376
+ "initialStatus": "DRAFT"
377
+ }
378
+
379
+ Generic governance Body structure with Parent:
380
+ {
381
+ "class" : "NewGovernanceDefinitionRequestBody",
382
+ "externalSourceGUID": "add guid here",
383
+ "externalSourceName": "add qualified name here",
384
+ "effectiveTime" : "{{$isoTimestamp}}",
385
+ "forLineage" : false,
386
+ "forDuplicateProcessing" : false,
387
+ "anchorGUID" : "add guid here",
388
+ "isOwnAnchor": false,
389
+ "parentGUID": "add guid here",
390
+ "parentRelationshipTypeName": "add type name here",
391
+ "parentRelationshipProperties": {
392
+ "class": "ElementProperties",
393
+ "propertyValueMap" : {
394
+ "description" : {
395
+ "class": "PrimitiveTypePropertyValue",
396
+ "typeName": "string",
397
+ "primitiveValue" : "New description"
398
+ }
399
+ }
400
+ },
401
+ "parentAtEnd1": false,
402
+ "properties": {
403
+ "class" : "GovernanceDefinitionProperties",
404
+ "typeName" : "enter the type of the governance definition",
405
+ "domainIdentifier": 0,
406
+ "documentIdentifier": "add unique name here",
407
+ "title": "add short name here",
408
+ "summary": "add summary here",
409
+ "description": "add description here",
410
+ "scope": "add scope of effect for this definition",
411
+ "importance": "add importance for this definition",
412
+ "implications": [],
413
+ "outcomes": [],
414
+ "results": [],
415
+ "additionalProperties": {
416
+ "property1" : "propertyValue1",
417
+ "property2" : "propertyValue2"
418
+ },
419
+ "effectiveFrom": "{{$isoTimestamp}}",
420
+ "effectiveTo": "{{$isoTimestamp}}"
421
+ },
422
+ "initialStatus": "DRAFT"
423
+ }
424
+
425
+ """
426
+ url = (f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/"
427
+ f"{self.url_marker}/governance-definitions")
428
+ return await self._async_create_element_body_request(url, GOV_DEF_PROPERTIES_LIST, body)
429
+
430
+ @dynamic_catch
431
+ def create_governance_definition(self, body: dict | NewElementRequestBody) -> str:
432
+ """ Create a governance definition. It may be of type:
433
+ * BusinessImperative
434
+ * RegulationArticle
435
+ * Threat
436
+ * GovernancePrinciple
437
+ * GovernanceObligation
438
+ * GovernanceApproach
439
+ * GovernanceProcessingPurpose
440
+ The type is added to the "typeName" property.
441
+
442
+ Parameters
443
+ ----------
444
+
445
+ body: dict
446
+ A dictionary containing the definition of the governance definition to create.
447
+
448
+ Returns
449
+ -------
450
+
451
+ str - guid of the definition created.
452
+
453
+ Raises
454
+ ------
455
+ InvalidParameterException
456
+ one of the parameters is null or invalid or
457
+ PropertyServerException
458
+ There is a problem adding the element properties to the metadata repository or
459
+ UserNotAuthorizedException
460
+ the requesting user is not authorized to issue this request.
461
+
462
+ Notes
463
+ ----
464
+ Governance definitions can be simple or anchored to a parent element - Both are shown below. depending on
465
+ which structure is used for the body.
466
+
467
+ Many kinds of governance definition have additional properties added. Details are described in the UML diagrams
468
+ on the website and summarized in the table below which shows the property class name and which types
469
+ of governance definitions use it. The test_governance_officer module offers some usage examples.
470
+
471
+ Property Class Name | Definition Types
472
+ ===================================================================================
473
+ GovernanceDefinitionProperties | BusinessImperative, RegulationArticle, Threat, GovernanceProcessingPurpose,
474
+ | GovernancePrinciple, GovernanceObligation, GovernanceApproach
475
+ GovernanceStrategyProperties | GovernanceStrategy
476
+ RegulationProperties | Regulation
477
+ GovernanceControlProperties | GovernanceControl
478
+ SecurityGroupProperties | SecurityGroup
479
+ NamingStandardRuleProperties | NamingStandardRule
480
+ CertificationTypeProperties | CertificationType
481
+ LicenseTyoeProperties | LicenseType
482
+ GovernanceApproachProperties | GovernanceApproach
483
+
484
+ Simple body structure:
485
+ {
486
+ "class": "NewElementRequestBody",
487
+ "properties": {
488
+ "class" : "GovernanceDefinitionProperties",
489
+ "typeName" : "enter the type of the governance definition",
490
+ "domainIdentifier": 0,
491
+ "documentIdentifier": "add unique name here",
492
+ "title": "add short name here",
493
+ "summary": "add summary here",
494
+ "description": "add description here",
495
+ "scope": "add scope of effect for this definition",
496
+ "importance": "add importance for this definition",
497
+ "implications": [],
498
+ "outcomes": [],
499
+ "results": [],
500
+ "additionalProperties": {
501
+ "property1" : "propertyValue1",
502
+ "property2" : "propertyValue2"
503
+ }
504
+ },
505
+ "initialStatus": "DRAFT"
506
+ }
507
+
508
+ Body structure with Parent:
509
+ {
510
+ "class" : "NewGovernanceDefinitionRequestBody",
511
+ "externalSourceGUID": "add guid here",
512
+ "externalSourceName": "add qualified name here",
513
+ "effectiveTime" : "{{$isoTimestamp}}",
514
+ "forLineage" : false,
515
+ "forDuplicateProcessing" : false,
516
+ "anchorGUID" : "add guid here",
517
+ "isOwnAnchor": false,
518
+ "parentGUID": "add guid here",
519
+ "parentRelationshipTypeName": "add type name here",
520
+ "parentRelationshipProperties": {
521
+ "class": "ElementProperties",
522
+ "propertyValueMap" : {
523
+ "description" : {
524
+ "class": "PrimitiveTypePropertyValue",
525
+ "typeName": "string",
526
+ "primitiveValue" : "New description"
527
+ }
528
+ }
529
+ },
530
+ "parentAtEnd1": false,
531
+ "properties": {
532
+ "class" : "GovernanceDefinitionProperties",
533
+ "typeName" : "enter the type of the governance definition",
534
+ "domainIdentifier": 0,
535
+ "documentIdentifier": "add unique name here",
536
+ "title": "add short name here",
537
+ "summary": "add summary here",
538
+ "description": "add description here",
539
+ "scope": "add scope of effect for this definition",
540
+ "importance": "add importance for this definition",
541
+ "implications": [],
542
+ "outcomes": [],
543
+ "results": [],
544
+ "additionalProperties": {
545
+ "property1" : "propertyValue1",
546
+ "property2" : "propertyValue2"
547
+ },
548
+ "effectiveFrom": "{{$isoTimestamp}}",
549
+ "effectiveTo": "{{$isoTimestamp}}"
550
+ },
551
+ "initialStatus": "DRAFT"
552
+ }
553
+
554
+
555
+ """
556
+
557
+ loop = asyncio.get_event_loop()
558
+ response = loop.run_until_complete(self._async_create_governance_definition(body))
559
+ return response
560
+
561
+ @dynamic_catch
562
+ async def _async_create_governance_definition_from_template(self, body: dict | TemplateRequestBody) -> str:
563
+ """ Create a new metadata element to represent a governance definition using an existing metadata element
564
+ as a template. The template defines additional classifications and relationships that should be added to
565
+ the new element. Async version.
566
+
567
+ Parameters
568
+ ----------
569
+
570
+ body: dict
571
+ A dictionary containing the definition of the governance definition to create.
572
+
573
+ Returns
574
+ -------
575
+
576
+ str - guid of the governance definition created.
577
+
578
+ Raises
579
+ ------
580
+ InvalidParameterException
581
+ one of the parameters is null or invalid or
582
+ PropertyServerException
583
+ There is a problem adding the element properties to the metadata repository or
584
+ UserNotAuthorizedException
585
+ the requesting user is not authorized to issue this request.
586
+
587
+ Notes
588
+ ----
589
+ https://egeria-project.org/concepts/governance-definition
590
+
591
+ Body structure:
592
+
593
+ {
594
+ "class" : "TemplateRequestBody",
595
+ "externalSourceGUID": "add guid here",
596
+ "externalSourceName": "add qualified name here",
597
+ "effectiveTime" : "{{$isoTimestamp}}",
598
+ "forLineage" : false,
599
+ "forDuplicateProcessing" : false,
600
+ "anchorGUID" : "add guid here",
601
+ "isOwnAnchor": false,
602
+ "parentGUID": "add guid here",
603
+ "parentRelationshipTypeName": "add type name here",
604
+ "parentRelationshipProperties": {
605
+ "class": "ElementProperties",
606
+ "propertyValueMap" : {
607
+ "description" : {
608
+ "class": "PrimitiveTypePropertyValue",
609
+ "typeName": "string",
610
+ "primitiveValue" : "New description"
611
+ }
612
+ }
613
+ },
614
+ "parentAtEnd1": false,
615
+ "templateGUID": "add guid here",
616
+ "replacementProperties": {
617
+ "class": "ElementProperties",
618
+ "propertyValueMap" : {
619
+ "description" : {
620
+ "class": "PrimitiveTypePropertyValue",
621
+ "typeName": "string",
622
+ "primitiveValue" : "New description"
623
+ }
624
+ }
625
+ },
626
+ "placeholderPropertyValues": {
627
+ "placeholder1" : "propertyValue1",
628
+ "placeholder2" : "propertyValue2"
629
+ }
630
+ }
631
+
632
+ """
633
+ url = (f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/"
634
+ f"{self.url_marker}/governance-definitions/from-template")
635
+
636
+ if isinstance(body, TemplateRequestBody):
637
+ validated_body = body
638
+ elif isinstance(body, dict):
639
+ validated_body = self._template_request_adapter.validate_python(body)
640
+ else:
641
+ raise PyegeriaInvalidParameterException(
642
+ additional_info={"reason": "body must be a dict or TemplateRequestBody"})
643
+
644
+ json_body = validated_body.model_dump_json(indent=2, exclude_none=True)
645
+ logger.info(json_body)
646
+ resp = await self._async_make_request("POST", url, json_body, is_json=True)
647
+ logger.info(f"Created governance definition from template with GUID: {resp.json().get('guid')}")
648
+ return resp.json().get("guid", NO_GUID_RETURNED)
649
+
650
+ @dynamic_catch
651
+ def create_governance_definition_from_template(self, body: dict | TemplateRequestBody) -> str:
652
+ """ Create a new metadata element to represent a governance definition using an existing metadata element
653
+ as a template. The template defines additional classifications and relationships that should be added to
654
+ the new element.
655
+
656
+ Parameters
657
+ ----------
658
+
659
+ body: dict
660
+ A dictionary containing the definition of the governance definition to create.
661
+
662
+ Returns
663
+ -------
664
+
665
+ str - guid of the governance definition created.
666
+
667
+ Raises
668
+ ------
669
+ InvalidParameterException
670
+ one of the parameters is null or invalid or
671
+ PropertyServerException
672
+ There is a problem adding the element properties to the metadata repository or
673
+ UserNotAuthorizedException
674
+ the requesting user is not authorized to issue this request.
675
+
676
+ Notes
677
+ ----
678
+ https://egeria-project.org/concepts/governance-definition
679
+
680
+ Body structure:
681
+
682
+ {
683
+ "class" : "TemplateRequestBody",
684
+ "externalSourceGUID": "add guid here",
685
+ "externalSourceName": "add qualified name here",
686
+ "effectiveTime" : "{{$isoTimestamp}}",
687
+ "forLineage" : false,
688
+ "forDuplicateProcessing" : false,
689
+ "anchorGUID" : "add guid here",
690
+ "isOwnAnchor": false,
691
+ "parentGUID": "add guid here",
692
+ "parentRelationshipTypeName": "add type name here",
693
+ "parentRelationshipProperties": {
694
+ "class": "ElementProperties",
695
+ "propertyValueMap" : {
696
+ "description" : {
697
+ "class": "PrimitiveTypePropertyValue",
698
+ "typeName": "string",
699
+ "primitiveValue" : "New description"
700
+ }
701
+ }
702
+ },
703
+ "parentAtEnd1": false,
704
+ "templateGUID": "add guid here",
705
+ "replacementProperties": {
706
+ "class": "ElementProperties",
707
+ "propertyValueMap" : {
708
+ "description" : {
709
+ "class": "PrimitiveTypePropertyValue",
710
+ "typeName": "string",
711
+ "primitiveValue" : "New description"
712
+ }
713
+ }
714
+ },
715
+ "placeholderPropertyValues": {
716
+ "placeholder1" : "propertyValue1",
717
+ "placeholder2" : "propertyValue2"
718
+ }
719
+ }
720
+
721
+ """
722
+
723
+ loop = asyncio.get_event_loop()
724
+ response = loop.run_until_complete(self._async_create_governance_definition_from_template(body))
725
+ return response
726
+
727
+ @dynamic_catch
728
+ async def _async_update_governance_definition(self, guid: str, body: dict | UpdateElementRequestBody) -> None:
729
+ """ Update a governance definition."""
730
+
731
+ """ Update the properties of a governance definition. Async Version.
732
+
733
+ Parameters
734
+ ----------
735
+ guid: str
736
+ guid of the governance definition to update.
737
+ body: dict
738
+ A dictionary containing the updates to the governance definition.
739
+ replace_all_properties: bool, optional
740
+ Whether to replace all properties with those provided in the body or to merge with existing properties.
741
+
742
+ Returns
743
+ -------
744
+
745
+ None
746
+
747
+ Raises
748
+ ------
749
+ InvalidParameterException
750
+ one of the parameters is null or invalid or
751
+ PropertyServerException
752
+ There is a problem adding the element properties to the metadata repository or
753
+ UserNotAuthorizedException
754
+ the requesting user is not authorized to issue this request.
755
+
756
+ Notes
757
+ ----
758
+
759
+ Body structure:
760
+ {
761
+ "class" : "UpdateElementRequestBody",
762
+ "externalSourceGUID": "add guid here",
763
+ "externalSourceName": "add qualified name here",
764
+ "effectiveTime" : "{{$isoTimestamp}}",
765
+ "forLineage" : false,
766
+ "forDuplicateProcessing" : false,
767
+ "properties": {
768
+ "class" : "GovernanceDefinitionProperties",
769
+ "typeName" : "Add type name here",
770
+ "qualifiedName": "add unique name here",
771
+ "displayName": "add short name here",
772
+ "description": "add description here",
773
+ "namespace": "add namespace for this structure",
774
+ "versionIdentifier": "add version for this structure",
775
+ "additionalProperties": {
776
+ "property1" : "propertyValue1",
777
+ "property2" : "propertyValue2"
778
+ },
779
+ "extendedProperties": {
780
+ "property1" : "propertyValue1",
781
+ "property2" : "propertyValue2"
782
+ },
783
+ "effectiveFrom": "{{$isoTimestamp}}",
784
+ "effectiveTo": "{{$isoTimestamp}}"
785
+ }
786
+ }
787
+ """
788
+
789
+ url = (
790
+ f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/"
791
+ f"{self.url_marker}/governance-definitions/"
792
+ f"{guid}/update")
793
+ await self._async_update_element_body_request(url, GOV_DEF_PROPERTIES_LIST, body)
794
+
795
+ @dynamic_catch
796
+ def _async_update_governance_definition(self, guid: str, body: dict | UpdateElementRequestBody) -> None:
797
+ """ Update a governance definition. Async Version."""
798
+
799
+ def update_governance_definition(self, guid: str, body: dict | UpdateStatusRequestBody) -> None:
800
+ """ Update the properties of a governance definition.
801
+
802
+ Parameters
803
+ ----------
804
+ guid: str
805
+ guid of the governance definition to update.
806
+ body: dict
807
+ A dictionary containing the updates to the governance definition.
808
+ replace_all_properties: bool, optional
809
+ Whether to replace all properties with those provided in the body or to merge with existing properties.
810
+
811
+ Returns
812
+ -------
813
+
814
+ None
815
+
816
+ Raises
817
+ ------
818
+ InvalidParameterException
819
+ one of the parameters is null or invalid or
820
+ PropertyServerException
821
+ There is a problem adding the element properties to the metadata repository or
822
+ UserNotAuthorizedException
823
+ the requesting user is not authorized to issue this request.
824
+
825
+ Notes
826
+ ----
827
+
828
+ Body structure:
829
+ {
830
+ "class" : "UpdateElementRequestBody",
831
+ "externalSourceGUID": "add guid here",
832
+ "externalSourceName": "add qualified name here",
833
+ "effectiveTime" : "{{$isoTimestamp}}",
834
+ "forLineage" : false,
835
+ "forDuplicateProcessing" : false,
836
+ "properties": {
837
+ "class" : "GovernanceDefinitionProperties",
838
+ "typeName" : "Add type name here",
839
+ "qualifiedName": "add unique name here",
840
+ "displayName": "add short name here",
841
+ "description": "add description here",
842
+ "namespace": "add namespace for this structure",
843
+ "versionIdentifier": "add version for this structure",
844
+ "additionalProperties": {
845
+ "property1" : "propertyValue1",
846
+ "property2" : "propertyValue2"
847
+ },
848
+ "extendedProperties": {
849
+ "property1" : "propertyValue1",
850
+ "property2" : "propertyValue2"
851
+ },
852
+ "effectiveFrom": "{{$isoTimestamp}}",
853
+ "effectiveTo": "{{$isoTimestamp}}"
854
+ }
855
+ }
856
+ """
857
+ loop = asyncio.get_event_loop()
858
+ loop.run_until_complete(self._async_update_governance_definition(guid, body))
859
+
860
+ @dynamic_catch
861
+ async def _async_update_governance_definition_status(self, guid: str, status: str = None,
862
+ body: dict | UpdateStatusRequestBody = None) -> None:
863
+ """ Update the status of a governance definition. Async Version.
864
+
865
+ Parameters
866
+ ----------
867
+ guid: str
868
+ guid of the governance definition to update.
869
+ status: str, optional, default is None
870
+ The status to update the governance definition to. Superseded by the body definition if present.
871
+ body: dict
872
+ A dictionary containing the updates to the governance definition.
873
+
874
+ Returns
875
+ -------
876
+
877
+ None
878
+
879
+ Raises
880
+ ------
881
+ InvalidParameterException
882
+ one of the parameters is null or invalid or
883
+ PropertyServerException
884
+ There is a problem adding the element properties to the metadata repository or
885
+ UserNotAuthorizedException
886
+ the requesting user is not authorized to issue this request.
887
+
888
+ Notes
889
+ ----
890
+
891
+ Body structure:
892
+ {
893
+ "class": "UpdateGovernanceDefinitionRequestBody",
894
+ "externalSourceGUID": "add guid here",
895
+ "externalSourceName": "add qualified name here",
896
+ "effectiveTime": "{{$isoTimestamp}}",
897
+ "forLineage": false,
898
+ "forDuplicateProcessing": false,
899
+ "status": "ACTIVE"
900
+ }
901
+ """
902
+
903
+ url = (
904
+ f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/{self.url_marker}/governance-defnitions/"
905
+ f"{guid}/update-status")
906
+
907
+ await self._async_update_status_request(url, status, body)
908
+
909
+ def update_governance_definition_status(self, guid: str, status: str = None,
910
+ body: dict | UpdateStatusRequestBody = None) -> None:
911
+ """ Update the status of a governance definition.
912
+
913
+ Parameters
914
+ ----------
915
+ guid: str
916
+ guid of the information governance definition to update.
917
+ status: str, optional, default is None
918
+ The status to update the governance definition to. Superseded by the body definition if present.
919
+ body: dict
920
+ A dictionary containing the updates to the governance definition.
921
+
922
+ Returns
923
+ -------
924
+
925
+ None
926
+
927
+ Raises
928
+ ------
929
+ InvalidParameterException
930
+ one of the parameters is null or invalid or
931
+ PropertyServerException
932
+ There is a problem adding the element properties to the metadata repository or
933
+ UserNotAuthorizedException
934
+ the requesting user is not authorized to issue this request.
935
+
936
+ Notes
937
+ ----
938
+
939
+ Body structure:
940
+ {
941
+ "class" : "UpdateGovernanceDefinitionRequestBody",
942
+ "externalSourceGUID": "add guid here",
943
+ "externalSourceName": "add qualified name here",
944
+ "effectiveTime" : "{{$isoTimestamp}}",
945
+ "forLineage" : false,
946
+ "forDuplicateProcessing" : false,
947
+ "status": "ACTIVE"
948
+ }
949
+ """
950
+ loop = asyncio.get_event_loop()
951
+ loop.run_until_complete(self._async_update_governance_definition_status(guid, status, body))
952
+
953
+ @dynamic_catch
954
+ async def _async_delete_governance_definition(self, definition_guid: str,
955
+ body: dict | DeleteRequestBody = None,
956
+ cascade: bool = False) -> None:
957
+ """ Delete a governance definition. Async Version.
958
+
959
+ Parameters
960
+ ----------
961
+ definition_guid: str
962
+ The guid of the governance definition to delete.
963
+
964
+ cascade: bool, optional, defaults to True
965
+ If true, a cascade delete is performed.
966
+
967
+ body: dict DeleteRequestBodyt, optional, default = None
968
+ A dict representing the details of the relationship.
969
+
970
+ Returns
971
+ -------
972
+ Nothing
973
+
974
+ Raises
975
+ ------
976
+ PyegeriaInvalidParameterException
977
+ If the client passes incorrect parameters on the request - such as bad URLs or invalid values
978
+ ValidationException
979
+ Raised by pydantic when the request body is invalid.
980
+ NotAuthorizedException
981
+ The principle specified by the user_id does not have authorization for the requested action
982
+
983
+ Notes
984
+ _____
985
+ JSON Structure looks like:
986
+ {
987
+ "class" : "MetadataSourceRequestBody",
988
+ "externalSourceGUID": "add guid here",
989
+ "externalSourceName": "add qualified name here",
990
+ "effectiveTime" : "{{$isoTimestamp}}",
991
+ "forLineage" : false,
992
+ "forDuplicateProcessing" : false
993
+ }
994
+ """
995
+ url = (
996
+ f"{self.platform_url}/s"
997
+ f"ervers/{self.view_server}/api/open-metadata/governance-officer/governance-definitions/"
998
+ f"{definition_guid}/delete")
999
+ await self._async_delete_request(url, body, cascade)
1000
+ logger.info(f"Deleted collection {definition_guid} with cascade {cascade}")
1001
+
1002
+ def delete_governance_definition(self, definition_guid: str, body: dict | DeleteRequestBody = None,
1003
+ cascade: bool = False) -> None:
1004
+ """Delete a governance definition.
1005
+
1006
+ Parameters
1007
+ ----------
1008
+ definition_guid: str
1009
+ The guid of the governance definition to delete.
1010
+
1011
+ cascade: bool, optional, defaults to True
1012
+ If true, a cascade delete is performed.
1013
+
1014
+ body: dict DeleteRequestBodyt, optional, default = None
1015
+ A dict representing the details of the relationship.
1016
+
1017
+ Returns
1018
+ -------
1019
+ Nothing
1020
+
1021
+ Raises
1022
+ ------
1023
+ PyegeriaInvalidParameterException
1024
+ If the client passes incorrect parameters on the request - such as bad URLs or invalid values
1025
+ ValidationException
1026
+ Raised by pydantic when the request body is invalid.
1027
+ NotAuthorizedException
1028
+ The principle specified by the user_id does not have authorization for the requested action
1029
+
1030
+ Notes
1031
+ _____
1032
+ JSON Structure looks like:
1033
+ {
1034
+ "class" : "MetadataSourceRequestBody",
1035
+ "externalSourceGUID": "add guid here",
1036
+ "externalSourceName": "add qualified name here",
1037
+ "effectiveTime" : "{{$isoTimestamp}}",
1038
+ "forLineage" : false,
1039
+ "forDuplicateProcessing" : false
1040
+ }
1041
+ """
1042
+ loop = asyncio.get_event_loop()
1043
+ loop.run_until_complete(self._async_delete_governance_definition(definition_guid, body, cascade))
1044
+
1045
+ @dynamic_catch
1046
+ async def _async_link_peer_definitions(self, definition_guid1: str, relationship_type: str, definition_guid2: str,
1047
+ body: dict = None | NewRelationshipRequestBody) -> None:
1048
+ """ Attach two peer governance definitions. Request body is optional. Async Version.
1049
+
1050
+ Parameters
1051
+ ----------
1052
+ definition_guid1: str
1053
+ guid of the first governance definition to link.
1054
+ definition_guid2: str
1055
+ guid of the second governance definition to link.
1056
+ relationship_type: str
1057
+ Relationship type name linking the governance definitions..
1058
+ body: dict
1059
+ The body describing the link between the two segments.
1060
+
1061
+ Returns
1062
+ -------
1063
+ None
1064
+
1065
+ Raises
1066
+ ------
1067
+ InvalidParameterException
1068
+ one of the parameters is null or invalid or
1069
+ PropertyServerException
1070
+ There is a problem adding the element properties to the metadata repository or
1071
+ UserNotAuthorizedException
1072
+ the requesting user is not authorized to issue this request.
1073
+
1074
+ Notes
1075
+ ----
1076
+ The relationshipTypeNme can be:
1077
+ * GovernanceDriverLink between governance drivers (GovernanceStrategy, BusinessImperative, Regulation,
1078
+ RegulationArticle, Threat).
1079
+ * GovernancePolicyLink between governance policies (GovernancePrinciple, GovernanceObligation,
1080
+ GovernanceApproach).
1081
+ * GovernanceControlLink between governance controls (GovernanceRule, GovernanceProcess,
1082
+ GovernanceResponsibility, GovernanceProcedure, SecurityAccessControl, SecurityGroup).
1083
+
1084
+ Body structure:
1085
+ {
1086
+ "class" : "RelationshipRequestBody",
1087
+ "externalSourceGUID": "add guid here",
1088
+ "externalSourceName": "add qualified name here",
1089
+ "effectiveTime" : "{{$isoTimestamp}}",
1090
+ "forLineage" : false,
1091
+ "forDuplicateProcessing" : false,
1092
+ "properties": {
1093
+ "class": "PeerDefinitionProperties",
1094
+ "description": "",
1095
+ "effectiveFrom": "{{$isoTimestamp}}",
1096
+ "effectiveTo": "{{$isoTimestamp}}"
1097
+ }
1098
+ }
1099
+ """
1100
+ url = (
1101
+ f"{self.platform_url}/s"
1102
+ f"ervers/{self.view_server}/api/open-metadata/governance-officer/governance-definitions/"
1103
+ f"{definition_guid1}/peer-definitions/{relationship_type}/{definition_guid2}/attach")
1104
+
1105
+ await self._async_new_relationship_request(url, "PeerDefinitionProperties", body)
1106
+ logger.info(f"Linked {definition_guid1} -> {definition_guid2}")
1107
+
1108
+ @dynamic_catch
1109
+ def link_peer_definitions(self, definition_guid1: str, relationship_type: str, definition_guid2: str,
1110
+ body: dict | NewElementRequestBody = None) -> None:
1111
+ """ Attach two peer governance definitions. Async Version.
1112
+
1113
+ Parameters
1114
+ ----------
1115
+ definition_guid1: str
1116
+ guid of the first governance definition to link.
1117
+ definition_guid2: str
1118
+ guid of the second governance definition to link.
1119
+ relationship_type: str
1120
+ Relationship type name linking the governance definitions..
1121
+ body: dict
1122
+ The body describing the link between the two segments.
1123
+
1124
+ Returns
1125
+ -------
1126
+ None
1127
+
1128
+ Raises
1129
+ ------
1130
+ InvalidParameterException
1131
+ one of the parameters is null or invalid or
1132
+ PropertyServerException
1133
+ There is a problem adding the element properties to the metadata repository or
1134
+ UserNotAuthorizedException
1135
+ the requesting user is not authorized to issue this request.
1136
+
1137
+ Notes
1138
+ ----
1139
+ The relationshipTypeNme can be:
1140
+ * GovernanceDriverLink between governance drivers (GovernanceStrategy, BusinessImperitive, Regulation,
1141
+ RegulationArticle, Threat).
1142
+ * GovernancePolicyLink between governance policies (GovernancePrinciple, GovernanceObligation,
1143
+ GovernanceApproach).
1144
+ * GovernanceControlLink between governance controls (GovernanceRule, GovernanceProcess,
1145
+ GovernanceResponsibility, GovernanceProcedure, SecurityAccessControl, SecurityGroup).
1146
+
1147
+ Body structure:
1148
+ {
1149
+ "class" : "RelationshipRequestBody",
1150
+ "externalSourceGUID": "add guid here",
1151
+ "externalSourceName": "add qualified name here",
1152
+ "effectiveTime" : "{{$isoTimestamp}}",
1153
+ "forLineage" : false,
1154
+ "forDuplicateProcessing" : false,
1155
+ "properties": {
1156
+ "class": "PeerDefinitionProperties",
1157
+ "description": "",
1158
+ "effectiveFrom": "{{$isoTimestamp}}",
1159
+ "effectiveTo": "{{$isoTimestamp}}"
1160
+ }
1161
+ }
1162
+ """
1163
+ loop = asyncio.get_event_loop()
1164
+ loop.run_until_complete(
1165
+ self._async_link_peer_definitions(definition_guid1, relationship_type, definition_guid2, body))
1166
+
1167
+ @dynamic_catch
1168
+ async def _async_detach_peer_definitions(self, definition_guid1: str, relationship_type: str, definition_guid2: str,
1169
+ body: dict | DeleteRequestBody = None) -> None:
1170
+ """ Detach two peer governance definitions. Request body is optional. Async Version.
1171
+
1172
+ Parameters
1173
+ ----------
1174
+ definition_guid1: str
1175
+ guid of the first governance definition to link.
1176
+ definition_guid2: str
1177
+ guid of the second governance definition to link.
1178
+ relationship_type: str
1179
+ Relationship type name linking the governance definitions..
1180
+ body: dict, optional
1181
+ The body describing the link between the two segments.
1182
+
1183
+ Returns
1184
+ -------
1185
+ None
1186
+
1187
+ Raises
1188
+ ------
1189
+ InvalidParameterException
1190
+ one of the parameters is null or invalid or
1191
+ PropertyServerException
1192
+ There is a problem adding the element properties to the metadata repository or
1193
+ UserNotAuthorizedException
1194
+ the requesting user is not authorized to issue this request.
1195
+
1196
+ Notes
1197
+ ----
1198
+
1199
+ Body structure:
1200
+
1201
+ {
1202
+ "class": "MetadataSourceRequestBody",
1203
+ "externalSourceGUID": "add guid here",
1204
+ "externalSourceName": "add qualified name here",
1205
+ "effectiveTime": "{{$isoTimestamp}}",
1206
+ "forLineage": false,
1207
+ "forDuplicateProcessing": false
1208
+ }
1209
+ """
1210
+ url = (
1211
+ f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/"
1212
+ f"{self.url_marker}/governance-definitions/"
1213
+ f"{definition_guid1}/peer-definitions/{relationship_type}/{definition_guid2}/detach")
1214
+ await self._async_delete_request(url, body)
1215
+ logger.info(f"Detached peer definitions: {definition_guid1} -> {definition_guid2}")
1216
+
1217
+ @dynamic_catch
1218
+ def detach_peer_definitions(self, definition_guid1: str, relationship_type: str, definition_guid2: str,
1219
+ body: dict = None | DeleteRequestBody) -> None:
1220
+ """ Detach two peer governance definitions. Request body is optional.
1221
+
1222
+ Parameters
1223
+ ----------
1224
+ definition_guid1: str
1225
+ guid of the first governance definition to link.
1226
+ definition_guid2: str
1227
+ guid of the second governance definition to link.
1228
+ relationship_type: str
1229
+ Relationship type name linking the governance definitions..
1230
+ body: dict, optional
1231
+ The body describing the link between the two segments.
1232
+
1233
+ Returns
1234
+ -------
1235
+ None
1236
+
1237
+ Raises
1238
+ ------
1239
+ InvalidParameterException
1240
+ one of the parameters is null or invalid or
1241
+ PropertyServerException
1242
+ There is a problem adding the element properties to the metadata repository or
1243
+ UserNotAuthorizedException
1244
+ the requesting user is not authorized to issue this request.
1245
+
1246
+ Notes
1247
+ ----
1248
+
1249
+ Body structure:
1250
+
1251
+ {
1252
+ "class": "MetadataSourceRequestBody",
1253
+ "externalSourceGUID": "add guid here",
1254
+ "externalSourceName": "add qualified name here",
1255
+ "effectiveTime": "{{$isoTimestamp}}",
1256
+ "forLineage": false,
1257
+ "forDuplicateProcessing": false
1258
+ }
1259
+ """
1260
+ loop = asyncio.get_event_loop()
1261
+ loop.run_until_complete(
1262
+ self._async_detach_peer_definitions(definition_guid1, relationship_type, definition_guid2, body))
1263
+
1264
+ @dynamic_catch
1265
+ async def _async_attach_supporting_definitions(self, definition_guid1: str, relationship_type: str,
1266
+ definition_guid2: str,
1267
+ body: dict | NewRelationshipRequestBody = None) -> None:
1268
+ """ Attach a supporting governance definition. Request body is optional.
1269
+ The relationshipTypeNme can be:
1270
+ * GovernanceResponse between governance drivers (GovernanceStrategy, BusinessImperative, Regulation,
1271
+ RegulationArticle, Threat) and governance policies (GovernancePrinciple, GovernanceObligation,
1272
+ GovernanceApproach).
1273
+ * GovernanceImplementation between governance policies (GovernancePrinciple, GovernanceObligation,
1274
+ GovernanceApproach) and governance controls (GovernanceRule, GovernanceProcess, GovernanceResponsibility,
1275
+ GovernanceProcedure, SecurityAccessControl, SecurityGroup).
1276
+
1277
+ Async Version.
1278
+
1279
+ Parameters
1280
+ ----------
1281
+ definition_guid1: str
1282
+ guid of the first governance definition to link.
1283
+ definition_guid2: str
1284
+ guid of the second governance definition to link.
1285
+ relationship_type: str
1286
+ Relationship type name linking the governance definitions..
1287
+ body: dict
1288
+ The body describing the link between the two segments.
1289
+
1290
+ Returns
1291
+ -------
1292
+ None
1293
+
1294
+ Raises
1295
+ ------
1296
+ InvalidParameterException
1297
+ one of the parameters is null or invalid or
1298
+ PropertyServerException
1299
+ There is a problem adding the element properties to the metadata repository or
1300
+ UserNotAuthorizedException
1301
+ the requesting user is not authorized to issue this request.
1302
+
1303
+ Notes
1304
+ ----
1305
+
1306
+ Body structure:
1307
+ {
1308
+ "class" : "RelationshipRequestBody",
1309
+ "externalSourceGUID": "add guid here",
1310
+ "externalSourceName": "add qualified name here",
1311
+ "effectiveTime" : "{{$isoTimestamp}}",
1312
+ "forLineage" : false,
1313
+ "forDuplicateProcessing" : false,
1314
+ "properties": {
1315
+ "class": "SupportingDefinitionProperties",
1316
+ "rationale": "",
1317
+ "effectiveFrom": "{{$isoTimestamp}}",
1318
+ "effectiveTo": "{{$isoTimestamp}}"
1319
+ }
1320
+ }
1321
+ """
1322
+ url = (
1323
+ f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/"
1324
+ f"{self.url_marker}/governance-definitions/"
1325
+ f"{definition_guid1}/supporting-definitions/{relationship_type}/{definition_guid2}/attach")
1326
+ await self._async_new_relationship_request(url, "SupportingDefinitionProperties", body)
1327
+ logger.info(f"Linked {definition_guid1} -> {definition_guid2}")
1328
+
1329
+ @dynamic_catch
1330
+ def attach_supporting_definitions(self, definition_guid1: str, relationship_type: str, definition_guid2: str,
1331
+ body: dict | NewRelationshipRequestBody = None) -> None:
1332
+ """ Attach a supporting governance definition. Request body is optional.
1333
+ The relationshipTypeNme can be:
1334
+ * GovernanceResponse between governance drivers (GovernanceStrategy, BusinessImperative, Regulation,
1335
+ RegulationArticle, Threat) and governance policies (GovernancePrinciple, GovernanceObligation,
1336
+ GovernanceApproach).
1337
+ * GovernanceImplementation between governance policies (GovernancePrinciple, GovernanceObligation,
1338
+ GovernanceApproach) and governance controls (GovernanceRule, GovernanceProcess, GovernanceResponsibility,
1339
+ GovernanceProcedure, SecurityAccessControl, SecurityGroup).
1340
+
1341
+ Parameters
1342
+ ----------
1343
+ definition_guid1: str
1344
+ guid of the first governance definition to link.
1345
+ definition_guid2: str
1346
+ guid of the second governance definition to link.
1347
+ relationship_type: str
1348
+ Relationship type name linking the governance definitions..
1349
+ body: dict
1350
+ The body describing the link between the two segments.
1351
+
1352
+ Returns
1353
+ -------
1354
+ None
1355
+
1356
+ Raises
1357
+ ------
1358
+ InvalidParameterException
1359
+ one of the parameters is null or invalid or
1360
+ PropertyServerException
1361
+ There is a problem adding the element properties to the metadata repository or
1362
+ UserNotAuthorizedException
1363
+ the requesting user is not authorized to issue this request.
1364
+
1365
+ Notes
1366
+ ----
1367
+
1368
+ Body structure:
1369
+ {
1370
+ "class" : "RelationshipRequestBody",
1371
+ "externalSourceGUID": "add guid here",
1372
+ "externalSourceName": "add qualified name here",
1373
+ "effectiveTime" : "{{$isoTimestamp}}",
1374
+ "forLineage" : false,
1375
+ "forDuplicateProcessing" : false,
1376
+ "properties": {
1377
+ "class": "SupportingDefinitionProperties",
1378
+ "rationale": "",
1379
+ "effectiveFrom": "{{$isoTimestamp}}",
1380
+ "effectiveTo": "{{$isoTimestamp}}"
1381
+ }
1382
+ }
1383
+ """
1384
+ loop = asyncio.get_event_loop()
1385
+ loop.run_until_complete(
1386
+ self._async_attach_supporting_definitions(definition_guid1, relationship_type, definition_guid2, body))
1387
+
1388
+ @dynamic_catch
1389
+ async def _async_detach_supporting_definitions(self, definition_guid1: str, relationship_type: str,
1390
+ definition_guid2: str,
1391
+ body: dict | DeleteRequestBody = None) -> None:
1392
+ """ Detach a governance definition from a supporting governance definition.
1393
+ Request body is optional. Async Version.
1394
+
1395
+ Parameters
1396
+ ----------
1397
+ definition_guid1: str
1398
+ guid of the first governance definition to unlink.
1399
+ definition_guid2: str
1400
+ guid of the second governance definition to unlink.
1401
+ relationship_type: str
1402
+ Relationship type name linking the governance definitions..
1403
+ body: dict, optional
1404
+ The body describing the link between the two segments.
1405
+
1406
+ Returns
1407
+ -------
1408
+ None
1409
+
1410
+ Raises
1411
+ ------
1412
+ InvalidParameterException
1413
+ one of the parameters is null or invalid or
1414
+ PropertyServerException
1415
+ There is a problem adding the element properties to the metadata repository or
1416
+ UserNotAuthorizedException
1417
+ the requesting user is not authorized to issue this request.
1418
+
1419
+ Notes
1420
+ ----
1421
+
1422
+ Body structure:
1423
+ {
1424
+ "class": "MetadataSourceRequestBody",
1425
+ "externalSourceGUID": "add guid here",
1426
+ "externalSourceName": "add qualified name here",
1427
+ "effectiveTime": "{{$isoTimestamp}}",
1428
+ "forLineage": false,
1429
+ "forDuplicateProcessing": false
1430
+ }
1431
+ """
1432
+ url = (
1433
+ f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/"
1434
+ f"{self.url_marker}/governance-definitions/"
1435
+ f"{definition_guid1}/supporting-definitions/{relationship_type}/{definition_guid2}/detach"
1436
+ )
1437
+ await self._async_delete_request(url, body)
1438
+ logger.info(f"Detached digital supporting definitions: {definition_guid1} -> {definition_guid2}")
1439
+
1440
+ @dynamic_catch
1441
+ def detach_supporting_definitions(self, definition_guid1: str, relationship_type: str, definition_guid2: str,
1442
+ body: dict | DeleteRequestBody = None) -> None:
1443
+ """ Detach a governance definition from a supporting governance definition.
1444
+ Request body is optional.
1445
+
1446
+ Parameters
1447
+ ----------
1448
+ definition_guid1: str
1449
+ guid of the first governance definition to unlink.
1450
+ definition_guid2: str
1451
+ guid of the second governance definition to unlink.
1452
+ relationship_type: str
1453
+ Relationship type name linking the governance definitions..
1454
+ body: dict, optional
1455
+ The body describing the link between the two segments.
1456
+
1457
+ Returns
1458
+ -------
1459
+ None
1460
+
1461
+ Raises
1462
+ ------
1463
+ InvalidParameterException
1464
+ one of the parameters is null or invalid or
1465
+ PropertyServerException
1466
+ There is a problem adding the element properties to the metadata repository or
1467
+ UserNotAuthorizedException
1468
+ the requesting user is not authorized to issue this request.
1469
+
1470
+ Notes
1471
+ ----
1472
+
1473
+ Body structure:
1474
+ {
1475
+ "class" : "MetadataSourceRequestBody",
1476
+ "externalSourceGUID": "add guid here",
1477
+ "externalSourceName": "add qualified name here",
1478
+ "effectiveTime" : "{{$isoTimestamp}}",
1479
+ "forLineage" : false,
1480
+ "forDuplicateProcessing" : false
1481
+ }
1482
+ """
1483
+ loop = asyncio.get_event_loop()
1484
+ loop.run_until_complete(
1485
+ self._async_detach_supporting_definitions(definition_guid1, relationship_type, definition_guid2, body))
1486
+
1487
+ @dynamic_catch
1488
+ async def _async_delete_governance_definition(self, guid: str, body: dict | DeleteRequestBody = None) -> None:
1489
+ """ Delete an information supply. Async version.
1490
+
1491
+ Parameters
1492
+ ----------
1493
+ guid: str
1494
+ GUID of the governance definition to delete.
1495
+
1496
+ body: dict, optional
1497
+ A dictionary containing the definition of the governance definition to create.
1498
+
1499
+ Returns
1500
+ -------
1501
+
1502
+ str - guid of the governance definition created.
1503
+
1504
+ Raises
1505
+ ------
1506
+ InvalidParameterException
1507
+ one of the parameters is null or invalid or
1508
+ PropertyServerException
1509
+ There is a problem adding the element properties to the metadata repository or
1510
+ UserNotAuthorizedException
1511
+ the requesting user is not authorized to issue this request.
1512
+
1513
+ Notes
1514
+ ----
1515
+ https://egeria-project.org/concepts/governance-definition
1516
+
1517
+ Body structure:
1518
+ {
1519
+ "class": "MetadataSourceRequestBody",
1520
+ "externalSourceGUID": "add guid here",
1521
+ "externalSourceName": "add qualified name here",
1522
+ "effectiveTime": "{{$isoTimestamp}}",
1523
+ "forLineage": false,
1524
+ "forDuplicateProcessing": false
1525
+ }
1526
+
1527
+ """
1528
+ url = (f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/"
1529
+ f"{self.url_marker}/governance-definitions/{guid}/delete")
1530
+ await self._async_delete_request(url, body)
1531
+ logger.info(f"Deleted governance definition: {guid} ")
1532
+
1533
+ @dynamic_catch
1534
+ def delete_governance_definition(self, guid: str, body: dict | DeleteRequestBody = None) -> None:
1535
+ """ Delete an information supply. Request body is optional. Async version.
1536
+
1537
+ Parameters
1538
+ ----------
1539
+ guid: str
1540
+ GUID of the governance definition to delete.
1541
+
1542
+ body: dict, optionl
1543
+ A dictionary containing the definition of the governance definition to create.
1544
+
1545
+ Returns
1546
+ -------
1547
+
1548
+ str - guid of the governance definition created.
1549
+
1550
+ Raises
1551
+ ------
1552
+ InvalidParameterException
1553
+ one of the parameters is null or invalid or
1554
+ PropertyServerException
1555
+ There is a problem adding the element properties to the metadata repository or
1556
+ UserNotAuthorizedException
1557
+ the requesting user is not authorized to issue this request.
1558
+
1559
+ Notes
1560
+ ----
1561
+ https://egeria-project.org/concepts/governance-definition
1562
+
1563
+ Body structure:
1564
+ {
1565
+ "class": "MetadataSourceRequestBody",
1566
+ "externalSourceGUID": "add guid here",
1567
+ "externalSourceName": "add qualified name here",
1568
+ "effectiveTime": "{{$isoTimestamp}}",
1569
+ "forLineage": false,
1570
+ "forDuplicateProcessing": false
1571
+ }
1572
+
1573
+ """
1574
+
1575
+ loop = asyncio.get_event_loop()
1576
+ loop.run_until_complete(self._async_delete_governance_definition(guid, body))
1577
+
1578
+ @dynamic_catch
1579
+ async def _async_find_governance_definitions(self, search_string: str = "*", classification_names: list[str] = None,
1580
+ metadata_element_types: list[str] = None,
1581
+ starts_with: bool = True,
1582
+ ends_with: bool = False, ignore_case: bool = False,
1583
+ start_from: int = 0, page_size: int = 0,
1584
+ output_format: str = 'JSON', output_format_set: dict = None,
1585
+ body: dict | SearchStringRequestBody = None,
1586
+ ) -> list | str:
1587
+ """ Retrieve the list of governance definition metadata elements that contain the search string.
1588
+ Async version.
1589
+
1590
+ Parameters
1591
+ ----------
1592
+ search_string : str
1593
+ - string to search for.
1594
+ starts_with : bool, [default=False], optional
1595
+ Starts with the supplied string.
1596
+ ends_with : bool, [default=False], optional
1597
+ Ends with the supplied string
1598
+ ignore_case : bool, [default=False], optional
1599
+ Ignore case when searching
1600
+ body: dict, optional, default = None
1601
+ - additional optional specifications for the search.
1602
+ output_format: str, default = 'JSON'
1603
+ Type of output to produce:
1604
+ JSON - output standard json
1605
+ MD - output standard markdown with no preamble
1606
+ FORM - output markdown with a preamble for a form
1607
+ REPORT - output markdown with a preamble for a report
1608
+ Mermaid - output markdown with a mermaid graph
1609
+
1610
+ Returns
1611
+ -------
1612
+ list[dict] | str
1613
+ A list of information governance definition structures or a string if there are no elements found.
1614
+
1615
+ Raises
1616
+ ------
1617
+ InvalidParameterException
1618
+ one of the parameters is null or invalid or
1619
+ PropertyServerException
1620
+ There is a problem adding the element properties to the metadata repository or
1621
+ UserNotAuthorizedException
1622
+ the requesting user is not authorized to issue this request.
1623
+
1624
+ Notes
1625
+ -----
1626
+ If a body is provided it overrides the filter_string parameter.
1627
+
1628
+ Body structure:
1629
+ {
1630
+ "class": "FilterRequestBody",
1631
+ "asOfTime": {{isotime}},
1632
+ "effectiveTime": {{isotime}},
1633
+ "forLineage": false,
1634
+ "forDuplicateProcessing": false,
1635
+ "limitResultsByStatus": ["ACTIVE"],
1636
+ "sequencingOrder": "PROPERTY_ASCENDING",
1637
+ "sequencingProperty": "qualifiedName",
1638
+ "filter": "Add name here",
1639
+ "templateFilter": "NO_TEMPLATES"
1640
+ }
1641
+ """
1642
+
1643
+ url = (
1644
+ f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/"
1645
+ f"{self.url_marker}/governance-definitions/"
1646
+ f"by-search-string")
1647
+ return await self._async_find_request(url, _type="GovernanceDefinition",
1648
+ _gen_output=self._generate_governance_definition_output,
1649
+ search_string=search_string, classification_names=classification_names,
1650
+ metadata_element_types=metadata_element_types,
1651
+ starts_with=starts_with, ends_with=ends_with, ignore_case=ignore_case,
1652
+ start_from=start_from, page_size=page_size,
1653
+ output_format=output_format, output_format_set=output_format_set,
1654
+ body=body)
1655
+
1656
+ @dynamic_catch
1657
+ def find_governance_definitions(self, search_string: str = "*", classification_names: list[str] = None,
1658
+ metadata_element_types: list[str] = None,
1659
+ starts_with: bool = True, ends_with: bool = False,
1660
+ ignore_case: bool = False, start_from: int = 0, page_size: int = 0,
1661
+ output_format: str = 'JSON', output_format_set: dict = None,
1662
+ body: dict | SearchStringRequestBody = None, ) -> list | str:
1663
+ """ Retrieve the list of governance definition metadata elements that contain the search string.
1664
+
1665
+ Parameters
1666
+ ----------
1667
+ search_string : str
1668
+ - filter_string string to search for.
1669
+ starts_with : bool, [default=False], optional
1670
+ Starts with the supplied string.
1671
+ ends_with : bool, [default=False], optional
1672
+ Ends with the supplied string
1673
+ ignore_case : bool, [default=False], optional
1674
+ Ignore case when searching
1675
+ body: dict, optional, default = None
1676
+ - additional optional specifications for the search.
1677
+ output_format: str, default = 'JSON'
1678
+ Type of output to produce:
1679
+ JSON - output standard json
1680
+ MD - output standard markdown with no preamble
1681
+ FORM - output markdown with a preamble for a form
1682
+ REPORT - output markdown with a preamble for a report
1683
+ Mermaid - output markdown with a mermaid graph
1684
+
1685
+ Returns
1686
+ -------
1687
+ list[dict] | str
1688
+ A list of information governance definition structures or a string if there are no elements found.
1689
+
1690
+ Raises
1691
+ ------
1692
+ InvalidParameterException
1693
+ one of the parameters is null or invalid or
1694
+ PropertyServerException
1695
+ There is a problem adding the element properties to the metadata repository or
1696
+ UserNotAuthorizedException
1697
+ the requesting user is not authorized to issue this request.
1698
+
1699
+ Notes
1700
+ -----
1701
+ If a body is provided it overrides the filter_string parameter.
1702
+
1703
+ Body structure:
1704
+ {
1705
+ "class": "FilterRequestBody",
1706
+ "asOfTime": {{isotime}},
1707
+ "effectiveTime": {{isotime}},
1708
+ "forLineage": false,
1709
+ "forDuplicateProcessing": false,
1710
+ "limitResultsByStatus": ["ACTIVE"],
1711
+ "sequencingOrder": "PROPERTY_ASCENDING",
1712
+ "sequencingProperty": "qualifiedName",
1713
+ "filter": "Add name here",
1714
+ "templateFilter": "NO_TEMPLATES"
1715
+ }
1716
+ """
1717
+
1718
+ loop = asyncio.get_event_loop()
1719
+ response = loop.run_until_complete(
1720
+ self._async_find_governance_definitions(search_string, classification_names, metadata_element_types,
1721
+ starts_with, ends_with, ignore_case, start_from,
1722
+ page_size, output_format, output_format_set, body))
1723
+ return response
1724
+
1725
+ @dynamic_catch
1726
+ async def _async_get_governance_definitions_by_name(self, filter_string: str,
1727
+ classification_names: list[str] = None,
1728
+ body: dict | FilterRequestBody = None,
1729
+ start_from: int = 0, page_size: int = 0,
1730
+ output_format: str = "JSON",
1731
+ output_format_set: dict = None) -> list | str:
1732
+ """ Returns the list of governance definitions with a particular name. Async Version.
1733
+
1734
+ Parameters
1735
+ ----------
1736
+ filter_string: str
1737
+ name of the information governance definition to retrieve.
1738
+ body: dict, optional
1739
+ A dictionary containing parameters of the retrieval.
1740
+ output_format: str, default = 'JSON'
1741
+ Type of output to produce include:
1742
+ JSON - output standard json
1743
+ MD - output standard markdown with no preamble
1744
+ FORM - output markdown with a preamble for a form
1745
+ REPORT - output markdown with a preamble for a report
1746
+ MERMAID - output mermaid markdown
1747
+
1748
+ Returns
1749
+ -------
1750
+ [dict] | str
1751
+ A list of information governance definitions matching the name.
1752
+
1753
+ Raises
1754
+ ------
1755
+ InvalidParameterException
1756
+ one of the parameters is null or invalid or
1757
+ PropertyServerException
1758
+ There is a problem adding the element properties to the metadata repository or
1759
+ UserNotAuthorizedException
1760
+ the requesting user is not authorized to issue this request.
1761
+
1762
+ Notes
1763
+ -----
1764
+ If a body is provided it overrides the filter_string parameter.
1765
+ Body structure:
1766
+ {
1767
+ "class": "FilterRequestBody",
1768
+ "asOfTime": {{isotime}},
1769
+ "effectiveTime": {{isotime}},
1770
+ "forLineage": false,
1771
+ "forDuplicateProcessing": false,
1772
+ "limitResultsByStatus": ["ACTIVE"],
1773
+ "sequencingOrder": "PROPERTY_ASCENDING",
1774
+ "sequencingProperty": "qualifiedName",
1775
+ "filter": "Add name here",
1776
+ "templateFilter": "NO_TEMPLATES"
1777
+ }
1778
+
1779
+ """
1780
+
1781
+ url = (
1782
+ f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/"
1783
+ f"{self.url_marker}/governance-definitions/by-name")
1784
+ response = await self._async_get_name_request(url, _type="GovernanceDefinition",
1785
+ _gen_output=self._generate_governance_definition_output,
1786
+ filter_string=filter_string,
1787
+ classification_names=classification_names,
1788
+ start_from=start_from, page_size=page_size,
1789
+ output_format=output_format, output_format_set=output_format_set,
1790
+ body=body)
1791
+
1792
+ return response
1793
+
1794
+ @dynamic_catch
1795
+ def get_governance_definitions_by_name(self, filter_string: str, classification_names: list[str] = None,
1796
+ body: dict | FilterRequestBody = None,
1797
+ start_from: int = 0, page_size: int = 0,
1798
+ output_format: str = "JSON",
1799
+ output_format_set: dict = None) -> list | str:
1800
+ """ Returns the list of governance definitions with a particular name."""
1801
+
1802
+ """ Returns the list of information governance definitions with a particular name. Async Version.
1803
+
1804
+ Parameters
1805
+ ----------
1806
+ filter_string: str
1807
+ name of the information governance definition to retrieve.
1808
+ body: dict, optional
1809
+ A dictionary containing parameters of the retrieval.
1810
+ add_implementation: bool, optional
1811
+ Whether to add the implementation details to the response.
1812
+ start_from: int, [default=0], optional
1813
+ When multiple pages of results are available, the page number to start from.
1814
+ page_size: int, [default=0], optional
1815
+ The number of items to return in a single page. If not specified, the default will be taken from
1816
+ the class instance.
1817
+ output_format: str, default = 'JSON'
1818
+ Type of output to produce:
1819
+ JSON - output standard json
1820
+ MD - output standard markdown with no preamble
1821
+ FORM - output markdown with a preamble for a form
1822
+ REPORT - output markdown with a preamble for a report
1823
+ MERMAID - output mermaid markdown
1824
+
1825
+ Returns
1826
+ -------
1827
+ [dict] | str
1828
+ A list of information governance definitions matching the name.
1829
+
1830
+ Raises
1831
+ ------
1832
+ InvalidParameterException
1833
+ one of the parameters is null or invalid or
1834
+ PropertyServerException
1835
+ There is a problem adding the element properties to the metadata repository or
1836
+ UserNotAuthorizedException
1837
+ the requesting user is not authorized to issue this request.
1838
+
1839
+ Notes
1840
+ -----
1841
+ Body structure:
1842
+ {
1843
+ "class": "FilterRequestBody",
1844
+ "asOfTime": {{isotime}},
1845
+ "effectiveTime": {{isotime}},
1846
+ "forLineage": false,
1847
+ "forDuplicateProcessing": false,
1848
+ "limitResultsByStatus": ["ACTIVE"],
1849
+ "sequencingOrder": "PROPERTY_ASCENDING",
1850
+ "sequencingProperty": "qualifiedName",
1851
+ "filter": "Add name here",
1852
+ "templateFilter": "NO_TEMPLATES"
1853
+ }
1854
+
1855
+ """
1856
+ loop = asyncio.get_event_loop()
1857
+ response = loop.run_until_complete(
1858
+ self._async_get_governance_definitions_by_name(filter_string, classification_names, body,
1859
+ start_from, page_size, output_format, output_format_set))
1860
+ return response
1861
+
1862
+ @dynamic_catch
1863
+ async def _async_get_governance_definition_by_guid(self, guid: str, element_type: str = None,
1864
+ body: dict | FilterRequestBody = None,
1865
+ output_format: str = "JSON",
1866
+ output_format_set: dict = None) -> dict | str:
1867
+
1868
+ """ Get governance definition by guid.
1869
+ Async version.
1870
+
1871
+ Parameters
1872
+ ----------
1873
+ guid: str
1874
+ GUID of the governance definition to get.
1875
+
1876
+ body: dict, optional
1877
+ A dictionary containing the definition of the governance definition to create.
1878
+ output_format: str
1879
+ The output format to use.
1880
+
1881
+ Returns
1882
+ -------
1883
+
1884
+ dict | str
1885
+ A list of information governance definition structures or a string if there are no elements found.
1886
+
1887
+
1888
+ Raises
1889
+ ------
1890
+ InvalidParameterException
1891
+ one of the parameters is null or invalid or
1892
+ PropertyServerException
1893
+ There is a problem adding the element properties to the metadata repository or
1894
+ UserNotAuthorizedException
1895
+ the requesting user is not authorized to issue this request.
1896
+
1897
+ Notes
1898
+ ----
1899
+ https://egeria-project.org/concepts/governance-definition
1900
+
1901
+ Body structure:
1902
+ {
1903
+ "class" : "GetRequestBody",
1904
+ "asOfTime" : "{{$isoTimestamp}}",
1905
+ "effectiveTime" : "{{$isoTimestamp}}",
1906
+ "forLineage" : false,
1907
+ "forDuplicateProcessing" : false
1908
+ }
1909
+
1910
+ """
1911
+
1912
+ url = (
1913
+ f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/"
1914
+ f"{self.url_marker}/governance-definitions/"
1915
+ f"{guid}/retrieve")
1916
+ type = element_type if element_type else "GovernanceDefinition"
1917
+
1918
+ response = await self._async_get_guid_request(url, _type=type,
1919
+ _gen_output=self._generate_governance_definition_output,
1920
+ output_format=output_format, output_format_set=output_format_set,
1921
+ body=body)
1922
+
1923
+ return response
1924
+
1925
+ @dynamic_catch
1926
+ def get_governance_definition_by_guid(self, guid: str, element_type: str = None, body: dict = None,
1927
+ output_format: str = "JSON",
1928
+ output_format_set: dict = None) -> dict | str:
1929
+
1930
+ """ Get governance definition by guid.
1931
+
1932
+ Parameters
1933
+ ----------
1934
+ guid: str
1935
+ GUID of the governance definition to get.
1936
+
1937
+ body: dict, optional
1938
+ A dictionary containing the definition of the governance definition to create.
1939
+ output_format: str, default = "JSON"
1940
+ The output format to use.
1941
+
1942
+ Returns
1943
+ -------
1944
+
1945
+ dict | str
1946
+ A list of information governance definition structures or a string if there are no elements found.
1947
+
1948
+
1949
+ Raises
1950
+ ------
1951
+ InvalidParameterException
1952
+ one of the parameters is null or invalid or
1953
+ PropertyServerException
1954
+ There is a problem adding the element properties to the metadata repository or
1955
+ UserNotAuthorizedException
1956
+ the requesting user is not authorized to issue this request.
1957
+
1958
+ Notes
1959
+ ----
1960
+ https://egeria-project.org/concepts/governance-definition
1961
+ Body structure:
1962
+ {
1963
+ "class" : "GetRequestBody",
1964
+ "asOfTime" : "{{$isoTimestamp}}",
1965
+ "effectiveTime" : "{{$isoTimestamp}}",
1966
+ "forLineage" : false,
1967
+ "forDuplicateProcessing" : false
1968
+ }
1969
+
1970
+ """
1971
+
1972
+ loop = asyncio.get_event_loop()
1973
+ response = loop.run_until_complete(self._async_get_governance_definition_by_guid(guid, element_type, body,
1974
+ output_format,
1975
+ output_format_set))
1976
+ return response
1977
+
1978
+ @dynamic_catch
1979
+ async def _async_link_design_to_implementation(self, design_desc_guid: str, implementation_guid: str,
1980
+ body: dict | NewRelationshipRequestBody = None) -> None:
1981
+ """ Attach a design object such as a solution component or governance definition to its implementation via the
1982
+ ImplementedBy relationship. Request body is optional. Async Version.
1983
+ https://egeria-project.org/types/7/0737-Solution-Implementation/
1984
+
1985
+ Parameters
1986
+ ----------
1987
+ design_desc_guid: str
1988
+ guid of the design element to link.
1989
+ implementation_guid: str
1990
+ guid of the implementation definition to link.
1991
+ body: dict, optional
1992
+ The body describing the link between the two segments.
1993
+
1994
+ Returns
1995
+ -------
1996
+ None
1997
+
1998
+ Raises
1999
+ ------
2000
+ InvalidParameterException
2001
+ one of the parameters is null or invalid or
2002
+ PropertyServerException
2003
+ There is a problem adding the element properties to the metadata repository or
2004
+ UserNotAuthorizedException
2005
+ the requesting user is not authorized to issue this request.
2006
+
2007
+ Notes
2008
+ ----
2009
+
2010
+ Body structure:
2011
+ {
2012
+ "class" : "RelationshipRequestBody",
2013
+ "externalSourceGUID": "add guid here",
2014
+ "externalSourceName": "add qualified name here",
2015
+ "effectiveTime" : "{{$isoTimestamp}}",
2016
+ "forLineage" : false,
2017
+ "forDuplicateProcessing" : false,
2018
+ "properties": {
2019
+ "class": "ImplementedByProperties",
2020
+ "designStep": "",
2021
+ "role": "",
2022
+ "transformation": "",
2023
+ "description": "",
2024
+ "iscQualifiedName": "",
2025
+ "effectiveFrom": "{{$isoTimestamp}}",
2026
+ "effectiveTo": "{{$isoTimestamp}}"
2027
+ }
2028
+ }
2029
+ """
2030
+ url = (f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/{self.url_marker}/designs/"
2031
+ f"{design_desc_guid}/implementations/{implementation_guid}/attach")
2032
+ await self._async_new_relationship_request(url, "ImplementedByProperties", body)
2033
+ logger.info(f"Linked design to implementation: {design_desc_guid} -> {implementation_guid}")
2034
+
2035
+ @dynamic_catch
2036
+ def link_design_to_implementation(self, design_desc_guid: str, implementation_guid: str,
2037
+ body: dict | NewRelationshipRequestBody = None) -> None:
2038
+ """ Attach a design object such as a solution component or governance definition to its implementation via the
2039
+ ImplementedBy relationship. Request body is optional.
2040
+ https://egeria-project.org/types/7/0737-Solution-Implementation/
2041
+
2042
+ Parameters
2043
+ ----------
2044
+ design_desc_guid: str
2045
+ guid of the design element to link.
2046
+ implementation_guid: str
2047
+ guid of the implementation definition to link.
2048
+ body: dict, optional
2049
+ The body describing the link between the two segments.
2050
+
2051
+ Returns
2052
+ -------
2053
+ None
2054
+
2055
+ Raises
2056
+ ------
2057
+ InvalidParameterException
2058
+ one of the parameters is null or invalid or
2059
+ PropertyServerException
2060
+ There is a problem adding the element properties to the metadata repository or
2061
+ UserNotAuthorizedException
2062
+ the requesting user is not authorized to issue this request.
2063
+
2064
+ Notes
2065
+ ----
2066
+
2067
+ Body structure:
2068
+ {
2069
+ "class" : "RelationshipRequestBody",
2070
+ "externalSourceGUID": "add guid here",
2071
+ "externalSourceName": "add qualified name here",
2072
+ "effectiveTime" : "{{$isoTimestamp}}",
2073
+ "forLineage" : false,
2074
+ "forDuplicateProcessing" : false,
2075
+ "properties": {
2076
+ "class": "ImplementedByProperties",
2077
+ "designStep": "",
2078
+ "role": "",
2079
+ "transformation": "",
2080
+ "description": "",
2081
+ "iscQualifiedName": "",
2082
+ "effectiveFrom": "{{$isoTimestamp}}",
2083
+ "effectiveTo": "{{$isoTimestamp}}"
2084
+ }
2085
+ }
2086
+ """
2087
+ loop = asyncio.get_event_loop()
2088
+ loop.run_until_complete(self._async_link_design_to_implementation(design_desc_guid, implementation_guid, body))
2089
+
2090
+ @dynamic_catch
2091
+ async def _async_detach_design_from_implementation(self, design_desc_guid: str, implementation_guid: str,
2092
+ body: dict | DeleteRequestBody = None) -> None:
2093
+ """ Detach a governance definition from its implementation. Async Version.
2094
+
2095
+ Parameters
2096
+ ----------
2097
+ design_desc_guid: str
2098
+ guid of the technical control to link.
2099
+ implementation_guid: str
2100
+ guid of the implementation definition to unlink.
2101
+ body: dict
2102
+ The body describing the link between the two segments.
2103
+
2104
+ Returns
2105
+ -------
2106
+ None
2107
+
2108
+ Raises
2109
+ ------
2110
+ InvalidParameterException
2111
+ one of the parameters is null or invalid or
2112
+ PropertyServerException
2113
+ There is a problem adding the element properties to the metadata repository or
2114
+ UserNotAuthorizedException
2115
+ the requesting user is not authorized to issue this request.
2116
+
2117
+ Notes
2118
+ ----
2119
+
2120
+ Body structure:
2121
+ {
2122
+ "class": "MetadataSourceRequestBody",
2123
+ "externalSourceGUID": "string",
2124
+ "externalSourceName": "string",
2125
+ "forLineage": true,
2126
+ "forDuplicateProcessing": true,
2127
+ "effectiveTime": "2025-06-13T15:13:31.339Z"
2128
+ }
2129
+ """
2130
+
2131
+ url = (f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/{self.url_marker}/designs/"
2132
+ f"{design_desc_guid}/implementations/{implementation_guid}/detach")
2133
+ await self._async_delete_request(url, body)
2134
+ logger.info(
2135
+ f"Detached design from implementation: {design_desc_guid} -> {implementation_guid}")
2136
+
2137
+ @dynamic_catch
2138
+ def detach_design_from_implementation(self, design_desc_guid: str, implementation_guid: str,
2139
+ body: dict | DeleteRequestBody = None) -> None:
2140
+ """ Detach a governance definition from its implementation. Request body is optional.
2141
+
2142
+ Parameters
2143
+ ----------
2144
+ design_descl_guid: str
2145
+ guid of the technical control to unlink.
2146
+ implementation_guid: str
2147
+ guid of the implementation definition to unlink.
2148
+ body: dict, optional
2149
+ The body describing the link between the two segments.
2150
+
2151
+ Returns
2152
+ -------
2153
+ None
2154
+
2155
+ Raises
2156
+ ------
2157
+ InvalidParameterException
2158
+ one of the parameters is null or invalid or
2159
+ PropertyServerException
2160
+ There is a problem adding the element properties to the metadata repository or
2161
+ UserNotAuthorizedException
2162
+ the requesting user is not authorized to issue this request.
2163
+
2164
+ Notes
2165
+ ----
2166
+
2167
+ Body structure:
2168
+ {
2169
+ "externalSourceGUID": "string",
2170
+ "externalSourceName": "string",
2171
+ "forLineage": true,
2172
+ "forDuplicateProcessing": true,
2173
+ "effectiveTime": "2025-06-13T15:13:31.339Z"
2174
+ }
2175
+ """
2176
+ loop = asyncio.get_event_loop()
2177
+ loop.run_until_complete(
2178
+ self._async_detach_design_from_implementation(design_desc_guid, implementation_guid, body))
2179
+
2180
+ @dynamic_catch
2181
+ async def _async_link_implementation_resource(self, design_desc_guid: str, implementation_guid: str,
2182
+ body: dict | NewRelationshipRequestBody = None) -> None:
2183
+ """ Attach a design object such as a solution component or governance definition to one of its implementation
2184
+ resource via the ImplementationResource relationship. Request body is optional.
2185
+ https://egeria-project.org/types/7/0737-Solution-Implementation/
2186
+
2187
+ Parameters
2188
+ ----------
2189
+ design_desc_guid: str
2190
+ guid of the design element to link.
2191
+ implementation_guid: str
2192
+ guid of the implementation definition to link.
2193
+ body: dict, optional
2194
+ The body describing the link between the two segments.
2195
+
2196
+ Returns
2197
+ -------
2198
+ None
2199
+
2200
+ Raises
2201
+ ------
2202
+ InvalidParameterException
2203
+ one of the parameters is null or invalid or
2204
+ PropertyServerException
2205
+ There is a problem adding the element properties to the metadata repository or
2206
+ UserNotAuthorizedException
2207
+ the requesting user is not authorized to issue this request.
2208
+
2209
+ Notes
2210
+ ----
2211
+
2212
+ Body structure:
2213
+ {
2214
+ "class" : "RelationshipRequestBody",
2215
+ "externalSourceGUID": "add guid here",
2216
+ "externalSourceName": "add qualified name here",
2217
+ "effectiveTime" : "{{$isoTimestamp}}",
2218
+ "forLineage" : false,
2219
+ "forDuplicateProcessing" : false,
2220
+ "properties": {
2221
+ "class": "ImplementedByProperties",
2222
+ "designStep": "",
2223
+ "role": "",
2224
+ "transformation": "",
2225
+ "description": "",
2226
+ "iscQualifiedName": "",
2227
+ "effectiveFrom": "{{$isoTimestamp}}",
2228
+ "effectiveTo": "{{$isoTimestamp}}"
2229
+ }
2230
+ }
2231
+ """
2232
+
2233
+ url = (f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/{self.url_marker}/designs/"
2234
+ f"{design_desc_guid}/implementation-resources/{implementation_guid}/attach")
2235
+ await self._async_new_relationship_request(url, "ImplementationResourceProperties", body)
2236
+ logger.info(f"Linked design to implementation resource: {design_desc_guid} -> {implementation_guid}")
2237
+
2238
+ @dynamic_catch
2239
+ def link_implementation_resource(self, design_desc_guid: str, implementation_guid: str,
2240
+ body: dict | NewRelationshipRequestBody = None) -> None:
2241
+ """ Attach a design object such as a solution component or governance definition to its implementation via the
2242
+ ImplementedBy relationship. Request body is optional.
2243
+ https://egeria-project.org/types/7/0737-Solution-Implementation/
2244
+
2245
+ Parameters
2246
+ ----------
2247
+ design_desc_guid: str
2248
+ guid of the design element to link.
2249
+ implementation_guid: str
2250
+ guid of the implementation definition to link.
2251
+ body: dict, optional
2252
+ The body describing the link between the two segments.
2253
+
2254
+ Returns
2255
+ -------
2256
+ None
2257
+
2258
+ Raises
2259
+ ------
2260
+ InvalidParameterException
2261
+ one of the parameters is null or invalid or
2262
+ PropertyServerException
2263
+ There is a problem adding the element properties to the metadata repository or
2264
+ UserNotAuthorizedException
2265
+ the requesting user is not authorized to issue this request.
2266
+
2267
+ Notes
2268
+ ----
2269
+
2270
+ Body structure:
2271
+ {
2272
+ "class" : "RelationshipRequestBody",
2273
+ "externalSourceGUID": "add guid here",
2274
+ "externalSourceName": "add qualified name here",
2275
+ "effectiveTime" : "{{$isoTimestamp}}",
2276
+ "forLineage" : false,
2277
+ "forDuplicateProcessing" : false,
2278
+ "properties": {
2279
+ "class": "ImplementedByProperties",
2280
+ "designStep": "",
2281
+ "role": "",
2282
+ "transformation": "",
2283
+ "description": "",
2284
+ "iscQualifiedName": "",
2285
+ "effectiveFrom": "{{$isoTimestamp}}",
2286
+ "effectiveTo": "{{$isoTimestamp}}"
2287
+ }
2288
+ }
2289
+ """
2290
+ loop = asyncio.get_event_loop()
2291
+ loop.run_until_complete(self._async_link_implementation_resource(design_desc_guid, implementation_guid, body))
2292
+
2293
+ @dynamic_catch
2294
+ async def _async_detach_implementation_resource(self, design_desc_guid: str, implementation_guid: str,
2295
+ body: dict | DeleteRequestBody = None) -> None:
2296
+ """ Detach a design object such as a solution component or governance definition from one of its implementation
2297
+ resources. Request body is optional. Async version.
2298
+
2299
+ Parameters
2300
+ ----------
2301
+ design_desc_guid: str
2302
+ guid of the technical control to link.
2303
+ implementation_guid: str
2304
+ guid of the implementation definition to unlink.
2305
+ body: dict
2306
+ The body describing the link between the two segments.
2307
+
2308
+ Returns
2309
+ -------
2310
+ None
2311
+
2312
+ Raises
2313
+ ------
2314
+ InvalidParameterException
2315
+ one of the parameters is null or invalid or
2316
+ PropertyServerException
2317
+ There is a problem adding the element properties to the metadata repository or
2318
+ UserNotAuthorizedException
2319
+ the requesting user is not authorized to issue this request.
2320
+
2321
+ Notes
2322
+ ----
2323
+
2324
+ Body structure:
2325
+ {
2326
+ "class": "MetadataSourceRequestBody",
2327
+ "externalSourceGUID": "string",
2328
+ "externalSourceName": "string",
2329
+ "forLineage": true,
2330
+ "forDuplicateProcessing": true,
2331
+ "effectiveTime": "2025-06-13T15:13:31.339Z"
2332
+ }
2333
+ """
2334
+
2335
+ url = (f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/{self.url_marker}/designs/"
2336
+ f"{design_desc_guid}/implementation-resources/{implementation_guid}/detach")
2337
+ await self._async_delete_request(url, body)
2338
+ logger.info(
2339
+ f"Detached design from implementation resource: {design_desc_guid} -> {implementation_guid}")
2340
+
2341
+ def detach_implementation_resource(self, design_desc_guid: str, implementation_guid: str,
2342
+ body: dict | DeleteRequestBody = None) -> None:
2343
+ """ Detach a design object such as a solution component or governance definition from one of its implementation
2344
+ resources. Request body is optional.
2345
+
2346
+ Parameters
2347
+ ----------
2348
+ design_desc_guid: str
2349
+ guid of the technical control to link.
2350
+ implementation_guid: str
2351
+ guid of the implementation definition to unlink.
2352
+ body: dict, optional
2353
+ The body describing the link between the two segments.
2354
+
2355
+ Returns
2356
+ -------
2357
+ None
2358
+
2359
+ Raises
2360
+ ------
2361
+ InvalidParameterException
2362
+ one of the parameters is null or invalid or
2363
+ PropertyServerException
2364
+ There is a problem adding the element properties to the metadata repository or
2365
+ UserNotAuthorizedException
2366
+ the requesting user is not authorized to issue this request.
2367
+
2368
+ Notes
2369
+ ----
2370
+
2371
+ Body structure:
2372
+ {
2373
+ "class": "MetadataSourceRequestBody",
2374
+ "externalSourceGUID": "string",
2375
+ "externalSourceName": "string",
2376
+ "forLineage": true,
2377
+ "forDuplicateProcessing": true,
2378
+ "effectiveTime": "2025-06-13T15:13:31.339Z"
2379
+ }
2380
+ """
2381
+ loop = asyncio.get_event_loop()
2382
+ loop.run_until_complete(self._async_detach_implementation_resource(design_desc_guid, implementation_guid, body))
2383
+
2384
+ # async def _async_get_gov_def_in_context(self, guid: str, body: dict = None, output_format: str = "JSON",
2385
+ # start_from: int = 0,
2386
+ # page_size: int = 0) -> list[dict] | str:
2387
+ # """ Get governance definition in context. Brings back the graph.
2388
+ # Async version.
2389
+ #
2390
+ # Parameters
2391
+ # ----------
2392
+ # guid: str
2393
+ # GUID of the governance definition to get.
2394
+ #
2395
+ # body: dict
2396
+ # A dictionary containing the definition of the governance definition to get.
2397
+ # output_format: str
2398
+ # The output format to use.
2399
+ # start_from: int, default= 0
2400
+ # Indicates the start of the page range.
2401
+ # page_size: int, default = 0
2402
+ # The page size to use.
2403
+ #
2404
+ # Returns
2405
+ # -------
2406
+ #
2407
+ # list[dict] | str
2408
+ # A list of information governance definition structures or a string if there are no elements found.
2409
+ #
2410
+ #
2411
+ # Raises
2412
+ # ------
2413
+ # InvalidParameterException
2414
+ # one of the parameters is null or invalid or
2415
+ # PropertyServerException
2416
+ # There is a problem adding the element properties to the metadata repository or
2417
+ # UserNotAuthorizedException
2418
+ # the requesting user is not authorized to issue this request.
2419
+ #
2420
+ # Notes
2421
+ # ----
2422
+ # https://egeria-project.org/concepts/governance-definition
2423
+ #
2424
+ # Body structure:
2425
+ # {
2426
+ # "forLineage": true,
2427
+ # "forDuplicateProcessing": true,
2428
+ # "effectiveTime": "2025-06-13T14:12:44.896Z",
2429
+ # "limitResultsByStatus": [
2430
+ # "InstanceStatus{ordinal=0, name='<Unknown>', description='Unknown instance status.'}"
2431
+ # ],
2432
+ # "asOfTime": "2025-06-13T14:12:44.896Z",
2433
+ # "sequencingOrder": "SequencingOrder{Any Order}",
2434
+ # "sequencingProperty": "string"
2435
+ # }
2436
+ #
2437
+ # """
2438
+ # possible_query_params = query_string([("startFrom", start_from), ("pageSize", page_size)])
2439
+ #
2440
+ # url = (
2441
+ # f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/"
2442
+ # f"{self.url_marker}/governance-definitions/"
2443
+ # f"{guid}/in-context{possible_query_params}")
2444
+ #
2445
+ # if body:
2446
+ # response = await self._async_make_request("POST", url, body_slimmer(body))
2447
+ # else:
2448
+ # response = await self._async_make_request("POST", url)
2449
+ #
2450
+ # element = response.json().get("element", NO_ELEMENTS_FOUND)
2451
+ # if output_format != 'JSON': # return a simplified markdown representation
2452
+ # return self.generate_governance_definition_output(element, "", output_format)
2453
+ # return response.json().get("element", NO_ELEMENTS_FOUND)
2454
+ #
2455
+ # def get_gov_def_in_context(self, guid: str, body: dict = None, output_format: str = "JSON", start_from: int = 0,
2456
+ # page_size: int = 0) -> list[dict] | str:
2457
+ # """ Get governance definition in context. Brings back the graph.
2458
+ #
2459
+ # Parameters
2460
+ # ----------
2461
+ # guid: str
2462
+ # GUID of the governance definition to get.
2463
+ #
2464
+ # body: dict
2465
+ # A dictionary containing the definition of the governance definition to get.
2466
+ # output_format: str
2467
+ # The output format to use.
2468
+ # start_from: int, default= 0
2469
+ # Indicates the start of the page range.
2470
+ # page_size: int, default = 0
2471
+ # The page size to use.
2472
+ #
2473
+ # Returns
2474
+ # -------
2475
+ #
2476
+ # list[dict] | str
2477
+ # A list of information governance definition structures or a string if there are no elements found.
2478
+ #
2479
+ #
2480
+ # Raises
2481
+ # ------
2482
+ # InvalidParameterException
2483
+ # one of the parameters is null or invalid or
2484
+ # PropertyServerException
2485
+ # There is a problem adding the element properties to the metadata repository or
2486
+ # UserNotAuthorizedException
2487
+ # the requesting user is not authorized to issue this request.
2488
+ #
2489
+ # Notes
2490
+ # ----
2491
+ # https://egeria-project.org/concepts/governance-definition
2492
+ #
2493
+ # Body structure:
2494
+ # {
2495
+ # "forLineage": true,
2496
+ # "forDuplicateProcessing": true,
2497
+ # "effectiveTime": "2025-06-13T14:12:44.896Z",
2498
+ # "limitResultsByStatus": [
2499
+ # "InstanceStatus{ordinal=0, name='<Unknown>', description='Unknown instance status.'}"
2500
+ # ],
2501
+ # "asOfTime": "2025-06-13T14:12:44.896Z",
2502
+ # "sequencingOrder": "SequencingOrder{Any Order}",
2503
+ # "sequencingProperty": "string"
2504
+ # }
2505
+ #
2506
+ # """
2507
+ #
2508
+ # loop = asyncio.get_event_loop()
2509
+ # response = loop.run_until_complete(
2510
+ # self._async_get_gov_def_in_context(guid, body, output_format, start_from, page_size))
2511
+ # return response
2512
+
2513
+
2514
+ if __name__ == "__main__":
2515
+ print("Main-Metadata Explorer")