pyegeria 5.3.9.9.3__py3-none-any.whl → 5.5.3.3__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.

Potentially problematic release.


This version of pyegeria might be problematic. Click here for more details.

Files changed (272) hide show
  1. commands/__init__.py +24 -0
  2. commands/cat/Dr-Egeria_md-orig.py +2 -2
  3. commands/cat/__init__.py +1 -17
  4. commands/cat/collection_actions.py +197 -0
  5. commands/cat/dr_egeria_command_help.py +372 -0
  6. commands/cat/dr_egeria_jupyter.py +7 -7
  7. commands/cat/dr_egeria_md.py +27 -182
  8. commands/cat/exp_list_glossaries.py +11 -14
  9. commands/cat/get_asset_graph.py +37 -267
  10. commands/cat/{get_collection.py → get_collection_tree.py} +10 -18
  11. commands/cat/get_project_dependencies.py +14 -14
  12. commands/cat/get_project_structure.py +15 -14
  13. commands/cat/get_tech_type_elements.py +16 -116
  14. commands/cat/glossary_actions.py +145 -298
  15. commands/cat/list_assets.py +3 -11
  16. commands/cat/list_cert_types.py +17 -63
  17. commands/cat/list_collections.py +46 -138
  18. commands/cat/list_deployed_catalogs.py +15 -27
  19. commands/cat/list_deployed_database_schemas.py +27 -43
  20. commands/cat/list_deployed_databases.py +16 -31
  21. commands/cat/list_deployed_servers.py +35 -54
  22. commands/cat/list_glossaries.py +18 -17
  23. commands/cat/list_projects.py +10 -12
  24. commands/cat/list_tech_type_elements.py +21 -37
  25. commands/cat/list_tech_types.py +13 -25
  26. commands/cat/list_terms.py +38 -79
  27. commands/cat/list_todos.py +4 -11
  28. commands/cat/list_user_ids.py +3 -10
  29. commands/cat/my_reports.py +559 -0
  30. commands/cat/run_report.py +394 -0
  31. commands/cat/run_report_orig.py +528 -0
  32. commands/cli/egeria.py +222 -247
  33. commands/cli/egeria_cat.py +68 -81
  34. commands/cli/egeria_my.py +13 -0
  35. commands/cli/egeria_ops.py +69 -74
  36. commands/cli/egeria_tech.py +17 -93
  37. commands/cli/ops_config.py +3 -6
  38. commands/{cat/list_categories.py → deprecated/list_data_designer.py} +53 -64
  39. commands/{cat/list_data_structures.py → deprecated/list_data_structures_full.py} +3 -6
  40. commands/deprecated/old_get_asset_graph.py +315 -0
  41. commands/my/__init__.py +0 -2
  42. commands/my/list_my_profile.py +27 -34
  43. commands/my/list_my_roles.py +1 -7
  44. commands/my/monitor_my_todos.py +1 -7
  45. commands/my/monitor_open_todos.py +6 -7
  46. commands/my/todo_actions.py +4 -5
  47. commands/ops/__init__.py +0 -2
  48. commands/ops/gov_server_actions.py +17 -21
  49. commands/ops/list_archives.py +17 -38
  50. commands/ops/list_catalog_targets.py +33 -40
  51. commands/ops/load_archive.py +35 -26
  52. commands/ops/{monitor_engine_activity_c.py → monitor_active_engine_activity.py} +51 -82
  53. commands/ops/{monitor_integ_daemon_status.py → monitor_daemon_status.py} +35 -55
  54. commands/ops/monitor_engine_activity.py +79 -77
  55. commands/ops/{monitor_gov_eng_status.py → monitor_engine_status.py} +10 -7
  56. commands/ops/monitor_platform_status.py +38 -50
  57. commands/ops/monitor_server_startup.py +6 -11
  58. commands/ops/monitor_server_status.py +7 -11
  59. commands/ops/orig_monitor_server_list.py +8 -8
  60. commands/ops/orig_monitor_server_status.py +1 -5
  61. commands/ops/refresh_integration_daemon.py +5 -5
  62. commands/ops/restart_integration_daemon.py +5 -5
  63. commands/ops/table_integ_daemon_status.py +6 -6
  64. commands/ops/x_engine_actions.py +7 -7
  65. commands/tech/__init__.py +0 -2
  66. commands/tech/{generic_actions.py → element_actions.py} +6 -11
  67. commands/tech/get_element_info.py +20 -29
  68. commands/tech/get_guid_info.py +23 -42
  69. commands/tech/get_tech_details.py +20 -35
  70. commands/tech/get_tech_type_template.py +28 -39
  71. commands/tech/list_all_om_type_elements.py +24 -30
  72. commands/tech/list_all_om_type_elements_x.py +22 -28
  73. commands/tech/list_all_related_elements.py +19 -28
  74. commands/tech/list_anchored_elements.py +22 -30
  75. commands/tech/list_asset_types.py +19 -24
  76. commands/tech/list_elements_by_classification_by_property_value.py +26 -32
  77. commands/tech/list_elements_by_property_value.py +19 -25
  78. commands/tech/list_elements_by_property_value_x.py +20 -28
  79. commands/tech/list_elements_for_classification.py +28 -41
  80. commands/tech/list_gov_action_processes.py +16 -27
  81. commands/tech/list_information_supply_chains.py +22 -30
  82. commands/tech/list_registered_services.py +14 -26
  83. commands/tech/list_related_elements_with_prop_value.py +15 -25
  84. commands/tech/list_related_specification.py +1 -4
  85. commands/tech/list_relationship_types.py +15 -25
  86. commands/tech/list_relationships.py +20 -36
  87. commands/tech/list_solution_blueprints.py +28 -33
  88. commands/tech/list_solution_components.py +23 -29
  89. commands/tech/list_solution_roles.py +21 -32
  90. commands/tech/list_tech_templates.py +51 -54
  91. commands/tech/list_valid_metadata_values.py +5 -9
  92. commands/tech/table_tech_templates.py +2 -6
  93. commands/tech/x_list_related_elements.py +1 -4
  94. examples/GeoSpatial Products Example.py +524 -0
  95. examples/Jupyter Notebooks/P-egeria-server-config.ipynb +2137 -0
  96. examples/Jupyter Notebooks/README.md +2 -0
  97. examples/Jupyter Notebooks/common/P-environment-check.ipynb +115 -0
  98. examples/Jupyter Notebooks/common/__init__.py +14 -0
  99. examples/Jupyter Notebooks/common/common-functions.ipynb +4694 -0
  100. examples/Jupyter Notebooks/common/environment-check.ipynb +52 -0
  101. examples/Jupyter Notebooks/common/globals.ipynb +184 -0
  102. examples/Jupyter Notebooks/common/globals.py +154 -0
  103. examples/Jupyter Notebooks/common/orig_globals.py +152 -0
  104. examples/format_sets/all_format_sets.json +910 -0
  105. examples/format_sets/custom_format_sets.json +268 -0
  106. examples/format_sets/subset_format_sets.json +187 -0
  107. examples/format_sets_save_load_example.py +291 -0
  108. examples/jacquard_data_sets.py +129 -0
  109. examples/output_formats_example.py +193 -0
  110. examples/test_jacquard_data_sets.py +54 -0
  111. examples/test_jacquard_data_sets_scenarios.py +94 -0
  112. md_processing/__init__.py +90 -0
  113. md_processing/command_dispatcher.py +33 -0
  114. md_processing/command_mapping.py +221 -0
  115. md_processing/data/commands/commands_data_designer.json +537 -0
  116. md_processing/data/commands/commands_external_reference.json +733 -0
  117. md_processing/data/commands/commands_feedback.json +155 -0
  118. md_processing/data/commands/commands_general.json +204 -0
  119. md_processing/data/commands/commands_glossary.json +218 -0
  120. md_processing/data/commands/commands_governance.json +3678 -0
  121. md_processing/data/commands/commands_product_manager.json +865 -0
  122. md_processing/data/commands/commands_project.json +642 -0
  123. md_processing/data/commands/commands_solution_architect.json +366 -0
  124. md_processing/data/commands.json +17568 -0
  125. md_processing/data/commands_working.json +30641 -0
  126. md_processing/data/gened_report_specs.py +6584 -0
  127. md_processing/data/generated_format_sets.json +6533 -0
  128. md_processing/data/generated_format_sets_old.json +4137 -0
  129. md_processing/data/generated_format_sets_old.py +45 -0
  130. md_processing/dr_egeria.py +182 -0
  131. md_processing/md_commands/__init__.py +3 -0
  132. md_processing/md_commands/data_designer_commands.py +1276 -0
  133. md_processing/md_commands/ext_ref_commands.py +530 -0
  134. md_processing/md_commands/feedback_commands.py +726 -0
  135. md_processing/md_commands/glossary_commands.py +684 -0
  136. md_processing/md_commands/governance_officer_commands.py +600 -0
  137. md_processing/md_commands/product_manager_commands.py +1266 -0
  138. md_processing/md_commands/project_commands.py +383 -0
  139. md_processing/md_commands/solution_architect_commands.py +1184 -0
  140. md_processing/md_commands/view_commands.py +295 -0
  141. md_processing/md_processing_utils/__init__.py +4 -0
  142. md_processing/md_processing_utils/common_md_proc_utils.py +1249 -0
  143. md_processing/md_processing_utils/common_md_utils.py +578 -0
  144. md_processing/md_processing_utils/determine_width.py +103 -0
  145. md_processing/md_processing_utils/extraction_utils.py +547 -0
  146. md_processing/md_processing_utils/gen_report_specs.py +643 -0
  147. md_processing/md_processing_utils/generate_dr_help.py +193 -0
  148. md_processing/md_processing_utils/generate_md_cmd_templates.py +144 -0
  149. md_processing/md_processing_utils/generate_md_templates.py +83 -0
  150. md_processing/md_processing_utils/md_processing_constants.py +1228 -0
  151. md_processing/md_processing_utils/message_constants.py +19 -0
  152. pyegeria/__init__.py +201 -443
  153. pyegeria/core/__init__.py +40 -0
  154. pyegeria/core/_base_platform_client.py +574 -0
  155. pyegeria/core/_base_server_client.py +573 -0
  156. pyegeria/core/_exceptions.py +457 -0
  157. pyegeria/core/_globals.py +60 -0
  158. pyegeria/core/_server_client.py +6073 -0
  159. pyegeria/core/_validators.py +257 -0
  160. pyegeria/core/config.py +654 -0
  161. pyegeria/{create_tech_guid_lists.py → core/create_tech_guid_lists.py} +0 -1
  162. pyegeria/core/load_config.py +37 -0
  163. pyegeria/core/logging_configuration.py +207 -0
  164. pyegeria/core/mcp_adapter.py +144 -0
  165. pyegeria/core/mcp_server.py +212 -0
  166. pyegeria/core/utils.py +405 -0
  167. pyegeria/deprecated/__init__.py +0 -0
  168. pyegeria/{_client.py → deprecated/_client.py} +62 -24
  169. pyegeria/{_deprecated_gov_engine.py → deprecated/_deprecated_gov_engine.py} +16 -16
  170. pyegeria/{classification_manager_omvs.py → deprecated/classification_manager_omvs.py} +1988 -1878
  171. pyegeria/deprecated/output_formatter_with_machine_keys.py +1127 -0
  172. pyegeria/{runtime_manager_omvs.py → deprecated/runtime_manager_omvs.py} +216 -229
  173. pyegeria/{valid_metadata_omvs.py → deprecated/valid_metadata_omvs.py} +93 -93
  174. pyegeria/{x_action_author_omvs.py → deprecated/x_action_author_omvs.py} +2 -3
  175. pyegeria/egeria_cat_client.py +25 -51
  176. pyegeria/egeria_client.py +140 -98
  177. pyegeria/egeria_config_client.py +48 -24
  178. pyegeria/egeria_tech_client.py +170 -83
  179. pyegeria/models/__init__.py +150 -0
  180. pyegeria/models/collection_models.py +168 -0
  181. pyegeria/models/models.py +654 -0
  182. pyegeria/omvs/__init__.py +84 -0
  183. pyegeria/omvs/action_author.py +342 -0
  184. pyegeria/omvs/actor_manager.py +5980 -0
  185. pyegeria/omvs/asset_catalog.py +842 -0
  186. pyegeria/omvs/asset_maker.py +2736 -0
  187. pyegeria/omvs/automated_curation.py +4403 -0
  188. pyegeria/omvs/classification_manager.py +11213 -0
  189. pyegeria/omvs/collection_manager.py +5780 -0
  190. pyegeria/omvs/community_matters_omvs.py +468 -0
  191. pyegeria/{core_omag_server_config.py → omvs/core_omag_server_config.py} +157 -157
  192. pyegeria/{data_designer_omvs.py → omvs/data_designer.py} +1991 -1691
  193. pyegeria/omvs/data_discovery.py +869 -0
  194. pyegeria/omvs/data_engineer.py +372 -0
  195. pyegeria/omvs/digital_business.py +1133 -0
  196. pyegeria/omvs/external_links.py +1752 -0
  197. pyegeria/omvs/feedback_manager.py +834 -0
  198. pyegeria/{full_omag_server_config.py → omvs/full_omag_server_config.py} +73 -69
  199. pyegeria/omvs/glossary_manager.py +3231 -0
  200. pyegeria/omvs/governance_officer.py +3009 -0
  201. pyegeria/omvs/lineage_linker.py +314 -0
  202. pyegeria/omvs/location_arena.py +1525 -0
  203. pyegeria/omvs/metadata_expert.py +668 -0
  204. pyegeria/omvs/metadata_explorer_omvs.py +2943 -0
  205. pyegeria/omvs/my_profile.py +1042 -0
  206. pyegeria/omvs/notification_manager.py +358 -0
  207. pyegeria/omvs/people_organizer.py +394 -0
  208. pyegeria/{platform_services.py → omvs/platform_services.py} +113 -193
  209. pyegeria/omvs/product_manager.py +1825 -0
  210. pyegeria/omvs/project_manager.py +1907 -0
  211. pyegeria/omvs/reference_data.py +1140 -0
  212. pyegeria/omvs/registered_info.py +334 -0
  213. pyegeria/omvs/runtime_manager.py +2817 -0
  214. pyegeria/omvs/schema_maker.py +446 -0
  215. pyegeria/{server_operations.py → omvs/server_operations.py} +27 -26
  216. pyegeria/omvs/solution_architect.py +6490 -0
  217. pyegeria/omvs/specification_properties.py +37 -0
  218. pyegeria/omvs/subject_area.py +1042 -0
  219. pyegeria/omvs/template_manager_omvs.py +236 -0
  220. pyegeria/omvs/time_keeper.py +1761 -0
  221. pyegeria/omvs/valid_metadata.py +3221 -0
  222. pyegeria/omvs/valid_metadata_lists.py +37 -0
  223. pyegeria/omvs/valid_type_lists.py +37 -0
  224. pyegeria/view/__init__.py +28 -0
  225. pyegeria/view/_output_format_models.py +514 -0
  226. pyegeria/view/_output_formats.py +14 -0
  227. pyegeria/view/base_report_formats.py +2719 -0
  228. pyegeria/view/dr_egeria_reports.py +56 -0
  229. pyegeria/view/format_set_executor.py +397 -0
  230. pyegeria/{md_processing_utils.py → view/md_processing_utils.py} +5 -5
  231. pyegeria/{mermaid_utilities.py → view/mermaid_utilities.py} +2 -154
  232. pyegeria/view/output_formatter.py +1297 -0
  233. pyegeria-5.5.3.3.dist-info/METADATA +218 -0
  234. pyegeria-5.5.3.3.dist-info/RECORD +241 -0
  235. {pyegeria-5.3.9.9.3.dist-info → pyegeria-5.5.3.3.dist-info}/WHEEL +2 -1
  236. pyegeria-5.5.3.3.dist-info/entry_points.txt +103 -0
  237. pyegeria-5.5.3.3.dist-info/top_level.txt +4 -0
  238. commands/cat/.DS_Store +0 -0
  239. commands/cat/README.md +0 -16
  240. commands/cli/txt_custom_v2.tcss +0 -19
  241. commands/my/README.md +0 -17
  242. commands/ops/README.md +0 -24
  243. commands/ops/monitor_asset_events.py +0 -108
  244. commands/tech/README.md +0 -24
  245. pyegeria/.DS_Store +0 -0
  246. pyegeria/README.md +0 -35
  247. pyegeria/_globals.py +0 -47
  248. pyegeria/_validators.py +0 -385
  249. pyegeria/asset_catalog_omvs.py +0 -864
  250. pyegeria/automated_curation_omvs.py +0 -3765
  251. pyegeria/collection_manager_omvs.py +0 -2744
  252. pyegeria/dr.egeria spec.md +0 -9
  253. pyegeria/egeria_my_client.py +0 -56
  254. pyegeria/feedback_manager_omvs.py +0 -4573
  255. pyegeria/glossary_browser_omvs.py +0 -3728
  256. pyegeria/glossary_manager_omvs.py +0 -2440
  257. pyegeria/m_test.py +0 -118
  258. pyegeria/md_processing_helpers.py +0 -58
  259. pyegeria/md_processing_utils_orig.py +0 -1103
  260. pyegeria/metadata_explorer_omvs.py +0 -2326
  261. pyegeria/my_profile_omvs.py +0 -1022
  262. pyegeria/output_formatter.py +0 -389
  263. pyegeria/project_manager_omvs.py +0 -1933
  264. pyegeria/registered_info.py +0 -167
  265. pyegeria/solution_architect_omvs.py +0 -2156
  266. pyegeria/template_manager_omvs.py +0 -1414
  267. pyegeria/utils.py +0 -197
  268. pyegeria-5.3.9.9.3.dist-info/METADATA +0 -72
  269. pyegeria-5.3.9.9.3.dist-info/RECORD +0 -143
  270. pyegeria-5.3.9.9.3.dist-info/entry_points.txt +0 -99
  271. /pyegeria/{_exceptions.py → deprecated/_exceptions.py} +0 -0
  272. {pyegeria-5.3.9.9.3.dist-info → pyegeria-5.5.3.3.dist-info/licenses}/LICENSE +0 -0
