pyegeria 5.3.6.2.5__py3-none-any.whl → 5.3.6.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. pyegeria/__init__.py +3 -0
  2. pyegeria/_client.py +10 -0
  3. pyegeria/commands/cat/{freddie_jupyter.py → dr_egeria_jupyter.py} +8 -16
  4. pyegeria/commands/cat/{freddie_md.py → dr_egeria_md.py} +39 -33
  5. pyegeria/commands/cat/glossary_actions.py +59 -1
  6. pyegeria/commands/cat/list_categories.py +185 -0
  7. pyegeria/commands/cat/list_glossaries.py +26 -33
  8. pyegeria/commands/cat/list_terms.py +47 -47
  9. pyegeria/commands/cli/egeria.py +51 -29
  10. pyegeria/commands/cli/egeria_cat.py +53 -31
  11. pyegeria/create_tech_guid_lists.py +2 -5
  12. pyegeria/glossary_browser_omvs.py +283 -113
  13. pyegeria/glossary_manager_omvs.py +150 -1594
  14. pyegeria/md_processing_utils.py +853 -0
  15. {pyegeria-5.3.6.2.5.dist-info → pyegeria-5.3.6.4.dist-info}/METADATA +1 -1
  16. {pyegeria-5.3.6.2.5.dist-info → pyegeria-5.3.6.4.dist-info}/RECORD +21 -31
  17. {pyegeria-5.3.6.2.5.dist-info → pyegeria-5.3.6.4.dist-info}/entry_points.txt +5 -0
  18. pyegeria/commands/cat/freddie_jup.py +0 -124
  19. pyegeria/commands/cat/freddie_utils.py +0 -590
  20. pyegeria/commands/cat/freddies-inbox/freddie_intro.md +0 -221
  21. pyegeria/commands/cat/freddies-outbox/Terms-2025-03-06-13-19-29-Report.md +0 -69
  22. pyegeria/commands/cat/freddies-outbox/Terms-2025-03-06-13-20-30-Update-Form.md +0 -78
  23. pyegeria/commands/cat/freddies-outbox/Terms-2025-03-06-19-39-25-Update-Form.md +0 -78
  24. pyegeria/commands/cat/glossary_creation_experiment.ipynb +0 -235
  25. pyegeria/test_j.html +0 -0
  26. pyegeria/test_m.html +0 -213
  27. pyegeria/test_m1.html +0 -273
  28. pyegeria/test_mer.ipynb +0 -596
  29. pyegeria/test_w.html +0 -213
  30. /pyegeria/commands/cat/{freddies-inbox → dr_egeria_inbox}/glossary_creation_experiment.ipynb +0 -0
  31. /pyegeria/commands/cat/{freddies-inbox → dr_egeria_inbox}/glossary_exp.md +0 -0
  32. {pyegeria-5.3.6.2.5.dist-info → pyegeria-5.3.6.4.dist-info}/LICENSE +0 -0
  33. {pyegeria-5.3.6.2.5.dist-info → pyegeria-5.3.6.4.dist-info}/WHEEL +0 -0
@@ -15,7 +15,7 @@ import json
15
15
  from pyegeria._client import Client
16
16
  from pyegeria._validators import validate_guid, validate_name, validate_search_string
17
17
  from pyegeria.utils import body_slimmer
18
- from pyegeria._globals import NO_ELEMENTS_FOUND
18
+ from pyegeria._globals import NO_ELEMENTS_FOUND, NO_CATALOGS_FOUND, NO_CATEGORIES_FOUND, NO_TERMS_FOUND
19
19
  MD_SEPERATOR = "\n---\n\n"
20
20
 
21
21
  class GlossaryBrowser(Client):
@@ -53,15 +53,61 @@ class GlossaryBrowser(Client):
53
53
 
54
54
  Client.__init__(self, view_server, platform_url, user_id, user_pwd, token)
55
55
 
56
- def generate_glossaries_md(self, elements: list, search_string: str, form:bool = True)-> str:
57
- if form:
58
- elements_md = f"# Update Glossaries Form - created at {datetime.now().strftime('%Y-%m-%d %H:%M')}\n"
59
- elements_action = "Update Glossary"
60
- else:
61
- elements_md = f"# Glossaries Report - created at {datetime.now().strftime('%Y-%m-%d %H:%M')}\n"
56
+
57
+ def make_preamble(self, obj_type, search_string, output_format: str = 'MD')-> tuple[str, str | None]:
58
+ """
59
+ Creates a preamble string and an elements action based on the given object type, search string,
60
+ and output format. The preamble provides a descriptive header based on the intent: To make a form,
61
+ a report, or unadorned markdwon. The elements action specifies the action to be taken on the object type.
62
+
63
+ Args:
64
+ obj_type: The type of object being updated or reported on (e.g., "Product", "Category").
65
+ search_string: The search string used to filter objects. Defaults to "All Terms" if None.
66
+ output_format: A format identifier determining the output structure.
67
+ JSON - output standard json
68
+ MD - output standard markdown with no preamble
69
+ FORM - output markdown with a preamble for a form
70
+ REPORT - output markdown with a preamble for a report
71
+
72
+ Returns:
73
+ tuple: A tuple containing:
74
+ - A string representing the formatted update or report preamble.
75
+ - A string or None indicating the action description for the elements,
76
+ depending on the output format.
77
+ """
78
+ search_string = search_string if search_string else "All Elements"
79
+ elements_action = "Update " + obj_type
80
+ if output_format == "FORM":
81
+ preamble = (f"\n# Update {obj_type} Form - created at {datetime.now().strftime('%Y-%m-%d %H:%M')}\n"
82
+ f"\t {obj_type} found from the search string: `{search_string}`\n\n")
83
+
84
+ return preamble, elements_action
85
+ elif output_format == "REPORT":
86
+ elements_md = (f"# {obj_type} Report - created at {datetime.now().strftime('%Y-%m-%d %H:%M')}\n"
87
+ f"\t{obj_type} found from the search string: `{search_string}`\n\n")
62
88
  elements_action = None