@@ -1,3728 +0,0 @@
1
- """
2
- PDX-License-Identifier: Apache-2.0
3
- Copyright Contributors to the ODPi Egeria project.
4
-
5
- This module contains an initial version of the glossary_browser omvs module. There are additional methods that will be
6
- added in subsequent versions of the glossary_omvs module.
7
-
8
- """
9
-
10
- import asyncio
11
- from datetime import datetime
12
-
13
- from pyegeria import NO_GLOSSARIES_FOUND, max_paging_size
14
- from pyegeria._client import Client
15
- from pyegeria._exceptions import InvalidParameterException, PropertyServerException, UserNotAuthorizedException
16
- from pyegeria._globals import NO_CATEGORIES_FOUND, NO_TERMS_FOUND
17
- from pyegeria._validators import validate_guid, validate_name, validate_search_string
18
- from pyegeria.utils import body_slimmer
19
- from pyegeria.output_formatter import (
20
- make_preamble,
21
- make_md_attribute,
22
- format_for_markdown_table,
23
- generate_entity_md,
24
- generate_entity_md_table,
25
- generate_entity_dict,
26
- generate_output,
27
- MD_SEPARATOR
28
- )
29
-
30
-
31
- class GlossaryBrowser(Client):
32
- """
33
- GlossaryBrowser is a class that extends the Client class. It provides methods to search and retrieve glossaries,
34
- terms, and categories.
35
-
36
- Attributes:
37
-
38
- view_server: str
39
- The name of the View Server to connect to.
40
- platform_url : str
41
- URL of the server platform to connect to
42
- user_id : str
43
- The identity of the user calling the method - this sets a default optionally used by the methods
44
- when the user doesn't pass the user_id on a method call.
45
- user_pwd: str
46
- The password associated with the user_id. Defaults to None
47
-
48
- """
49
-
50
- def __init__(self, view_server: str, platform_url: str, user_id: str, user_pwd: str = None, token: str = None, ):
51
- self.view_server = view_server
52
- self.platform_url = platform_url
53
- self.user_pwd = user_pwd
54
- self.user_id = user_id
55
- self.g_browser_command_root: str
56
-
57
- Client.__init__(self, view_server, platform_url, user_id, user_pwd, token)
58
-
59
-
60
- def _extract_glossary_properties(self, element: dict, output_format: str = None) -> dict:
61
- """
62
- Extract common properties from a glossary element.
63
-
64
- Args:
65
- element (dict): The glossary element
66
- output_format (str, optional): The output format (FORM, REPORT, etc.)
67
-
68
- Returns:
69
- dict: Dictionary of extracted properties
70
- """
71
- guid = element['elementHeader'].get("guid", None)
72
- properties = element['glossaryProperties']
73
- display_name = properties.get("displayName", "") or ""
74
- description = properties.get("description", "") or ""
75
- language = properties.get("language", "") or ""
76
- usage = properties.get("usage", "") or ""
77
- qualified_name = properties.get("qualifiedName", "") or ""
78
-
79
- categories = self.get_categories_for_glossary(guid)
80
- cat_md_display = ''
81
- cat_md_qn = ''
82
- category_names = ''
83
- category_qualified_names = ''
84
-
85
- if type(categories) is list:
86
- for category in categories:
87
- cat_md_display += f" {category['glossaryCategoryProperties'][('displayName')]},\n"
88
- cat_md_qn += f" {category['glossaryCategoryProperties'][('qualifiedName')]},\n"
89
- category_names = cat_md_display.rstrip(',')
90
- category_qualified_names = cat_md_qn.rstrip(',')
91
-
92
- result = {
93
- 'guid': guid, 'properties': properties, 'display_name': display_name, 'description': description,
94
- 'language': language, 'usage': usage, 'qualified_name': qualified_name
95
- }
96
-
97
- # Include appropriate category information based on output format
98
- if output_format == 'FORM':
99
- result['categories_qualified_names'] = category_qualified_names
100
- else:
101
- result['categories_names'] = category_names
102
-
103
- return result
104
-
105
- def _generate_entity_md(self, elements: list, elements_action: str, output_format: str, entity_type: str,
106
- extract_properties_func, get_additional_props_func=None) -> str:
107
- """
108
- Generic method to generate markdown for entities (glossaries, terms, categories).
109
-
110
- Args:
111
- elements (list): List of entity elements
112
- elements_action (str): Action description for elements
113
- output_format (str): Output format
114
- entity_type (str): Type of entity (Glossary, Term, Category)
115
- extract_properties_func: Function to extract properties from an element
116
- get_additional_props_func: Optional function to get additional properties
117
-
118
- Returns:
119
- str: Markdown representation
120
- """
121
- return generate_entity_md(
122
- elements=elements,
123
- elements_action=elements_action,
124
- output_format=output_format,
125
- entity_type=entity_type,
126
- extract_properties_func=extract_properties_func,
127
- get_additional_props_func=get_additional_props_func
128
- )
129
-
130
- def _generate_glossary_md(self, elements: list, elements_action: str, output_format: str) -> str:
131
- """
132
- Generate markdown for glossaries.
133
-
134
- Args:
135
- elements (list): List of glossary elements
136
- elements_action (str): Action description for elements
137
- output_format (str): Output format
138
-
139
- Returns:
140
- str: Markdown representation
141
- """
142
- # Store the current output format for use by _extract_glossary_properties_with_format
143
- self._current_output_format = output_format
144
-
145
- return self._generate_entity_md(elements=elements, elements_action=elements_action, output_format=output_format,
146
- entity_type="Glossary",
147
- extract_properties_func=self._extract_glossary_properties_with_format)
148
-
149
- def _generate_entity_md_table(self, elements: list, search_string: str, entity_type: str, extract_properties_func,
150
- columns: list, get_additional_props_func=None, output_format: str = 'LIST') -> str:
151
- """
152
- Generic method to generate a markdown table for entities (glossaries, terms, categories).
153
-
154
- Args:
155
- elements (list): List of entity elements
156
- search_string (str): The search string used
157
- entity_type (str): Type of entity (Glossary, Term, Category)
158
- extract_properties_func: Function to extract properties from an element
159
- columns: List of column definitions, each containing 'name', 'key', and 'format' (optional)
160
- get_additional_props_func: Optional function to get additional properties
161
- output_format (str): Output format (FORM, REPORT, LIST, etc.)
162
-
163
- Returns:
164
- str: Markdown table
165
- """
166
- return generate_entity_md_table(
167
- elements=elements,
168
- search_string=search_string,
169
- entity_type=entity_type,
170
- extract_properties_func=extract_properties_func,
171
- columns=columns,
172
- get_additional_props_func=get_additional_props_func,
173
- output_format=output_format
174
- )
175
-
176
- def _generate_glossary_md_table(self, elements: list, search_string: str) -> str:
177
- """
178
- Generate a markdown table for glossaries.
179
-
180
- Args:
181
- elements (list): List of glossary elements
182
- search_string (str): The search string used
183
-
184
- Returns:
185
- str: Markdown table
186
- """
187
- # Store the current output format for use by _extract_glossary_properties_with_format
188
- self._current_output_format = 'LIST' # Tables use LIST format
189
-
190
- columns = [{'name': 'Glossary Name', 'key': 'display_name'},
191
- {'name': 'Qualified Name', 'key': 'qualified_name'},
192
- {'name': 'Language', 'key': 'language', 'format': True},
193
- {'name': 'Description', 'key': 'description', 'format': True},
194
- {'name': 'Usage', 'key': 'usage', 'format': True},
195
- {'name': 'Categories', 'key': 'categories_names', 'format': True}, ]
196
-
197
- return self._generate_entity_md_table(elements=elements, search_string=search_string, entity_type="Glossary",
198
- extract_properties_func=self._extract_glossary_properties_with_format,
199
- columns=columns)
200
-
201
- def _generate_entity_dict(self, elements: list, extract_properties_func, get_additional_props_func=None,
202
- include_keys=None, exclude_keys=None, output_format: str = 'DICT') -> list:
203
- """
204
- Generic method to generate a dictionary representation of entities (glossaries, terms, categories).
205
-
206
- Args:
207
- elements (list): List of entity elements
208
- extract_properties_func: Function to extract properties from an element
209
- get_additional_props_func: Optional function to get additional properties
210
- include_keys: Optional list of keys to include in the result (if None, include all)
211
- exclude_keys: Optional list of keys to exclude from the result (if None, exclude none)
212
- output_format (str): Output format (FORM, REPORT, DICT, etc.)
213
-
214
- Returns:
215
- list: List of entity dictionaries
216
- """
217
- return generate_entity_dict(
218
- elements=elements,
219
- extract_properties_func=extract_properties_func,
220
- get_additional_props_func=get_additional_props_func,
221
- include_keys=include_keys,
222
- exclude_keys=exclude_keys,
223
- output_format=output_format
224
- )
225
-
226
- def _generate_glossary_dict(self, elements: list, output_format: str = 'DICT') -> list:
227
- """
228
- Generate a dictionary representation of glossaries.
229
-
230
- Args:
231
- elements (list): List of glossary elements
232
- output_format (str): Output format (FORM, REPORT, DICT, etc.)
233
-
234
- Returns:
235
- list: List of glossary dictionaries
236
- """
237
- # Store the current output format for use by _extract_glossary_properties_with_format
238
- self._current_output_format = output_format
239
-
240
- return self._generate_entity_dict(elements=elements, extract_properties_func=self._extract_glossary_properties_with_format,
241
- exclude_keys=['properties'], output_format=output_format)
242
-
243
- def _extract_glossary_properties_with_format(self, element: dict) -> dict:
244
- """
245
- Wrapper function for _extract_glossary_properties that passes the current output format.
246
- This is used internally by generate_glossaries_md.
247
-
248
- Args:
249
- element (dict): The glossary element
250
-
251
- Returns:
252
- dict: Dictionary of extracted properties
253
- """
254
- # The output_format is stored as an instance variable during generate_glossaries_md
255
- return self._extract_glossary_properties(element, self._current_output_format)
256
-
257
- def generate_glossaries_md(self, elements: list | dict, search_string: str,
258
- output_format: str = 'MD') -> str | list:
259
- """
260
- Generate markdown or dictionary representation of glossaries.
261
-
262
- Args:
263
- elements (list | dict): List or dictionary of glossary elements
264
- search_string (str): The search string used
265
- output_format (str): Output format (MD, FORM, REPORT, LIST, DICT)
266
-
267
- Returns:
268
- str | list: Markdown string or list of dictionaries depending on output_format
269
- """
270
- # Store the current output format for use by _extract_glossary_properties_with_format
271
- self._current_output_format = output_format
272
-
273
- # Define columns for LIST format
274
- columns = [
275
- {'name': 'Glossary Name', 'key': 'display_name'},
276
- {'name': 'Qualified Name', 'key': 'qualified_name'},
277
- {'name': 'Language', 'key': 'language', 'format': True},
278
- {'name': 'Description', 'key': 'description', 'format': True},
279
- {'name': 'Usage', 'key': 'usage', 'format': True},
280
- {'name': 'Categories', 'key': 'categories_names', 'format': True},
281
- ]
282
-
283
- return generate_output(
284
- elements=elements,
285
- search_string=search_string,
286
- entity_type="Glossary",
287
- output_format=output_format,
288
- extract_properties_func=self._extract_glossary_properties_with_format,
289
- columns=columns if output_format == 'LIST' else None
290
- )
291
-
292
- def _extract_term_properties(self, element: dict) -> dict:
293
- """
294
- Extract common properties from a term element.
295
-
296
- Args:
297
- element (dict): The term element
298
-
299
- Returns:
300
- dict: Dictionary of extracted properties
301
- """
302
- guid = element['elementHeader'].get("guid", None)
303
- properties = element['glossaryTermProperties']
304
- display_name = properties.get("displayName", "") or ""
305
- summary = properties.get("summary", "") or ""
306
- description = properties.get("description", "") or ""
307
- examples = properties.get("examples", "") or ""
308
- usage = properties.get("usage", "") or ""
309
- pub_version = properties.get("publishVersionIdentifier", "") or ""
310
- qualified_name = properties.get("qualifiedName", "") or ""
311
- status = element['elementHeader'].get('status', "") or ""
312
- aliases = ", ".join(properties.get("aliases", "")) or ""
313
-
314
- return {
315
- 'guid': guid, 'properties': properties, 'display_name': display_name, 'aliases': aliases,
316
- 'summary': summary, 'description': description, 'examples': examples, 'usage': usage,
317
- 'version identifier': pub_version, 'qualified_name': qualified_name, 'status': status
318
- }
319
-
320
- def _get_categories_for_term(self, term_guid: str, output_format: str = None) -> tuple[list, str]:
321
- """
322
- Get a list of categories for a given term.
323
-
324
- Args:
325
- term_guid (str): The GUID of the term
326
- output_format (str): Output format (FORM, REPORT, LIST, etc.)
327
-
328
- Returns:
329
- tuple: A tuple containing:
330
- - list: List of category names
331
- - str: Formatted string of category names for markdown
332
- """
333
- category_names = []
334
- category_list_md = "\n"
335
-
336
- category_list = self.get_categories_for_term(term_guid)
337
- if type(category_list) is str and category_list == NO_CATEGORIES_FOUND:
338
- category_list_md = ''
339
- elif isinstance(category_list, list) and len(category_list) > 0:
340
- first_cat = True
341
- for category in category_list:
342
- # Use qualified name for FORM output, display name for REPORT and LIST output
343
- if output_format in ['REPORT', 'LIST']:
344
- category_name = category["glossaryCategoryProperties"].get("displayName", '---')
345
- else:
346
- category_name = category["glossaryCategoryProperties"].get("qualifiedName", '---')
347
-
348
- if category_name:
349
- category_names.append(category_name)
350
- if first_cat:
351
- category_list_md += f" {category_name}\n"
352
- first_cat = False
353
- else:
354
- category_list_md += f", {category_name}\n"
355
- else:
356
- category_list_md = '---'
357
-
358
- return category_names, category_list_md
359
-
360
- def _get_term_table_properties(self, element: dict, term_guid: str, output_format: str = None) -> dict:
361
- """
362
- Get properties for a term table row.
363
-
364
- Args:
365
- element (dict): The term element
366
- term_guid (str): The GUID of the term
367
- output_format (str): Output format (FORM, REPORT, etc.)
368
-
369
- Returns:
370
- dict: Dictionary of properties for the table row
371
- """
372
- # Get glossary information
373
- glossary_qualified_name = self._get_glossary_name_for_element(element, output_format)
374
-
375
- # Get categories
376
- category_names, _ = self._get_categories_for_term(term_guid, output_format)
377
- categories_str = ", ".join(category_names) if category_names else "---"
378
-
379
- return {
380
- 'glossary': glossary_qualified_name, 'categories_str': categories_str
381
- }
382
-
383
- def _generate_term_md_table(self, elements: list, search_string: str, output_format: str = 'LIST') -> str:
384
- """
385
- Generate a markdown table for terms.
386
-
387
- Args:
388
- elements (list): List of term elements
389
- search_string (str): The search string used
390
- output_format (str): Output format (FORM, REPORT, LIST, etc.)
391
-
392
- Returns:
393
- str: Markdown table
394
- """
395
- columns = [{'name': 'Term Name', 'key': 'display_name'}, {'name': 'Qualified Name', 'key': 'qualified_name'},
396
- {'name': 'Aliases', 'key': 'aliases', 'format': True},
397
- {'name': 'Summary', 'key': 'summary', 'format': True}, {'name': 'Glossary', 'key': 'glossary'},
398
- {'name': 'Categories', 'key': 'categories_str', 'format': True}]
399
-
400
- # Create a wrapper function to pass output_format to _get_term_table_properties
401
- def get_table_props_with_format(element, term_guid, output_format_param=None):
402
- return self._get_term_table_properties(element, term_guid, output_format)
403
-
404
- return self._generate_entity_md_table(elements=elements, search_string=search_string, entity_type="Term",
405
- extract_properties_func=self._extract_term_properties, columns=columns,
406
- get_additional_props_func=get_table_props_with_format)
407
-
408
- def _get_term_dict_properties(self, element: dict, term_guid: str, output_format: str = None) -> dict:
409
- """
410
- Get additional properties for a term dictionary.
411
-
412
- Args:
413
- element (dict): The term element
414
- term_guid (str): The GUID of the term
415
- output_format (str): Output format (FORM, REPORT, etc.)
416
-
417
- Returns:
418
- dict: Dictionary of additional properties
419
- """
420
- # Get glossary information
421
- glossary_qualified_name = self._get_glossary_name_for_element(element, output_format)
422
-
423
- # Get categories
424
- category_names, _ = self._get_categories_for_term(term_guid, output_format)
425
-
426
- return {
427
- 'in_glossary': glossary_qualified_name, 'categories': category_names,
428
- 'version': element['glossaryTermProperties'].get('publishfinVersionIdentifier', '')
429
- }
430
-
431
- def _generate_term_dict(self, elements: list, output_format: str = 'DICT') -> list:
432
- """
433
- Generate a dictionary representation of terms.
434
-
435
- Args:
436
- elements (list): List of term elements
437
- output_format (str): Output format (FORM, REPORT, DICT, etc.)
438
-
439
- Returns:
440
- list: List of term dictionaries
441
- """
442
-
443
- # Create a wrapper function to pass output_format to _get_term_dict_properties
444
- def get_dict_props_with_format(element, term_guid, output_format_param=None):
445
- return self._get_term_dict_properties(element, term_guid, output_format)
446
-
447
- return self._generate_entity_dict(elements=elements, extract_properties_func=self._extract_term_properties,
448
- get_additional_props_func=get_dict_props_with_format,
449
- exclude_keys=['properties', 'pub_version']
450
- # Exclude raw properties and pub_version (renamed to version)
451
- )
452
-
453
- def _get_term_additional_properties(self, element: dict, term_guid: str, output_format: str = None) -> dict:
454
- """
455
- Get additional properties for a term.
456
-
457
- Args:
458
- element (dict): The term element
459
- term_guid (str): The GUID of the term
460
- output_format (str): Output format (FORM, REPORT, etc.)
461
-
462
- Returns:
463
- dict: Dictionary of additional properties
464
- """
465
- # Get glossary information
466
- glossary_qualified_name = self._get_glossary_name_for_element(element, output_format)
467
-
468
- # Get categories
469
- _, category_list_md = self._get_categories_for_term(term_guid, output_format)
470
-
471
- return {
472
- 'in_glossary': glossary_qualified_name, 'categories': category_list_md
473
- }
474
-
475
- def _generate_term_md(self, elements: list, elements_action: str, output_format: str) -> str:
476
- """
477
- Generate markdown for terms.
478
-
479
- Args:
480
- elements (list): List of term elements
481
- elements_action (str): Action description for elements
482
- output_format (str): Output format
483
-
484
- Returns:
485
- str: Markdown representation
486
- """
487
- return self._generate_entity_md(elements=elements, elements_action=elements_action, output_format=output_format,
488
- entity_type="Term", extract_properties_func=self._extract_term_properties,
489
- get_additional_props_func=self._get_term_additional_properties)
490
-
491
- def generate_terms_md(self, elements: list | dict, search_string: str, output_format: str = 'MD') -> str | list:
492
- """
493
- Generate markdown or dictionary representation of terms.
494
-
495
- Args:
496
- elements (list | dict): List or dictionary of term elements
497
- search_string (str): The search string used
498
- output_format (str): Output format (MD, MD-TABLE, DICT, FORM, REPORT)
499
-
500
- Returns:
501
- str | list: Markdown string or list of dictionaries depending on output_format
502
- """
503
- # Define columns for LIST format
504
- columns = [
505
- {'name': 'Term Name', 'key': 'display_name'},
506
- {'name': 'Qualified Name', 'key': 'qualified_name'},
507
- {'name': 'Summary', 'key': 'summary', 'format': True},
508
- {'name': 'Description', 'key': 'description', 'format': True},
509
- {'name': 'Status', 'key': 'status'},
510
- {'name': 'Categories', 'key': 'categories', 'format': True},
511
- {'name': 'Glossary', 'key': 'glossary_name'},
512
- ]
513
-
514
- return generate_output(
515
- elements=elements,
516
- search_string=search_string,
517
- entity_type="Term",
518
- output_format=output_format,
519
- extract_properties_func=self._extract_term_properties,
520
- get_additional_props_func=self._get_term_additional_properties,
521
- columns=columns if output_format == 'LIST' else None
522
- )
523
-
524
- def _get_parent_category_name(self, category_guid: str, output_format: str = None) -> str:
525
- """
526
- Get the parent category name for a given category.
527
-
528
- Args:
529
- category_guid (str): The GUID of the category
530
- output_format (str): Output format (FORM, REPORT, LIST, etc.)
531
-
532
- Returns:
533
- str: The parent category name or ' ' if no parent
534
- """
535
- parent_cat = self.get_category_parent(category_guid)
536
- if isinstance(parent_cat, str):
537
- return ' '
538
-
539
- # Return qualified name for FORM output, display name for REPORT and LIST output
540
- if output_format == 'FORM':
541
- return parent_cat['glossaryCategoryProperties']['qualifiedName']
542
- elif output_format in ['REPORT', 'LIST']:
543
- return parent_cat['glossaryCategoryProperties']['displayName']
544
- else:
545
- # Default to qualified name for backward compatibility
546
- return parent_cat['glossaryCategoryProperties']['qualifiedName']
547
-
548
- def _get_subcategories_list(self, category_guid: str, output_format: str = None) -> tuple[list, str]:
549
- """
550
- Get a list of subcategories for a given category.
551
-
552
- Args:
553
- category_guid (str): The GUID of the category
554
- output_format (str): Output format (FORM, REPORT, LIST, etc.)
555
-
556
- Returns:
557
- tuple: A tuple containing:
558
- - list: List of subcategory names
559
- - str: Formatted string of subcategory names for markdown
560
- """
561
- subcategories = self.get_glossary_subcategories(category_guid)
562
- subcategory_list = []
563
-
564
- if isinstance(subcategories, str) and subcategories == NO_CATEGORIES_FOUND:
565
- subcategory_list_md = '---'
566
- elif isinstance(subcategories, list) and len(subcategories) > 0:
567
- for subcat in subcategories:
568
- # Use qualified name for FORM output, display name for REPORT and LIST output
569
- if output_format == 'FORM':
570
- subcat_name = subcat["glossaryCategoryProperties"].get("qualifiedName", '')
571
- elif output_format in ['REPORT', 'LIST']:
572
- subcat_name = subcat["glossaryCategoryProperties"].get("displayName", '')
573
- else:
574
- # Default to qualified name for backward compatibility
575
- subcat_name = subcat["glossaryCategoryProperties"].get("qualifiedName", '')
576
-
577
- if subcat_name:
578
- subcategory_list.append(subcat_name)
579
- subcategory_list_md = ", ".join(subcategory_list)
580
- else:
581
- subcategory_list_md = '---'
582
-
583
- return subcategory_list, subcategory_list_md
584
-
585
- def _get_glossary_name_for_element(self, element: dict, output_format: str = None) -> str:
586
- """
587
- Get the glossary name for a given element.
588
-
589
- Args:
590
- element (dict): The element dictionary
591
- output_format (str): Output format (FORM, REPORT, etc.)
592
-
593
- Returns:
594
- str: The glossary name or '---' if not found
595
- """
596
- classification_props = element["elementHeader"]['classifications'][0].get('classificationProperties', None)
597
- if classification_props is None:
598
- return '---'
599
-
600
- glossary_guid = classification_props.get('anchorScopeGUID', '---')
601
- if glossary_guid == '---':
602
- return '---'
603
-
604
- glossary = self.get_glossary_by_guid(glossary_guid)
605
-
606
- # Return display name for REPORT output, qualified name otherwise
607
- if output_format == 'REPORT':
608
- return glossary['glossaryProperties']['displayName']
609
- else:
610
- return glossary['glossaryProperties']['qualifiedName']
611
-
612
- def _extract_category_properties(self, element: dict) -> dict:
613
- """
614
- Extract common properties from a category element.
615
-
616
- Args:
617
- element (dict): The category element
618
-
619
- Returns:
620
- dict: Dictionary of extracted properties
621
- """
622
- guid = element['elementHeader'].get("guid", None)
623
- properties = element['glossaryCategoryProperties']
624
- display_name = properties.get("displayName", "") or ""
625
- description = properties.get("description", "") or ""
626
- qualified_name = properties.get("qualifiedName", "") or ""
627
-
628
- return {
629
- 'guid': guid, 'properties': properties, 'display_name': display_name, 'description': description,
630
- 'qualified_name': qualified_name
631
- }
632
-
633
- def _get_category_table_properties(self, element: dict, category_guid: str, output_format: str = None) -> dict:
634
- """
635
- Get properties for a category table row.
636
-
637
- Args:
638
- element (dict): The category element
639
- category_guid (str): The GUID of the category
640
- output_format (str): Output format (FORM, REPORT, etc.)
641
-
642
- Returns:
643
- dict: Dictionary of properties for the table row
644
- """
645
- # Get parent category
646
- parent_cat_md = self._get_parent_category_name(category_guid, output_format)
647
-
648
- # Get subcategories
649
- _, subcategory_list_md = self._get_subcategories_list(category_guid, output_format)
650
-
651
- return {
652
- 'parent_category': parent_cat_md, 'subcategories': subcategory_list_md
653
- }
654
-
655
- def _generate_category_md_table(self, elements: list, search_string: str, output_format: str = 'LIST') -> str:
656
- """
657
- Generate a markdown table for categories.
658
-
659
- Args:
660
- elements (list): List of category elements
661
- search_string (str): The search string used
662
- output_format (str): Output format (FORM, REPORT, etc.)
663
-
664
- Returns:
665
- str: Markdown table
666
- """
667
- columns = [{'name': 'Display Name', 'key': 'display_name'},
668
- {'name': 'Description', 'key': 'description', 'format': True},
669
- {'name': 'Qualified Name', 'key': 'qualified_name'},
670
- {'name': 'Parent Category', 'key': 'parent_category'},
671
- {'name': 'Subcategories', 'key': 'subcategories', 'format': True}]
672
-
673
- # Create a wrapper function to pass output_format to _get_category_table_properties
674
- def get_table_props_with_format(element, category_guid, output_format_param=None):
675
- return self._get_category_table_properties(element, category_guid, output_format)
676
-
677
- return self._generate_entity_md_table(elements=elements, search_string=search_string, entity_type="Category",
678
- extract_properties_func=self._extract_category_properties,
679
- columns=columns, get_additional_props_func=get_table_props_with_format)
680
-
681
- def _get_category_dict_properties(self, element: dict, category_guid: str, output_format: str = None) -> dict:
682
- """
683
- Get additional properties for a category dictionary.
684
-
685
- Args:
686
- element (dict): The category element
687
- category_guid (str): The GUID of the category
688
- output_format (str): Output format (FORM, REPORT, etc.)
689
-
690
- Returns:
691
- dict: Dictionary of additional properties
692
- """
693
- # Get parent category
694
- parent_cat_md = self._get_parent_category_name(category_guid, output_format)
695
-
696
- # Get subcategories
697
- subcategory_list, _ = self._get_subcategories_list(category_guid, output_format)
698
-
699
- # Get glossary information
700
- glossary_qualified_name = self._get_glossary_name_for_element(element, output_format)
701
-
702
- return {
703
- 'parent_category': parent_cat_md, 'subcategories': subcategory_list, 'in_glossary': glossary_qualified_name
704
- }
705
-
706
- def _generate_category_dict(self, elements: list, output_format: str = 'DICT') -> list:
707
- """
708
- Generate a dictionary representation of categories.
709
-
710
- Args:
711
- elements (list): List of category elements
712
- output_format (str): Output format (FORM, REPORT, etc.)
713
-
714
- Returns:
715
- list: List of category dictionaries
716
- """
717
-
718
- # Create a wrapper function to pass output_format to _get_category_dict_properties
719
- def get_dict_props_with_format(element, category_guid, output_format_param=None):
720
- return self._get_category_dict_properties(element, category_guid, output_format)
721
-
722
- return self._generate_entity_dict(elements=elements, extract_properties_func=self._extract_category_properties,
723
- get_additional_props_func=get_dict_props_with_format,
724
- exclude_keys=['properties'], # Exclude raw properties
725
- output_format=output_format)
726
-
727
- def _get_category_additional_properties(self, element: dict, category_guid: str, output_format: str = None) -> dict:
728
- """
729
- Get additional properties for a category.
730
-
731
- Args:
732
- element (dict): The category element
733
- category_guid (str): The GUID of the category
734
- output_format (str): Output format (FORM, REPORT, etc.)
735
-
736
- Returns:
737
- dict: Dictionary of additional properties
738
- """
739
- # Get parent category
740
- parent_cat_md = self._get_parent_category_name(category_guid, output_format)
741
-
742
- # Get glossary information
743
- glossary_qualified_name = self._get_glossary_name_for_element(element, output_format)
744
-
745
- # Only include subcategories if output_format is not FORM, REPORT, or MD
746
- if output_format not in ['FORM', 'REPORT', 'MD']:
747
- # Get subcategories
748
- _, subcategory_list_md = self._get_subcategories_list(category_guid, output_format)
749
- return {
750
- 'in_glossary': glossary_qualified_name, 'parent_category': parent_cat_md,
751
- 'subcategories': subcategory_list_md
752
- }
753
- else:
754
- return {
755
- 'in_glossary': glossary_qualified_name, 'parent_category': parent_cat_md
756
- }
757
-
758
- def _generate_category_md(self, elements: list, elements_action: str, output_format: str) -> str:
759
- """
760
- Generate markdown for categories.
761
-
762
- Args:
763
- elements (list): List of category elements
764
- elements_action (str): Action description for elements
765
- output_format (str): Output format
766
-
767
- Returns:
768
- str: Markdown representation
769
- """
770
-
771
- # Create a wrapper function to pass output_format to _get_category_additional_properties
772
- def get_additional_props_with_format(element, category_guid, output_format_param=None):
773
- return self._get_category_additional_properties(element, category_guid, output_format)
774
-
775
- return self._generate_entity_md(elements=elements, elements_action=elements_action, output_format=output_format,
776
- entity_type="Category",
777
- extract_properties_func=self._extract_category_properties,
778
- get_additional_props_func=get_additional_props_with_format)
779
-
780
- def generate_categories_md(self, elements: list | dict, search_string: str,
781
- output_format: str = 'MD') -> str | list:
782
- """
783
- Generate markdown or dictionary representation of categories.
784
-
785
- Args:
786
- elements (list | dict): List or dictionary of category elements
787
- search_string (str): The search string used
788
- output_format (str): Output format (MD, LIST, DICT, FORM, REPORT)
789
-
790
- Returns:
791
- str | list: Markdown string or list of dictionaries depending on output_format
792
- """
793
- # Define columns for LIST format
794
- columns = [
795
- {'name': 'Category Name', 'key': 'display_name'},
796
- {'name': 'Qualified Name', 'key': 'qualified_name'},
797
- {'name': 'Description', 'key': 'description', 'format': True},
798
- {'name': 'Parent Category', 'key': 'parent_category', 'format': True},
799
- {'name': 'Subcategories', 'key': 'subcategories', 'format': True},
800
- {'name': 'Glossary', 'key': 'glossary_name'},
801
- ]
802
-
803
- # Create a wrapper function to pass output_format to _get_category_additional_properties
804
- def get_additional_props_with_format(element, category_guid, output_format_param=None):
805
- return self._get_category_additional_properties(element, category_guid, output_format)
806
-
807
- return generate_output(
808
- elements=elements,
809
- search_string=search_string,
810
- entity_type="Category",
811
- output_format=output_format,
812
- extract_properties_func=self._extract_category_properties,
813
- get_additional_props_func=get_additional_props_with_format,
814
- columns=columns if output_format == 'LIST' else None
815
- )
816
-
817
- #
818
- # Get Valid Values for Enumerations
819
- #
820
-
821
- async def _async_get_glossary_term_statuses(self) -> [str]:
822
- """Return the list of glossary term status enum values. Async version.
823
-
824
- Parameters
825
- ----------
826
-
827
-
828
- Returns
829
- -------
830
- List[str]
831
- A list of glossary term statuses retrieved from the server.
832
-
833
- """
834
-
835
- url = (f"{self.platform_url}/servers/{self.view_server}"
836
- f"/api/open-metadata/glossary-browser/glossaries/terms/status-list")
837
-
838
- response = await self._async_make_request("GET", url)
839
- return response.json().get("statuses", [])
840
-
841
- def get_glossary_term_statuses(self) -> [str]:
842
- """Return the list of glossary term status enum values.
843
-
844
- Parameters
845
- ----------
846
-
847
-
848
- Returns
849
- -------
850
- list of str
851
- A list of glossary term statuses. Each status is represented as a string.
852
-
853
- """
854
- loop = asyncio.get_event_loop()
855
- response = loop.run_until_complete(self._async_get_glossary_term_statuses())
856
- return response
857
-
858
- async def _async_get_glossary_term_rel_statuses(self) -> [str]:
859
- """Return the list of glossary term relationship status enum values. These values are stored in a
860
- term-to-term, or term-to-category, relationship and are used to indicate how much the relationship should be
861
- trusted. Async version.
862
-
863
- Parameters
864
- ----------
865
-
866
-
867
- Returns
868
- -------
869
- List[str]
870
- A list of glossary term statuses retrieved from the server.
871
-
872
- """
873
-
874
- url = (f"{self.platform_url}/servers/{self.view_server}"
875
- f"/api/open-metadata/glossary-browser/glossaries/terms/relationships/status-list")
876
-
877
- response = await self._async_make_request("GET", url)
878
- return response.json().get("statuses", [])
879
-
880
- def get_glossary_term_rel_statuses(self) -> [str]:
881
- """Return the list of glossary term relationship status enum values. These values are stored in a
882
- term-to-term, or term-to-category, relationship and are used to indicate how much the relationship should be
883
- trusted.
884
-
885
- Parameters
886
- ----------
887
-
888
-
889
- Returns
890
- -------
891
- list of str
892
- A list of glossary term statuses. Each status is represented as a string.
893
-
894
- """
895
- loop = asyncio.get_event_loop()
896
- response = loop.run_until_complete(self._async_get_glossary_term_rel_statuses())
897
- return response
898
-
899
- async def _async_get_glossary_term_activity_types(self) -> [str]:
900
- """Return the list of glossary term activity type enum values. Async version.
901
-
902
- Parameters
903
- ----------
904
-
905
-
906
- Returns
907
- -------
908
- List[str]
909
- A list of glossary term statuses retrieved from the server.
910
-
911
- """
912
-
913
- url = (f"{self.platform_url}/servers/{self.view_server}"
914
- f"/api/open-metadata/glossary-browser/glossaries/terms/activity-types")
915
-
916
- response = await self._async_make_request("GET", url)
917
- return response.json().get("types", [])
918
-
919
- def get_glossary_term_activity_types(self) -> [str]:
920
- """Return the list of glossary term activity type enum values.
921
-
922
- Parameters
923
- ----------
924
-
925
-
926
- Returns
927
- -------
928
- list of str
929
- A list of glossary term statuses. Each status is represented as a string.
930
-
931
- """
932
- loop = asyncio.get_event_loop()
933
- response = loop.run_until_complete(self._async_get_glossary_term_statuses())
934
- return response
935
-
936
- async def _async_get_term_relationship_types(self) -> [str]:
937
- """Return the list of term relationship types enum values. Async version.
938
-
939
- Parameters
940
- ----------
941
-
942
-
943
- Returns
944
- -------
945
- List[str]
946
- A list of glossary term relationships retrieved from the server.
947
-
948
- """
949
-
950
- url = (f"{self.platform_url}/servers/{self.view_server}"
951
- f"/api/open-metadata/glossary-manager/glossaries/terms/relationships/type-names")
952
-
953
- response = await self._async_make_request("GET", url)
954
- return response.json().get("names", [])
955
-
956
- def get_term_relationship_types(self) -> [str]:
957
- """Return the list of term relationship type enum values.
958
-
959
- Parameters
960
- ----------
961
-
962
-
963
- Returns
964
- -------
965
- list of str
966
- A list of term relationship types. Each status is represented as a string.
967
-
968
- """
969
- loop = asyncio.get_event_loop()
970
- response = loop.run_until_complete(self._async_get_term_relationship_types())
971
- return response
972
-
973
- #
974
- # Glossaries
975
- #
976
-
977
- async def _async_find_glossaries(self, search_string: str, effective_time: str = None, starts_with: bool = False,
978
- ends_with: bool = False, ignore_case: bool = False, for_lineage: bool = False,
979
- for_duplicate_processing: bool = False, type_name: str = None, start_from: int = 0,
980
- page_size: int = None, output_format: str = 'JSON') -> list | str:
981
- """Retrieve the list of glossary metadata elements that contain the search string. Async version.
982
- The search string is located in the request body and is interpreted as a plain string.
983
- The request parameters, startsWith, endsWith, and ignoreCase can be used to allow a fuzzy search.
984
-
985
- Parameters
986
- ----------
987
- search_string: str,
988
- Search string to use to find matching glossaries. If the search string is '*' then all glossaries returned.
989
-
990
- effective_time: str, [default=None], optional
991
- Effective time of the query. If not specified will default to any time. Time format is
992
- "YYYY-MM-DDTHH:MM:SS" (ISO 8601)
993
-
994
- If not provided, the server name associated with the instance is used.
995
- starts_with : bool, [default=False], optional
996
- Starts with the supplied string.
997
- ends_with : bool, [default=False], optional
998
- Ends with the supplied string
999
- ignore_case : bool, [default=False], optional
1000
- Ignore case when searching
1001
- for_lineage : bool, [default=False], optional
1002
-
1003
- for_duplicate_processing : bool, [default=False], optional
1004
- type_name: str, [default=None], optional
1005
- An optional parameter indicating the subtype of the glossary to filter by.
1006
- Values include 'ControlledGlossary', 'EditingGlossary', and 'StagingGlossary'
1007
- start_from: int, [default=0], optional
1008
- When multiple pages of results are available, the page number to start from.
1009
- page_size: int, [default=None]
1010
- The number of items to return in a single page. If not specified, the default will be taken from
1011
- the class instance.
1012
- output_format: str, default = 'JSON'
1013
- Type of output to produce:
1014
- JSON - output standard json
1015
- MD - output standard markdown with no preamble
1016
- FORM - output markdown with a preamble for a form
1017
- REPORT - output markdown with a preamble for a report
1018
-
1019
- Returns
1020
- -------
1021
- List | str
1022
-
1023
- A list of glossary definitions active in the server.
1024
-
1025
- Raises
1026
- ------
1027
-
1028
- InvalidParameterException
1029
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values
1030
- PropertyServerException
1031
- Raised by the server when an issue arises in processing a valid request
1032
- NotAuthorizedException
1033
- The principle specified by the user_id does not have authorization for the requested action
1034
-
1035
- """
1036
-
1037
- if page_size is None:
1038
- page_size = self.page_size
1039
- starts_with_s = str(starts_with).lower()
1040
- ends_with_s = str(ends_with).lower()
1041
- ignore_case_s = str(ignore_case).lower()
1042
- for_lineage_s = str(for_lineage).lower()
1043
- for_duplicate_processing_s = str(for_duplicate_processing).lower()
1044
-
1045
- validate_search_string(search_string)
1046
-
1047
- if search_string == "*":
1048
- search_string = None
1049
-
1050
- body = {
1051
- "class": "SearchStringRequestBody", "searchString": search_string, "effectiveTime": effective_time,
1052
- "typeName": type_name,
1053
- }
1054
- body = body_slimmer(body)
1055
-
1056
- url = (f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/"
1057
- f"by-search-string?startFrom={start_from}&pageSize={page_size}&startsWith={starts_with_s}&"
1058
- f"endsWith={ends_with_s}&ignoreCase={ignore_case_s}&forLineage={for_lineage_s}&"
1059
- f"forDuplicateProcessing={for_duplicate_processing_s}")
1060
-
1061
- response = await self._async_make_request("POST", url, body_slimmer(body))
1062
- element = response.json().get("elementList", NO_GLOSSARIES_FOUND)
1063
- if element == NO_GLOSSARIES_FOUND:
1064
- if output_format == 'JSON':
1065
- return NO_GLOSSARIES_FOUND
1066
- elif output_format in ['MD', 'FORM', 'REPORT', 'LIST']:
1067
- return "\n# No glossaries found.\n"
1068
- elif output_format == 'DICT':
1069
- return None
1070
-
1071
- if output_format != 'JSON': # return a simplified markdown representation
1072
- return self.generate_glossaries_md(element, search_string, output_format)
1073
- return response.json().get("elementList", NO_GLOSSARIES_FOUND)
1074
-
1075
- def find_glossaries(self, search_string: str, effective_time: str = None, starts_with: bool = False,
1076
- ends_with: bool = False, ignore_case: bool = False, for_lineage: bool = False,
1077
- for_duplicate_processing: bool = False, type_name: str = None, start_from: int = 0,
1078
- page_size: int = None, output_format: str = "JSON") -> list | str:
1079
- """Retrieve the list of glossary metadata elements that contain the search string.
1080
- The search string is located in the request body and is interpreted as a plain string.
1081
- The request parameters, startsWith, endsWith, and ignoreCase can be used to allow a fuzzy search.
1082
-
1083
- Parameters
1084
- ----------
1085
- search_string: str,
1086
- Search string to use to find matching glossaries. If the search string is '*',
1087
- then all glossaries returned.
1088
-
1089
- effective_time: str, [default=None], optional
1090
- Effective time of the query. If not specified will default to any time. Time format is
1091
- "YYYY-MM-DDTHH:MM:SS" (ISO 8601)
1092
-
1093
- If not provided, the server name associated with the instance is used.
1094
- starts_with : bool, [default=False], optional
1095
- Starts with the supplied string.
1096
- ends_with : bool, [default=False], optional
1097
- Ends with the supplied string
1098
- ignore_case : bool, [default=False], optional
1099
- Ignore case when searching
1100
- for_lineage : bool, [default=False], optional
1101
- Indicates the search is for lineage.
1102
- for_duplicate_processing : bool, [default=False], optional
1103
- type_name: str, [default=None], optional
1104
- An optional parameter indicating the subtype of the glossary to filter by.
1105
- Values include 'ControlledGlossary', 'EditingGlossary', and 'StagingGlossary'
1106
- start_from : int, [default=0], optional
1107
- When multiple pages of results are available, the page number to start from.
1108
- page_size: int, [default=None]
1109
- The number of items to return in a single page. If not specified, the default will be taken from
1110
- the class instance.
1111
- output_format: str, default = 'JSON'
1112
- Type of output to produce:
1113
- JSON - output standard json
1114
- MD - output standard markdown with no preamble
1115
- FORM - output markdown with a preamble for a form
1116
- REPORT - output markdown with a preamble for a report
1117
- LIST - output a markdown table with columns for Glossary Name, Qualified Name, Language, Description,
1118
- Usage
1119
- DICT - output a dictionary structure containing all attributes
1120
- Returns
1121
- -------
1122
- List | str
1123
-
1124
- A list of glossary definitions active in the server.
1125
-
1126
- Raises
1127
- ------
1128
-
1129
- InvalidParameterException
1130
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values
1131
- PropertyServerException
1132
- Raised by the server when an issue arises in processing a valid request
1133
- NotAuthorizedException
1134
- The principle specified by the user_id does not have authorization for the requested action
1135
-
1136
- """
1137
- loop = asyncio.get_event_loop()
1138
- response = loop.run_until_complete(
1139
- self._async_find_glossaries(search_string, effective_time, starts_with, ends_with, ignore_case, for_lineage,
1140
- for_duplicate_processing, type_name, start_from, page_size, output_format))
1141
-
1142
- return response
1143
-
1144
- async def _async_get_glossary_by_guid(self, glossary_guid: str, effective_time: str = None,
1145
- output_format: str = "JSON") -> dict | str:
1146
- """Retrieves information about a glossary
1147
- Parameters
1148
- ----------
1149
- glossary_guid : str
1150
- Unique idetifier for the glossary
1151
- effective_time: str, optional
1152
- Effective time of the query. If not specified will default to any time. Time format is
1153
- "YYYY-MM-DDTHH:MM:SS" (ISO 8601)
1154
- output_format: str, default = 'JSON'
1155
- Type of output to produce:
1156
- JSON - output standard json
1157
- MD - output standard markdown with no preamble
1158
- FORM - output markdown with a preamble for a form
1159
- REPORT - output markdown with a preamble for a report
1160
- LIST - output a markdown table with columns for Glossary Name, Qualified Name, Language, Description,
1161
- Usage
1162
- DICT - output a dictionary structure containing all attributes
1163
-
1164
- Returns
1165
- -------
1166
- dict | str
1167
- if output format is JSON: The glossary definition associated with the glossary_guid
1168
- if output format is MD: A markdown string with the same information.
1169
- Raises
1170
- ------
1171
- InvalidParameterException
1172
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
1173
- PropertyServerException
1174
- Raised by the server when an issue arises in processing a valid request.
1175
- NotAuthorizedException
1176
- The principle specified by the user_id does not have authorization for the requested action.
1177
- Notes
1178
- -----
1179
- """
1180
- output_format = output_format.upper()
1181
- validate_guid(glossary_guid)
1182
-
1183
- body = {
1184
- "class": "EffectiveTimeQueryRequestBody", "effectiveTime": effective_time
1185
- }
1186
- url = (f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/"
1187
- f"{glossary_guid}/retrieve")
1188
- response = await self._async_make_request("POST", url, body_slimmer(body))
1189
- element = response.json().get("element", NO_GLOSSARIES_FOUND)
1190
- if element == NO_GLOSSARIES_FOUND:
1191
- return NO_GLOSSARIES_FOUND
1192
- if output_format != 'JSON': # return a simplified markdown representation
1193
- return self.generate_glossaries_md(element, "GUID", output_format)
1194
- return response.json().get("element", NO_GLOSSARIES_FOUND)
1195
-
1196
- def get_glossary_by_guid(self, glossary_guid: str, effective_time: str = None, output_format: str = "JSON") -> dict:
1197
- """Retrieves information about a glossary
1198
- Parameters
1199
- ----------
1200
- glossary_guid : str
1201
- Unique idetifier for the glossary
1202
- effective_time: str, optional
1203
- Effective time of the query. If not specified will default to any time. Time format is
1204
- "YYYY-MM-DDTHH:MM:SS" (ISO 8601)
1205
- output_format: str, default = 'JSON'
1206
- Type of output to produce:
1207
- JSON - output standard json
1208
- MD - output standard markdown with no preamble
1209
- FORM - output markdown with a preamble for a form
1210
- REPORT - output markdown with a preamble for a report
1211
- LIST - output a markdown table with columns for Glossary Name, Qualified Name, Language, Description,
1212
- Usage
1213
- DICT - output a dictionary structure containing all attributes
1214
-
1215
- Returns
1216
- -------
1217
- dict
1218
- The glossary definition associated with the glossary_guid
1219
-
1220
- Raises
1221
- ------
1222
- InvalidParameterException
1223
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
1224
- PropertyServerException
1225
- Raised by the server when an issue arises in processing a valid request.
1226
- NotAuthorizedException
1227
- The principle specified by the user_id does not have authorization for the requested action.
1228
- Notes
1229
- -----
1230
- """
1231
- loop = asyncio.get_event_loop()
1232
- response = loop.run_until_complete(
1233
- self._async_get_glossary_by_guid(glossary_guid, effective_time, output_format))
1234
- return response
1235
-
1236
- async def _async_get_glossaries_by_name(self, glossary_name: str, effective_time: str = None, start_from: int = 0,
1237
- page_size: int = None, ) -> dict | str:
1238
- """Retrieve the list of glossary metadata elements with an exactly matching qualified or display name.
1239
- There are no wildcards supported on this request.
1240
-
1241
- Parameters
1242
- ----------
1243
- glossary_name: str,
1244
- Name of the glossary to be retrieved
1245
- effective_time: datetime, [default=None], optional
1246
- Effective time of the query. If not specified will default to any effective time. Time format is
1247
- "YYYY-MM-DDTHH:MM:SS" (ISO 8601)
1248
-
1249
- If not provided, the server name associated with the instance is used.
1250
- start_from: int, [default=0], optional
1251
- When multiple pages of results are available, the page number to start from.
1252
- page_size: int, [default=None]
1253
- The number of items to return in a single page. If not specified, the default will be taken from
1254
- the class instance.
1255
-
1256
- Returns
1257
- -------
1258
- None
1259
-
1260
- Raises
1261
- ------
1262
-
1263
- InvalidParameterException
1264
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values
1265
- PropertyServerException
1266
- Raised by the server when an issue arises in processing a valid request
1267
- NotAuthorizedException
1268
- The principle specified by the user_id does not have authorization for the requested action
1269
- ConfigurationErrorException
1270
- Raised when configuration parameters passed on earlier calls turn out to be
1271
- invalid or make the new call invalid.
1272
- """
1273
-
1274
- if page_size is None:
1275
- page_size = self.page_size
1276
- validate_name(glossary_name)
1277
-
1278
- if effective_time is None:
1279
- body = {"name": glossary_name}
1280
- else:
1281
- body = {"name": glossary_name, "effectiveTime": effective_time}
1282
-
1283
- url = (f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/"
1284
- f"by-name?startFrom={start_from}&pageSize={page_size}")
1285
-
1286
- response = await self._async_make_request("POST", url, body)
1287
- return response.json().get("elementList", "No glossaries found")
1288
-
1289
- def get_glossaries_by_name(self, glossary_name: str, effective_time: str = None, start_from: int = 0,
1290
- page_size: int = None, ) -> dict | str:
1291
- """Retrieve the list of glossary metadata elements with an exactly matching qualified or display name.
1292
- There are no wildcards supported on this request.
1293
-
1294
- Parameters
1295
- ----------
1296
- glossary_name: str,
1297
- Name of the glossary to be retrieved
1298
- effective_time: datetime, [default=None], optional
1299
- Effective time of the query. If not specified will default to any effective time.
1300
-
1301
- If not provided, the server name associated with the instance is used.
1302
- start_from: int, [default=0], optional
1303
- When multiple pages of results are available, the page number to start from.
1304
- page_size: int, [default=None]
1305
- The number of items to return in a single page. If not specified, the default will be taken from
1306
- the class instance.
1307
-
1308
- Returns
1309
- -------
1310
- None
1311
-
1312
- Raises
1313
- ------
1314
- InvalidParameterException
1315
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values
1316
- PropertyServerException
1317
- Raised by the server when an issue arises in processing a valid request
1318
- NotAuthorizedException
1319
- The principle specified by the user_id does not have authorization for the requested action
1320
- ConfigurationErrorException
1321
- Raised when configuration parameters passed on earlier calls turn out to be
1322
- invalid or make the new call invalid.
1323
- """
1324
- loop = asyncio.get_event_loop()
1325
- response = loop.run_until_complete(
1326
- self._async_get_glossaries_by_name(glossary_name, effective_time, start_from, page_size))
1327
- return response
1328
-
1329
- #
1330
- # Glossary Categories
1331
- #
1332
-
1333
- async def _async_get_glossary_for_category(self, glossary_category_guid: str,
1334
- effective_time: str = None, ) -> dict | str:
1335
- """Retrieve the glossary metadata element for the requested category. The optional request body allows you to
1336
- specify that the glossary element should only be returned if it was effective at a particular time.
1337
-
1338
- Parameters
1339
- ----------
1340
- glossary_category_guid: str,
1341
- Unique identifier for the glossary category.
1342
- effective_time: datetime, [default=None], optional
1343
- Effective time of the query. If not specified will default to any effective time. Time format is
1344
- "YYYY-MM-DDTHH:MM:SS" (ISO 8601)
1345
-
1346
- If not provided, the server name associated with the instance is used.
1347
-
1348
- Returns
1349
- -------
1350
- A dict structure with the glossary metadata element for the requested category.
1351
-
1352
- Raises
1353
- ------
1354
-
1355
- InvalidParameterException
1356
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values
1357
- PropertyServerException
1358
- Raised by the server when an issue arises in processing a valid request
1359
- NotAuthorizedException
1360
- The principle specified by the user_id does not have authorization for the requested action
1361
- ConfigurationErrorException
1362
- Raised when configuration parameters passed on earlier calls turn out to be
1363
- invalid or make the new call invalid.
1364
- """
1365
-
1366
- body = {
1367
- "class": "EffectiveTimeQueryRequestBody", "effectiveTime": effective_time,
1368
- }
1369
-
1370
- url = (f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/"
1371
- f"for-category/{glossary_category_guid}/retrieve")
1372
-
1373
- response = await self._async_make_request("POST", url, body)
1374
- return response.json().get("elementList", "No categories found")
1375
-
1376
- def get_glossary_for_category(self, glossary_category_guid: str, effective_time: str = None, ) -> dict | str:
1377
- """Retrieve the glossary metadata element for the requested category. The optional request body allows you to
1378
- specify that the glossary element should only be returned if it was effective at a particular time.
1379
-
1380
- Parameters
1381
- ----------
1382
- glossary_category_guid: str,
1383
- Unique identifier for the glossary category.
1384
- effective_time: datetime, [default=None], optional
1385
- Effective time of the query. If not specified will default to any effective time. Time format is
1386
- "YYYY-MM-DDTHH:MM:SS" (ISO 8601)
1387
-
1388
- If not provided, the server name associated with the instance is used.
1389
-
1390
- Returns
1391
- -------
1392
- A dict structure with the glossary metadata element for the requested category.
1393
-
1394
- Raises
1395
- ------
1396
-
1397
- InvalidParameterException
1398
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values
1399
- PropertyServerException
1400
- Raised by the server when an issue arises in processing a valid request
1401
- NotAuthorizedException
1402
- The principle specified by the user_id does not have authorization for the requested action
1403
- ConfigurationErrorException
1404
- Raised when configuration parameters passed on earlier calls turn out to be
1405
- invalid or make the new call invalid.
1406
- """
1407
- loop = asyncio.get_event_loop()
1408
- response = loop.run_until_complete(
1409
- self._async_get_glossary_for_category(glossary_category_guid, effective_time))
1410
- return response
1411
-
1412
- async def _async_get_glossary_subcategories(self, glossary_category_guid: str, effective_time: str = None,
1413
- start_from: int = 0, page_size: int = max_paging_size,
1414
- for_lineage: bool = False,
1415
- for_duplicate_processing: bool = False, ) -> dict | str:
1416
- """Glossary categories can be organized in a hierarchy. Retrieve the subcategories for the glossary category
1417
- metadata element with the supplied unique identifier. If the requested category does not have any subcategories,
1418
- null is returned. The optional request body contain an effective time for the query.
1419
-
1420
- Parameters
1421
- ----------
1422
- glossary_category_guid: str,
1423
- Unique identifier for the glossary category.
1424
- effective_time: datetime, [default=None], optional
1425
- Effective time of the query. If not specified will default to any effective time. Time format is
1426
- "YYYY-MM-DDTHH:MM:SS" (ISO 8601)
1427
- start_from: int, [default=0], optional
1428
- The page to start from.
1429
- page_size: int, [default=max_paging_size], optional
1430
- The number of results per page to return.
1431
- for_lineage: bool, [default=False], optional
1432
- Indicates the search is for lineage.
1433
- for_duplicate_processing: bool, [default=False], optional
1434
- If set to True the user will handle duplicate processing.
1435
-
1436
- Returns
1437
- -------
1438
- A dict list with the glossary metadata element for the requested category.
1439
-
1440
- Raises
1441
- ------
1442
-
1443
- InvalidParameterException
1444
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values
1445
- PropertyServerException
1446
- Raised by the server when an issue arises in processing a valid request
1447
- NotAuthorizedException
1448
- The principle specified by the user_id does not have authorization for the requested action
1449
- ConfigurationErrorException
1450
- Raised when configuration parameters passed on earlier calls turn out to be
1451
- invalid or make the new call invalid.
1452
- """
1453
- for_lineage_s = str(for_lineage).lower()
1454
- for_duplicate_processing_s = str(for_duplicate_processing).lower()
1455
-
1456
- body = {
1457
- "class": "EffectiveTimeQueryRequestBody", "effectiveTime": effective_time,
1458
- }
1459
-
1460
- url = (f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/"
1461
- f"categories/{glossary_category_guid}/subcategories/retrieve?startFrom={start_from}&pageSize="
1462
- f"{page_size}&"
1463
- f"forLineage={for_lineage_s}&forDuplicateProcessing={for_duplicate_processing_s}")
1464
- if effective_time:
1465
- response = await self._async_make_request("POST", url, body_slimmer(body))
1466
- else:
1467
- response = await self._async_make_request("POST", url)
1468
-
1469
- return response.json().get("elementList", "No categories found")
1470
-
1471
- def get_glossary_subcategories(self, glossary_category_guid: str, effective_time: str = None, start_from: int = 0,
1472
- page_size: int = max_paging_size, for_lineage: bool = False,
1473
- for_duplicate_processing: bool = False, ) -> dict | str:
1474
- """Glossary categories can be organized in a hierarchy. Retrieve the subcategories for the glossary category
1475
- metadata element with the supplied unique identifier. If the requested category does not have any subcategories,
1476
- null is returned. The optional request body contain an effective time for the query.
1477
-
1478
- Parameters
1479
- ----------
1480
- glossary_category_guid: str,
1481
- Unique identifier for the glossary category.
1482
- effective_time: datetime, [default=None], optional
1483
- Effective time of the query. If not specified will default to any effective time. Time format is
1484
- "YYYY-MM-DDTHH:MM:SS" (ISO 8601)
1485
- start_from: int, [default=0], optional
1486
- The page to start from.
1487
- page_size: int, [default=max_paging_size], optional
1488
- The number of results per page to return.
1489
- for_lineage: bool, [default=False], optional
1490
- Indicates the search is for lineage.
1491
- for_duplicate_processing: bool, [default=False], optional
1492
- If set to True the user will handle duplicate processing.
1493
-
1494
- Returns
1495
- -------
1496
- A dict list with the glossary metadata element for the requested category.
1497
-
1498
- Raises
1499
- ------
1500
-
1501
- InvalidParameterException
1502
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values
1503
- PropertyServerException
1504
- Raised by the server when an issue arises in processing a valid request
1505
- NotAuthorizedException
1506
- The principle specified by the user_id does not have authorization for the requested action
1507
- ConfigurationErrorException
1508
- Raised when configuration parameters passed on earlier calls turn out to be
1509
- invalid or make the new call invalid.
1510
- """
1511
- loop = asyncio.get_event_loop()
1512
- response = loop.run_until_complete(
1513
- self._async_get_glossary_subcategories(glossary_category_guid, effective_time, start_from, page_size,
1514
- for_lineage, for_duplicate_processing))
1515
- return response
1516
-
1517
- async def _async_find_glossary_categories(self, search_string: str, effective_time: str = None,
1518
- starts_with: bool = False, ends_with: bool = False,
1519
- ignore_case: bool = False, start_from: int = 0, page_size: int = None,
1520
- output_format: str = "JSON") -> list | str:
1521
- """Retrieve the list of glossary category metadata elements that contain the search string.
1522
- The search string is located in the request body and is interpreted as a plain string.
1523
- The request parameters, startsWith, endsWith, and ignoreCase can be used to allow a fuzzy search.
1524
- Async version.
1525
-
1526
- Parameters
1527
- ----------
1528
- search_string: str,
1529
- Search string to use to find matching glossaries. If the search string is '*' then all glossaries returned.
1530
-
1531
- effective_time: str, [default=None], optional
1532
- Effective time of the query. If not specified will default to any time. Time format is
1533
- "YYYY-MM-DDTHH:MM:SS" (ISO 8601)
1534
-
1535
- If not provided, the server name associated with the instance is used.
1536
- starts_with : bool, [default=False], optional
1537
- Starts with the supplied string.
1538
- ends_with : bool, [default=False], optional
1539
- Ends with the supplied string
1540
- ignore_case : bool, [default=False], optional
1541
- Ignore case when searching
1542
- start_from: int, [default=0], optional
1543
- When multiple pages of results are available, the page number to start from.
1544
- page_size: int, [default=None]
1545
- The number of items to return in a single page. If not specified, the default will be taken from
1546
- the class instance.
1547
- output_format: str, default = 'JSON'
1548
- Type of output to produce:
1549
- JSON - output standard json
1550
- MD - output standard markdown with no preamble
1551
- FORM - output markdown with a preamble for a form
1552
- REPORT - output markdown with a preamble for a report
1553
-
1554
- Returns
1555
- -------
1556
- List | str
1557
-
1558
- A list of glossary definitions active in the server.
1559
-
1560
- Raises
1561
- ------
1562
-
1563
- InvalidParameterException
1564
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values
1565
- PropertyServerException
1566
- Raised by the server when an issue arises in processing a valid request
1567
- NotAuthorizedException
1568
- The principle specified by the user_id does not have authorization for the requested action
1569
-
1570
- """
1571
-
1572
- if page_size is None:
1573
- page_size = self.page_size
1574
- starts_with_s = str(starts_with).lower()
1575
- ends_with_s = str(ends_with).lower()
1576
- ignore_case_s = str(ignore_case).lower()
1577
-
1578
- validate_search_string(search_string)
1579
-
1580
- if search_string == "*":
1581
- search_string = None
1582
-
1583
- body = {
1584
- "class": "SearchStringRequestBody", "searchString": search_string, "effectiveTime": effective_time,
1585
- }
1586
-
1587
- url = (f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/"
1588
- f"categories/by-search-string?startFrom={start_from}&pageSize={page_size}&startsWith={starts_with_s}&"
1589
- f"endsWith={ends_with_s}&ignoreCase={ignore_case_s}")
1590
- response = await self._async_make_request("POST", url, body_slimmer(body))
1591
- element = response.json().get("elementList", NO_CATEGORIES_FOUND)
1592
- if element == NO_CATEGORIES_FOUND:
1593
- if output_format == 'JSON':
1594
- return NO_CATEGORIES_FOUND
1595
- elif output_format in ['MD', 'FORM', 'REPORT', 'LIST']:
1596
- return "\n# No categories found.\n"
1597
- elif output_format == 'DICT':
1598
- return None
1599
- if output_format != 'JSON': # return a simplified markdown representation
1600
- return self.generate_categories_md(element, search_string, output_format)
1601
- return response.json().get("elementList", NO_CATEGORIES_FOUND)
1602
-
1603
- def find_glossary_categories(self, search_string: str, effective_time: str = None, starts_with: bool = False,
1604
- ends_with: bool = False, ignore_case: bool = False, start_from: int = 0,
1605
- page_size: int = None, output_format: str = "JSON") -> list | str:
1606
- """Retrieve the list of glossary category metadata elements that contain the search string.
1607
- The search string is located in the request body and is interpreted as a plain string.
1608
- The request parameters, startsWith, endsWith, and ignoreCase can be used to allow a fuzzy search.
1609
-
1610
- Parameters
1611
- ----------
1612
- search_string: str,
1613
- Search string to use to find matching glossaries. If the search string is '*' then all
1614
- glossaries returned.
1615
-
1616
- effective_time: str, [default=None], optional
1617
- Effective time of the query. If not specified will default to any time. Time format is
1618
- "YYYY-MM-DDTHH:MM:SS" (ISO 8601)
1619
-
1620
- If not provided, the server name associated with the instance is used.
1621
- starts_with : bool, [default=False], optional
1622
- Starts with the supplied string.
1623
- ends_with : bool, [default=False], optional
1624
- Ends with the supplied string
1625
- ignore_case : bool, [default=False], optional
1626
- Ignore case when searching
1627
- start_from: int, [default=0], optional
1628
- When multiple pages of results are available, the page number to start from.
1629
- page_size: int, [default=None]
1630
- The number of items to return in a single page. If not specified, the default will be taken from
1631
- the class instance.
1632
- output_format: str, default = 'JSON'
1633
- Type of output to produce:
1634
- JSON - output standard json
1635
- MD - output standard markdown with no preamble
1636
- FORM - output markdown with a preamble for a form
1637
- REPORT - output markdown with a preamble for a report
1638
-
1639
- Returns
1640
- -------
1641
- List | str
1642
-
1643
- A list of glossary definitions active in the server.
1644
-
1645
- Raises
1646
- ------
1647
-
1648
- InvalidParameterException
1649
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values
1650
- PropertyServerException
1651
- Raised by the server when an issue arises in processing a valid request
1652
- NotAuthorizedException
1653
- The principle specified by the user_id does not have authorization for the requested action
1654
-
1655
- """
1656
- loop = asyncio.get_event_loop()
1657
- response = loop.run_until_complete(
1658
- self._async_find_glossary_categories(search_string, effective_time, starts_with, ends_with, ignore_case,
1659
- start_from, page_size, output_format))
1660
-
1661
- return response
1662
-
1663
- async def _async_get_categories_for_glossary(self, glossary_guid: str, start_from: int = 0,
1664
- page_size: int = None, ) -> list | str:
1665
- """Return the list of categories associated with a glossary.
1666
- Async version.
1667
-
1668
- Parameters
1669
- ----------
1670
- glossary_guid: str,
1671
- Unique identity of the glossary
1672
-
1673
- If not provided, the server name associated with the instance is used.
1674
- start_from: int, [default=0], optional
1675
- When multiple pages of results are available, the page number to start from.
1676
- page_size: int, [default=None]
1677
- The number of items to return in a single page. If not specified, the default will be taken from
1678
- the class instance.
1679
- Returns
1680
- -------
1681
- List | str
1682
-
1683
- A list of categories associated with a glossary.
1684
-
1685
- Raises
1686
- ------
1687
-
1688
- InvalidParameterException
1689
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values
1690
- PropertyServerException
1691
- Raised by the server when an issue arises in processing a valid request
1692
- NotAuthorizedException
1693
- The principle specified by the user_id does not have authorization for the requested action
1694
-
1695
- """
1696
-
1697
- if page_size is None:
1698
- page_size = self.page_size
1699
-
1700
- url = (f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/"
1701
- f"{glossary_guid}/categories/retrieve?startFrom={start_from}&pageSize={page_size}")
1702
-
1703
- response = await self._async_make_request("POST", url)
1704
- return response.json().get("elementList", "No Categories found")
1705
-
1706
- def get_categories_for_glossary(self, glossary_guid: str, start_from: int = 0,
1707
- page_size: int = None, ) -> list | str:
1708
- """Return the list of categories associated with a glossary.
1709
-
1710
- Parameters
1711
- ----------
1712
- glossary_guid: str,
1713
- Unique identity of the glossary
1714
-
1715
- If not provided, the server name associated with the instance is used.
1716
- start_from: int, [default=0], optional
1717
- When multiple pages of results are available, the page number to start from.
1718
- page_size: int, [default=None]
1719
- The number of items to return in a single page. If not specified, the default will be taken from
1720
- the class instance.
1721
- Returns
1722
- -------
1723
- List | str
1724
-
1725
- A list of categories associated with a glossary.
1726
-
1727
- Raises
1728
- ------
1729
-
1730
- InvalidParameterException
1731
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values
1732
- PropertyServerException
1733
- Raised by the server when an issue arises in processing a valid request
1734
- NotAuthorizedException
1735
- The principle specified by the user_id does not have authorization for the requested action
1736
-
1737
- """
1738
- loop = asyncio.get_event_loop()
1739
- response = loop.run_until_complete(
1740
- self._async_get_categories_for_glossary(glossary_guid, start_from, page_size))
1741
- return response
1742
-
1743
- async def _async_get_categories_for_term(self, glossary_term_guid: str, start_from: int = 0,
1744
- page_size: int = None, ) -> list | str:
1745
- """Return the list of categories associated with a glossary term.
1746
- Async version.
1747
-
1748
- Parameters
1749
- ----------
1750
- glossary_term_guid: str,
1751
- Unique identity of a glossary term
1752
-
1753
- start_from: int, [default=0], optional
1754
- When multiple pages of results are available, the page number to start from.
1755
- page_size: int, [default=None]
1756
- The number of items to return in a single page. If not specified, the default will be taken from
1757
- the class instance.
1758
- Returns
1759
- -------
1760
- List | str
1761
-
1762
- A list of categories associated with a glossary term.
1763
-
1764
- Raises
1765
- ------
1766
-
1767
- InvalidParameterException
1768
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values
1769
- PropertyServerException
1770
- Raised by the server when an issue arises in processing a valid request
1771
- NotAuthorizedException
1772
- The principle specified by the user_id does not have authorization for the requested action
1773
-
1774
- """
1775
-
1776
- if page_size is None:
1777
- page_size = self.page_size
1778
-
1779
- url = (f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/terms/"
1780
- f"{glossary_term_guid}/categories/retrieve?startFrom={start_from}&pageSize={page_size}")
1781
-
1782
- response = await self._async_make_request("POST", url)
1783
- return response.json().get("elementList", NO_CATEGORIES_FOUND)
1784
-
1785
- def get_categories_for_term(self, glossary_term_guid: str, start_from: int = 0,
1786
- page_size: int = None, ) -> list | str:
1787
- """Return the list of categories associated with a glossary term.
1788
-
1789
- Parameters
1790
- ----------
1791
- glossary_term_guid: str,
1792
- Unique identity of a glossary term
1793
-
1794
- start_from: int, [default=0], optional
1795
- When multiple pages of results are available, the page number to start from.
1796
- page_size: int, [default=None]
1797
- The number of items to return in a single page. If not specified, the default will be taken from
1798
- the class instance.
1799
- Returns
1800
- -------
1801
- List | str
1802
-
1803
- A list of categories associated with a glossary term.
1804
-
1805
- Raises
1806
- ------
1807
-
1808
- InvalidParameterException
1809
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values
1810
- PropertyServerException
1811
- Raised by the server when an issue arises in processing a valid request
1812
- NotAuthorizedException
1813
- The principle specified by the user_id does not have authorization for the requested action
1814
-
1815
- """
1816
- loop = asyncio.get_event_loop()
1817
- response = loop.run_until_complete(
1818
- self._async_get_categories_for_term(glossary_term_guid, start_from, page_size))
1819
- return response
1820
-
1821
- async def _async_get_categories_by_name(self, name: str, glossary_guid: str = None, status: [str] = ["ACTIVE"],
1822
- start_from: int = 0, page_size: int = None, ) -> list | str:
1823
- """Retrieve the list of glossary category metadata elements that either have the requested qualified name or
1824
- display name. The name to search for is located in the request body and is interpreted as a plain string.
1825
- The request body also supports the specification of a glossaryGUID to restrict the search to within a single
1826
- glossary.
1827
-
1828
- Async version.
1829
-
1830
- Parameters
1831
- ----------
1832
- name: str,
1833
- category name to search for.
1834
- glossary_guid: str, optional
1835
- The identity of the glossary to search. If not specified, all glossaries will be searched.
1836
- start_from: int, [default=0], optional
1837
- When multiple pages of results are available, the page number to start from.
1838
- page_size: int, [default=None]
1839
- The number of items to return in a single page. If not specified, the default will be taken from
1840
- the class instance.
1841
- Returns
1842
- -------
1843
- List | str
1844
-
1845
- A list of categories with the corresponding display name or qualified name.
1846
-
1847
- Raises
1848
- ------
1849
-
1850
- InvalidParameterException
1851
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values
1852
- PropertyServerException
1853
- Raised by the server when an issue arises in processing a valid request
1854
- NotAuthorizedException
1855
- The principle specified by the user_id does not have authorization for the requested action
1856
-
1857
- """
1858
-
1859
- if page_size is None:
1860
- page_size = self.page_size
1861
- validate_name(name)
1862
-
1863
- url = (
1864
- f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/categories/"
1865
- f"by-name?startFrom={start_from}&pageSize={page_size}")
1866
-
1867
- body = {
1868
- "class": "GlossaryNameRequestBody", "name": name, "glossaryGUID": glossary_guid,
1869
- "limitResultsByStatus": status,
1870
- }
1871
-
1872
- response = await self._async_make_request("POST", url, body)
1873
- return response.json().get("elementList", NO_CATEGORIES_FOUND)
1874
-
1875
- def get_categories_by_name(self, name: str, glossary_guid: str = None, status: [str] = ["ACTIVE"],
1876
- start_from: int = 0, page_size: int = None) -> list | str:
1877
- """Retrieve the list of glossary category metadata elements that either have the requested qualified name or
1878
- display name. The name to search for is located in the request body and is interpreted as a plain string.
1879
- The request body also supports the specification of a glossaryGUID to restrict the search to within a
1880
- single glossary.
1881
-
1882
- Parameters
1883
- ----------
1884
- name: str,
1885
- category name to search for.
1886
- glossary_guid: str, optional
1887
- The identity of the glossary to search. If not specified, all glossaries will be searched.
1888
- start_from: int, [default=0], optional
1889
- When multiple pages of results are available, the page number to start from.
1890
- page_size: int, [default=None]
1891
- The number of items to return in a single page. If not specified, the default will be taken from
1892
- the class instance.
1893
- Returns
1894
- -------
1895
- List | str
1896
-
1897
- A list of categories with the corresponding display name or qualified name.
1898
-
1899
- Raises
1900
- ------
1901
-
1902
- InvalidParameterException
1903
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values
1904
- PropertyServerException
1905
- Raised by the server when an issue arises in processing a valid request
1906
- NotAuthorizedException
1907
- The principle specified by the user_id does not have authorization for the requested action
1908
-
1909
- """
1910
- loop = asyncio.get_event_loop()
1911
- response = loop.run_until_complete(
1912
- self._async_get_categories_by_name(name, glossary_guid, status, start_from, page_size))
1913
- return response
1914
-
1915
- async def _async_get_category_by_guid(self, glossary_category_guid: str, effective_time: str = None,
1916
- output_format: str = 'JSON', ) -> list | str:
1917
- """Retrieve the requested glossary category metadata element. The optional request body contain an effective
1918
- time for the query..
1919
-
1920
- Async version.
1921
-
1922
- Parameters
1923
- ----------
1924
- glossary_category_guid: str
1925
- The identity of the glossary category to search.
1926
- effective_time: str, optional
1927
- If specified, the category should only be returned if it was effective at the specified time.
1928
- Time format is "YYYY-MM-DDTHH:MM:SS" (ISO 8601)
1929
-
1930
- output_format: str, default = 'JSON'
1931
- Type of output to produce:
1932
- JSON - output standard json
1933
- MD - output standard markdown with no preamble
1934
- FORM - output markdown with a preamble for a form
1935
- REPORT - output markdown with a preamble for a report
1936
-
1937
- Returns
1938
- -------
1939
- List | str
1940
-
1941
- Details for the category with the glossary category GUID.
1942
-
1943
- Raises
1944
- ------
1945
-
1946
- InvalidParameterException
1947
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values
1948
- PropertyServerException
1949
- Raised by the server when an issue arises in processing a valid request
1950
- NotAuthorizedException
1951
- The principle specified by the user_id does not have authorization for the requested action
1952
-
1953
- """
1954
- output_format = output_format.upper()
1955
- url = (
1956
- f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/categories/"
1957
- f"{glossary_category_guid}/retrieve")
1958
-
1959
- body = {
1960
- "class": "EffectiveTimeQueryRequestBody", "effectiveTime": effective_time,
1961
- }
1962
-
1963
- response = await self._async_make_request("POST", url, body_slimmer(body))
1964
- element = response.json().get("element", NO_CATEGORIES_FOUND)
1965
- if element == NO_CATEGORIES_FOUND:
1966
- return NO_CATEGORIES_FOUND
1967
- if output_format != 'JSON': # return a simplified markdown representation
1968
- return self.generate_categories_md(element, "GUID", output_format)
1969
- return response.json().get("element", NO_CATEGORIES_FOUND)
1970
-
1971
- def get_category_by_guid(self, glossary_category_guid: str, effective_time: str = None,
1972
- output_format: str = 'JSON', ) -> list | str:
1973
- """Retrieve the requested glossary category metadata element. The optional request body contain an effective
1974
- time for the query..
1975
-
1976
- Parameters
1977
- ----------
1978
- glossary_category_guid: str
1979
- The identity of the glossary category to search.
1980
- effective_time: str, optional
1981
- If specified, the category should only be returned if it was effective at the specified time.
1982
- Time format is "YYYY-MM-DDTHH:MM:SS" (ISO 8601)
1983
-
1984
- output_format: str, default = 'JSON'
1985
- Type of output to produce:
1986
- JSON - output standard json
1987
- MD - output standard markdown with no preamble
1988
- FORM - output markdown with a preamble for a form
1989
- REPORT - output markdown with a preamble for a report
1990
-
1991
- Returns
1992
- -------
1993
- List | str
1994
-
1995
- Details for the category with the glossary category GUID.
1996
-
1997
- Raises
1998
- ------
1999
-
2000
- InvalidParameterException
2001
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values
2002
- PropertyServerException
2003
- Raised by the server when an issue arises in processing a valid request
2004
- NotAuthorizedException
2005
- The principle specified by the user_id does not have authorization for the requested action
2006
-
2007
- """
2008
- loop = asyncio.get_event_loop()
2009
- response = loop.run_until_complete(
2010
- self._async_get_category_by_guid(glossary_category_guid, effective_time, output_format))
2011
- return response
2012
-
2013
- async def _async_get_category_parent(self, glossary_category_guid: str, effective_time: str = None, ) -> list | str:
2014
- """Glossary categories can be organized in a hierarchy. Retrieve the parent glossary category metadata
2015
- element for the glossary category with the supplied unique identifier. If the requested category
2016
- does not have a parent category, null is returned. The optional request body contain an effective time
2017
- for the query.
2018
-
2019
- Async version.
2020
-
2021
- Parameters
2022
- ----------
2023
- glossary_category_guid: str
2024
- The identity of the glossary category to search.
2025
- effective_time: str, optional
2026
- If specified, the category should only be returned if it was effective at the specified time.
2027
- Time format is "YYYY-MM-DDTHH:MM:SS" (ISO 8601)
2028
-
2029
- If not provided, the server name associated with the instance is used.
2030
-
2031
- Returns
2032
- -------
2033
- List | str
2034
-
2035
- Details for the parent category with the glossary category GUID.
2036
-
2037
- Raises
2038
- ------
2039
-
2040
- InvalidParameterException
2041
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values
2042
- PropertyServerException
2043
- Raised by the server when an issue arises in processing a valid request
2044
- NotAuthorizedException
2045
- The principle specified by the user_id does not have authorization for the requested action
2046
-
2047
- """
2048
-
2049
- url = (
2050
- f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/categories/"
2051
- f"{glossary_category_guid}/parent/retrieve")
2052
-
2053
- body = {
2054
- "class": "EffectiveTimeQueryRequestBody", "effectiveTime": effective_time,
2055
- }
2056
-
2057
- response = await self._async_make_request("POST", url, body)
2058
- return response.json().get("element", "No Parent Category found")
2059
-
2060
- def get_category_parent(self, glossary_category_guid: str, effective_time: str = None, ) -> list | str:
2061
- """Glossary categories can be organized in a hierarchy. Retrieve the parent glossary category metadata
2062
- element for the glossary category with the supplied unique identifier. If the requested category
2063
- does not have a parent category, null is returned. The optional request body contain an effective time
2064
- for the query.
2065
-
2066
- Parameters
2067
- ----------
2068
- glossary_category_guid: str
2069
- The identity of the glossary category to search.
2070
- effective_time: str, optional
2071
- If specified, the category should only be returned if it was effective at the specified time.
2072
- Time format is "YYYY-MM-DDTHH:MM:SS" (ISO 8601).
2073
-
2074
- If not provided, the server name associated with the instance is used.
2075
-
2076
- Returns
2077
- -------
2078
- List | str
2079
-
2080
- Details for the parent category with the glossary category GUID.
2081
-
2082
- Raises
2083
- ------
2084
-
2085
- InvalidParameterException
2086
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values
2087
- PropertyServerException
2088
- Raised by the server when an issue arises in processing a valid request
2089
- NotAuthorizedException
2090
- The principle specified by the user_id does not have authorization for the requested action
2091
-
2092
- """
2093
- loop = asyncio.get_event_loop()
2094
- response = loop.run_until_complete(self._async_get_category_parent(glossary_category_guid, effective_time))
2095
- return response
2096
-
2097
- def get_glossary_category_structure(self, glossary_guid: str, output_format: str = "DICT") -> dict | str:
2098
- """Derive the category structure of an Egeria glossary.
2099
-
2100
- This method builds a hierarchical representation of the categories in a glossary,
2101
- showing the parent-child relationships between categories.
2102
-
2103
- Parameters
2104
- ----------
2105
- glossary_guid: str
2106
- The unique identifier of the glossary.
2107
- output_format: str, default = 'DICT'
2108
- The format of the output:
2109
- - DICT: Returns a Python dictionary structure
2110
- - LIST: Returns a markdown table
2111
- - MD: Returns a markdown outline with bullets and indentations
2112
-
2113
- Returns
2114
- -------
2115
- dict | str
2116
- If output_format is DICT, returns a dictionary structure representing the category hierarchy.
2117
- If output_format is LIST, returns a markdown table representing the category hierarchy.
2118
- If output_format is MD, returns a markdown outline with bullets and indentations.
2119
-
2120
- Raises
2121
- ------
2122
- InvalidParameterException
2123
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values
2124
- PropertyServerException
2125
- Raised by the server when an issue arises in processing a valid request
2126
- NotAuthorizedException
2127
- The principle specified by the user_id does not have authorization for the requested action
2128
- """
2129
- from pyegeria._validators import validate_guid
2130
-
2131
- validate_guid(glossary_guid)
2132
-
2133
- # Get all categories in the glossary
2134
- all_categories = self.get_categories_for_glossary(glossary_guid)
2135
- if isinstance(all_categories, str):
2136
- return NO_CATEGORIES_FOUND
2137
-
2138
- # Create a dictionary to store categories by GUID for quick lookup
2139
- categories_by_guid = {cat['elementHeader']['guid']: cat for cat in all_categories}
2140
-
2141
- # Identify root categories (categories with no parent)
2142
- root_guids = []
2143
- for cat_guid in categories_by_guid.keys():
2144
- parent = self.get_category_parent(cat_guid)
2145
- if isinstance(parent, str):
2146
- root_guids.append(cat_guid) # This category has no parent
2147
-
2148
- # Build the category tree
2149
- category_tree = []
2150
-
2151
- def build_category_tree(category_guid):
2152
- """Recursively build a category tree for a category."""
2153
- if category_guid not in categories_by_guid:
2154
- return None
2155
-
2156
- category = categories_by_guid[category_guid]
2157
- display_name = category['glossaryCategoryProperties'].get('displayName', '---')
2158
- qualified_name = category['glossaryCategoryProperties'].get('qualifiedName', '---')
2159
- description = category['glossaryCategoryProperties'].get('description', '---')
2160
-
2161
- # Get subcategories
2162
- subcategories = self.get_glossary_subcategories(category_guid)
2163
- children = []
2164
-
2165
- if isinstance(subcategories, list):
2166
- for subcat in subcategories:
2167
- subcat_guid = subcat['elementHeader']['guid']
2168
- child_tree = build_category_tree(subcat_guid)
2169
- if child_tree:
2170
- children.append(child_tree)
2171
-
2172
- # Get parent category information
2173
- parent_info = None
2174
- parent = self.get_category_parent(category_guid)
2175
- if not isinstance(parent, str):
2176
- parent_guid = parent['elementHeader']['guid']
2177
- parent_name = parent['glossaryCategoryProperties'].get('displayName', '---')
2178
- parent_info = {
2179
- 'guid': parent_guid, 'name': parent_name
2180
- }
2181
-
2182
- return {
2183
- 'guid': category_guid, 'name': display_name, 'qualifiedName': qualified_name,
2184
- 'description': description, 'parent': parent_info, 'children': children
2185
- }
2186
-
2187
- # Build tree for each root category
2188
- for root_guid in root_guids:
2189
- tree = build_category_tree(root_guid)
2190
- if tree:
2191
- category_tree.append(tree)
2192
-
2193
- # Format the output according to the specified output_format
2194
- if output_format == "DICT":
2195
- return {
2196
- 'glossary_guid': glossary_guid, 'categories': category_tree
2197
- }
2198
- elif output_format == "LIST":
2199
- # Generate markdown table
2200
- md_table = "| Category | Path | Description | Parent Category | Child Categories |\n"
2201
- md_table += "|---------|------|-------------|----------------|------------------|\n"
2202
-
2203
- def add_categories_to_table(categories, path=""):
2204
- nonlocal md_table
2205
- for category in categories:
2206
- category_path = f"{path}/{category['name']}" if path else category['name']
2207
-
2208
- # Get parent category name
2209
- parent_name = "None"
2210
- if category['parent']:
2211
- parent_name = category['parent']['name']
2212
-
2213
- # Get child categories names
2214
- child_names = []
2215
- for child in category['children']:
2216
- child_names.append(child['name'])
2217
- child_categories = ", ".join(child_names) if child_names else "None"
2218
-
2219
- md_table += (f"| {category['name']} | {category_path} | "
2220
- f"{self._format_for_markdown_table(category['description'])} | "
2221
- f"{parent_name} | {child_categories} |\n")
2222
- if category['children']:
2223
- add_categories_to_table(category['children'], category_path)
2224
-
2225
- add_categories_to_table(category_tree)
2226
- return md_table
2227
- elif output_format == "MD":
2228
- # Generate markdown outline with bullets and indentations
2229
- md_outline = f"# Category Structure for Glossary (GUID: {glossary_guid})\n\n"
2230
-
2231
- def add_categories_to_outline(categories, indent_level=0):
2232
- nonlocal md_outline
2233
- for category in categories:
2234
- # Add bullet with proper indentation
2235
- indent = " " * indent_level
2236
- md_outline += f"{indent}- **{category['name']}**"
2237
-
2238
- # Add description if available
2239
- if category['description'] and category['description'] != '---':
2240
- md_outline += f": {category['description']}"
2241
-
2242
- md_outline += "\n"
2243
-
2244
- # Process children with increased indentation
2245
- if category['children']:
2246
- add_categories_to_outline(category['children'], indent_level + 1)
2247
-
2248
- add_categories_to_outline(category_tree)
2249
- return md_outline
2250
- else:
2251
- return f"Unsupported output format: {output_format}. Use 'DICT', 'LIST', or 'MD'."
2252
-
2253
- #
2254
- # Terms
2255
- #
2256
-
2257
- async def _async_get_terms_for_category(self, glossary_category_guid: str, effective_time: str = None,
2258
- start_from: int = 0, page_size: int = None, ) -> list | str:
2259
- """Retrieve ALL the glossary terms in a category.
2260
- The request body also supports the specification of an effective time for the query.
2261
-
2262
- Async Version.
2263
-
2264
- Parameters
2265
- ----------
2266
- glossary_category_guid : str
2267
- Unique identifier for the glossary category to retrieve terms from.
2268
- effective_time : str, optional
2269
- If specified, the terms are returned if they are active at the `effective_time
2270
- Time format is "YYYY-MM-DDTHH:MM:SS" (ISO 8601)
2271
- start_from: int, optional defaults to 0
2272
- The page number to start retrieving elements from
2273
- page_size : int, optional defaults to None
2274
- The number of elements to retrieve
2275
- Returns
2276
- -------
2277
- [dict]
2278
- The glossary definition associated with the glossary_guid
2279
-
2280
- Raises
2281
- ------
2282
- InvalidParameterException
2283
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
2284
- PropertyServerException
2285
- Raised by the server when an issue arises in processing a valid request.
2286
- NotAuthorizedException
2287
- The principle specified by the user_id does not have authorization for the requested action.
2288
-
2289
- """
2290
-
2291
- validate_guid(glossary_category_guid)
2292
-
2293
- if page_size is None:
2294
- page_size = self.page_size
2295
-
2296
- url = (
2297
- f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/categories/"
2298
- f"{glossary_category_guid}/terms/retrieve?startFrom={start_from}&pageSize={page_size}")
2299
-
2300
- if effective_time is not None:
2301
- body = {"effectiveTime": effective_time}
2302
- response = await self._async_make_request("POST", url, body)
2303
- else:
2304
- response = await self._async_make_request("POST", url)
2305
-
2306
- return response.json().get("elementList", "No terms found")
2307
-
2308
- def get_terms_for_category(self, glossary_category_guid: str, effective_time: str = None, start_from: int = 0,
2309
- page_size: int = None, ) -> list | str:
2310
- """Retrieve ALL the glossary terms in a category.
2311
- The request body also supports the specification of an effective time for the query.
2312
-
2313
- Async Version.
2314
-
2315
- Parameters
2316
- ----------
2317
- glossary_category_guid : str
2318
- Unique identifier for the glossary category to retrieve terms from.
2319
-
2320
- effective_time : str, optional
2321
- If specified, the terms are returned if they are active at the `effective_time.
2322
- Time format is "YYYY-MM-DDTHH:MM:SS" (ISO 8601)`.
2323
- start_from: int, optional defaults to 0
2324
- The page number to start retrieving elements from
2325
- page_size : int, optional defaults to None
2326
- The number of elements to retrieve
2327
- Returns
2328
- -------
2329
- dict
2330
- The glossary definition associated with the glossary_guid
2331
-
2332
- Raises
2333
- ------
2334
- InvalidParameterException
2335
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
2336
- PropertyServerException
2337
- Raised by the server when an issue arises in processing a valid request.
2338
- NotAuthorizedException
2339
- The principle specified by the user_id does not have authorization for the requested action.
2340
- Notes
2341
- -----
2342
- """
2343
- loop = asyncio.get_event_loop()
2344
- response = loop.run_until_complete(
2345
- self._async_get_terms_for_category(glossary_category_guid, effective_time, start_from, page_size, ))
2346
-
2347
- return response
2348
-
2349
- async def _async_get_terms_for_glossary(self, glossary_guid: str, effective_time: str = None, start_from: int = 0,
2350
- page_size: int = None, ) -> list | str:
2351
- """Retrieve the list of glossary terms associated with a glossary.
2352
- The request body also supports the specification of an effective time for the query.
2353
- Parameters
2354
- ----------
2355
- glossary_guid : str
2356
- Unique identifier for the glossary
2357
-
2358
- effective_time : str, optional
2359
- If specified, terms are potentially included if they are active at the`effective_time.
2360
- Time format is "YYYY-MM-DDTHH:MM:SS" (ISO 8601)`
2361
- start_from: int, optional defaults to 0
2362
- The page number to start retrieving elements from
2363
- page_size : int, optional defaults to None
2364
- The number of elements to retrieve
2365
- Returns
2366
- -------
2367
- dict
2368
- The glossary definition associated with the glossary_guid
2369
-
2370
- Raises
2371
- ------
2372
- InvalidParameterException
2373
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
2374
- PropertyServerException
2375
- Raised by the server when an issue arises in processing a valid request.
2376
- NotAuthorizedException
2377
- The principle specified by the user_id does not have authorization for the requested action.
2378
- Notes
2379
- -----
2380
- """
2381
-
2382
- validate_guid(glossary_guid)
2383
-
2384
- if page_size is None:
2385
- page_size = self.page_size
2386
-
2387
- url = (f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/"
2388
- f"{glossary_guid}/terms/retrieve?startFrom={start_from}&pageSize={page_size}")
2389
-
2390
- if effective_time is not None:
2391
- body = {"effectiveTime": effective_time}
2392
- response = await self._async_make_request("POST", url, body)
2393
- else:
2394
- response = await self._async_make_request("POST", url)
2395
-
2396
- return response.json().get("elementList", "No terms found")
2397
-
2398
- def get_terms_for_glossary(self, glossary_guid: str, effective_time: str = None, start_from: int = 0,
2399
- page_size: int = None, ) -> list | str:
2400
- """Retrieve the list of glossary terms associated with a glossary.
2401
- The request body also supports the specification of an effective time for the query.
2402
- Parameters
2403
- ----------
2404
- glossary_guid : str
2405
- Unique identifier for the glossary
2406
-
2407
- effective_time : str, optional
2408
- If specified, terms are potentially returned if they are active at the `effective_time`
2409
- Time format is "YYYY-MM-DDTHH:MM:SS" (ISO 8601)
2410
- start_from: int, optional defaults to 0
2411
- The page number to start retrieving elements from
2412
- page_size : int, optional defaults to None
2413
- The number of elements to retrieve
2414
- Returns
2415
- -------
2416
- dict
2417
- The glossary definition associated with the glossary_guid
2418
-
2419
- Raises
2420
- ------
2421
- InvalidParameterException
2422
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
2423
- PropertyServerException
2424
- Raised by the server when an issue arises in processing a valid request.
2425
- NotAuthorizedException
2426
- The principle specified by the user_id does not have authorization for the requested action.
2427
- Notes
2428
- -----
2429
- """
2430
- loop = asyncio.get_event_loop()
2431
- response = loop.run_until_complete(
2432
- self._async_get_terms_for_glossary(glossary_guid, effective_time, start_from, page_size))
2433
-
2434
- return response
2435
-
2436
- async def _async_get_related_terms(self, term_guid: str, effective_time: str = None, start_from: int = 0,
2437
- page_size: int = None, output_format: str = "JSON") -> list | str:
2438
- """This call retrieves details of the glossary terms linked to this glossary term.
2439
- Notice the original org 1 glossary term is linked via the "SourcedFrom" relationship.
2440
- Parameters
2441
- ----------
2442
- term_guid : str
2443
- Unique identifier for the glossary term
2444
-
2445
- effective_time : str, optional
2446
- If specified, term relationships are included if they are active at the `effective_time`.
2447
- Time format is "YYYY-MM-DDTHH:MM:SS" (ISO 8601)
2448
- start_from: int, optional defaults to 0
2449
- The page number to start retrieving elements from
2450
- page_size : int, optional defaults to None
2451
- The number of elements to retrieve
2452
- Returns
2453
- -------
2454
- dict
2455
- The glossary definition associated with the glossary_guid
2456
-
2457
- Raises
2458
- ------
2459
- InvalidParameterException
2460
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
2461
- PropertyServerException
2462
- Raised by the server when an issue arises in processing a valid request.
2463
- NotAuthorizedException
2464
- The principle specified by the user_id does not have authorization for the requested action.
2465
- Notes
2466
- -----
2467
- """
2468
-
2469
- validate_guid(term_guid)
2470
-
2471
- if page_size is None:
2472
- page_size = self.page_size
2473
-
2474
- url = (f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/terms/"
2475
- f"{term_guid}/related-terms?startFrom={start_from}&pageSize={page_size}")
2476
-
2477
- if effective_time is not None:
2478
- body = {"effectiveTime": effective_time}
2479
- response = await self._async_make_request("POST", url, body)
2480
- else:
2481
- response = await self._async_make_request("POST", url)
2482
-
2483
- term_elements = response.json().get("elementList", NO_TERMS_FOUND)
2484
- if term_elements == NO_TERMS_FOUND:
2485
- if output_format == 'JSON':
2486
- return NO_TERMS_FOUND
2487
- elif output_format in ['MD', 'FORM', 'REPORT', 'LIST']:
2488
- return "\n# No Terms found.\n"
2489
- elif output_format == 'DICT':
2490
- return None
2491
- if output_format != "JSON": # return a simplified markdown representation
2492
- return self.generate_related_terms_md(term_elements, term_guid, output_format)
2493
- return response.json().get("elementList", NO_TERMS_FOUND)
2494
-
2495
- def get_related_terms(self, term_guid: str, effective_time: str = None, start_from: int = 0, page_size: int = None,
2496
- output_format="JSON") -> list | str:
2497
- """This call retrieves details of the glossary terms linked to this glossary term.
2498
- Notice the original org 1 glossary term is linked via the "SourcedFrom" relationship..
2499
- Parameters
2500
- ----------
2501
- term_guid : str
2502
- Unique identifier for the glossary term
2503
-
2504
- effective_time : str, optional
2505
- If specified, term relationships are included if they are active at the `effective_time`.
2506
- Time format is "YYYY-MM-DDTHH:MM:SS" (ISO 8601)
2507
- start_from: int, optional defaults to 0
2508
- The page number to start retrieving elements from
2509
- page_size : int, optional defaults to None
2510
- The number of elements to retrieve
2511
- Returns
2512
- -------
2513
- dict
2514
- The glossary definition associated with the glossary_guid
2515
-
2516
- Raises
2517
- ------
2518
- InvalidParameterException
2519
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
2520
- PropertyServerException
2521
- Raised by the server when an issue arises in processing a valid request.
2522
- NotAuthorizedException
2523
- The principle specified by the user_id does not have authorization for the requested action.
2524
- Notes
2525
- -----
2526
- """
2527
- loop = asyncio.get_event_loop()
2528
- response = loop.run_until_complete(
2529
- self._async_get_related_terms(term_guid, effective_time, start_from, page_size, output_format))
2530
-
2531
- return response
2532
-
2533
- def generate_related_terms_md(self, term_elements: list, term_guid: str, output_format: str = 'MD') -> str | list:
2534
- """
2535
- Generate a simplified representation of related terms.
2536
-
2537
- Args:
2538
- term_elements (list): List of term elements with relationship information
2539
- term_guid (str): GUID of the term for which to generate related terms
2540
- output_format (str): Output format (MD, LIST, DICT, etc.)
2541
-
2542
- Returns:
2543
- str | list: Markdown string or list of dictionaries depending on output_format
2544
- """
2545
- # Get the first term's display name and qualified name
2546
- term_name = "Term"
2547
- try:
2548
- term_info = self.get_term_by_guid(term_guid, output_format="DICT")
2549
- # Handle case where term_info is a list of dictionaries
2550
- if isinstance(term_info, list) and len(term_info) > 0:
2551
- term_info = term_info[0] # Get the first term
2552
- if isinstance(term_info, dict) and 'display_name' in term_info:
2553
- term_name = term_info['display_name']
2554
- except:
2555
- # If we can't get the term info, just use the default name
2556
- pass
2557
-
2558
- # Create a list to store the simplified related terms
2559
- related_terms = []
2560
-
2561
- # Process each term element
2562
- for element in term_elements:
2563
- # Extract relationship type from the relationship header
2564
- relationship_type = element['relatedBy']['relationshipHeader']['type']['typeName']
2565
-
2566
- # Extract related term information
2567
- related_term = {
2568
- 'first_term_display_name': term_name, 'first_term_qualified_name': term_info.get('qualified_name', ''),
2569
- 'related_term_display_name': element['glossaryTermProperties'].get('displayName', ''),
2570
- 'related_term_qualified_name': element['glossaryTermProperties'].get('qualifiedName', ''),
2571
- 'relationship_type': relationship_type
2572
- }
2573
-
2574
- related_terms.append(related_term)
2575
-
2576
- # Return based on output format
2577
- if output_format == 'DICT':
2578
- return related_terms
2579
-
2580
- # For MD, LIST, FORM, REPORT formats, create a markdown representation
2581
- md_output = f"# Related Terms for {term_name}\n\n"
2582
-
2583
- if output_format == 'LIST':
2584
- # Create a table
2585
- md_output += ("| First Term | First Term Qualified Name | Related Term | Related Term Qualified Name | "
2586
- "Relationship Type |\n")
2587
- md_output += \
2588
- "|------------|---------------------------|--------------|------------------------------|-------------------|\n"
2589
-
2590
- for term in related_terms:
2591
- md_output += f"| {term['first_term_display_name']} | {term['first_term_qualified_name']} | "
2592
- md_output += f"{term['related_term_display_name']} | {term['related_term_qualified_name']} | "
2593
- md_output += f"{term['relationship_type']} |\n"
2594
- else:
2595
- # For other formats, create a more detailed representation
2596
- for term in related_terms:
2597
- md_output += f"## {term['relationship_type']} Relationship\n\n"
2598
- md_output += (f"**First Term:** {term['first_term_display_name']} ("
2599
- f"{term['first_term_qualified_name']})\n\n")
2600
- md_output += f"**Related Term:** {term[('related_term_dis'
2601
- 'play_name')]} ({term['related_term_qualified_name']})\n\n"
2602
- md_output += "---\n\n"
2603
-
2604
- return md_output
2605
-
2606
- def get_term_details(self, term_name: str, effective_time: str = None, output_format: str = 'DICT') -> dict | str:
2607
- """Retrieve detailed information about a term, combining basic term details and related terms.
2608
-
2609
- This method combines the term details retrieved from get_term_by_guid and the related terms
2610
- information from generate_related_terms_md.
2611
-
2612
- Parameters
2613
- ----------
2614
- term_name : str
2615
- Either the display name or the qualified name of the term to retrieve.
2616
- effective_time : str, optional
2617
- Time at which the term is active. If not specified, the current time is used.
2618
- output_format : str, default = 'DICT'
2619
- Type of output to produce:
2620
- DICT - output a dictionary with combined term details and related terms
2621
- REPORT - output a markdown report with combined term details and related terms
2622
-
2623
- Returns
2624
- -------
2625
- dict | str
2626
- A dictionary or markdown string containing the combined term details and related terms.
2627
-
2628
- Raises
2629
- ------
2630
- InvalidParameterException
2631
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
2632
- PropertyServerException
2633
- Raised by the server when an issue arises in processing a valid request.
2634
- NotAuthorizedException
2635
- The principle specified by the user_id does not have authorization for the requested action.
2636
- """
2637
- # Check if the output format is supported
2638
- if output_format not in ["DICT", "REPORT"]:
2639
- return f"Unsupported output format: {output_format}. Supported formats are DICT and REPORT."
2640
-
2641
- # Search for the term using the qualified name
2642
- terms = self.get_terms_by_name(term_name, effective_time=effective_time, output_format="DICT")
2643
-
2644
- # Check if we found any terms
2645
- if not terms or (isinstance(terms, str) and terms == NO_TERMS_FOUND):
2646
- return f"No term found with name: {term_name}"
2647
-
2648
- # Make sure we only have one term
2649
- if isinstance(terms, list) and len(terms) > 1:
2650
- return f"Multiple terms found with name: {term_name} - please specify the qualified name."
2651
-
2652
- term_details = terms[0]
2653
-
2654
- # Get related terms
2655
- try:
2656
- related_terms_response = self.get_related_terms(term_details.get('guid', ''), output_format="DICT")
2657
- except (InvalidParameterException, PropertyServerException, UserNotAuthorizedException):
2658
- # If we can't get related terms, set to empty list
2659
- related_terms_response = []
2660
-
2661
- # If no related terms were found, set to empty list
2662
- if isinstance(related_terms_response, str) and related_terms_response == NO_TERMS_FOUND:
2663
- related_terms = []
2664
- elif related_terms_response is None:
2665
- related_terms = []
2666
- else:
2667
- related_terms = related_terms_response
2668
-
2669
- # Combine the data
2670
- if output_format == "DICT":
2671
- # Create a combined dictionary
2672
- combined_data = {
2673
- "term_details": term_details, "related_terms": related_terms
2674
- }
2675
- return combined_data
2676
- elif output_format == "REPORT":
2677
- # Create a markdown report
2678
- md_output = f"# Term Details Report for `{term_name}` \n\n"
2679
-
2680
- # Add term details
2681
- md_output += "## Basic Term Information\n\n"
2682
- md_output += f"**Display Name:** {term_details.get('display_name', '')}\n\n"
2683
- md_output += f"**Qualified Name:** {term_details.get('qualified_name', '')}\n\n"
2684
- md_output += f"**GUID:** {term_details.get('guid', '')}\n\n"
2685
-
2686
- if 'summary' in term_details and term_details['summary']:
2687
- md_output += f"**Summary:** {term_details.get('summary', '')}\n\n"
2688
-
2689
- if 'description' in term_details and term_details['description']:
2690
- md_output += f"**Description:** {term_details.get('description', '')}\n\n"
2691
-
2692
- if 'examples' in term_details and term_details['examples']:
2693
- md_output += f"**Examples:** {term_details.get('examples', '')}\n\n"
2694
-
2695
- if 'usage' in term_details and term_details['usage']:
2696
- md_output += f"**Usage:** {term_details.get('usage', '')}\n\n"
2697
-
2698
- if 'aliases' in term_details and term_details['aliases']:
2699
- md_output += f"**Aliases:** {term_details.get('aliases', '')}\n\n"
2700
-
2701
- if 'status' in term_details and term_details['status']:
2702
- md_output += f"**Status:** {term_details.get('status', '')}\n\n"
2703
-
2704
- if 'in_glossary' in term_details and term_details['in_glossary']:
2705
- md_output += f"**Glossary:** {term_details.get('in_glossary', '')}\n\n"
2706
-
2707
- if 'categories' in term_details and term_details['categories']:
2708
- md_output += f"**Categories:** {', '.join(term_details.get('categories', []))}\n\n"
2709
-
2710
- # Add related terms
2711
- md_output += "## Related Terms\n\n"
2712
-
2713
- if not related_terms:
2714
- md_output += "No related terms found.\n\n"
2715
- else:
2716
- # Create a table for related terms
2717
- md_output += "| Related Term | Qualified Name | Relationship Type |\n"
2718
- md_output += "|--------------|---------------|-------------------|\n"
2719
-
2720
- for term in related_terms:
2721
- md_output += f"| {term.get('related_term_display_name', '')} | "
2722
- md_output += f"{term.get('related_term_qualified_name', '')} | "
2723
- md_output += f"{term.get('relationship_type', '')} |\n"
2724
-
2725
- return md_output
2726
- else:
2727
- return f"Unsupported output format: {output_format}. Supported formats are DICT and REPORT."
2728
-
2729
- async def _async_get_glossary_for_term(self, term_guid: str, effective_time: str = None) -> dict | str:
2730
- """Retrieve the glossary metadata element for the requested term. The optional request body allows you to
2731
- specify that the glossary element should only be returned if it was effective at a particular time.
2732
-
2733
- Async Version.
2734
-
2735
- Parameters
2736
- ----------
2737
- term_guid : str
2738
- The unique identifier for the term.
2739
-
2740
- effective_time : datetime, optional
2741
- If specified, the term information will be retrieved if it is active at the `effective_time`.
2742
- Time format is "YYYY-MM-DDTHH:MM:SS" (ISO 8601)
2743
-
2744
- Returns
2745
- -------
2746
- dict
2747
- The glossary information retrieved for the specified term.
2748
- Raises
2749
- ------
2750
- InvalidParameterException
2751
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
2752
- PropertyServerException
2753
- Raised by the server when an issue arises in processing a valid request.
2754
- NotAuthorizedException
2755
- The principle specified by the user_id does not have authorization for the requested action.
2756
- Notes
2757
- -----
2758
- """
2759
-
2760
- validate_guid(term_guid)
2761
-
2762
- body = {
2763
- "class": "EffectiveTimeQueryRequestBody", "effectiveTime": effective_time,
2764
- }
2765
- url = (f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/"
2766
- f"for-term/{term_guid}/retrieve")
2767
-
2768
- response = await self._async_make_request("POST", url, body_slimmer(body))
2769
- return response.json().get("element", NO_GLOSSARIES_FOUND)
2770
-
2771
- def get_glossary_for_term(self, term_guid: str, effective_time: str = None) -> dict | str:
2772
- """Retrieve the glossary metadata element for the requested term. The optional request body allows you to
2773
- specify that the glossary element should only be returned if it was effective at a particular time.
2774
-
2775
- Async Version.
2776
-
2777
- Parameters
2778
- ----------
2779
- term_guid : str
2780
- The unique identifier for the term.
2781
-
2782
- effective_time : datetime, optional
2783
- TIf specified, the term information will be retrieved if it is active at the `effective_time`.
2784
- Time format is "YYYY-MM-DDTHH:MM:SS" (ISO 8601).
2785
-
2786
- Returns
2787
- -------
2788
- dict
2789
- The glossary information retrieved for the specified term.
2790
- Raises
2791
- ------
2792
- InvalidParameterException
2793
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
2794
- PropertyServerException
2795
- Raised by the server when an issue arises in processing a valid request.
2796
- NotAuthorizedException
2797
- The principle specified by the user_id does not have authorization for the requested action.
2798
- Notes
2799
- -----
2800
- """
2801
- loop = asyncio.get_event_loop()
2802
- response = loop.run_until_complete(self._async_get_glossary_for_term(term_guid, effective_time))
2803
- return response
2804
-
2805
- async def _async_get_terms_by_name(self, term: str, glossary_guid: str = None, status_filter: list = [],
2806
- effective_time: str = None, for_lineage: bool = False,
2807
- for_duplicate_processing: bool = False, start_from: int = 0,
2808
- page_size: int = None, output_format="JSON") -> list:
2809
- """Retrieve glossary terms by display name or qualified name. Async Version.
2810
-
2811
- Parameters
2812
- ----------
2813
- term : str
2814
- The term to search for in the glossaries.
2815
- glossary_guid : str, optional
2816
- The GUID of the glossary to search in. If not provided, the search will be performed in all glossaries.
2817
- status_filter : list, optional
2818
- A list of status values to filter the search results. Default is an empty list, which means no filtering.
2819
-
2820
- effective_time : datetime, optional
2821
- If specified, the term information will be retrieved if it is active at the `effective_time`.
2822
- Time format is "YYYY-MM-DDTHH:MM:SS" (ISO 8601)
2823
- for_lineage : bool, optional
2824
- Flag to indicate whether the search should include lineage information. Default is False.
2825
- for_duplicate_processing : bool, optional
2826
- Flag to indicate whether the search should include duplicate processing information. Default is False.
2827
- start_from : int, optional
2828
- The index of the first term to retrieve. Default is 0.
2829
- page_size : int, optional
2830
- The number of terms to retrieve per page. If not provided, it will use the default page size.
2831
- output_format: str, default = 'JSON'
2832
- Type of output to produce:
2833
- JSON - output standard json
2834
- MD - output standard markdown with no preamble
2835
- FORM - output markdown with a preamble for a form
2836
- REPORT - output markdown with a preamble for a report
2837
- DICT - output a simplified DICT structure
2838
-
2839
- Returns
2840
- -------
2841
- list
2842
- A list of terms matching the search criteria. If no terms are found, it returns the string "No terms found".
2843
-
2844
- Raises
2845
- ------
2846
- InvalidParameterException
2847
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
2848
- PropertyServerException
2849
- Raised by the server when an issue arises in processing a valid request.
2850
- NotAuthorizedException
2851
- The principle specified by the user_id does not have authorization for the requested action.
2852
- """
2853
-
2854
- if page_size is None:
2855
- page_size = self.page_size
2856
-
2857
- validate_name(term)
2858
-
2859
- for_lineage_s = str(for_lineage).lower()
2860
- for_duplicate_processing_s = str(for_duplicate_processing).lower()
2861
-
2862
- body = {
2863
- "class": "GlossaryNameRequestBody", "glossaryGUID": glossary_guid, "name": term,
2864
- "effectiveTime": effective_time, "limitResultsByStatus": status_filter,
2865
- }
2866
- # body = body_slimmer(body)
2867
-
2868
- url = (f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/"
2869
- f"terms/by-name?startFrom={start_from}&pageSize={page_size}&"
2870
- f"&forLineage={for_lineage_s}&forDuplicateProcessing={for_duplicate_processing_s}")
2871
-
2872
- # print(f"\n\nURL is: \n {url}\n\nBody is: \n{body}")
2873
- response = await self._async_make_request("POST", url, body_slimmer(body))
2874
- term_elements = response.json().get("elementList", NO_TERMS_FOUND)
2875
- if term_elements == NO_TERMS_FOUND:
2876
- if output_format == 'JSON':
2877
- return NO_TERMS_FOUND
2878
- elif output_format in ['MD', 'FORM', 'REPORT', 'LIST']:
2879
- return "\n# No Terms found.\n"
2880
- elif output_format == 'DICT':
2881
- return None
2882
- if output_format != "JSON": # return a simplified markdown representation
2883
- return self.generate_terms_md(term_elements, term, output_format)
2884
- return response.json().get("elementList", NO_TERMS_FOUND)
2885
-
2886
- def get_terms_by_name(self, term: str, glossary_guid: str = None, status_filter: list = [],
2887
- effective_time: str = None, for_lineage: bool = False, for_duplicate_processing: bool = False,
2888
- start_from: int = 0, page_size: int = None, output_format="JSON") -> list:
2889
- """Retrieve glossary terms by display name or qualified name.
2890
-
2891
- Parameters
2892
- ----------
2893
- term : str
2894
- The term to search for in the glossaries.
2895
- glossary_guid : str, optional
2896
- The GUID of the glossary to search in. If not provided, the search will be performed in all glossaries.
2897
- status_filter : list, optional
2898
- A list of status values to filter the search results. Default is an empty list, which means no filtering.
2899
-
2900
- effective_time : datetime, optional
2901
- If specified, the term information will be retrieved if it is active at the `effective_time`.
2902
- Time format is "YYYY-MM-DDTHH:MM:SS" (ISO 8601)
2903
- for_lineage : bool, optional
2904
- Flag to indicate whether the search should include lineage information. Default is False.
2905
- for_duplicate_processing : bool, optional
2906
- Flag to indicate whether the search should include duplicate processing information. Default is False.
2907
- start_from : int, optional
2908
- The index of the first term to retrieve. Default is 0.
2909
- page_size : int, optional
2910
- The number of terms to retrieve per page. If not provided, it will use the default page size.
2911
- output_format: str, default = 'JSON'
2912
- Type of output to produce:
2913
- JSON - output standard json
2914
- MD - output standard markdown with no preamble
2915
- FORM - output markdown with a preamble for a form
2916
- REPORT - output markdown with a preamble for a report
2917
- DICT - output a simplified DICT structure
2918
-
2919
- Returns
2920
- -------
2921
- list
2922
- A list of terms matching the search criteria. If no terms are found,
2923
- it returns the string "No terms found".
2924
-
2925
- Raises
2926
- ------
2927
- InvalidParameterException
2928
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
2929
- PropertyServerException
2930
- Raised by the server when an issue arises in processing a valid request.
2931
- NotAuthorizedException
2932
- The principle specified by the user_id does not have authorization for the requested action.
2933
- """
2934
- loop = asyncio.get_event_loop()
2935
- response = loop.run_until_complete(
2936
- self._async_get_terms_by_name(term, glossary_guid, status_filter, effective_time, for_lineage,
2937
- for_duplicate_processing, start_from, page_size, output_format))
2938
- return response
2939
-
2940
- async def _async_get_term_by_guid(self, term_guid: str, output_format: str = 'JSON') -> dict | str:
2941
- """Retrieve a term using its unique id. Async version.
2942
- Parameters
2943
- ----------
2944
- term_guid : str
2945
- The GUID of the glossary term to retrieve.
2946
- output_format: str, default = 'JSON'
2947
- Type of output to produce:
2948
- JSON - output standard json
2949
- MD - output standard markdown with no preamble
2950
- FORM - output markdown with a preamble for a form
2951
- REPORT - output markdown with a preamble for a report
2952
-
2953
- Returns
2954
- -------
2955
- dict | str
2956
- A dict detailing the glossary term represented by the GUID. If no term is found, the string
2957
- "No term found" will be returned.
2958
-
2959
- Raises
2960
- ------
2961
- InvalidParameterException
2962
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
2963
- PropertyServerException
2964
- Raised by the server when an issue arises in processing a valid request.
2965
- NotAuthorizedException
2966
- The principle specified by the user_id does not have authorization for the requested action.
2967
- """
2968
- output_format = output_format.upper()
2969
- validate_guid(term_guid)
2970
-
2971
- url = (f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/terms/"
2972
- f"{term_guid}/retrieve")
2973
- response = await self._async_make_request("POST", url)
2974
- term_element = response.json().get("element", NO_TERMS_FOUND)
2975
- if term_element == NO_TERMS_FOUND:
2976
- return NO_TERMS_FOUND
2977
- if output_format != 'JSON': # return a simplified markdown representation
2978
- return self.generate_terms_md(term_element, "GUID", output_format)
2979
- return response.json().get("element", NO_TERMS_FOUND)
2980
-
2981
- def get_term_by_guid(self, term_guid: str, output_format: str = 'JSON') -> dict | str:
2982
- """Retrieve a term using its unique id. Async version.
2983
- Parameters
2984
- ----------
2985
- term_guid : str
2986
- The GUID of the glossary term to retrieve.
2987
- output_format: str, default = 'JSON'
2988
- Type of output to produce:
2989
- JSON - output standard json
2990
- MD - output standard markdown with no preamble
2991
- FORM - output markdown with a preamble for a form
2992
- REPORT - output markdown with a preamble for a report
2993
- Returns
2994
- -------
2995
- dict | str
2996
- A dict detailing the glossary term represented by the GUID. If no term is found, the string
2997
- "No term found" will be returned.
2998
- Raises
2999
- ------
3000
- InvalidParameterException
3001
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
3002
- PropertyServerException
3003
- Raised by the server when an issue arises in processing a valid request.
3004
- NotAuthorizedException
3005
- The principle specified by the user_id does not have authorization for the requested action.
3006
- """
3007
-
3008
- loop = asyncio.get_event_loop()
3009
- response = loop.run_until_complete(self._async_get_term_by_guid(term_guid, output_format))
3010
-
3011
- return response
3012
-
3013
- async def _async_get_term_versions(self, term_guid: str, effective_time: str = None, from_time: str = None,
3014
- to_time: str = None, oldest_first: bool = False, for_lineage: bool = False,
3015
- for_duplicate_processing: bool = False, start_from: int = 0,
3016
- page_size=max_paging_size,
3017
-
3018
- ) -> list | str:
3019
- """Retrieve the versions of a glossary term. Async version.
3020
- Parameters
3021
- ----------
3022
- term_guid : str
3023
- The GUID of the glossary term to retrieve.
3024
-
3025
- start_from : int, optional
3026
- The index of the first term to retrieve. Default is 0.
3027
- page_size : int, optional
3028
- The number of terms to retrieve per page. If not provided, it will use the default page size.
3029
- Returns
3030
- -------
3031
- list | str
3032
- A [dict] detailing the glossary term represented by the GUID. If no term is found, the string
3033
- "No term found" will be returned.
3034
-
3035
- Raises
3036
- ------
3037
- InvalidParameterException
3038
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
3039
- PropertyServerException
3040
- Raised by the server when an issue arises in processing a valid request.
3041
- NotAuthorizedException
3042
- The principle specified by the user_id does not have authorization for the requested action.
3043
-
3044
- Args:
3045
- term_guid:
3046
- effective_time:
3047
- from_time:
3048
- to_time:
3049
- oldest_first:
3050
- for_lineage:
3051
- for_duplicate_processing:
3052
- start_from:
3053
- page_size:
3054
- """
3055
-
3056
- body = {
3057
- "effective_time": effective_time, "fromTime": from_time, "toTime": to_time, "forLineage": for_lineage,
3058
- "forDuplicateProcessing": for_duplicate_processing
3059
- }
3060
-
3061
- oldest_first_s = str(oldest_first).lower()
3062
- validate_guid(term_guid)
3063
-
3064
- url = (f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/terms/"
3065
- f"{term_guid}/history?startFrom={start_from}&pageSize={page_size}&oldestFirst={oldest_first_s}&"
3066
- f"forDuplicateProcessing={for_duplicate_processing}&forLineage={for_lineage}")
3067
-
3068
- response = await self._async_make_request("POST", url, body_slimmer(body))
3069
- return response.json().get("elementList", "No term found")
3070
-
3071
- def get_term_versions(self, term_guid: str, effective_time: str = None, from_time: str = None, to_time: str = None,
3072
- oldest_first: bool = False, for_lineage: bool = False, for_duplicate_processing: bool = False,
3073
- start_from: int = 0, page_size=max_paging_size, ) -> dict | str:
3074
- """Retrieve the versions of a glossary term.
3075
- Parameters
3076
- ----------
3077
- term_guid : str
3078
- The GUID of the glossary term to retrieve.
3079
-
3080
- start_from : int, optional
3081
- The index of the first term to retrieve. Default is 0.
3082
- page_size : int, optional
3083
- The number of terms to retrieve per page. If not provided, it will use the default page size.
3084
- Returns
3085
- -------
3086
- [dict] | str
3087
- A [dict] detailing the glossary term represented by the GUID. If no term is found, the string
3088
- "No term found" will be returned.
3089
-
3090
- Raises
3091
- ------
3092
- InvalidParameterException
3093
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
3094
- PropertyServerException
3095
- Raised by the server when an issue arises in processing a valid request.
3096
- NotAuthorizedException
3097
- The principle specified by the user_id does not have authorization for the requested action.
3098
- """
3099
-
3100
- loop = asyncio.get_event_loop()
3101
- response = loop.run_until_complete(
3102
- self._async_get_term_versions(term_guid, effective_time, from_time, to_time, oldest_first, for_lineage,
3103
- for_duplicate_processing, start_from, page_size))
3104
-
3105
- return response
3106
-
3107
- async def _async_get_term_revision_logs(self, term_guid: str, start_from: int = 0, page_size=None, ) -> dict | str:
3108
- """Retrieve the revision log history for a term. Async version.
3109
- Parameters
3110
- ----------
3111
- term_guid : str
3112
- The GUID of the glossary term to retrieve.
3113
-
3114
- start_from : int, optional
3115
- The index of the first term to retrieve. Default is 0.
3116
- page_size : int, optional
3117
- The number of terms to retrieve per page. If not provided, it will use the default page size.
3118
- Returns
3119
- -------
3120
- dict | str
3121
- A dict detailing the glossary term revision log history. If no term is found, the string
3122
- "No log found" will be returned.
3123
-
3124
- Raises
3125
- ------
3126
- InvalidParameterException
3127
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
3128
- PropertyServerException
3129
- Raised by the server when an issue arises in processing a valid request.
3130
- NotAuthorizedException
3131
- The principle specified by the user_id does not have authorization for the requested action.
3132
- """
3133
-
3134
- if page_size is None:
3135
- page_size = self.page_size
3136
-
3137
- validate_guid(term_guid)
3138
-
3139
- url = (f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/elements/"
3140
- f"{term_guid}/note-logs/retrieve?startFrom={start_from}&pageSize={page_size}")
3141
-
3142
- response = await self._async_make_request("POST", url)
3143
- return response.json().get("elementList", "No log found")
3144
-
3145
- def get_term_revision_logs(self, term_guid: str, start_from: int = 0, page_size=None, ) -> dict | str:
3146
- """Retrieve the revision log history for a term.
3147
- Parameters
3148
- ----------
3149
- term_guid : str
3150
- The GUID of the glossary term to retrieve.
3151
-
3152
- start_from : int, optional
3153
- The index of the first term to retrieve. Default is 0.
3154
- page_size : int, optional
3155
- The number of terms to retrieve per page. If not provided, it will use the default page size.
3156
- Returns
3157
- -------
3158
- dict | str
3159
- A dict detailing the glossary term revision log history. If no term is found, the string
3160
- "No log found" will be returned.
3161
-
3162
- Raises
3163
- ------
3164
- InvalidParameterException
3165
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
3166
- PropertyServerException
3167
- Raised by the server when an issue arises in processing a valid request.
3168
- NotAuthorizedException
3169
- The principle specified by the user_id does not have authorization for the requested action.
3170
- """
3171
-
3172
- loop = asyncio.get_event_loop()
3173
- response = loop.run_until_complete(self._async_get_term_revision_logs(term_guid, start_from, page_size))
3174
-
3175
- return response
3176
-
3177
- async def _async_get_term_revision_history(self, term_revision_log_guid: str, start_from: int = 0,
3178
- page_size=None, ) -> dict | str:
3179
- """Retrieve the revision history for a glossary term. Async version.
3180
-
3181
- Parameters
3182
- ----------
3183
- term_revision_log_guid : str
3184
- The GUID of the glossary term revision log to retrieve.
3185
-
3186
- start_from : int, optional
3187
- The index of the first term to retrieve. Default is 0.
3188
- page_size : int, optional
3189
- The number of terms to retrieve per page. If not provided, it will use the default page size.
3190
- Returns
3191
- -------
3192
- dict | str
3193
- A dict detailing the glossary term revision history.
3194
-
3195
- Raises
3196
- ------
3197
- InvalidParameterException
3198
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
3199
- PropertyServerException
3200
- Raised by the server when an issue arises in processing a valid request.
3201
- NotAuthorizedException
3202
- The principle specified by the user_id does not have authorization for the requested action.
3203
-
3204
-
3205
- Notes
3206
- -----
3207
- This revision history is created automatically. The text is supplied on the update request.
3208
- If no text is supplied, the value "None" is show.
3209
- """
3210
-
3211
- if page_size is None:
3212
- page_size = self.page_size
3213
-
3214
- validate_guid(term_revision_log_guid)
3215
-
3216
- url = (f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/note-logs/"
3217
- f"{term_revision_log_guid}/notes/retrieve?startFrom={start_from}&pageSize={page_size}")
3218
-
3219
- response = await self._async_make_request("POST", url)
3220
- return response.json().get("elementList", "No logs found")
3221
-
3222
- def get_term_revision_history(self, term_revision_log_guid: str, start_from: int = 0,
3223
- page_size=None, ) -> dict | str:
3224
- """Retrieve the revision history for a glossary term.
3225
-
3226
- Parameters
3227
- ----------
3228
- term_revision_log_guid : str
3229
- The GUID of the glossary term revision log to retrieve.
3230
-
3231
- start_from : int, optional
3232
- The index of the first term to retrieve. Default is 0.
3233
- page_size : int, optional
3234
- The number of terms to retrieve per page. If not provided, it will use the default page size.
3235
- Returns
3236
- -------
3237
- dict | str
3238
- A dict detailing the glossary term revision history.
3239
-
3240
- Raises
3241
- ------
3242
- InvalidParameterException
3243
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
3244
- PropertyServerException
3245
- Raised by the server when an issue arises in processing a valid request.
3246
- NotAuthorizedException
3247
- The principle specified by the user_id does not have authorization for the requested action.
3248
-
3249
-
3250
- Notes
3251
- -----
3252
- This revision history is created automatically. The text is supplied on the update request.
3253
- If no text is supplied, the value "None" is show.
3254
- """
3255
-
3256
- loop = asyncio.get_event_loop()
3257
- response = loop.run_until_complete(
3258
- self._async_get_term_revision_history(term_revision_log_guid, start_from, page_size))
3259
-
3260
- return response
3261
-
3262
- def list_term_revision_history(self, term_guid: str, output_format: str = "DICT") -> list | str:
3263
- """
3264
- Retrieve the revision history for a term.
3265
-
3266
- This method retrieves the revision logs associated with a term, and for each revision log,
3267
- retrieves the revision history. The results are formatted according to the specified output format.
3268
-
3269
- Parameters
3270
- ----------
3271
- term_guid : str
3272
- The GUID of the glossary term to retrieve the revision history for.
3273
- output_format : str, optional
3274
- The format in which to return the results. Can be "DICT", "MD", or "LIST".
3275
- Defaults to "DICT".
3276
-
3277
- Returns
3278
- -------
3279
- list | str
3280
- If output_format is "DICT", returns a list of dictionaries containing the revision history.
3281
- If output_format is "MD", returns a markdown representation of the revision history.
3282
- If output_format is "LIST", returns a markdown table of the revision history.
3283
- If no revision logs are found, returns a string message "No revision logs found".
3284
- """
3285
- validate_guid(term_guid)
3286
-
3287
- # Get revision logs for the term
3288
- revision_logs = self.get_term_revision_logs(term_guid)
3289
- if isinstance(revision_logs, str):
3290
- return "No revision logs found"
3291
-
3292
- # Process each revision log
3293
- all_entries = []
3294
- for log in revision_logs:
3295
- log_guid = log['elementHeader']['guid']
3296
- qualified_name = log.get('properties', {}).get('qualifiedName', '---')
3297
-
3298
- # Get revision history for this log
3299
- history = self.get_term_revision_history(log_guid)
3300
- if isinstance(history, str):
3301
- continue
3302
-
3303
- # Process each entry in the history
3304
- for entry in history:
3305
- # Extract update time from the title
3306
- title = entry.get('properties', {}).get('title', '---')
3307
-
3308
- keyword_index = title.index('on')
3309
- update_time = title[keyword_index + 2:].strip()
3310
-
3311
- entry_data = {
3312
- 'qualifiedName': qualified_name, 'title': title,
3313
- 'text': entry.get('properties', {}).get('text', '---'), 'updateTime': update_time
3314
- # Use extracted date/time or fall back to title
3315
- }
3316
- all_entries.append(entry_data)
3317
-
3318
- # Sort entries by update time
3319
- sorted_entries = sorted(all_entries, key=lambda x: x['updateTime'] if x['updateTime'] != '---' else '',
3320
- reverse=True)
3321
-
3322
- # Return in the specified format
3323
- if output_format == "DICT":
3324
- return sorted_entries
3325
- elif output_format == "LIST":
3326
- # Create markdown table
3327
- if not sorted_entries:
3328
- return "No revision entries found"
3329
-
3330
- # Get headers
3331
- headers = sorted_entries[0].keys()
3332
-
3333
- # Create header row
3334
- header_row = " | ".join(headers)
3335
- separator_row = " | ".join(["---"] * len(headers))
3336
-
3337
- # Create rows
3338
- rows = []
3339
- for entry in sorted_entries:
3340
- row = " | ".join(str(entry.get(header, "---")) for header in headers)
3341
- rows.append(row)
3342
-
3343
- # Combine into table
3344
- markdown_table = f"{header_row}\n{separator_row}\n" + "\n".join(rows)
3345
- return markdown_table
3346
- elif output_format == "MD":
3347
- # Create markdown representation
3348
- if not sorted_entries:
3349
- return "No revision entries found"
3350
-
3351
- md_output = "\n"
3352
-
3353
- for entry in sorted_entries:
3354
- md_output += f"* Note Log Name: \n{entry['qualifiedName']}\n\n"
3355
- md_output += f"* Note Log Entry Title: \n{entry['title']}\n\n"
3356
- md_output += f"* Note Log Entry: \n\t{entry['text']}\n\n"
3357
- md_output += "---\n\n"
3358
-
3359
- return md_output
3360
- else:
3361
- # Default to DICT format
3362
- return sorted_entries
3363
-
3364
- def list_full_term_history(self, term_guid: str, output_type: str = "DICT") -> list | str:
3365
- """
3366
- Retrieves and formats the entire version history of a specific term in the repository.
3367
- The version history is either returned as a list of dictionaries or in a Markdown table
3368
- format.
3369
-
3370
- The returned history includes details about the creation and update timestamps, user
3371
- information, and additional glossary term properties such as `displayName`,
3372
- `qualifiedName`, `description`, and others.
3373
-
3374
- Parameter
3375
- ---------
3376
- term_guid: The unique identifier of the glossary term for which the version
3377
- history needs to be retrieved.
3378
- output_type: The format in which the history should be returned. It can be
3379
- either "DICT" (a list of dictionaries) or "LIST" (a Markdown table).
3380
- Defaults to "DICT".
3381
-
3382
- Returns
3383
- -------
3384
- list | str: A list of dictionaries representing the version history
3385
- (if output_type is "DICT"), or a Markdown table of the version details
3386
- (if output_type is "LIST"). If no history is found, returns a string
3387
- message "No History Found".
3388
- """
3389
- history = self.get_term_versions(term_guid)
3390
- if type(history) is str:
3391
- return "No History Found"
3392
- version_history = []
3393
- for ver in history:
3394
- create_time = ver["elementHeader"]["versions"].get("createTime", " ")
3395
- update_time = ver["elementHeader"]["versions"].get("createTime", " ")
3396
- created_by = ver["elementHeader"]["versions"].get("createdBy", " ")
3397
- updated_by = ver["elementHeader"]["versions"].get("updatedBy", "---")
3398
- version = ver["elementHeader"]["versions"].get("version")
3399
-
3400
- qualified_name = ver["glossaryTermProperties"].get("qualifiedName", ' ')
3401
- display_name = ver["glossaryTermProperties"].get("displayName", ' ')
3402
- summary = ver["glossaryTermProperties"].get("summary", ' ')
3403
- description = ver["glossaryTermProperties"].get("description", ' ')
3404
- examples = ver["glossaryTermProperties"].get("examples", ' ')
3405
- usage = ver["glossaryTermProperties"].get("usage", ' ')
3406
- version_identifier = ver["glossaryTermProperties"].get("versionIdentifier", ' ')
3407
-
3408
- version_history.append({
3409
- "version": version, "displayName": display_name, "summary": summary, "created": create_time,
3410
- "updated": update_time, "createdBy": created_by, "updatedBy": updated_by,
3411
- "qualifiedName": qualified_name, "description": description, "examples": examples, "usage": usage,
3412
- "versionIdentifier": version_identifier,
3413
- })
3414
- sorted_history = sorted(version_history, key=lambda i: i['version'], reverse=True)
3415
- if output_type == "DICT":
3416
- return sorted_history
3417
- elif output_type == "LIST":
3418
- # Get the headers from the keys of the first dictionary
3419
- headers = sorted_history[0].keys()
3420
-
3421
- # Create the header row
3422
- header_row = " | ".join(headers)
3423
- separator_row = " | ".join(["---"] * len(headers)) # Markdown separator row
3424
-
3425
- # Create the rows for the table
3426
- rows = []
3427
- for entry in sorted_history:
3428
- row = " | ".join(str(entry.get(header, "---")) for header in headers)
3429
- rows.append(row)
3430
-
3431
- # Combine everything into a Markdown table string
3432
- markdown_table = f"{header_row}\n{separator_row}\n" + "\n".join(rows)
3433
- return markdown_table
3434
- else:
3435
- return None
3436
-
3437
- async def _async_find_glossary_terms(self, search_string: str, glossary_guid: str = None, status_filter: list = [],
3438
- effective_time: str = None, starts_with: bool = False, ends_with: bool = False,
3439
- ignore_case: bool = False, for_lineage: bool = False,
3440
- for_duplicate_processing: bool = False, start_from: int = 0,
3441
- page_size: int = None, output_format: str = "JSON", ) -> list | str:
3442
- """Retrieve the list of glossary term metadata elements that contain the search string.
3443
-
3444
- Parameters
3445
- ----------
3446
- search_string: str
3447
- Search string to use to find matching glossaries. If the search string is '*' then all glossaries returned.
3448
- glossary_guid str
3449
- Identifier of the glossary to search within. If None, then all glossaries are searched.
3450
- status_filter: list, default = [], optional
3451
- Filters the results by the included Term statuses (such as 'ACTIVE', 'DRAFT'). If not specified,
3452
- the results will not be filtered.
3453
- effective_time: str, [default=None], optional
3454
- If specified, the term information will be retrieved if it is active at the `effective_time`.
3455
- Time format is "YYYY-MM-DDTHH:MM:SS" (ISO 8601)
3456
-
3457
- If not provided, the server name associated with the instance is used.
3458
- starts_with : bool, [default=False], optional
3459
- Starts with the supplied string.
3460
- ends_with : bool, [default=False], optional
3461
- Ends with the supplied string
3462
- ignore_case : bool, [default=False], optional
3463
- Ignore case when searching
3464
- for_lineage : bool, [default=False], optional
3465
-
3466
- for_duplicate_processing : bool, [default=False], optional
3467
-
3468
- start_from: str, [default=0], optional
3469
- Page of results to start from
3470
- page_size : int, optional
3471
- Number of elements to return per page - if None, then default for class will be used.
3472
- output_format: str, default = 'JSON'
3473
- Type of output to produce:
3474
- JSON - output standard json
3475
- MD - output standard markdown with no preamble
3476
- FORM - output markdown with a preamble for a form
3477
- REPORT - output markdown with a preamble for a report
3478
-
3479
- Returns
3480
- -------
3481
- List | str
3482
-
3483
- A list of term definitions
3484
-
3485
- Raises
3486
- ------
3487
- InvalidParameterException
3488
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values
3489
- PropertyServerException
3490
- Raised by the server when an issue arises in processing a valid request
3491
- NotAuthorizedException
3492
- The principle specified by the user_id does not have authorization for the requested action
3493
-
3494
- Notes
3495
- -----
3496
- The search string is located in the request body and is interpreted as a plain string.
3497
- The request parameters, startsWith, endsWith, and ignoreCase can be used to allow a fuzzy search.
3498
- The request body also supports the specification of a glossaryGUID to restrict the search to within a single
3499
- glossary.
3500
- """
3501
-
3502
- if page_size is None:
3503
- page_size = self.page_size
3504
- if effective_time is None:
3505
- effective_time = datetime.now().isoformat()
3506
- starts_with_s = str(starts_with).lower()
3507
- ends_with_s = str(ends_with).lower()
3508
- ignore_case_s = str(ignore_case).lower()
3509
- for_lineage_s = str(for_lineage).lower()
3510
- for_duplicate_processing_s = str(for_duplicate_processing).lower()
3511
- if search_string == "*":
3512
- search_string = None
3513
-
3514
- # validate_search_string(search_string)
3515
-
3516
- body = {
3517
- "class": "GlossarySearchStringRequestBody", "glossaryGUID": glossary_guid, "searchString": search_string,
3518
- "effectiveTime": effective_time, "limitResultsByStatus": status_filter,
3519
- }
3520
-
3521
- url = (f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/"
3522
- f"terms/by-search-string?startFrom={start_from}&pageSize={page_size}&startsWith={starts_with_s}&"
3523
- f"endsWith={ends_with_s}&ignoreCase={ignore_case_s}&forLineage={for_lineage_s}&"
3524
- f"forDuplicateProcessing={for_duplicate_processing_s}")
3525
-
3526
- response = await self._async_make_request("POST", url, body_slimmer(body))
3527
- term_elements = response.json().get("elementList", NO_TERMS_FOUND)
3528
- if term_elements == NO_TERMS_FOUND:
3529
- if output_format == 'JSON':
3530
- return NO_TERMS_FOUND
3531
- elif output_format in ['MD', 'FORM', 'REPORT', 'LIST']:
3532
- return "\n# No Terms found.\n"
3533
- elif output_format == 'DICT':
3534
- return None
3535
- if output_format != "JSON": # return a simplified markdown representation
3536
- return self.generate_terms_md(term_elements, search_string, output_format)
3537
- return response.json().get("elementList", NO_TERMS_FOUND)
3538
-
3539
- def find_glossary_terms(self, search_string: str, glossary_guid: str = None, status_filter: list = [],
3540
- effective_time: str = None, starts_with: bool = False, ends_with: bool = False,
3541
- ignore_case: bool = False, for_lineage: bool = False,
3542
- for_duplicate_processing: bool = False, start_from: int = 0, page_size: int = None,
3543
- output_format: str = "JSON", ) -> list | str:
3544
- """Retrieve the list of glossary term metadata elements that contain the search string.
3545
-
3546
- Parameters
3547
- ----------
3548
- search_string: str
3549
- Search string to use to find matching glossaries. If the search string is '*' then all glossaries
3550
- returned.
3551
- glossary_guid str
3552
- Identifier of the glossary to search within. If None, then all glossaries are searched.
3553
- status_filter: list, default = [], optional
3554
- Filters the results by the included Term statuses (such as 'ACTIVE', 'DRAFT'). If not specified,
3555
- the results will not be filtered.
3556
- effective_time: str, [default=None], optional
3557
- If specified, the term information will be retrieved if it is active at the `effective_time`.
3558
- Time format is "YYYY-MM-DDTHH:MM:SS" (ISO 8601)
3559
-
3560
- If not provided, the server name associated with the instance is used.
3561
- starts_with : bool, [default=False], optional
3562
- Starts with the supplied string.
3563
- ends_with : bool, [default=False], optional
3564
- Ends with the supplied string
3565
- ignore_case : bool, [default=False], optional
3566
- Ignore case when searching
3567
- for_lineage : bool, [default=False], optional
3568
-
3569
- for_duplicate_processing : bool, [default=False], optional
3570
-
3571
- start_from: str, [default=0], optional
3572
- Page of results to start from
3573
- page_size : int, optional
3574
- Number of elements to return per page - if None, then default for class will be used.
3575
- output_format: str, default = 'JSON'
3576
- Type of output to produce:
3577
- JSON - output standard json
3578
- MD - output standard markdown with no preamble
3579
- FORM - output markdown with a preamble for a form
3580
- REPORT - output markdown with a preamble for a report
3581
-
3582
- Returns
3583
- -------
3584
- List | str
3585
-
3586
- A list of term definitions
3587
-
3588
- Raises
3589
- ------
3590
- InvalidParameterException
3591
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values
3592
- PropertyServerException
3593
- Raised by the server when an issue arises in processing a valid request
3594
- NotAuthorizedException
3595
- The principle specified by the user_id does not have authorization for the requested action
3596
-
3597
- Notes
3598
- -----
3599
- The search string is located in the request body and is interpreted as a plain string.
3600
- The request parameters, startsWith, endsWith, and ignoreCase can be used to allow a fuzzy search.
3601
- The request body also supports the specification of a glossaryGUID to restrict the search to within a
3602
- single glossary.
3603
- """
3604
-
3605
- loop = asyncio.get_event_loop()
3606
- response = loop.run_until_complete(
3607
- self._async_find_glossary_terms(search_string, glossary_guid, status_filter, effective_time, starts_with,
3608
- ends_with, ignore_case, for_lineage, for_duplicate_processing, start_from,
3609
- page_size, output_format))
3610
-
3611
- return response
3612
-
3613
- #
3614
- # Feedback
3615
- #
3616
- async def _async_get_comment(self, commemt_guid: str, effective_time: str, for_lineage: bool = False,
3617
- for_duplicate_processing: bool = False, ) -> dict | list:
3618
- """Retrieve the comment specified by the comment GUID"""
3619
-
3620
- validate_guid(commemt_guid)
3621
-
3622
- if effective_time is None:
3623
- effective_time = datetime.now().isoformat()
3624
-
3625
- for_lineage_s = str(for_lineage).lower()
3626
- for_duplicate_processing_s = str(for_duplicate_processing).lower()
3627
-
3628
- body = {"effective_time": effective_time}
3629
-
3630
- url = (f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/comments/"
3631
- f"{commemt_guid}?forLineage={for_lineage_s}&"
3632
- f"forDuplicateProcessing={for_duplicate_processing_s}")
3633
-
3634
- # print(f"\n\nURL is: \n {url}\n\nBody is: \n{body}")
3635
-
3636
- response = await self._async_make_request("POST", url, body)
3637
- return response.json()
3638
-
3639
- async def _async_add_comment_reply(self, comment_guid: str, is_public: bool, comment_type: str, comment_text: str,
3640
- for_lineage: bool = False, for_duplicate_processing: bool = False, ) -> str:
3641
- """Reply to a comment"""
3642
-
3643
- validate_guid(comment_guid)
3644
- validate_name(comment_type)
3645
-
3646
- is_public_s = str(is_public).lower()
3647
- for_lineage_s = str(for_lineage).lower()
3648
- for_duplicate_processing_s = str(for_duplicate_processing).lower()
3649
-
3650
- body = {
3651
- "class": "CommentRequestBody", "commentType": comment_type, "commentText": comment_text,
3652
- "isPublic": is_public,
3653
- }
3654
-
3655
- url = (f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/comments/"
3656
- f"{comment_guid}/replies?isPublic={is_public_s}&forLineage={for_lineage_s}&"
3657
- f"forDuplicateProcessing={for_duplicate_processing_s}")
3658
-
3659
- # print(f"\n\nURL is: \n {url}\n\nBody is: \n{body}")
3660
-
3661
- response = await self._async_make_request("POST", url, body)
3662
- return response
3663
-
3664
- async def _async_update_comment(self, comment_guid: str, is_public: bool, comment_type: str, comment_text: str,
3665
- is_merge_update: bool = False, for_lineage: bool = False,
3666
- for_duplicate_processing: bool = False, ) -> str:
3667
- """Update the specified comment"""
3668
-
3669
- validate_guid(comment_guid)
3670
- validate_name(comment_type)
3671
-
3672
- is_public_s = str(is_public).lower()
3673
- for_lineage_s = str(for_lineage).lower()
3674
- for_duplicate_processing_s = str(for_duplicate_processing).lower()
3675
-
3676
- body = {
3677
- "class": "CommentRequestBody", "commentType": comment_type, "commentText": comment_text,
3678
- "isPublic": is_public,
3679
- }
3680
-
3681
- url = (f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/comments/"
3682
- f"{comment_guid}/replies?isPublic={is_public_s}&forLineage={for_lineage_s}&"
3683
- f"forDuplicateProcessing={for_duplicate_processing_s}")
3684
-
3685
- # print(f"\n\nURL is: \n {url}\n\nBody is: \n{body}")
3686
-
3687
- response = await self._async_make_request("POST", url, body)
3688
- return response
3689
-
3690
- async def _async_find_comment(self, search_string: str, glossary_guid: str = None, status_filter: list = [],
3691
- effective_time: str = None, starts_with: bool = False, ends_with: bool = False,
3692
- ignore_case: bool = False, for_lineage: bool = False,
3693
- for_duplicate_processing: bool = False, start_from: int = 0, page_size: int = None, ):
3694
- """Find comments by search string"""
3695
-
3696
- if page_size is None:
3697
- page_size = self.page_size
3698
- if effective_time is None:
3699
- effective_time = datetime.now().isoformat()
3700
- starts_with_s = str(starts_with).lower()
3701
- ends_with_s = str(ends_with).lower()
3702
- ignore_case_s = str(ignore_case).lower()
3703
- for_lineage_s = str(for_lineage).lower()
3704
- for_duplicate_processing_s = str(for_duplicate_processing).lower()
3705
- if search_string == "*":
3706
- search_string = None
3707
-
3708
- # validate_search_string(search_string)
3709
-
3710
- body = {
3711
- "class": "GlossarySearchStringRequestBody", "glossaryGUID": glossary_guid, "searchString": search_string,
3712
- "effectiveTime": effective_time, "limitResultsByStatus": status_filter,
3713
- }
3714
- # body = body_slimmer(body)
3715
-
3716
- url = (f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/"
3717
- f"terms/by-search-string?startFrom={start_from}&pageSize={page_size}&startsWith={starts_with_s}&"
3718
- f"endsWith={ends_with_s}&ignoreCase={ignore_case_s}&forLineage={for_lineage_s}&"
3719
- f"forDuplicateProcessing={for_duplicate_processing_s}")
3720
-
3721
- # print(f"\n\nURL is: \n {url}\n\nBody is: \n{body}")
3722
-
3723
- response = await self._async_make_request("POST", url, body)
3724
- return response.json().get("elementList", "No terms found")
3725
-
3726
-
3727
- if __name__ == "__main__":
3728
- print("Main-Glossary Browser")