63
- search_string = search_string if search_string else "All Glossaries"
64
- elements_md += f"Glossaries found from the search string: `{search_string}`\n\n"
89
+ return elements_md, elements_action
90
+
91
+ else:
92
+ return "\n", elements_action
93
+
94
+ def make_md_attribute(self, attribute_name: str, attribute_value: str, output_type: str) -> str | None:
95
+ output = ""
96
+ attribute_value = attribute_value.strip() if attribute_value else None
97
+ attribute_title = attribute_name.title() if attribute_name else None
98
+ if output_type in ["FORM", "MD"]:
99
+ output = f"## {attribute_title}\n{attribute_value}\n\n"
100
+ elif output_type == "REPORT":
101
+ if attribute_value:
102
+ output = f"## {attribute_title}\n{attribute_value}\n\n"
103
+ return output
104
+
105
+
106
+ def generate_glossaries_md(self, elements: list | dict, search_string: str, output_format: str = 'MD')-> str:
107
+ elements_md, elements_action = self.make_preamble(obj_type="Glossary", search_string=search_string,
108
+ output_format=output_format)
109
+ if isinstance(elements, dict):
110
+ elements = [elements]
65
111
 
66
112
  for element in elements:
67
113
  guid = element['elementHeader'].get("guid", None)
@@ -72,30 +118,28 @@ class GlossaryBrowser(Client):
72
118
  usage = properties.get("usage", None)
73
119
  qualified_name = properties.get("qualifiedName", None)
74
120
 
75
- if form:
121
+ if output_format in ['FORM','MD']:
76
122
  elements_md += f"# {elements_action}\n\n"
77
- elements_md += f"## Glossary Name \n{display_name}\n\n"
78
- else:
123
+ elements_md += f"## Glossary Name \n\n{display_name}\n\n"
124
+
125
+ elif output_format == 'REPORT':
79
126
  elements_md += f"# Glossary Name: {display_name}\n\n"
127
+ else:
128
+ elements_md += f"## Glossary Name \n\n{display_name}\n\n"
80
129
 
130
+ elements_md += self.make_md_attribute( "description", description, output_format)
131
+ elements_md += self.make_md_attribute("language", language, output_format)
132
+ elements_md += self.make_md_attribute("usage", usage, output_format)
133
+ elements_md += self.make_md_attribute("qualified name", qualified_name, output_format)
134
+ elements_md += self.make_md_attribute("GUID", guid, output_format)
135
+ # elements_md += MD_SEPERATOR
81
136
 
82
- elements_md += f"## Description\n{description}\n\n"
83
- elements_md += f"## Language\n{language}\n\n"
84
- elements_md += f"## Usage\n{usage}\n\n"
85
- elements_md += f"## Qualified Name\n{qualified_name}\n\n"
86
- elements_md += f"## GUID\n{guid}\n\n"
87
- elements_md += MD_SEPERATOR
88
137
  return elements_md
89
138
 
90
- def generate_terms_md(self, elements: list, search_string: str, form:bool = True)-> str:
91
- if form:
92
- elements_md = f"# Update terms Form - created at {datetime.now().strftime('%Y-%m-%d %H:%M')}\n"
93
- elements_action = "Update Terms"
94
- else:
95
- elements_md = f"# Glossary Terms Report - created at {datetime.now().strftime('%Y-%m-%d %H:%M')}\n"
96
- elements_action = None
97
- search_string = search_string if search_string else "All Terms"
98
- elements_md += f"Terms found from the search string: `{search_string}`\n\n"
139
+ def generate_terms_md(self, elements: list | dict, search_string: str, output_format: str = 'MD') -> str:
140
+ elements_md, elements_action = self.make_preamble(obj_type="Term", search_string=search_string, output_format=output_format)
141
+ if isinstance(elements, dict):
142
+ elements = [elements]
99
143
 
100
144
  for element in elements:
101
145
  guid = element['elementHeader'].get("guid", None)
@@ -107,23 +151,78 @@ class GlossaryBrowser(Client):
107
151
  usage = element_properties.get("usage", None)
108
152
  pub_version = element_properties.get("publishedVersionIdentifier", None)
109
153
  qualified_name = element_properties.get("qualifiedName", None)
110
- status = element['elementHeader']['classifications'][0].get('status', None)
154
+ status = element['elementHeader'].get('status', None)
155
+
156
+ glossary_guid = element['elementHeader'].get('classifications', [{}])[0].get('classificationProperties', {}).get('anchorGUID', None)
157
+ glossary_qualified_name = self.get_glossary_by_guid(glossary_guid)['glossaryProperties']['qualifiedName']
111
158
 
112
- if form:
159
+ category_list_md = "\n"
160
+ category_list = self.get_categories_for_term(guid)
161
+ if type(category_list) is str and category_list == NO_CATEGORIES_FOUND:
162
+ category_list_md = ['---']
163
+ elif isinstance(category_list, list) and len(category_list) > 0:
164
+ for category in category_list:
165
+ category_name = category["glossaryCategoryProperties"].get("qualifiedName", '---')
166
+ category_list_md += f" {category_name}\n"
167
+
168
+ if output_format in ['FORM', 'MD']:
113
169
  elements_md += f"# {elements_action}\n\n"
114
- elements_md += f"## Term Name \n{display_name}\n\n"
115
- else:
170
+ elements_md += f"## Term Name \n\n{display_name}\n\n"
171
+ elif output_format == 'REPORT':
116
172
  elements_md += f"# Term Name: {display_name}\n\n"
173
+ else:
174
+ elements_md += f"## Term Name \n\n{display_name}\n\n"
175
+
176
+ elements_md += self.make_md_attribute("summary", summary, output_format)
177
+ elements_md += self.make_md_attribute("in glossary", glossary_qualified_name, output_format)
178
+ elements_md += self.make_md_attribute( "categories", category_list_md, output_format)
179
+ elements_md += self.make_md_attribute( "status", status, output_format)
180
+ elements_md += self.make_md_attribute( "description", description, output_format)
181
+ elements_md += self.make_md_attribute( "examples", examples, output_format)
182
+ elements_md += self.make_md_attribute("usage", usage, output_format)
183
+ elements_md += self.make_md_attribute("published version", pub_version, output_format)
184
+ elements_md += self.make_md_attribute("qualified name", qualified_name, output_format)
185
+ elements_md += self.make_md_attribute("GUID", guid, output_format)
186
+ # elements_md += MD_SEPERATOR
187
+
188
+ return elements_md
189
+
190
+ def generate_categories_md(self, elements: list | dict, search_string: str, output_format: str = 'MD')-> str:
191
+ elements_md, elements_action = self.make_preamble(obj_type="Categories", search_string=search_string,
192
+ output_format=output_format)
193
+ if isinstance(elements, dict):
194
+ elements = [elements]
117
195
 
118
- elements_md += f"## Status\n{status}\n\n"
119
- elements_md += f"## Summary\n{summary}\n\n"
120
- elements_md += f"## Description\n{description}\n\n"
121
- elements_md += f"## Examples\n{examples}\n\n"
122
- elements_md += f"## Usage\n{usage}\n\n"
123
- elements_md += f"## Published Version\n{pub_version}\n\n"
124
- elements_md += f"## Qualified Name\n{qualified_name}\n\n"
125
- elements_md += f"## GUID\n{guid}\n\n"
196
+ for element in elements:
197
+ guid = element['elementHeader'].get("guid", None)
198
+ properties = element['glossaryCategoryProperties']
199
+ display_name = properties.get("displayName", None)
200
+ description = properties.get("description", None)
201
+ qualified_name = properties.get("qualifiedName", None)
202
+
203
+ classification_props = element["elementHeader"]['classifications'][0].get('classificationProperties', None)
204
+ glossary_qualified_name = '---'
205
+ if classification_props is not None:
206
+ glossary_guid = classification_props.get('anchorGUID', '---')
207
+ glossary_qualified_name = (
208
+ self.get_glossary_by_guid(glossary_guid))['glossaryProperties']['qualifiedName']
209
+
210
+ if output_format in ['FORM', 'MD']:
211
+ elements_md += f"# {elements_action}\n\n"
212
+ elements_md += f"## Category Name \n\n{display_name}\n\n"
213
+
214
+ elif output_format == 'REPORT':
215
+ elements_md += f"# Category Name: {display_name}\n\n"
216
+ else:
217
+ elements_md += f"## Category Name \n\n{display_name}\n\n"
218
+
219
+
220
+ elements_md += self.make_md_attribute("description", description, output_format)
221
+ elements_md += self.make_md_attribute("in glossary", glossary_qualified_name, output_format)
222
+ elements_md += self.make_md_attribute("qualified name", qualified_name, output_format)
223
+ elements_md += self.make_md_attribute("GUID", guid, output_format)
126
224
  elements_md += MD_SEPERATOR
225
+
127
226
  return elements_md
128
227
 
129
228
  #
@@ -267,8 +366,7 @@ class GlossaryBrowser(Client):
267
366
  type_name: str = None,
268
367
  start_from: int = 0,
269
368
  page_size: int = None,
270
- md: bool = False,
271
- form: bool = True
369
+ output_format: str = 'JSON'
272
370
  ) -> list | str:
273
371
  """Retrieve the list of glossary metadata elements that contain the search string. Async version.
274
372
  The search string is located in the request body and is interpreted as a plain string.
@@ -301,11 +399,12 @@ class GlossaryBrowser(Client):
301
399
  page_size: int, [default=None]
302
400
  The number of items to return in a single page. If not specified, the default will be taken from
303
401
  the class instance.
304
- md: bool, [default=False]
305
- If true, a simplified markdown representation of the glossary will be returned
306
- form: bool, [default=True]
307
- If true and md is true, a form for the glossaries will be returned as a markdown string.
308
- If false and md is true, a report for the glossaries will be returned.
402
+ output_format: str, default = 'JSON'
403
+ Type of output to produce:
404
+ JSON - output standard json
405
+ MD - output standard markdown with no preamble
406
+ FORM - output markdown with a preamble for a form
407
+ REPORT - output markdown with a preamble for a report
309
408
 
310
409
  Returns
311
410
  -------
@@ -353,14 +452,15 @@ class GlossaryBrowser(Client):
353
452
  f"forDuplicateProcessing={for_duplicate_processing_s}"
354
453
  )
355
454
 
356
- response = await self._async_make_request("POST", url, body)
357
- glossary_elements = response.json().get("elementList", NO_GLOSSARIES_FOUND)
358
- if glossary_elements == NO_GLOSSARIES_FOUND:
455
+ response = await self._async_make_request("POST", url, body_slimmer(body))
456
+ element = response.json().get("elementList", NO_GLOSSARIES_FOUND)
457
+ if element == NO_GLOSSARIES_FOUND:
359
458
  return NO_GLOSSARIES_FOUND
360
- if md: # return a simplified markdown representation
361
- return self.generate_glossaries_md(glossary_elements, search_string,form)
459
+ if output_format != 'JSON': # return a simplified markdown representation
460
+ return self.generate_glossaries_md(element, search_string, output_format)
362
461
  return response.json().get("elementList", NO_GLOSSARIES_FOUND)
363
462
 
463
+
364
464
  def find_glossaries(
365
465
  self,
366
466
  search_string: str,
@@ -373,8 +473,7 @@ class GlossaryBrowser(Client):
373
473
  type_name: str = None,
374
474
  start_from: int = 0,
375
475
  page_size: int = None,
376
- md: bool = False,
377
- form: bool = True
476
+ output_format: str = "JSON"
378
477
  ) -> list | str:
379
478
  """Retrieve the list of glossary metadata elements that contain the search string.
380
479
  The search string is located in the request body and is interpreted as a plain string.
@@ -408,11 +507,12 @@ class GlossaryBrowser(Client):
408
507
  page_size: int, [default=None]
409
508
  The number of items to return in a single page. If not specified, the default will be taken from
410
509
  the class instance.
411
- md: bool, [default=False]
412
- If true, a simplified markdown representation of the glossary will be returned
413
- form: bool, [default=True]
414
- If true and md is true, a form for the glossaries will be returned as a markdown string.
415
- If false and md is true, a report for the glossaries will be returned.
510
+ output_format: str, default = 'JSON'
511
+ Type of output to produce:
512
+ JSON - output standard json
513
+ MD - output standard markdown with no preamble
514
+ FORM - output markdown with a preamble for a form
515
+ REPORT - output markdown with a preamble for a report
416
516
  Returns
417
517
  -------
418
518
  List | str
@@ -443,15 +543,14 @@ class GlossaryBrowser(Client):
443
543
  type_name,
444
544
  start_from,
445
545
  page_size,
446
- md,
447
- form
546
+ output_format
448
547
  )
449
548
  )
450
549
 
451
550
  return response
452
551
 
453
552
  async def _async_get_glossary_by_guid(
454
- self, glossary_guid: str, effective_time: str = None
553
+ self, glossary_guid: str, effective_time: str = None, output_format: str = "JSON"
455
554
  ) -> dict:
456
555
  """Retrieves information about a glossary
457
556
  Parameters
@@ -461,6 +560,13 @@ class GlossaryBrowser(Client):
461
560
  effective_time: str, optional
462
561
  Effective time of the query. If not specified will default to any time. Time format is
463
562
  "YYYY-MM-DDTHH:MM:SS" (ISO 8601)
563
+ output_format: str, default = 'JSON'
564
+ Type of output to produce:
565
+ JSON - output standard json
566
+ MD - output standard markdown with no preamble
567
+ FORM - output markdown with a preamble for a form
568
+ REPORT - output markdown with a preamble for a report
569
+
464
570
  Returns
465
571
  -------
466
572
  dict
@@ -477,22 +583,28 @@ class GlossaryBrowser(Client):
477
583
  Notes
478
584
  -----
479
585
  """
480
-
586
+ output_format = output_format.upper()
481
587
  validate_guid(glossary_guid)
482
588
 
483
589
  body = {
484
590
  "class": "EffectiveTimeQueryRequestBody",
485
- "effectiveTime": effective_time
591
+ "effectiveTime" : effective_time
486
592
  }
487
593
  url = (
488
594
  f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/"
489
595
  f"{glossary_guid}/retrieve"
490
596
  )
491
- response = await self._async_make_request("POST", url, body)
597
+ response = await self._async_make_request("POST", url, body_slimmer(body))
598
+ element = response.json().get("element", NO_GLOSSARIES_FOUND)
599
+ if element == NO_GLOSSARIES_FOUND:
600
+ return NO_GLOSSARIES_FOUND
601
+ if output_format != 'JSON': # return a simplified markdown representation
602
+ return self.generate_glossaries_md(element, "GUID", output_format)
492
603
  return response.json().get("element", NO_GLOSSARIES_FOUND)
493
604
 
605
+
494
606
  def get_glossary_by_guid(
495
- self, glossary_guid: str, effective_time: str = None
607
+ self, glossary_guid: str, effective_time: str = None, output_format: str = "JSON"
496
608
  ) -> dict:
497
609
  """Retrieves information about a glossary
498
610
  Parameters
@@ -502,6 +614,12 @@ class GlossaryBrowser(Client):
502
614
  effective_time: str, optional
503
615
  Effective time of the query. If not specified will default to any time. Time format is
504
616
  "YYYY-MM-DDTHH:MM:SS" (ISO 8601)
617
+ output_format: str, default = 'JSON'
618
+ Type of output to produce:
619
+ JSON - output standard json
620
+ MD - output standard markdown with no preamble
621
+ FORM - output markdown with a preamble for a form
622
+ REPORT - output markdown with a preamble for a report
505
623
 
506
624
  Returns
507
625
  -------
@@ -521,7 +639,7 @@ class GlossaryBrowser(Client):
521
639
  """
522
640
  loop = asyncio.get_event_loop()
523
641
  response = loop.run_until_complete(
524
- self._async_get_glossary_by_guid(glossary_guid, effective_time)
642
+ self._async_get_glossary_by_guid(glossary_guid, effective_time, output_format)
525
643
  )
526
644
  return response
527
645
 
@@ -738,6 +856,7 @@ class GlossaryBrowser(Client):
738
856
  ignore_case: bool = False,
739
857
  start_from: int = 0,
740
858
  page_size: int = None,
859
+ output_format: str = "JSON"
741
860
  ) -> list | str:
742
861
  """Retrieve the list of glossary category metadata elements that contain the search string.
743
862
  The search string is located in the request body and is interpreted as a plain string.
@@ -765,6 +884,13 @@ class GlossaryBrowser(Client):
765
884
  page_size: int, [default=None]
766
885
  The number of items to return in a single page. If not specified, the default will be taken from
767
886
  the class instance.
887
+ output_format: str, default = 'JSON'
888
+ Type of output to produce:
889
+ JSON - output standard json
890
+ MD - output standard markdown with no preamble
891
+ FORM - output markdown with a preamble for a form
892
+ REPORT - output markdown with a preamble for a report
893
+
768
894
  Returns
769
895
  -------
770
896
  List | str
@@ -799,17 +925,25 @@ class GlossaryBrowser(Client):
799
925
  "searchString": search_string,
800
926
  "effectiveTime": effective_time,
801
927
  }
802
- body = body_slimmer(body)
803
928
 
804
929
  url = (
805
930
  f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/"
806
931
  f"categories/by-search-string?startFrom={start_from}&pageSize={page_size}&startsWith={starts_with_s}&"
807
932
  f"endsWith={ends_with_s}&ignoreCase={ignore_case_s}"
808
933
  )
809
-
810
- response = await self._async_make_request("POST", url, body)
934
+ response = await self._async_make_request("POST", url, body_slimmer(body))
935
+ element = response.json().get("elementList", NO_CATEGORIES_FOUND)
936
+ if element == NO_CATEGORIES_FOUND:
937
+ return NO_CATEGORIES_FOUND
938
+ if output_format != 'JSON': # return a simplified markdown representation
939
+ return self.generate_categories_md(element, search_string, output_format)
811
940
  return response.json().get("elementList", NO_CATEGORIES_FOUND)
812
941
 
942
+
943
+
944
+
945
+
946
+
813
947
  def find_glossary_categories(
814
948
  self,
815
949
  search_string: str,
@@ -819,6 +953,7 @@ class GlossaryBrowser(Client):
819
953
  ignore_case: bool = False,
820
954
  start_from: int = 0,
821
955
  page_size: int = None,
956
+ output_format: str = "JSON"
822
957
  ) -> list | str:
823
958
  """Retrieve the list of glossary category metadata elements that contain the search string.
824
959
  The search string is located in the request body and is interpreted as a plain string.
@@ -841,11 +976,18 @@ class GlossaryBrowser(Client):
841
976
  Ends with the supplied string
842
977
  ignore_case : bool, [default=False], optional
843
978
  Ignore case when searching
844
- start_from: int, [default=0], optional
979
+ start_from: int, [default=0], optional
845
980
  When multiple pages of results are available, the page number to start from.
846
- page_size: int, [default=None]
981
+ page_size: int, [default=None]
847
982
  The number of items to return in a single page. If not specified, the default will be taken from
848
983
  the class instance.
984
+ output_format: str, default = 'JSON'
985
+ Type of output to produce:
986
+ JSON - output standard json
987
+ MD - output standard markdown with no preamble
988
+ FORM - output markdown with a preamble for a form
989
+ REPORT - output markdown with a preamble for a report
990
+
849
991
  Returns
850
992
  -------
851
993
  List | str
@@ -873,6 +1015,7 @@ class GlossaryBrowser(Client):
873
1015
  ignore_case,
874
1016
  start_from,
875
1017
  page_size,
1018
+ output_format
876
1019
  )
877
1020
  )
878
1021
 
@@ -1127,7 +1270,7 @@ class GlossaryBrowser(Client):
1127
1270
  }
1128
1271
 
1129
1272
  response = await self._async_make_request("POST", url, body)
1130
- return response.json().get("elementList", "No Categories found")
1273
+ return response.json().get("elementList", NO_CATEGORIES_FOUND)
1131
1274
 
1132
1275
  def get_categories_by_name(
1133
1276
  self,
@@ -1186,6 +1329,7 @@ class GlossaryBrowser(Client):
1186
1329
  self,
1187
1330
  glossary_category_guid: str,
1188
1331
  effective_time: str = None,
1332
+ output_format: str = 'JSON',
1189
1333
  ) -> list | str:
1190
1334
  """Retrieve the requested glossary category metadata element. The optional request body contain an effective
1191
1335
  time for the query..
@@ -1200,7 +1344,12 @@ class GlossaryBrowser(Client):
1200
1344
  If specified, the category should only be returned if it was effective at the specified time.
1201
1345
  Time format is "YYYY-MM-DDTHH:MM:SS" (ISO 8601)
1202
1346
 
1203
- If not provided, the server name associated with the instance is used.
1347
+ output_format: str, default = 'JSON'
1348
+ Type of output to produce:
1349
+ JSON - output standard json
1350
+ MD - output standard markdown with no preamble
1351
+ FORM - output markdown with a preamble for a form
1352
+ REPORT - output markdown with a preamble for a report
1204
1353
 
1205
1354
  Returns
1206
1355
  -------
@@ -1219,7 +1368,7 @@ class GlossaryBrowser(Client):
1219
1368
  The principle specified by the user_id does not have authorization for the requested action
1220
1369
 
1221
1370
  """
1222
-
1371
+ output_format = output_format.upper()
1223
1372
  url = (
1224
1373
  f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/categories/"
1225
1374
  f"{glossary_category_guid}/retrieve"
@@ -1230,13 +1379,19 @@ class GlossaryBrowser(Client):
1230
1379
  "effectiveTime": effective_time,
1231
1380
  }
1232
1381
 
1233
- response = await self._async_make_request("POST", url, body)
1234
- return response.json().get("element", "No Category found")
1382
+ response = await self._async_make_request("POST", url, body_slimmer(body))
1383
+ element = response.json().get("element", NO_CATEGORIES_FOUND)
1384
+ if element == NO_CATEGORIES_FOUND:
1385
+ return NO_CATEGORIES_FOUND
1386
+ if output_format != 'JSON': # return a simplified markdown representation
1387
+ return self.generate_categories_md(element, "GUID", output_format)
1388
+ return response.json().get("element", NO_CATEGORIES_FOUND)
1235
1389
 
1236
1390
  def get_categories_by_guid(
1237
1391
  self,
1238
1392
  glossary_category_guid: str,
1239
1393
  effective_time: str = None,
1394
+ output_format: str = 'JSON',
1240
1395
  ) -> list | str:
1241
1396
  """Retrieve the requested glossary category metadata element. The optional request body contain an effective
1242
1397
  time for the query..
@@ -1249,7 +1404,12 @@ class GlossaryBrowser(Client):
1249
1404
  If specified, the category should only be returned if it was effective at the specified time.
1250
1405
  Time format is "YYYY-MM-DDTHH:MM:SS" (ISO 8601)
1251
1406
 
1252
- If not provided, the server name associated with the instance is used.
1407
+ output_format: str, default = 'JSON'
1408
+ Type of output to produce:
1409
+ JSON - output standard json
1410
+ MD - output standard markdown with no preamble
1411
+ FORM - output markdown with a preamble for a form
1412
+ REPORT - output markdown with a preamble for a report
1253
1413
 
1254
1414
  Returns
1255
1415
  -------
@@ -1270,7 +1430,7 @@ class GlossaryBrowser(Client):
1270
1430
  """
1271
1431
  loop = asyncio.get_event_loop()
1272
1432
  response = loop.run_until_complete(
1273
- self._async_get_categories_by_guid(glossary_category_guid, effective_time)
1433
+ self._async_get_categories_by_guid(glossary_category_guid, effective_time, output_format)
1274
1434
  )
1275
1435
  return response
1276
1436
 
@@ -1390,7 +1550,6 @@ class GlossaryBrowser(Client):
1390
1550
  ----------
1391
1551
  glossary_category_guid : str
1392
1552
  Unique identifier for the glossary category to retrieve terms from.
1393
-
1394
1553
  effective_time : str, optional
1395
1554
  If specified, the terms are returned if they are active at the `effective_time
1396
1555
  Time format is "YYYY-MM-DDTHH:MM:SS" (ISO 8601)
@@ -1400,7 +1559,7 @@ class GlossaryBrowser(Client):
1400
1559
  The number of elements to retrieve
1401
1560
  Returns
1402
1561
  -------
1403
- dict
1562
+ [dict]
1404
1563
  The glossary definition associated with the glossary_guid
1405
1564
 
1406
1565
  Raises
@@ -1411,8 +1570,7 @@ class GlossaryBrowser(Client):
1411
1570
  Raised by the server when an issue arises in processing a valid request.
1412
1571
  NotAuthorizedException
1413
1572
  The principle specified by the user_id does not have authorization for the requested action.
1414
- Notes
1415
- -----
1573
+
1416
1574
  """
1417
1575
 
1418
1576
  validate_guid(glossary_category_guid)
@@ -1421,7 +1579,7 @@ class GlossaryBrowser(Client):
1421
1579
  page_size = self.page_size
1422
1580
 
1423
1581
  url = (
1424
- f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/terms/"
1582
+ f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/categories/"
1425
1583
  f"{glossary_category_guid}/terms/retrieve?startFrom={start_from}&pageSize={page_size}"
1426
1584
  )
1427
1585
 
@@ -1915,13 +2073,18 @@ class GlossaryBrowser(Client):
1915
2073
  )
1916
2074
  return response
1917
2075
 
1918
- async def _async_get_terms_by_guid(self, term_guid: str) -> dict | str:
2076
+ async def _async_get_terms_by_guid(self, term_guid: str, output_format: str = 'JSON') -> dict | str:
1919
2077
  """Retrieve a term using its unique id. Async version.
1920
2078
  Parameters
1921
2079
  ----------
1922
2080
  term_guid : str
1923
2081
  The GUID of the glossary term to retrieve.
1924
-
2082
+ output_format: str, default = 'JSON'
2083
+ Type of output to produce:
2084
+ JSON - output standard json
2085
+ MD - output standard markdown with no preamble
2086
+ FORM - output markdown with a preamble for a form
2087
+ REPORT - output markdown with a preamble for a report
1925
2088
 
1926
2089
  Returns
1927
2090
  -------
@@ -1938,31 +2101,39 @@ class GlossaryBrowser(Client):
1938
2101
  NotAuthorizedException
1939
2102
  The principle specified by the user_id does not have authorization for the requested action.
1940
2103
  """
1941
-
2104
+ output_format = output_format.upper()
1942
2105
  validate_guid(term_guid)
1943
2106
 
1944
2107
  url = (
1945
2108
  f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/terms/"
1946
2109
  f"{term_guid}/retrieve"
1947
2110
  )
1948
-
1949
2111
  response = await self._async_make_request("POST", url)
1950
- return response.json().get("element", "No term found")
2112
+ term_element = response.json().get("element", NO_TERMS_FOUND)
2113
+ if term_element == NO_TERMS_FOUND:
2114
+ return NO_TERMS_FOUND
2115
+ if output_format != 'JSON': # return a simplified markdown representation
2116
+ return self.generate_terms_md(term_element, "GUID", output_format)
2117
+ return response.json().get("element", NO_TERMS_FOUND)
2118
+
1951
2119
 
1952
- def get_terms_by_guid(self, term_guid: str) -> dict | str:
2120
+ def get_terms_by_guid(self, term_guid: str, output_format: str = 'JSON') -> dict | str:
1953
2121
  """Retrieve a term using its unique id. Async version.
1954
2122
  Parameters
1955
2123
  ----------
1956
2124
  term_guid : str
1957
2125
  The GUID of the glossary term to retrieve.
1958
-
1959
-
2126
+ output_format: str, default = 'JSON'
2127
+ Type of output to produce:
2128
+ JSON - output standard json
2129
+ MD - output standard markdown with no preamble
2130
+ FORM - output markdown with a preamble for a form
2131
+ REPORT - output markdown with a preamble for a report
1960
2132
  Returns
1961
2133
  -------
1962
2134
  dict | str
1963
2135
  A dict detailing the glossary term represented by the GUID. If no term is found, the string
1964
2136
  "No term found" will be returned.
1965
-
1966
2137
  Raises
1967
2138
  ------
1968
2139
  InvalidParameterException
@@ -1974,7 +2145,7 @@ class GlossaryBrowser(Client):
1974
2145
  """
1975
2146
 
1976
2147
  loop = asyncio.get_event_loop()
1977
- response = loop.run_until_complete(self._async_get_terms_by_guid(term_guid))
2148
+ response = loop.run_until_complete(self._async_get_terms_by_guid(term_guid, output_format))
1978
2149
 
1979
2150
  return response
1980
2151
 
@@ -2257,8 +2428,7 @@ class GlossaryBrowser(Client):
2257
2428
  for_duplicate_processing: bool = False,
2258
2429
  start_from: int = 0,
2259
2430
  page_size: int = None,
2260
- md: bool = False,
2261
- form: bool = True,
2431
+ output_format: str = "JSON",
2262
2432
  ) -> list | str:
2263
2433
  """Retrieve the list of glossary term metadata elements that contain the search string.
2264
2434
 
@@ -2290,11 +2460,12 @@ class GlossaryBrowser(Client):
2290
2460
  Page of results to start from
2291
2461
  page_size : int, optional
2292
2462
  Number of elements to return per page - if None, then default for class will be used.
2293
- md: bool, [default=False]
2294
- If true, a simplified markdown representation of the glossary will be returned
2295
- form: bool, [default=True]
2296
- If true and md is true, a form for the glossaries will be returned as a markdown string.
2297
- If false and md is true, a report for the glossaries will be returned.
2463
+ output_format: str, default = 'JSON'
2464
+ Type of output to produce:
2465
+ JSON - output standard json
2466
+ MD - output standard markdown with no preamble
2467
+ FORM - output markdown with a preamble for a form
2468
+ REPORT - output markdown with a preamble for a report
2298
2469
 
2299
2470
  Returns
2300
2471
  -------
@@ -2340,7 +2511,6 @@ class GlossaryBrowser(Client):
2340
2511
  "effectiveTime": effective_time,
2341
2512
  "limitResultsByStatus": status_filter,
2342
2513
  }
2343
- body = body_slimmer(body)
2344
2514
 
2345
2515
  url = (
2346
2516
  f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/"
@@ -2349,12 +2519,13 @@ class GlossaryBrowser(Client):
2349
2519
  f"forDuplicateProcessing={for_duplicate_processing_s}"
2350
2520
  )
2351
2521
 
2352
- response = await self._async_make_request("POST", url, body)
2522
+
2523
+ response = await self._async_make_request("POST", url, body_slimmer(body))
2353
2524
  term_elements = response.json().get("elementList", NO_TERMS_FOUND)
2354
2525
  if term_elements == NO_TERMS_FOUND:
2355
2526
  return NO_TERMS_FOUND
2356
- if md: # return a simplified markdown representation
2357
- return self.generate_terms_md(term_elements, search_string, form)
2527
+ if output_format != "JSON": # return a simplified markdown representation
2528
+ return self.generate_terms_md(term_elements, search_string, output_format)
2358
2529
  return response.json().get("elementList", NO_TERMS_FOUND)
2359
2530
 
2360
2531
 
@@ -2371,8 +2542,7 @@ class GlossaryBrowser(Client):
2371
2542
  for_duplicate_processing: bool = False,
2372
2543
  start_from: int = 0,
2373
2544
  page_size: int = None,
2374
- md: bool = False,
2375
- form: bool = True,
2545
+ output_format: str = "JSON",
2376
2546
  ) -> list | str:
2377
2547
  """Retrieve the list of glossary term metadata elements that contain the search string.
2378
2548
 
@@ -2405,11 +2575,12 @@ class GlossaryBrowser(Client):
2405
2575
  Page of results to start from
2406
2576
  page_size : int, optional
2407
2577
  Number of elements to return per page - if None, then default for class will be used.
2408
- md: bool, [default=False]
2409
- If true, a simplified markdown representation of the glossary will be returned
2410
- form: bool, [default=True]
2411
- If true and md is true, a form for the glossaries will be returned as a markdown string.
2412
- If false and md is true, a report for the glossaries will be returned.
2578
+ output_format: str, default = 'JSON'
2579
+ Type of output to produce:
2580
+ JSON - output standard json
2581
+ MD - output standard markdown with no preamble
2582
+ FORM - output markdown with a preamble for a form
2583
+ REPORT - output markdown with a preamble for a report
2413
2584
 
2414
2585
  Returns
2415
2586
  -------
@@ -2448,8 +2619,7 @@ class GlossaryBrowser(Client):
2448
2619
  for_duplicate_processing,
2449
2620
  start_from,
2450
2621
  page_size,
2451
- md,
2452
- form,
2622
+ output_format
2453
2623
  )
2454
2624
  )
2455
2625