pyegeria 5.3.8.3__py3-none-any.whl → 5.3.8.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.
@@ -10,14 +10,15 @@ added in subsequent versions of the glossary_omvs module.
10
10
  import asyncio
11
11
  from datetime import datetime
12
12
 
13
- from pyegeria import NO_GLOSSARIES_FOUND, NO_CATEGORIES_FOUND, NO_TERMS_FOUND, max_paging_size
14
- import json
13
+ from pyegeria import NO_GLOSSARIES_FOUND, max_paging_size
15
14
  from pyegeria._client import Client
15
+ from pyegeria._globals import NO_CATEGORIES_FOUND, NO_TERMS_FOUND
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, NO_CATALOGS_FOUND, NO_CATEGORIES_FOUND, NO_TERMS_FOUND
18
+
19
19
  MD_SEPERATOR = "\n---\n\n"
20
20
 
21
+
21
22
  class GlossaryBrowser(Client):
22
23
  """
23
24
  GlossaryBrowser is a class that extends the Client class. It provides methods to search and retrieve glossaries,
@@ -37,14 +38,7 @@ class GlossaryBrowser(Client):
37
38
 
38
39
  """
39
40
 
40
- def __init__(
41
- self,
42
- view_server: str,
43
- platform_url: str,
44
- user_id: str,
45
- user_pwd: str = None,
46
- token: str = None,
47
- ):
41
+ def __init__(self, view_server: str, platform_url: str, user_id: str, user_pwd: str = None, token: str = None, ):
48
42
  self.view_server = view_server
49
43
  self.platform_url = platform_url
50
44
  self.user_pwd = user_pwd
@@ -53,8 +47,7 @@ class GlossaryBrowser(Client):
53
47
 
54
48
  Client.__init__(self, view_server, platform_url, user_id, user_pwd, token)
55
49
 
56
-
57
- def make_preamble(self, obj_type, search_string, output_format: str = 'MD')-> tuple[str, str | None]:
50
+ def make_preamble(self, obj_type, search_string, output_format: str = 'MD') -> tuple[str, str | None]:
58
51
  """
59
52
  Creates a preamble string and an elements action based on the given object type, search string,
60
53
  and output format. The preamble provides a descriptive header based on the intent: To make a form,
@@ -117,7 +110,6 @@ class GlossaryBrowser(Client):
117
110
  # Replace newlines with spaces and escape pipe characters
118
111
  return text.replace("\n", " ").replace("|", "\\|")
119
112
 
120
-
121
113
  def _extract_glossary_properties(self, element: dict) -> dict:
122
114
  """
123
115
  Extract common properties from a glossary element.
@@ -136,18 +128,24 @@ class GlossaryBrowser(Client):
136
128
  usage = properties.get("usage", "") or ""
137
129
  qualified_name = properties.get("qualifiedName", "") or ""
138
130
 
131
+ categories = self.get_categories_for_glossary(guid)
132
+ cat_md_display = ''
133
+ cat_md_qn = ''
134
+ if type(categories) is list:
135
+ for category in categories:
136
+ cat_md_display += f"* {category['glossaryCategoryProperties'][('displayName')]}\n"
137
+ cat_md_qn += f"* {category['glossaryCategoryProperties'][('qualifiedName')]}\n"
138
+ cat_md = cat_md_display.strip()
139
+ cat_md_qn = cat_md_qn.strip()
140
+
139
141
  return {
140
- 'guid': guid,
141
- 'properties': properties,
142
- 'display_name': display_name,
143
- 'description': description,
144
- 'language': language,
145
- 'usage': usage,
146
- 'qualified_name': qualified_name
147
- }
142
+ 'guid': guid, 'properties': properties, 'display_name': display_name, 'description': description,
143
+ 'language': language, 'usage': usage, 'qualified_name': qualified_name, 'categories_dn_md': cat_md_display,
144
+ 'categories_qn_md': cat_md_qn
145
+ }
148
146
 
149
- def _generate_entity_md(self, elements: list, elements_action: str, output_format: str,
150
- entity_type: str, extract_properties_func, get_additional_props_func=None) -> str:
147
+ def _generate_entity_md(self, elements: list, elements_action: str, output_format: str, entity_type: str,
148
+ extract_properties_func, get_additional_props_func=None) -> str:
151
149
  """
152
150
  Generic method to generate markdown for entities (glossaries, terms, categories).
153
151
 
@@ -170,7 +168,7 @@ class GlossaryBrowser(Client):
170
168
  # Get additional properties if function is provided
171
169
  additional_props = {}
172
170
  if get_additional_props_func:
173
- additional_props = get_additional_props_func(element, props['guid'])
171
+ additional_props = get_additional_props_func(element, props['guid'], output_format)
174
172
 
175
173
  # Format header based on output format
176
174
  if output_format in ['FORM', 'MD']:
@@ -183,15 +181,26 @@ class GlossaryBrowser(Client):
183
181
 
184
182
  # Add common attributes
185
183
  for key, value in props.items():
184
+ # Skip categories_dn_md for FORM output and categories_qn_md for REPORT output
185
+ if key == 'categories_dn_md' and output_format == 'FORM':
186
+ continue
187
+ if key == 'categories_qn_md' and output_format == 'REPORT':
188
+ continue
186
189
  if key not in ['guid', 'properties', 'display_name']:
187
- elements_md += self.make_md_attribute(key.replace('_', ' '), value, output_format)
190
+ # Use "Categories" as the label for both categories_qn_md and categories_dn_md
191
+ if key == 'categories_qn_md' and output_format == 'FORM':
192
+ elements_md += self.make_md_attribute("Categories", value, output_format)
193
+ elif key == 'categories_dn_md' and output_format == 'REPORT':
194
+ elements_md += self.make_md_attribute("Categories", value, output_format)
195
+ else:
196
+ elements_md += self.make_md_attribute(key.replace('_', ' '), value, output_format)
188
197
 
189
198
  # Add additional properties
190
199
  for key, value in additional_props.items():
191
200
  elements_md += self.make_md_attribute(key.replace('_', ' '), value, output_format)
192
201
 
193
202
  # Add GUID
194
- elements_md += self.make_md_attribute("qualified name", props['qualified_name'], output_format)
203
+ # elements_md += self.make_md_attribute("qualified name", props['qualified_name'], output_format)
195
204
  elements_md += self.make_md_attribute("GUID", props['guid'], output_format)
196
205
 
197
206
  # Add separator if not the last element
@@ -212,16 +221,11 @@ class GlossaryBrowser(Client):
212
221
  Returns:
213
222
  str: Markdown representation
214
223
  """
215
- return self._generate_entity_md(
216
- elements=elements,
217
- elements_action=elements_action,
218
- output_format=output_format,
219
- entity_type="Glossary",
220
- extract_properties_func=self._extract_glossary_properties
221
- )
224
+ return self._generate_entity_md(elements=elements, elements_action=elements_action, output_format=output_format,
225
+ entity_type="Glossary", extract_properties_func=self._extract_glossary_properties)
222
226
 
223
- def _generate_entity_md_table(self, elements: list, search_string: str, entity_type: str,
224
- extract_properties_func, columns: list, get_additional_props_func=None) -> str:
227
+ def _generate_entity_md_table(self, elements: list, search_string: str, entity_type: str, extract_properties_func,
228
+ columns: list, get_additional_props_func=None, output_format: str = 'LIST') -> str:
225
229
  """
226
230
  Generic method to generate a markdown table for entities (glossaries, terms, categories).
227
231
 
@@ -232,13 +236,18 @@ class GlossaryBrowser(Client):
232
236
  extract_properties_func: Function to extract properties from an element
233
237
  columns: List of column definitions, each containing 'name', 'key', and 'format' (optional)
234
238
  get_additional_props_func: Optional function to get additional properties
239
+ output_format (str): Output format (FORM, REPORT, LIST, etc.)
235
240
 
236
241
  Returns:
237
242
  str: Markdown table
238
243
  """
239
244
  # Create table header
240
- elements_md = f"# {entity_type}s Table\n\n"
241
- elements_md += f"{entity_type}s found from the search string: `{search_string}`\n\n"
245
+
246
+ # Handle pluralization - if entity_type ends with 'y', use 'ies' instead of 's'
247
+ entity_type_plural = f"{entity_type[:-1]}ies" if entity_type.endswith('y') else f"{entity_type}s"
248
+
249
+ elements_md = f"# {entity_type_plural} Table\n\n"
250
+ elements_md += f"{entity_type_plural} found from the search string: `{search_string}`\n\n"
242
251
 
243
252
  # Add column headers
244
253
  header_row = "| "
@@ -257,7 +266,7 @@ class GlossaryBrowser(Client):
257
266
  # Get additional properties if function is provided
258
267
  additional_props = {}
259
268
  if get_additional_props_func:
260
- additional_props = get_additional_props_func(element, props['guid'])
269
+ additional_props = get_additional_props_func(element, props['guid'], output_format)
261
270
 
262
271
  # Build row
263
272
  row = "| "
@@ -292,24 +301,18 @@ class GlossaryBrowser(Client):
292
301
  Returns:
293
302
  str: Markdown table
294
303
  """
295
- columns = [
296
- {'name': 'Glossary Name', 'key': 'display_name'},
304
+ columns = [{'name': 'Glossary Name', 'key': 'display_name'},
297
305
  {'name': 'Qualified Name', 'key': 'qualified_name'},
298
306
  {'name': 'Language', 'key': 'language', 'format': True},
299
307
  {'name': 'Description', 'key': 'description', 'format': True},
300
- {'name': 'Usage', 'key': 'usage', 'format': True}
301
- ]
308
+ {'name': 'Usage', 'key': 'usage', 'format': True},
309
+ {'name': 'Categories', 'key': 'categories_dn_md', 'format': True}, ]
302
310
 
303
- return self._generate_entity_md_table(
304
- elements=elements,
305
- search_string=search_string,
306
- entity_type="Glossary",
307
- extract_properties_func=self._extract_glossary_properties,
308
- columns=columns
309
- )
311
+ return self._generate_entity_md_table(elements=elements, search_string=search_string, entity_type="Glossary",
312
+ extract_properties_func=self._extract_glossary_properties, columns=columns)
310
313
 
311
- def _generate_entity_dict(self, elements: list, extract_properties_func, get_additional_props_func=None,
312
- include_keys=None, exclude_keys=None) -> list:
314
+ def _generate_entity_dict(self, elements: list, extract_properties_func, get_additional_props_func=None,
315
+ include_keys=None, exclude_keys=None, output_format: str = 'DICT') -> list:
313
316
  """
314
317
  Generic method to generate a dictionary representation of entities (glossaries, terms, categories).
315
318
 
@@ -319,6 +322,7 @@ class GlossaryBrowser(Client):
319
322
  get_additional_props_func: Optional function to get additional properties
320
323
  include_keys: Optional list of keys to include in the result (if None, include all)
321
324
  exclude_keys: Optional list of keys to exclude from the result (if None, exclude none)
325
+ output_format (str): Output format (FORM, REPORT, DICT, etc.)
322
326
 
323
327
  Returns:
324
328
  list: List of entity dictionaries
@@ -331,7 +335,7 @@ class GlossaryBrowser(Client):
331
335
  # Get additional properties if function is provided
332
336
  additional_props = {}
333
337
  if get_additional_props_func:
334
- additional_props = get_additional_props_func(element, props['guid'])
338
+ additional_props = get_additional_props_func(element, props['guid'], output_format)
335
339
 
336
340
  # Create entity dictionary
337
341
  entity_dict = {}
@@ -339,7 +343,8 @@ class GlossaryBrowser(Client):
339
343
  # Add properties based on include/exclude lists
340
344
  for key, value in props.items():
341
345
  if key != 'properties': # Skip the raw properties object
342
- if (include_keys is None or key in include_keys) and (exclude_keys is None or key not in exclude_keys):
346
+ if (include_keys is None or key in include_keys) and (
347
+ exclude_keys is None or key not in exclude_keys):
343
348
  entity_dict[key] = value
344
349
 
345
350
  # Add additional properties
@@ -351,23 +356,22 @@ class GlossaryBrowser(Client):
351
356
 
352
357
  return result
353
358
 
354
- def _generate_glossary_dict(self, elements: list) -> list:
359
+ def _generate_glossary_dict(self, elements: list, output_format: str = 'DICT') -> list:
355
360
  """
356
361
  Generate a dictionary representation of glossaries.
357
362
 
358
363
  Args:
359
364
  elements (list): List of glossary elements
365
+ output_format (str): Output format (FORM, REPORT, DICT, etc.)
360
366
 
361
367
  Returns:
362
368
  list: List of glossary dictionaries
363
369
  """
364
- return self._generate_entity_dict(
365
- elements=elements,
366
- extract_properties_func=self._extract_glossary_properties,
367
- exclude_keys=['properties']
368
- )
370
+ return self._generate_entity_dict(elements=elements, extract_properties_func=self._extract_glossary_properties,
371
+ exclude_keys=['properties', 'categories_qn_md'], output_format=output_format)
369
372
 
370
- def generate_glossaries_md(self, elements: list | dict, search_string: str, output_format: str = 'MD')-> str | list:
373
+ def generate_glossaries_md(self, elements: list | dict, search_string: str,
374
+ output_format: str = 'MD') -> str | list:
371
375
  """
372
376
  Generate markdown or dictionary representation of glossaries.
373
377
 
@@ -384,13 +388,16 @@ class GlossaryBrowser(Client):
384
388
  if isinstance(elements, dict):
385
389
  elements = [elements]
386
390
 
391
+ if search_string is None or search_string == '':
392
+ search_string = "All"
393
+
387
394
  # If output format is LIST, create a markdown table
388
395
  if output_format == 'LIST':
389
396
  return self._generate_glossary_md_table(elements, search_string)
390
397
 
391
398
  # If output format is DICT, return a dictionary structure
392
399
  elif output_format == 'DICT':
393
- return self._generate_glossary_dict(elements)
400
+ return self._generate_glossary_dict(elements, output_format)
394
401
 
395
402
  # Original implementation for other formats (MD, FORM, REPORT)
396
403
  elements_md += self._generate_glossary_md(elements, elements_action, output_format)
@@ -413,29 +420,23 @@ class GlossaryBrowser(Client):
413
420
  description = properties.get("description", "") or ""
414
421
  examples = properties.get("examples", "") or ""
415
422
  usage = properties.get("usage", "") or ""
416
- pub_version = properties.get("publishfinVersionIdentifier", "") or ""
423
+ pub_version = properties.get("publishVersionIdentifier", "") or ""
417
424
  qualified_name = properties.get("qualifiedName", "") or ""
418
425
  status = element['elementHeader'].get('status', "") or ""
419
426
 
420
427
  return {
421
- 'guid': guid,
422
- 'properties': properties,
423
- 'display_name': display_name,
424
- 'summary': summary,
425
- 'description': description,
426
- 'examples': examples,
427
- 'usage': usage,
428
- 'pub_version': pub_version,
429
- 'qualified_name': qualified_name,
430
- 'status': status
431
- }
428
+ 'guid': guid, 'properties': properties, 'display_name': display_name, 'summary': summary,
429
+ 'description': description, 'examples': examples, 'usage': usage, 'version identifier': pub_version,
430
+ 'qualified_name': qualified_name, 'status': status
431
+ }
432
432
 
433
- def _get_categories_for_term(self, term_guid: str) -> tuple[list, str]:
433
+ def _get_categories_for_term(self, term_guid: str, output_format: str = None) -> tuple[list, str]:
434
434
  """
435
435
  Get a list of categories for a given term.
436
436
 
437
437
  Args:
438
438
  term_guid (str): The GUID of the term
439
+ output_format (str): Output format (FORM, REPORT, LIST, etc.)
439
440
 
440
441
  Returns:
441
442
  tuple: A tuple containing:
@@ -451,7 +452,12 @@ class GlossaryBrowser(Client):
451
452
  elif isinstance(category_list, list) and len(category_list) > 0:
452
453
  first_cat = True
453
454
  for category in category_list:
454
- category_name = category["glossaryCategoryProperties"].get("qualifiedName", '---')
455
+ # Use qualified name for FORM output, display name for REPORT and LIST output
456
+ if output_format in ['REPORT', 'LIST']:
457
+ category_name = category["glossaryCategoryProperties"].get("displayName", '---')
458
+ else:
459
+ category_name = category["glossaryCategoryProperties"].get("qualifiedName", '---')
460
+
455
461
  if category_name:
456
462
  category_names.append(category_name)
457
463
  if first_cat:
@@ -464,118 +470,118 @@ class GlossaryBrowser(Client):
464
470
 
465
471
  return category_names, category_list_md
466
472
 
467
- def _get_term_table_properties(self, element: dict, term_guid: str) -> dict:
473
+ def _get_term_table_properties(self, element: dict, term_guid: str, output_format: str = None) -> dict:
468
474
  """
469
475
  Get properties for a term table row.
470
476
 
471
477
  Args:
472
478
  element (dict): The term element
473
479
  term_guid (str): The GUID of the term
480
+ output_format (str): Output format (FORM, REPORT, etc.)
474
481
 
475
482
  Returns:
476
483
  dict: Dictionary of properties for the table row
477
484
  """
478
485
  # Get glossary information
479
- glossary_qualified_name = self._get_glossary_name_for_element(element)
486
+ glossary_qualified_name = self._get_glossary_name_for_element(element, output_format)
480
487
 
481
488
  # Get categories
482
- category_names, _ = self._get_categories_for_term(term_guid)
489
+ category_names, _ = self._get_categories_for_term(term_guid, output_format)
483
490
  categories_str = ", ".join(category_names) if category_names else "---"
484
491
 
485
492
  return {
486
- 'glossary': glossary_qualified_name,
487
- 'categories_str': categories_str
488
- }
493
+ 'glossary': glossary_qualified_name, 'categories_str': categories_str
494
+ }
489
495
 
490
- def _generate_term_md_table(self, elements: list, search_string: str) -> str:
496
+ def _generate_term_md_table(self, elements: list, search_string: str, output_format: str = 'LIST') -> str:
491
497
  """
492
498
  Generate a markdown table for terms.
493
499
 
494
500
  Args:
495
501
  elements (list): List of term elements
496
502
  search_string (str): The search string used
503
+ output_format (str): Output format (FORM, REPORT, LIST, etc.)
497
504
 
498
505
  Returns:
499
506
  str: Markdown table
500
507
  """
501
- columns = [
502
- {'name': 'Term Name', 'key': 'display_name'},
503
- {'name': 'Qualified Name', 'key': 'qualified_name'},
504
- {'name': 'Summary', 'key': 'summary', 'format': True},
505
- {'name': 'Glossary', 'key': 'glossary'},
506
- {'name': 'Categories', 'key': 'categories_str', 'format': True}
507
- ]
508
-
509
- return self._generate_entity_md_table(
510
- elements=elements,
511
- search_string=search_string,
512
- entity_type="Term",
513
- extract_properties_func=self._extract_term_properties,
514
- columns=columns,
515
- get_additional_props_func=self._get_term_table_properties
516
- )
517
-
518
- def _get_term_dict_properties(self, element: dict, term_guid: str) -> dict:
508
+ columns = [{'name': 'Term Name', 'key': 'display_name'}, {'name': 'Qualified Name', 'key': 'qualified_name'},
509
+ {'name': 'Summary', 'key': 'summary', 'format': True}, {'name': 'Glossary', 'key': 'glossary'},
510
+ {'name': 'Categories', 'key': 'categories_str', 'format': True}]
511
+
512
+ # Create a wrapper function to pass output_format to _get_term_table_properties
513
+ def get_table_props_with_format(element, term_guid, output_format_param=None):
514
+ return self._get_term_table_properties(element, term_guid, output_format)
515
+
516
+ return self._generate_entity_md_table(elements=elements, search_string=search_string, entity_type="Term",
517
+ extract_properties_func=self._extract_term_properties, columns=columns,
518
+ get_additional_props_func=get_table_props_with_format)
519
+
520
+ def _get_term_dict_properties(self, element: dict, term_guid: str, output_format: str = None) -> dict:
519
521
  """
520
522
  Get additional properties for a term dictionary.
521
523
 
522
524
  Args:
523
525
  element (dict): The term element
524
526
  term_guid (str): The GUID of the term
527
+ output_format (str): Output format (FORM, REPORT, etc.)
525
528
 
526
529
  Returns:
527
530
  dict: Dictionary of additional properties
528
531
  """
529
532
  # Get glossary information
530
- glossary_qualified_name = self._get_glossary_name_for_element(element)
533
+ glossary_qualified_name = self._get_glossary_name_for_element(element, output_format)
531
534
 
532
535
  # Get categories
533
- category_names, _ = self._get_categories_for_term(term_guid)
536
+ category_names, _ = self._get_categories_for_term(term_guid, output_format)
534
537
 
535
538
  return {
536
- 'in_glossary': glossary_qualified_name,
537
- 'categories': category_names,
539
+ 'in_glossary': glossary_qualified_name, 'categories': category_names,
538
540
  'version': element['glossaryTermProperties'].get('publishfinVersionIdentifier', '')
539
- }
541
+ }
540
542
 
541
- def _generate_term_dict(self, elements: list) -> list:
543
+ def _generate_term_dict(self, elements: list, output_format: str = 'DICT') -> list:
542
544
  """
543
545
  Generate a dictionary representation of terms.
544
546
 
545
547
  Args:
546
548
  elements (list): List of term elements
549
+ output_format (str): Output format (FORM, REPORT, DICT, etc.)
547
550
 
548
551
  Returns:
549
552
  list: List of term dictionaries
550
553
  """
551
- return self._generate_entity_dict(
552
- elements=elements,
553
- extract_properties_func=self._extract_term_properties,
554
- get_additional_props_func=self._get_term_dict_properties,
555
- exclude_keys=['properties', 'pub_version'] # Exclude raw properties and pub_version (renamed to version)
556
- )
557
554
 
558
- def _get_term_additional_properties(self, element: dict, term_guid: str) -> dict:
555
+ # Create a wrapper function to pass output_format to _get_term_dict_properties
556
+ def get_dict_props_with_format(element, term_guid, output_format_param=None):
557
+ return self._get_term_dict_properties(element, term_guid, output_format)
558
+
559
+ return self._generate_entity_dict(elements=elements, extract_properties_func=self._extract_term_properties,
560
+ get_additional_props_func=get_dict_props_with_format, exclude_keys=['properties', 'pub_version']
561
+ # Exclude raw properties and pub_version (renamed to version)
562
+ )
563
+
564
+ def _get_term_additional_properties(self, element: dict, term_guid: str, output_format: str = None) -> dict:
559
565
  """
560
566
  Get additional properties for a term.
561
567
 
562
568
  Args:
563
569
  element (dict): The term element
564
570
  term_guid (str): The GUID of the term
571
+ output_format (str): Output format (FORM, REPORT, etc.)
565
572
 
566
573
  Returns:
567
574
  dict: Dictionary of additional properties
568
575
  """
569
576
  # Get glossary information
570
- glossary_qualified_name = self._get_glossary_name_for_element(element)
577
+ glossary_qualified_name = self._get_glossary_name_for_element(element, output_format)
571
578
 
572
579
  # Get categories
573
- _, category_list_md = self._get_categories_for_term(term_guid)
580
+ _, category_list_md = self._get_categories_for_term(term_guid, output_format)
574
581
 
575
582
  return {
576
- 'in_glossary': glossary_qualified_name,
577
- 'categories': category_list_md
578
- }
583
+ 'in_glossary': glossary_qualified_name, 'categories': category_list_md
584
+ }
579
585
 
580
586
  def _generate_term_md(self, elements: list, elements_action: str, output_format: str) -> str:
581
587
  """
@@ -589,14 +595,9 @@ class GlossaryBrowser(Client):
589
595
  Returns:
590
596
  str: Markdown representation
591
597
  """
592
- return self._generate_entity_md(
593
- elements=elements,
594
- elements_action=elements_action,
595
- output_format=output_format,
596
- entity_type="Term",
597
- extract_properties_func=self._extract_term_properties,
598
- get_additional_props_func=self._get_term_additional_properties
599
- )
598
+ return self._generate_entity_md(elements=elements, elements_action=elements_action, output_format=output_format,
599
+ entity_type="Term", extract_properties_func=self._extract_term_properties,
600
+ get_additional_props_func=self._get_term_additional_properties)
600
601
 
601
602
  def generate_terms_md(self, elements: list | dict, search_string: str, output_format: str = 'MD') -> str | list:
602
603
  """
@@ -610,28 +611,33 @@ class GlossaryBrowser(Client):
610
611
  Returns:
611
612
  str | list: Markdown string or list of dictionaries depending on output_format
612
613
  """
613
- elements_md, elements_action = self.make_preamble(obj_type="Term", search_string=search_string, output_format=output_format)
614
+ elements_md, elements_action = self.make_preamble(obj_type="Term", search_string=search_string,
615
+ output_format=output_format)
614
616
  if isinstance(elements, dict):
615
617
  elements = [elements]
616
618
 
617
- # If output format is MD-TABLE, create a markdown table
619
+ if search_string is None or search_string == '':
620
+ search_string = "All"
621
+
622
+ # If output format is LIST, create a markdown table
618
623
  if output_format == 'LIST':
619
- return self._generate_term_md_table(elements, search_string)
624
+ return self._generate_term_md_table(elements, search_string, output_format)
620
625
 
621
626
  # If output format is DICT, return a dictionary structure
622
627
  elif output_format == 'DICT':
623
- return self._generate_term_dict(elements)
628
+ return self._generate_term_dict(elements, output_format)
624
629
 
625
630
  # Original implementation for other formats (MD, FORM, REPORT)
626
631
  elements_md += self._generate_term_md(elements, elements_action, output_format)
627
632
  return elements_md
628
633
 
629
- def _get_parent_category_name(self, category_guid: str) -> str:
634
+ def _get_parent_category_name(self, category_guid: str, output_format: str = None) -> str:
630
635
  """
631
636
  Get the parent category name for a given category.
632
637
 
633
638
  Args:
634
639
  category_guid (str): The GUID of the category
640
+ output_format (str): Output format (FORM, REPORT, LIST, etc.)
635
641
 
636
642
  Returns:
637
643
  str: The parent category name or '---' if no parent
@@ -639,14 +645,23 @@ class GlossaryBrowser(Client):
639
645
  parent_cat = self.get_category_parent(category_guid)
640
646
  if isinstance(parent_cat, str):
641
647
  return '---'
642
- return parent_cat['glossaryCategoryProperties']['qualifiedName']
643
648
 
644
- def _get_subcategories_list(self, category_guid: str) -> tuple[list, str]:
649
+ # Return qualified name for FORM output, display name for REPORT and LIST output
650
+ if output_format == 'FORM':
651
+ return parent_cat['glossaryCategoryProperties']['qualifiedName']
652
+ elif output_format in ['REPORT', 'LIST']:
653
+ return parent_cat['glossaryCategoryProperties']['displayName']
654
+ else:
655
+ # Default to qualified name for backward compatibility
656
+ return parent_cat['glossaryCategoryProperties']['qualifiedName']
657
+
658
+ def _get_subcategories_list(self, category_guid: str, output_format: str = None) -> tuple[list, str]:
645
659
  """
646
660
  Get a list of subcategories for a given category.
647
661
 
648
662
  Args:
649
663
  category_guid (str): The GUID of the category
664
+ output_format (str): Output format (FORM, REPORT, LIST, etc.)
650
665
 
651
666
  Returns:
652
667
  tuple: A tuple containing:
@@ -660,7 +675,15 @@ class GlossaryBrowser(Client):
660
675
  subcategory_list_md = '---'
661
676
  elif isinstance(subcategories, list) and len(subcategories) > 0:
662
677
  for subcat in subcategories:
663
- subcat_name = subcat["glossaryCategoryProperties"].get("qualifiedName", '')
678
+ # Use qualified name for FORM output, display name for REPORT and LIST output
679
+ if output_format == 'FORM':
680
+ subcat_name = subcat["glossaryCategoryProperties"].get("qualifiedName", '')
681
+ elif output_format in ['REPORT', 'LIST']:
682
+ subcat_name = subcat["glossaryCategoryProperties"].get("displayName", '')
683
+ else:
684
+ # Default to qualified name for backward compatibility
685
+ subcat_name = subcat["glossaryCategoryProperties"].get("qualifiedName", '')
686
+
664
687
  if subcat_name:
665
688
  subcategory_list.append(subcat_name)
666
689
  subcategory_list_md = ", ".join(subcategory_list)
@@ -669,12 +692,13 @@ class GlossaryBrowser(Client):
669
692
 
670
693
  return subcategory_list, subcategory_list_md
671
694
 
672
- def _get_glossary_name_for_element(self, element: dict) -> str:
695
+ def _get_glossary_name_for_element(self, element: dict, output_format: str = None) -> str:
673
696
  """
674
697
  Get the glossary name for a given element.
675
698
 
676
699
  Args:
677
700
  element (dict): The element dictionary
701
+ output_format (str): Output format (FORM, REPORT, etc.)
678
702
 
679
703
  Returns:
680
704
  str: The glossary name or '---' if not found
@@ -683,12 +707,17 @@ class GlossaryBrowser(Client):
683
707
  if classification_props is None:
684
708
  return '---'
685
709
 
686
- glossary_guid = classification_props.get('anchorGUID', '---')
710
+ glossary_guid = classification_props.get('anchorScopeGUID', '---')
687
711
  if glossary_guid == '---':
688
712
  return '---'
689
713
 
690
714
  glossary = self.get_glossary_by_guid(glossary_guid)
691
- return glossary['glossaryProperties']['qualifiedName']
715
+
716
+ # Return display name for REPORT output, qualified name otherwise
717
+ if output_format == 'REPORT':
718
+ return glossary['glossaryProperties']['displayName']
719
+ else:
720
+ return glossary['glossaryProperties']['qualifiedName']
692
721
 
693
722
  def _extract_category_properties(self, element: dict) -> dict:
694
723
  """
@@ -707,131 +736,127 @@ class GlossaryBrowser(Client):
707
736
  qualified_name = properties.get("qualifiedName", "") or ""
708
737
 
709
738
  return {
710
- 'guid': guid,
711
- 'properties': properties,
712
- 'display_name': display_name,
713
- 'description': description,
739
+ 'guid': guid, 'properties': properties, 'display_name': display_name, 'description': description,
714
740
  'qualified_name': qualified_name
715
- }
741
+ }
716
742
 
717
- def _get_category_table_properties(self, element: dict, category_guid: str) -> dict:
743
+ def _get_category_table_properties(self, element: dict, category_guid: str, output_format: str = None) -> dict:
718
744
  """
719
745
  Get properties for a category table row.
720
746
 
721
747
  Args:
722
748
  element (dict): The category element
723
749
  category_guid (str): The GUID of the category
750
+ output_format (str): Output format (FORM, REPORT, etc.)
724
751
 
725
752
  Returns:
726
753
  dict: Dictionary of properties for the table row
727
754
  """
728
755
  # Get parent category
729
- parent_cat_md = self._get_parent_category_name(category_guid)
756
+ parent_cat_md = self._get_parent_category_name(category_guid, output_format)
730
757
 
731
758
  # Get subcategories
732
- _, subcategory_list_md = self._get_subcategories_list(category_guid)
759
+ _, subcategory_list_md = self._get_subcategories_list(category_guid, output_format)
733
760
 
734
761
  return {
735
- 'parent_category': parent_cat_md,
736
- 'subcategories': subcategory_list_md
737
- }
762
+ 'parent_category': parent_cat_md, 'subcategories': subcategory_list_md
763
+ }
738
764
 
739
- def _generate_category_md_table(self, elements: list, search_string: str) -> str:
765
+ def _generate_category_md_table(self, elements: list, search_string: str, output_format: str = 'LIST') -> str:
740
766
  """
741
767
  Generate a markdown table for categories.
742
768
 
743
769
  Args:
744
770
  elements (list): List of category elements
745
771
  search_string (str): The search string used
772
+ output_format (str): Output format (FORM, REPORT, etc.)
746
773
 
747
774
  Returns:
748
775
  str: Markdown table
749
776
  """
750
- columns = [
751
- {'name': 'Display Name', 'key': 'display_name'},
777
+ columns = [{'name': 'Display Name', 'key': 'display_name'},
752
778
  {'name': 'Description', 'key': 'description', 'format': True},
753
- {'name': 'Qualified Name', 'key': 'qualified_name'},
754
- {'name': 'Parent Category', 'key': 'parent_category'},
755
- {'name': 'Subcategories', 'key': 'subcategories', 'format': True}
756
- ]
779
+ {'name': 'Qualified Name', 'key': 'qualified_name'}, {'name': 'Parent Category', 'key': 'parent_category'},
780
+ {'name': 'Subcategories', 'key': 'subcategories', 'format': True}]
757
781
 
758
- return self._generate_entity_md_table(
759
- elements=elements,
760
- search_string=search_string,
761
- entity_type="Category",
762
- extract_properties_func=self._extract_category_properties,
763
- columns=columns,
764
- get_additional_props_func=self._get_category_table_properties
765
- )
782
+ # Create a wrapper function to pass output_format to _get_category_table_properties
783
+ def get_table_props_with_format(element, category_guid, output_format_param=None):
784
+ return self._get_category_table_properties(element, category_guid, output_format)
766
785
 
767
- def _get_category_dict_properties(self, element: dict, category_guid: str) -> dict:
786
+ return self._generate_entity_md_table(elements=elements, search_string=search_string, entity_type="Category",
787
+ extract_properties_func=self._extract_category_properties, columns=columns,
788
+ get_additional_props_func=get_table_props_with_format)
789
+
790
+ def _get_category_dict_properties(self, element: dict, category_guid: str, output_format: str = None) -> dict:
768
791
  """
769
792
  Get additional properties for a category dictionary.
770
793
 
771
794
  Args:
772
795
  element (dict): The category element
773
796
  category_guid (str): The GUID of the category
797
+ output_format (str): Output format (FORM, REPORT, etc.)
774
798
 
775
799
  Returns:
776
800
  dict: Dictionary of additional properties
777
801
  """
778
802
  # Get parent category
779
- parent_cat_md = self._get_parent_category_name(category_guid)
803
+ parent_cat_md = self._get_parent_category_name(category_guid, output_format)
780
804
 
781
805
  # Get subcategories
782
- subcategory_list, _ = self._get_subcategories_list(category_guid)
806
+ subcategory_list, _ = self._get_subcategories_list(category_guid, output_format)
783
807
 
784
808
  # Get glossary information
785
- glossary_qualified_name = self._get_glossary_name_for_element(element)
809
+ glossary_qualified_name = self._get_glossary_name_for_element(element, output_format)
786
810
 
787
811
  return {
788
- 'parent_category': parent_cat_md,
789
- 'subcategories': subcategory_list,
790
- 'in_glossary': glossary_qualified_name
791
- }
812
+ 'parent_category': parent_cat_md, 'subcategories': subcategory_list, 'in_glossary': glossary_qualified_name
813
+ }
792
814
 
793
- def _generate_category_dict(self, elements: list) -> list:
815
+ def _generate_category_dict(self, elements: list, output_format: str = 'DICT') -> list:
794
816
  """
795
817
  Generate a dictionary representation of categories.
796
818
 
797
819
  Args:
798
820
  elements (list): List of category elements
821
+ output_format (str): Output format (FORM, REPORT, etc.)
799
822
 
800
823
  Returns:
801
824
  list: List of category dictionaries
802
825
  """
803
- return self._generate_entity_dict(
804
- elements=elements,
805
- extract_properties_func=self._extract_category_properties,
806
- get_additional_props_func=self._get_category_dict_properties,
807
- exclude_keys=['properties'] # Exclude raw properties
808
- )
809
826
 
810
- def _get_category_additional_properties(self, element: dict, category_guid: str) -> dict:
827
+ # Create a wrapper function to pass output_format to _get_category_dict_properties
828
+ def get_dict_props_with_format(element, category_guid, output_format_param=None):
829
+ return self._get_category_dict_properties(element, category_guid, output_format)
830
+
831
+ return self._generate_entity_dict(elements=elements, extract_properties_func=self._extract_category_properties,
832
+ get_additional_props_func=get_dict_props_with_format, exclude_keys=['properties'], # Exclude raw properties
833
+ output_format=output_format)
834
+
835
+ def _get_category_additional_properties(self, element: dict, category_guid: str, output_format: str = None) -> dict:
811
836
  """
812
837
  Get additional properties for a category.
813
838
 
814
839
  Args:
815
840
  element (dict): The category element
816
841
  category_guid (str): The GUID of the category
842
+ output_format (str): Output format (FORM, REPORT, etc.)
817
843
 
818
844
  Returns:
819
845
  dict: Dictionary of additional properties
820
846
  """
821
847
  # Get parent category
822
- parent_cat_md = self._get_parent_category_name(category_guid)
848
+ parent_cat_md = self._get_parent_category_name(category_guid, output_format)
823
849
 
824
850
  # Get subcategories
825
- _, subcategory_list_md = self._get_subcategories_list(category_guid)
851
+ _, subcategory_list_md = self._get_subcategories_list(category_guid, output_format)
826
852
 
827
853
  # Get glossary information
828
- glossary_qualified_name = self._get_glossary_name_for_element(element)
854
+ glossary_qualified_name = self._get_glossary_name_for_element(element, output_format)
829
855
 
830
856
  return {
831
- 'in_glossary': glossary_qualified_name,
832
- 'parent_category': parent_cat_md,
857
+ 'in_glossary': glossary_qualified_name, 'parent_category': parent_cat_md,
833
858
  'subcategories': subcategory_list_md
834
- }
859
+ }
835
860
 
836
861
  def _generate_category_md(self, elements: list, elements_action: str, output_format: str) -> str:
837
862
  """
@@ -845,16 +870,17 @@ class GlossaryBrowser(Client):
845
870
  Returns:
846
871
  str: Markdown representation
847
872
  """
848
- return self._generate_entity_md(
849
- elements=elements,
850
- elements_action=elements_action,
851
- output_format=output_format,
852
- entity_type="Category",
853
- extract_properties_func=self._extract_category_properties,
854
- get_additional_props_func=self._get_category_additional_properties
855
- )
856
873
 
857
- def generate_categories_md(self, elements: list | dict, search_string: str, output_format: str = 'MD')-> str | list:
874
+ # Create a wrapper function to pass output_format to _get_category_additional_properties
875
+ def get_additional_props_with_format(element, category_guid, output_format_param=None):
876
+ return self._get_category_additional_properties(element, category_guid, output_format)
877
+
878
+ return self._generate_entity_md(elements=elements, elements_action=elements_action, output_format=output_format,
879
+ entity_type="Category", extract_properties_func=self._extract_category_properties,
880
+ get_additional_props_func=get_additional_props_with_format)
881
+
882
+ def generate_categories_md(self, elements: list | dict, search_string: str,
883
+ output_format: str = 'MD') -> str | list:
858
884
  """
859
885
  Generate markdown or dictionary representation of categories.
860
886
 
@@ -871,13 +897,16 @@ class GlossaryBrowser(Client):
871
897
  if isinstance(elements, dict):
872
898
  elements = [elements]
873
899
 
900
+ if search_string is None or search_string == '':
901
+ search_string = "All"
902
+
874
903
  # If output format is LIST, create a markdown table
875
904
  if output_format == 'LIST':
876
- return self._generate_category_md_table(elements, search_string)
905
+ return self._generate_category_md_table(elements, search_string, output_format)
877
906
 
878
907
  # If output format is DICT, return a dictionary structure
879
908
  elif output_format == 'DICT':
880
- return self._generate_category_dict(elements)
909
+ return self._generate_category_dict(elements, output_format)
881
910
 
882
911
  # Original implementation for other formats (MD, FORM, REPORT)
883
912
  elements_md += self._generate_category_md(elements, elements_action, output_format)
@@ -901,10 +930,8 @@ class GlossaryBrowser(Client):
901
930
 
902
931
  """
903
932
 
904
- url = (
905
- f"{self.platform_url}/servers/{self.view_server}"
906
- f"/api/open-metadata/glossary-browser/glossaries/terms/status-list"
907
- )
933
+ url = (f"{self.platform_url}/servers/{self.view_server}"
934
+ f"/api/open-metadata/glossary-browser/glossaries/terms/status-list")
908
935
 
909
936
  response = await self._async_make_request("GET", url)
910
937
  return response.json().get("statuses", [])
@@ -942,10 +969,8 @@ class GlossaryBrowser(Client):
942
969
 
943
970
  """
944
971
 
945
- url = (
946
- f"{self.platform_url}/servers/{self.view_server}"
947
- f"/api/open-metadata/glossary-browser/glossaries/terms/relationships/status-list"
948
- )
972
+ url = (f"{self.platform_url}/servers/{self.view_server}"
973
+ f"/api/open-metadata/glossary-browser/glossaries/terms/relationships/status-list")
949
974
 
950
975
  response = await self._async_make_request("GET", url)
951
976
  return response.json().get("statuses", [])
@@ -983,10 +1008,8 @@ class GlossaryBrowser(Client):
983
1008
 
984
1009
  """
985
1010
 
986
- url = (
987
- f"{self.platform_url}/servers/{self.view_server}"
988
- f"/api/open-metadata/glossary-browser/glossaries/terms/activity-types"
989
- )
1011
+ url = (f"{self.platform_url}/servers/{self.view_server}"
1012
+ f"/api/open-metadata/glossary-browser/glossaries/terms/activity-types")
990
1013
 
991
1014
  response = await self._async_make_request("GET", url)
992
1015
  return response.json().get("types", [])
@@ -1012,20 +1035,10 @@ class GlossaryBrowser(Client):
1012
1035
  # Glossaries
1013
1036
  #
1014
1037
 
1015
- async def _async_find_glossaries(
1016
- self,
1017
- search_string: str,
1018
- effective_time: str = None,
1019
- starts_with: bool = False,
1020
- ends_with: bool = False,
1021
- ignore_case: bool = False,
1022
- for_lineage: bool = False,
1023
- for_duplicate_processing: bool = False,
1024
- type_name: str = None,
1025
- start_from: int = 0,
1026
- page_size: int = None,
1027
- output_format: str = 'JSON'
1028
- ) -> list | str:
1038
+ async def _async_find_glossaries(self, search_string: str, effective_time: str = None, starts_with: bool = False,
1039
+ ends_with: bool = False, ignore_case: bool = False, for_lineage: bool = False,
1040
+ for_duplicate_processing: bool = False, type_name: str = None, start_from: int = 0, page_size: int = None,
1041
+ output_format: str = 'JSON') -> list | str:
1029
1042
  """Retrieve the list of glossary metadata elements that contain the search string. Async version.
1030
1043
  The search string is located in the request body and is interpreted as a plain string.
1031
1044
  The request parameters, startsWith, endsWith and ignoreCase can be used to allow a fuzzy search.
@@ -1096,43 +1109,34 @@ class GlossaryBrowser(Client):
1096
1109
  search_string = None
1097
1110
 
1098
1111
  body = {
1099
- "class": "SearchStringRequestBody",
1100
- "searchString": search_string,
1101
- "effectiveTime": effective_time,
1112
+ "class": "SearchStringRequestBody", "searchString": search_string, "effectiveTime": effective_time,
1102
1113
  "typeName": type_name,
1103
- }
1114
+ }
1104
1115
  body = body_slimmer(body)
1105
1116
 
1106
- url = (
1107
- f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/"
1108
- f"by-search-string?startFrom={start_from}&pageSize={page_size}&startsWith={starts_with_s}&"
1109
- f"endsWith={ends_with_s}&ignoreCase={ignore_case_s}&forLineage={for_lineage_s}&"
1110
- f"forDuplicateProcessing={for_duplicate_processing_s}"
1111
- )
1117
+ url = (f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/"
1118
+ f"by-search-string?startFrom={start_from}&pageSize={page_size}&startsWith={starts_with_s}&"
1119
+ f"endsWith={ends_with_s}&ignoreCase={ignore_case_s}&forLineage={for_lineage_s}&"
1120
+ f"forDuplicateProcessing={for_duplicate_processing_s}")
1112
1121
 
1113
1122
  response = await self._async_make_request("POST", url, body_slimmer(body))
1114
1123
  element = response.json().get("elementList", NO_GLOSSARIES_FOUND)
1115
1124
  if element == NO_GLOSSARIES_FOUND:
1116
- return NO_GLOSSARIES_FOUND
1125
+ if output_format == 'JSON':
1126
+ return NO_GLOSSARIES_FOUND
1127
+ elif output_format in ['MD', 'FORM', 'REPORT', 'LIST']:
1128
+ return "\n# No glossaries found.\n"
1129
+ elif output_format == 'DICT':
1130
+ return None
1131
+
1117
1132
  if output_format != 'JSON': # return a simplified markdown representation
1118
1133
  return self.generate_glossaries_md(element, search_string, output_format)
1119
1134
  return response.json().get("elementList", NO_GLOSSARIES_FOUND)
1120
1135
 
1121
-
1122
- def find_glossaries(
1123
- self,
1124
- search_string: str,
1125
- effective_time: str = None,
1126
- starts_with: bool = False,
1127
- ends_with: bool = False,
1128
- ignore_case: bool = False,
1129
- for_lineage: bool = False,
1130
- for_duplicate_processing: bool = False,
1131
- type_name: str = None,
1132
- start_from: int = 0,
1133
- page_size: int = None,
1134
- output_format: str = "JSON"
1135
- ) -> list | str:
1136
+ def find_glossaries(self, search_string: str, effective_time: str = None, starts_with: bool = False,
1137
+ ends_with: bool = False, ignore_case: bool = False, for_lineage: bool = False,
1138
+ for_duplicate_processing: bool = False, type_name: str = None, start_from: int = 0, page_size: int = None,
1139
+ output_format: str = "JSON") -> list | str:
1136
1140
  """Retrieve the list of glossary metadata elements that contain the search string.
1137
1141
  The search string is located in the request body and is interpreted as a plain string.
1138
1142
  The request parameters, startsWith, endsWith and ignoreCase can be used to allow a fuzzy search.
@@ -1171,7 +1175,8 @@ class GlossaryBrowser(Client):
1171
1175
  MD - output standard markdown with no preamble
1172
1176
  FORM - output markdown with a preamble for a form
1173
1177
  REPORT - output markdown with a preamble for a report
1174
- LIST - output a markdown table with columns for Glossary Name, Qualified Name, Language, Description, Usage
1178
+ LIST - output a markdown table with columns for Glossary Name, Qualified Name, Language, Description,
1179
+ Usage
1175
1180
  DICT - output a dictionary structure containing all attributes
1176
1181
  Returns
1177
1182
  -------
@@ -1192,26 +1197,13 @@ class GlossaryBrowser(Client):
1192
1197
  """
1193
1198
  loop = asyncio.get_event_loop()
1194
1199
  response = loop.run_until_complete(
1195
- self._async_find_glossaries(
1196
- search_string,
1197
- effective_time,
1198
- starts_with,
1199
- ends_with,
1200
- ignore_case,
1201
- for_lineage,
1202
- for_duplicate_processing,
1203
- type_name,
1204
- start_from,
1205
- page_size,
1206
- output_format
1207
- )
1208
- )
1200
+ self._async_find_glossaries(search_string, effective_time, starts_with, ends_with, ignore_case, for_lineage,
1201
+ for_duplicate_processing, type_name, start_from, page_size, output_format))
1209
1202
 
1210
1203
  return response
1211
1204
 
1212
- async def _async_get_glossary_by_guid(
1213
- self, glossary_guid: str, effective_time: str = None, output_format: str = "JSON"
1214
- ) -> dict|str:
1205
+ async def _async_get_glossary_by_guid(self, glossary_guid: str, effective_time: str = None,
1206
+ output_format: str = "JSON") -> dict | str:
1215
1207
  """Retrieves information about a glossary
1216
1208
  Parameters
1217
1209
  ----------
@@ -1226,7 +1218,8 @@ class GlossaryBrowser(Client):
1226
1218
  MD - output standard markdown with no preamble
1227
1219
  FORM - output markdown with a preamble for a form
1228
1220
  REPORT - output markdown with a preamble for a report
1229
- LIST - output a markdown table with columns for Glossary Name, Qualified Name, Language, Description, Usage
1221
+ LIST - output a markdown table with columns for Glossary Name, Qualified Name, Language, Description,
1222
+ Usage
1230
1223
  DICT - output a dictionary structure containing all attributes
1231
1224
 
1232
1225
  Returns
@@ -1249,13 +1242,10 @@ class GlossaryBrowser(Client):
1249
1242
  validate_guid(glossary_guid)
1250
1243
 
1251
1244
  body = {
1252
- "class": "EffectiveTimeQueryRequestBody",
1253
- "effectiveTime" : effective_time
1254
- }
1255
- url = (
1256
- f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/"
1257
- f"{glossary_guid}/retrieve"
1258
- )
1245
+ "class": "EffectiveTimeQueryRequestBody", "effectiveTime": effective_time
1246
+ }
1247
+ url = (f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/"
1248
+ f"{glossary_guid}/retrieve")
1259
1249
  response = await self._async_make_request("POST", url, body_slimmer(body))
1260
1250
  element = response.json().get("element", NO_GLOSSARIES_FOUND)
1261
1251
  if element == NO_GLOSSARIES_FOUND:
@@ -1264,10 +1254,7 @@ class GlossaryBrowser(Client):
1264
1254
  return self.generate_glossaries_md(element, "GUID", output_format)
1265
1255
  return response.json().get("element", NO_GLOSSARIES_FOUND)
1266
1256
 
1267
-
1268
- def get_glossary_by_guid(
1269
- self, glossary_guid: str, effective_time: str = None, output_format: str = "JSON"
1270
- ) -> dict:
1257
+ def get_glossary_by_guid(self, glossary_guid: str, effective_time: str = None, output_format: str = "JSON") -> dict:
1271
1258
  """Retrieves information about a glossary
1272
1259
  Parameters
1273
1260
  ----------
@@ -1282,7 +1269,8 @@ class GlossaryBrowser(Client):
1282
1269
  MD - output standard markdown with no preamble
1283
1270
  FORM - output markdown with a preamble for a form
1284
1271
  REPORT - output markdown with a preamble for a report
1285
- LIST - output a markdown table with columns for Glossary Name, Qualified Name, Language, Description, Usage
1272
+ LIST - output a markdown table with columns for Glossary Name, Qualified Name, Language, Description,
1273
+ Usage
1286
1274
  DICT - output a dictionary structure containing all attributes
1287
1275
 
1288
1276
  Returns
@@ -1303,17 +1291,11 @@ class GlossaryBrowser(Client):
1303
1291
  """
1304
1292
  loop = asyncio.get_event_loop()
1305
1293
  response = loop.run_until_complete(
1306
- self._async_get_glossary_by_guid(glossary_guid, effective_time, output_format)
1307
- )
1294
+ self._async_get_glossary_by_guid(glossary_guid, effective_time, output_format))
1308
1295
  return response
1309
1296
 
1310
- async def _async_get_glossaries_by_name(
1311
- self,
1312
- glossary_name: str,
1313
- effective_time: str = None,
1314
- start_from: int = 0,
1315
- page_size: int = None,
1316
- ) -> dict | str:
1297
+ async def _async_get_glossaries_by_name(self, glossary_name: str, effective_time: str = None, start_from: int = 0,
1298
+ page_size: int = None, ) -> dict | str:
1317
1299
  """Retrieve the list of glossary metadata elements with an exactly matching qualified or display name.
1318
1300
  There are no wildcards supported on this request.
1319
1301
 
@@ -1359,21 +1341,14 @@ class GlossaryBrowser(Client):
1359
1341
  else:
1360
1342
  body = {"name": glossary_name, "effectiveTime": effective_time}
1361
1343
 
1362
- url = (
1363
- f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/"
1364
- f"by-name?startFrom={start_from}&pageSize={page_size}"
1365
- )
1344
+ url = (f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/"
1345
+ f"by-name?startFrom={start_from}&pageSize={page_size}")
1366
1346
 
1367
1347
  response = await self._async_make_request("POST", url, body)
1368
1348
  return response.json().get("elementList", "No glossaries found")
1369
1349
 
1370
- def get_glossaries_by_name(
1371
- self,
1372
- glossary_name: str,
1373
- effective_time: str = None,
1374
- start_from: int = 0,
1375
- page_size: int = None,
1376
- ) -> dict | str:
1350
+ def get_glossaries_by_name(self, glossary_name: str, effective_time: str = None, start_from: int = 0,
1351
+ page_size: int = None, ) -> dict | str:
1377
1352
  """Retrieve the list of glossary metadata elements with an exactly matching qualified or display name.
1378
1353
  There are no wildcards supported on this request.
1379
1354
 
@@ -1409,21 +1384,15 @@ class GlossaryBrowser(Client):
1409
1384
  """
1410
1385
  loop = asyncio.get_event_loop()
1411
1386
  response = loop.run_until_complete(
1412
- self._async_get_glossaries_by_name(
1413
- glossary_name, effective_time, start_from, page_size
1414
- )
1415
- )
1387
+ self._async_get_glossaries_by_name(glossary_name, effective_time, start_from, page_size))
1416
1388
  return response
1417
1389
 
1418
1390
  #
1419
1391
  # Glossary Categories
1420
1392
  #
1421
1393
 
1422
- async def _async_get_glossary_for_category(
1423
- self,
1424
- glossary_category_guid: str,
1425
- effective_time: str = None,
1426
- ) -> dict | str:
1394
+ async def _async_get_glossary_for_category(self, glossary_category_guid: str,
1395
+ effective_time: str = None, ) -> dict | str:
1427
1396
  """Retrieve the glossary metadata element for the requested category. The optional request body allows you to
1428
1397
  specify that the glossary element should only be returned if it was effective at a particular time.
1429
1398
 
@@ -1456,23 +1425,16 @@ class GlossaryBrowser(Client):
1456
1425
  """
1457
1426
 
1458
1427
  body = {
1459
- "class": "EffectiveTimeQueryRequestBody",
1460
- "effectiveTime": effective_time,
1461
- }
1428
+ "class": "EffectiveTimeQueryRequestBody", "effectiveTime": effective_time,
1429
+ }
1462
1430
 
1463
- url = (
1464
- f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/"
1465
- f"for-category/{glossary_category_guid}/retrieve"
1466
- )
1431
+ url = (f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/"
1432
+ f"for-category/{glossary_category_guid}/retrieve")
1467
1433
 
1468
1434
  response = await self._async_make_request("POST", url, body)
1469
1435
  return response.json().get("elementList", "No categories found")
1470
1436
 
1471
- def get_glossary_for_category(
1472
- self,
1473
- glossary_category_guid: str,
1474
- effective_time: str = None,
1475
- ) -> dict | str:
1437
+ def get_glossary_for_category(self, glossary_category_guid: str, effective_time: str = None, ) -> dict | str:
1476
1438
  """Retrieve the glossary metadata element for the requested category. The optional request body allows you to
1477
1439
  specify that the glossary element should only be returned if it was effective at a particular time.
1478
1440
 
@@ -1505,21 +1467,12 @@ class GlossaryBrowser(Client):
1505
1467
  """
1506
1468
  loop = asyncio.get_event_loop()
1507
1469
  response = loop.run_until_complete(
1508
- self._async_get_glossary_for_category(
1509
- glossary_category_guid, effective_time
1510
- )
1511
- )
1470
+ self._async_get_glossary_for_category(glossary_category_guid, effective_time))
1512
1471
  return response
1513
1472
 
1514
- async def _async_get_glossary_subcategories(
1515
- self,
1516
- glossary_category_guid: str,
1517
- effective_time: str = None,
1518
- start_from: int = 0,
1519
- page_size: int = max_paging_size,
1520
- for_lineage: bool = False,
1521
- for_duplicate_processing: bool = False,
1522
- ) -> dict | str:
1473
+ async def _async_get_glossary_subcategories(self, glossary_category_guid: str, effective_time: str = None,
1474
+ start_from: int = 0, page_size: int = max_paging_size, for_lineage: bool = False,
1475
+ for_duplicate_processing: bool = False, ) -> dict | str:
1523
1476
  """Glossary categories can be organized in a hierarchy. Retrieve the subcategories for the glossary category
1524
1477
  metadata element with the supplied unique identifier. If the requested category does not have any subcategories,
1525
1478
  null is returned. The optional request body contain an effective time for the query.
@@ -1561,15 +1514,13 @@ class GlossaryBrowser(Client):
1561
1514
  for_duplicate_processing_s = str(for_duplicate_processing).lower()
1562
1515
 
1563
1516
  body = {
1564
- "class": "EffectiveTimeQueryRequestBody",
1565
- "effectiveTime": effective_time,
1566
- }
1517
+ "class": "EffectiveTimeQueryRequestBody", "effectiveTime": effective_time,
1518
+ }
1567
1519
 
1568
- url = (
1569
- f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/"
1570
- f"categories/{glossary_category_guid}/subcategories/retrieve?startFrom={start_from}&pageSize={page_size}&"
1571
- f"forLineage={for_lineage_s}&forDuplicateProcessing={for_duplicate_processing_s}"
1572
- )
1520
+ url = (f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/"
1521
+ f"categories/{glossary_category_guid}/subcategories/retrieve?startFrom={start_from}&pageSize="
1522
+ f"{page_size}&"
1523
+ f"forLineage={for_lineage_s}&forDuplicateProcessing={for_duplicate_processing_s}")
1573
1524
  if effective_time:
1574
1525
  response = await self._async_make_request("POST", url, body_slimmer(body))
1575
1526
  else:
@@ -1577,15 +1528,9 @@ class GlossaryBrowser(Client):
1577
1528
 
1578
1529
  return response.json().get("elementList", "No categories found")
1579
1530
 
1580
- def get_glossary_subcategories(
1581
- self,
1582
- glossary_category_guid: str,
1583
- effective_time: str = None,
1584
- start_from: int = 0,
1585
- page_size: int = max_paging_size,
1586
- for_lineage: bool = False,
1587
- for_duplicate_processing: bool = False,
1588
- ) -> dict | str:
1531
+ def get_glossary_subcategories(self, glossary_category_guid: str, effective_time: str = None, start_from: int = 0,
1532
+ page_size: int = max_paging_size, for_lineage: bool = False,
1533
+ for_duplicate_processing: bool = False, ) -> dict | str:
1589
1534
  """Glossary categories can be organized in a hierarchy. Retrieve the subcategories for the glossary category
1590
1535
  metadata element with the supplied unique identifier. If the requested category does not have any subcategories,
1591
1536
  null is returned. The optional request body contain an effective time for the query.
@@ -1625,24 +1570,13 @@ class GlossaryBrowser(Client):
1625
1570
  """
1626
1571
  loop = asyncio.get_event_loop()
1627
1572
  response = loop.run_until_complete(
1628
- self._async_get_glossary_subcategories(
1629
- glossary_category_guid, effective_time, start_from,
1630
- page_size, for_lineage, for_duplicate_processing
1631
- )
1632
- )
1573
+ self._async_get_glossary_subcategories(glossary_category_guid, effective_time, start_from, page_size,
1574
+ for_lineage, for_duplicate_processing))
1633
1575
  return response
1634
1576
 
1635
- async def _async_find_glossary_categories(
1636
- self,
1637
- search_string: str,
1638
- effective_time: str = None,
1639
- starts_with: bool = False,
1640
- ends_with: bool = False,
1641
- ignore_case: bool = False,
1642
- start_from: int = 0,
1643
- page_size: int = None,
1644
- output_format: str = "JSON"
1645
- ) -> list | str:
1577
+ async def _async_find_glossary_categories(self, search_string: str, effective_time: str = None,
1578
+ starts_with: bool = False, ends_with: bool = False, ignore_case: bool = False, start_from: int = 0,
1579
+ page_size: int = None, output_format: str = "JSON") -> list | str:
1646
1580
  """Retrieve the list of glossary category metadata elements that contain the search string.
1647
1581
  The search string is located in the request body and is interpreted as a plain string.
1648
1582
  The request parameters, startsWith, endsWith and ignoreCase can be used to allow a fuzzy search.
@@ -1706,38 +1640,28 @@ class GlossaryBrowser(Client):
1706
1640
  search_string = None
1707
1641
 
1708
1642
  body = {
1709
- "class": "SearchStringRequestBody",
1710
- "searchString": search_string,
1711
- "effectiveTime": effective_time,
1712
- }
1643
+ "class": "SearchStringRequestBody", "searchString": search_string, "effectiveTime": effective_time,
1644
+ }
1713
1645
 
1714
- url = (
1715
- f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/"
1716
- f"categories/by-search-string?startFrom={start_from}&pageSize={page_size}&startsWith={starts_with_s}&"
1717
- f"endsWith={ends_with_s}&ignoreCase={ignore_case_s}"
1718
- )
1646
+ url = (f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/"
1647
+ f"categories/by-search-string?startFrom={start_from}&pageSize={page_size}&startsWith={starts_with_s}&"
1648
+ f"endsWith={ends_with_s}&ignoreCase={ignore_case_s}")
1719
1649
  response = await self._async_make_request("POST", url, body_slimmer(body))
1720
1650
  element = response.json().get("elementList", NO_CATEGORIES_FOUND)
1721
1651
  if element == NO_CATEGORIES_FOUND:
1722
- return NO_CATEGORIES_FOUND
1652
+ if output_format == 'JSON':
1653
+ return NO_CATEGORIES_FOUND
1654
+ elif output_format in ['MD', 'FORM', 'REPORT', 'LIST']:
1655
+ return "\n# No categories found.\n"
1656
+ elif output_format == 'DICT':
1657
+ return None
1723
1658
  if output_format != 'JSON': # return a simplified markdown representation
1724
1659
  return self.generate_categories_md(element, search_string, output_format)
1725
1660
  return response.json().get("elementList", NO_CATEGORIES_FOUND)
1726
1661
 
1727
-
1728
-
1729
-
1730
- def find_glossary_categories(
1731
- self,
1732
- search_string: str,
1733
- effective_time: str = None,
1734
- starts_with: bool = False,
1735
- ends_with: bool = False,
1736
- ignore_case: bool = False,
1737
- start_from: int = 0,
1738
- page_size: int = None,
1739
- output_format: str = "JSON"
1740
- ) -> list | str:
1662
+ def find_glossary_categories(self, search_string: str, effective_time: str = None, starts_with: bool = False,
1663
+ ends_with: bool = False, ignore_case: bool = False, start_from: int = 0, page_size: int = None,
1664
+ output_format: str = "JSON") -> list | str:
1741
1665
  """Retrieve the list of glossary category metadata elements that contain the search string.
1742
1666
  The search string is located in the request body and is interpreted as a plain string.
1743
1667
  The request parameters, startsWith, endsWith and ignoreCase can be used to allow a fuzzy search.
@@ -1790,26 +1714,13 @@ class GlossaryBrowser(Client):
1790
1714
  """
1791
1715
  loop = asyncio.get_event_loop()
1792
1716
  response = loop.run_until_complete(
1793
- self._async_find_glossary_categories(
1794
- search_string,
1795
- effective_time,
1796
- starts_with,
1797
- ends_with,
1798
- ignore_case,
1799
- start_from,
1800
- page_size,
1801
- output_format
1802
- )
1803
- )
1717
+ self._async_find_glossary_categories(search_string, effective_time, starts_with, ends_with, ignore_case,
1718
+ start_from, page_size, output_format))
1804
1719
 
1805
1720
  return response
1806
1721
 
1807
- async def _async_get_categories_for_glossary(
1808
- self,
1809
- glossary_guid: str,
1810
- start_from: int = 0,
1811
- page_size: int = None,
1812
- ) -> list | str:
1722
+ async def _async_get_categories_for_glossary(self, glossary_guid: str, start_from: int = 0,
1723
+ page_size: int = None, ) -> list | str:
1813
1724
  """Return the list of categories associated with a glossary.
1814
1725
  Async version.
1815
1726
 
@@ -1845,20 +1756,14 @@ class GlossaryBrowser(Client):
1845
1756
  if page_size is None:
1846
1757
  page_size = self.page_size
1847
1758
 
1848
- url = (
1849
- f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/"
1850
- f"{glossary_guid}/categories/retrieve?startFrom={start_from}&pageSize={page_size}"
1851
- )
1759
+ url = (f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/"
1760
+ f"{glossary_guid}/categories/retrieve?startFrom={start_from}&pageSize={page_size}")
1852
1761
 
1853
1762
  response = await self._async_make_request("POST", url)
1854
1763
  return response.json().get("elementList", "No Categories found")
1855
1764
 
1856
- def get_categories_for_glossary(
1857
- self,
1858
- glossary_guid: str,
1859
- start_from: int = 0,
1860
- page_size: int = None,
1861
- ) -> list | str:
1765
+ def get_categories_for_glossary(self, glossary_guid: str, start_from: int = 0,
1766
+ page_size: int = None, ) -> list | str:
1862
1767
  """Return the list of categories associated with a glossary.
1863
1768
 
1864
1769
  Parameters
@@ -1891,18 +1796,11 @@ class GlossaryBrowser(Client):
1891
1796
  """
1892
1797
  loop = asyncio.get_event_loop()
1893
1798
  response = loop.run_until_complete(
1894
- self._async_get_categories_for_glossary(
1895
- glossary_guid, start_from, page_size
1896
- )
1897
- )
1799
+ self._async_get_categories_for_glossary(glossary_guid, start_from, page_size))
1898
1800
  return response
1899
1801
 
1900
- async def _async_get_categories_for_term(
1901
- self,
1902
- glossary_term_guid: str,
1903
- start_from: int = 0,
1904
- page_size: int = None,
1905
- ) -> list | str:
1802
+ async def _async_get_categories_for_term(self, glossary_term_guid: str, start_from: int = 0,
1803
+ page_size: int = None, ) -> list | str:
1906
1804
  """Return the list of categories associated with a glossary term.
1907
1805
  Async version.
1908
1806
 
@@ -1937,20 +1835,14 @@ class GlossaryBrowser(Client):
1937
1835
  if page_size is None:
1938
1836
  page_size = self.page_size
1939
1837
 
1940
- url = (
1941
- f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/terms/"
1942
- f"{glossary_term_guid}/categories/retrieve?startFrom={start_from}&pageSize={page_size}"
1943
- )
1838
+ url = (f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/terms/"
1839
+ f"{glossary_term_guid}/categories/retrieve?startFrom={start_from}&pageSize={page_size}")
1944
1840
 
1945
1841
  response = await self._async_make_request("POST", url)
1946
1842
  return response.json().get("elementList", "No Categories found")
1947
1843
 
1948
- def get_categories_for_term(
1949
- self,
1950
- glossary_term_guid: str,
1951
- start_from: int = 0,
1952
- page_size: int = None,
1953
- ) -> list | str:
1844
+ def get_categories_for_term(self, glossary_term_guid: str, start_from: int = 0,
1845
+ page_size: int = None, ) -> list | str:
1954
1846
  """Return the list of categories associated with a glossary term.
1955
1847
 
1956
1848
  Parameters
@@ -1982,20 +1874,11 @@ class GlossaryBrowser(Client):
1982
1874
  """
1983
1875
  loop = asyncio.get_event_loop()
1984
1876
  response = loop.run_until_complete(
1985
- self._async_get_categories_for_term(
1986
- glossary_term_guid, start_from, page_size
1987
- )
1988
- )
1877
+ self._async_get_categories_for_term(glossary_term_guid, start_from, page_size))
1989
1878
  return response
1990
1879
 
1991
- async def _async_get_categories_by_name(
1992
- self,
1993
- name: str,
1994
- glossary_guid: str = None,
1995
- status: [str] = ["ACTIVE"],
1996
- start_from: int = 0,
1997
- page_size: int = None,
1998
- ) -> list | str:
1880
+ async def _async_get_categories_by_name(self, name: str, glossary_guid: str = None, status: [str] = ["ACTIVE"],
1881
+ start_from: int = 0, page_size: int = None, ) -> list | str:
1999
1882
  """Retrieve the list of glossary category metadata elements that either have the requested qualified name or
2000
1883
  display name. The name to search for is located in the request body and is interpreted as a plain string.
2001
1884
  The request body also supports the specification of a glossaryGUID to restrict the search to within a single
@@ -2042,27 +1925,18 @@ class GlossaryBrowser(Client):
2042
1925
 
2043
1926
  url = (
2044
1927
  f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/categories/"
2045
- f"by-name?startFrom={start_from}&pageSize={page_size}"
2046
- )
1928
+ f"by-name?startFrom={start_from}&pageSize={page_size}")
2047
1929
 
2048
1930
  body = {
2049
- "class": "GlossaryNameRequestBody",
2050
- "name": name,
2051
- "glossaryGUID": glossary_guid,
1931
+ "class": "GlossaryNameRequestBody", "name": name, "glossaryGUID": glossary_guid,
2052
1932
  "limitResultsByStatus": status,
2053
- }
1933
+ }
2054
1934
 
2055
1935
  response = await self._async_make_request("POST", url, body)
2056
1936
  return response.json().get("elementList", NO_CATEGORIES_FOUND)
2057
1937
 
2058
- def get_categories_by_name(
2059
- self,
2060
- name: str,
2061
- glossary_guid: str = None,
2062
- status: [str] = ["ACTIVE"],
2063
- start_from: int = 0,
2064
- page_size: int = None,
2065
- ) -> list | str:
1938
+ def get_categories_by_name(self, name: str, glossary_guid: str = None, status: [str] = ["ACTIVE"],
1939
+ start_from: int = 0, page_size: int = None, ) -> list | str:
2066
1940
  """Retrieve the list of glossary category metadata elements that either have the requested qualified name or
2067
1941
  display name. The name to search for is located in the request body and is interpreted as a plain string.
2068
1942
  The request body also supports the specification of a glossaryGUID to restrict the search to within a
@@ -2102,18 +1976,11 @@ class GlossaryBrowser(Client):
2102
1976
  """
2103
1977
  loop = asyncio.get_event_loop()
2104
1978
  response = loop.run_until_complete(
2105
- self._async_get_categories_by_name(
2106
- name, glossary_guid, status, start_from, page_size
2107
- )
2108
- )
1979
+ self._async_get_categories_by_name(name, glossary_guid, status, start_from, page_size))
2109
1980
  return response
2110
1981
 
2111
- async def _async_get_categories_by_guid(
2112
- self,
2113
- glossary_category_guid: str,
2114
- effective_time: str = None,
2115
- output_format: str = 'JSON',
2116
- ) -> list | str:
1982
+ async def _async_get_categories_by_guid(self, glossary_category_guid: str, effective_time: str = None,
1983
+ output_format: str = 'JSON', ) -> list | str:
2117
1984
  """Retrieve the requested glossary category metadata element. The optional request body contain an effective
2118
1985
  time for the query..
2119
1986
 
@@ -2154,13 +2021,11 @@ class GlossaryBrowser(Client):
2154
2021
  output_format = output_format.upper()
2155
2022
  url = (
2156
2023
  f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/categories/"
2157
- f"{glossary_category_guid}/retrieve"
2158
- )
2024
+ f"{glossary_category_guid}/retrieve")
2159
2025
 
2160
2026
  body = {
2161
- "class": "EffectiveTimeQueryRequestBody",
2162
- "effectiveTime": effective_time,
2163
- }
2027
+ "class": "EffectiveTimeQueryRequestBody", "effectiveTime": effective_time,
2028
+ }
2164
2029
 
2165
2030
  response = await self._async_make_request("POST", url, body_slimmer(body))
2166
2031
  element = response.json().get("element", NO_CATEGORIES_FOUND)
@@ -2170,12 +2035,8 @@ class GlossaryBrowser(Client):
2170
2035
  return self.generate_categories_md(element, "GUID", output_format)
2171
2036
  return response.json().get("element", NO_CATEGORIES_FOUND)
2172
2037
 
2173
- def get_categories_by_guid(
2174
- self,
2175
- glossary_category_guid: str,
2176
- effective_time: str = None,
2177
- output_format: str = 'JSON',
2178
- ) -> list | str:
2038
+ def get_categories_by_guid(self, glossary_category_guid: str, effective_time: str = None,
2039
+ output_format: str = 'JSON', ) -> list | str:
2179
2040
  """Retrieve the requested glossary category metadata element. The optional request body contain an effective
2180
2041
  time for the query..
2181
2042
 
@@ -2213,15 +2074,10 @@ class GlossaryBrowser(Client):
2213
2074
  """
2214
2075
  loop = asyncio.get_event_loop()
2215
2076
  response = loop.run_until_complete(
2216
- self._async_get_categories_by_guid(glossary_category_guid, effective_time, output_format)
2217
- )
2077
+ self._async_get_categories_by_guid(glossary_category_guid, effective_time, output_format))
2218
2078
  return response
2219
2079
 
2220
- async def _async_get_category_parent(
2221
- self,
2222
- glossary_category_guid: str,
2223
- effective_time: str = None,
2224
- ) -> list | str:
2080
+ async def _async_get_category_parent(self, glossary_category_guid: str, effective_time: str = None, ) -> list | str:
2225
2081
  """Glossary categories can be organized in a hierarchy. Retrieve the parent glossary category metadata
2226
2082
  element for the glossary category with the supplied unique identifier. If the requested category
2227
2083
  does not have a parent category, null is returned. The optional request body contain an effective time
@@ -2259,22 +2115,16 @@ class GlossaryBrowser(Client):
2259
2115
 
2260
2116
  url = (
2261
2117
  f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/categories/"
2262
- f"{glossary_category_guid}/parent/retrieve"
2263
- )
2118
+ f"{glossary_category_guid}/parent/retrieve")
2264
2119
 
2265
2120
  body = {
2266
- "class": "EffectiveTimeQueryRequestBody",
2267
- "effectiveTime": effective_time,
2268
- }
2121
+ "class": "EffectiveTimeQueryRequestBody", "effectiveTime": effective_time,
2122
+ }
2269
2123
 
2270
2124
  response = await self._async_make_request("POST", url, body)
2271
2125
  return response.json().get("element", "No Parent Category found")
2272
2126
 
2273
- def get_category_parent(
2274
- self,
2275
- glossary_category_guid: str,
2276
- effective_time: str = None,
2277
- ) -> list | str:
2127
+ def get_category_parent(self, glossary_category_guid: str, effective_time: str = None, ) -> list | str:
2278
2128
  """Glossary categories can be organized in a hierarchy. Retrieve the parent glossary category metadata
2279
2129
  element for the glossary category with the supplied unique identifier. If the requested category
2280
2130
  does not have a parent category, null is returned. The optional request body contain an effective time
@@ -2308,1262 +2158,1305 @@ class GlossaryBrowser(Client):
2308
2158
 
2309
2159
  """
2310
2160
  loop = asyncio.get_event_loop()
2311
- response = loop.run_until_complete(
2312
- self._async_get_category_parent(glossary_category_guid, effective_time)
2313
- )
2161
+ response = loop.run_until_complete(self._async_get_category_parent(glossary_category_guid, effective_time))
2314
2162
  return response
2315
2163
 
2316
- #
2317
- # Terms
2318
- #
2319
-
2320
- async def _async_get_terms_for_category(
2321
- self,
2322
- glossary_category_guid: str,
2323
- effective_time: str = None,
2324
- start_from: int = 0,
2325
- page_size: int = None,
2326
- ) -> list | str:
2327
- """Retrieve ALL the glossary terms in a category.
2328
- The request body also supports the specification of an effective time for the query.
2164
+ def get_glossary_category_structure(self, glossary_guid: str, output_format: str = "DICT") -> dict | str:
2165
+ """Derive the category structure of an Egeria glossary.
2329
2166
 
2330
- Async Version.
2167
+ This method builds a hierarchical representation of the categories in a glossary,
2168
+ showing the parent-child relationships between categories.
2331
2169
 
2332
2170
  Parameters
2333
2171
  ----------
2334
- glossary_category_guid : str
2335
- Unique identifier for the glossary category to retrieve terms from.
2336
- effective_time : str, optional
2337
- If specified, the terms are returned if they are active at the `effective_time
2338
- Time format is "YYYY-MM-DDTHH:MM:SS" (ISO 8601)
2339
- start_from: int, optional defaults to 0
2340
- The page number to start retrieving elements from
2341
- page_size : int, optional defaults to None
2342
- The number of elements to retrieve
2172
+ glossary_guid: str
2173
+ The unique identifier of the glossary.
2174
+ output_format: str, default = 'DICT'
2175
+ The format of the output:
2176
+ - DICT: Returns a Python dictionary structure
2177
+ - LIST: Returns a markdown table
2178
+ - MD: Returns a markdown outline with bullets and indentations
2179
+
2343
2180
  Returns
2344
2181
  -------
2345
- [dict]
2346
- The glossary definition associated with the glossary_guid
2182
+ dict | str
2183
+ If output_format is DICT, returns a dictionary structure representing the category hierarchy.
2184
+ If output_format is LIST, returns a markdown table representing the category hierarchy.
2185
+ If output_format is MD, returns a markdown outline with bullets and indentations.
2347
2186
 
2348
2187
  Raises
2349
2188
  ------
2350
- InvalidParameterException
2351
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
2352
- PropertyServerException
2353
- Raised by the server when an issue arises in processing a valid request.
2354
- NotAuthorizedException
2355
- The principle specified by the user_id does not have authorization for the requested action.
2356
-
2189
+ InvalidParameterException
2190
+ If the client passes incorrect parameters on the request - such as bad URLs or invalid values
2191
+ PropertyServerException
2192
+ Raised by the server when an issue arises in processing a valid request
2193
+ NotAuthorizedException
2194
+ The principle specified by the user_id does not have authorization for the requested action
2357
2195
  """
2196
+ from pyegeria._validators import validate_guid
2358
2197
 
2359
- validate_guid(glossary_category_guid)
2360
-
2361
- if page_size is None:
2362
- page_size = self.page_size
2198
+ validate_guid(glossary_guid)
2363
2199
 
2364
- url = (
2365
- f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/categories/"
2366
- f"{glossary_category_guid}/terms/retrieve?startFrom={start_from}&pageSize={page_size}"
2367
- )
2200
+ # Get all categories in the glossary
2201
+ all_categories = self.get_categories_for_glossary(glossary_guid)
2202
+ if isinstance(all_categories, str):
2203
+ return NO_CATEGORIES_FOUND
2368
2204
 
2369
- if effective_time is not None:
2370
- body = {"effectiveTime": effective_time}
2371
- response = await self._async_make_request("POST", url, body)
2205
+ # Create a dictionary to store categories by GUID for quick lookup
2206
+ categories_by_guid = {cat['elementHeader']['guid']: cat for cat in all_categories}
2207
+
2208
+ # Identify root categories (categories with no parent)
2209
+ root_guids = []
2210
+ for cat_guid in categories_by_guid.keys():
2211
+ parent = self.get_category_parent(cat_guid)
2212
+ if isinstance(parent, str):
2213
+ root_guids.append(cat_guid) # This category has no parent
2214
+
2215
+ # Build the category tree
2216
+ category_tree = []
2217
+
2218
+ def build_category_tree(category_guid):
2219
+ """Recursively build a category tree for a category."""
2220
+ if category_guid not in categories_by_guid:
2221
+ return None
2222
+
2223
+ category = categories_by_guid[category_guid]
2224
+ display_name = category['glossaryCategoryProperties'].get('displayName', '---')
2225
+ qualified_name = category['glossaryCategoryProperties'].get('qualifiedName', '---')
2226
+ description = category['glossaryCategoryProperties'].get('description', '---')
2227
+
2228
+ # Get subcategories
2229
+ subcategories = self.get_glossary_subcategories(category_guid)
2230
+ children = []
2231
+
2232
+ if isinstance(subcategories, list):
2233
+ for subcat in subcategories:
2234
+ subcat_guid = subcat['elementHeader']['guid']
2235
+ child_tree = build_category_tree(subcat_guid)
2236
+ if child_tree:
2237
+ children.append(child_tree)
2238
+
2239
+ # Get parent category information
2240
+ parent_info = None
2241
+ parent = self.get_category_parent(category_guid)
2242
+ if not isinstance(parent, str):
2243
+ parent_guid = parent['elementHeader']['guid']
2244
+ parent_name = parent['glossaryCategoryProperties'].get('displayName', '---')
2245
+ parent_info = {
2246
+ 'guid': parent_guid,
2247
+ 'name': parent_name
2248
+ }
2249
+
2250
+ return {
2251
+ 'guid': category_guid,
2252
+ 'name': display_name,
2253
+ 'qualifiedName': qualified_name,
2254
+ 'description': description,
2255
+ 'parent': parent_info,
2256
+ 'children': children
2257
+ }
2258
+
2259
+ # Build tree for each root category
2260
+ for root_guid in root_guids:
2261
+ tree = build_category_tree(root_guid)
2262
+ if tree:
2263
+ category_tree.append(tree)
2264
+
2265
+ # Format the output according to the specified output_format
2266
+ if output_format == "DICT":
2267
+ return {
2268
+ 'glossary_guid': glossary_guid,
2269
+ 'categories': category_tree
2270
+ }
2271
+ elif output_format == "LIST":
2272
+ # Generate markdown table
2273
+ md_table = "| Category | Path | Description | Parent Category | Child Categories |\n"
2274
+ md_table += "|---------|------|-------------|----------------|------------------|\n"
2275
+
2276
+ def add_categories_to_table(categories, path=""):
2277
+ nonlocal md_table
2278
+ for category in categories:
2279
+ category_path = f"{path}/{category['name']}" if path else category['name']
2280
+
2281
+ # Get parent category name
2282
+ parent_name = "None"
2283
+ if category['parent']:
2284
+ parent_name = category['parent']['name']
2285
+
2286
+ # Get child categories names
2287
+ child_names = []
2288
+ for child in category['children']:
2289
+ child_names.append(child['name'])
2290
+ child_categories = ", ".join(child_names) if child_names else "None"
2291
+
2292
+ md_table += f"| {category['name']} | {category_path} | {self._format_for_markdown_table(category['description'])} | {parent_name} | {child_categories} |\n"
2293
+ if category['children']:
2294
+ add_categories_to_table(category['children'], category_path)
2295
+
2296
+ add_categories_to_table(category_tree)
2297
+ return md_table
2298
+ elif output_format == "MD":
2299
+ # Generate markdown outline with bullets and indentations
2300
+ md_outline = f"# Category Structure for Glossary (GUID: {glossary_guid})\n\n"
2301
+
2302
+ def add_categories_to_outline(categories, indent_level=0):
2303
+ nonlocal md_outline
2304
+ for category in categories:
2305
+ # Add bullet with proper indentation
2306
+ indent = " " * indent_level
2307
+ md_outline += f"{indent}- **{category['name']}**"
2308
+
2309
+ # Add description if available
2310
+ if category['description'] and category['description'] != '---':
2311
+ md_outline += f": {category['description']}"
2312
+
2313
+ md_outline += "\n"
2314
+
2315
+ # Process children with increased indentation
2316
+ if category['children']:
2317
+ add_categories_to_outline(category['children'], indent_level + 1)
2318
+
2319
+ add_categories_to_outline(category_tree)
2320
+ return md_outline
2372
2321
  else:
2373
- response = await self._async_make_request("POST", url)
2322
+ return f"Unsupported output format: {output_format}. Use 'DICT', 'LIST', or 'MD'."
2374
2323
 
2375
- return response.json().get("elementList", "No terms found")
2376
2324
 
2377
- def get_terms_for_category(
2378
- self,
2379
- glossary_category_guid: str,
2380
- effective_time: str = None,
2381
- start_from: int = 0,
2382
- page_size: int = None,
2383
- ) -> list | str:
2384
- """Retrieve ALL the glossary terms in a category.
2385
- The request body also supports the specification of an effective time for the query.
2386
2325
 
2387
- Async Version.
2326
+ #
2327
+ # Terms
2328
+ #
2388
2329
 
2389
- Parameters
2390
- ----------
2391
- glossary_category_guid : str
2392
- Unique identifier for the glossary category to retrieve terms from.
2393
-
2394
- effective_time : str, optional
2395
- If specified, the terms are returned if they are active at the `effective_time.
2396
- Time format is "YYYY-MM-DDTHH:MM:SS" (ISO 8601)`.
2397
- start_from: int, optional defaults to 0
2398
- The page number to start retrieving elements from
2399
- page_size : int, optional defaults to None
2400
- The number of elements to retrieve
2401
- Returns
2402
- -------
2403
- dict
2404
- The glossary definition associated with the glossary_guid
2330
+ async def _async_get_terms_for_category(self, glossary_category_guid: str, effective_time: str = None,
2331
+ start_from: int = 0, page_size: int = None, ) -> list | str:
2332
+ """Retrieve ALL the glossary terms in a category.
2333
+ The request body also supports the specification of an effective time for the query.
2405
2334
 
2406
- Raises
2407
- ------
2408
- InvalidParameterException
2409
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
2410
- PropertyServerException
2411
- Raised by the server when an issue arises in processing a valid request.
2412
- NotAuthorizedException
2413
- The principle specified by the user_id does not have authorization for the requested action.
2414
- Notes
2415
- -----
2416
- """
2417
- loop = asyncio.get_event_loop()
2418
- response = loop.run_until_complete(
2419
- self._async_get_terms_for_category(
2420
- glossary_category_guid,
2421
- effective_time,
2422
- start_from,
2423
- page_size,
2424
- )
2425
- )
2335
+ Async Version.
2426
2336
 
2427
- return response
2337
+ Parameters
2338
+ ----------
2339
+ glossary_category_guid : str
2340
+ Unique identifier for the glossary category to retrieve terms from.
2341
+ effective_time : str, optional
2342
+ If specified, the terms are returned if they are active at the `effective_time
2343
+ Time format is "YYYY-MM-DDTHH:MM:SS" (ISO 8601)
2344
+ start_from: int, optional defaults to 0
2345
+ The page number to start retrieving elements from
2346
+ page_size : int, optional defaults to None
2347
+ The number of elements to retrieve
2348
+ Returns
2349
+ -------
2350
+ [dict]
2351
+ The glossary definition associated with the glossary_guid
2352
+
2353
+ Raises
2354
+ ------
2355
+ InvalidParameterException
2356
+ If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
2357
+ PropertyServerException
2358
+ Raised by the server when an issue arises in processing a valid request.
2359
+ NotAuthorizedException
2360
+ The principle specified by the user_id does not have authorization for the requested action.
2428
2361
 
2429
- async def _async_get_terms_for_glossary(
2430
- self,
2431
- glossary_guid: str,
2432
- effective_time: str = None,
2433
- start_from: int = 0,
2434
- page_size: int = None,
2435
- ) -> list | str:
2436
- """Retrieve the list of glossary terms associated with a glossary.
2437
- The request body also supports the specification of an effective time for the query.
2438
- Parameters
2439
- ----------
2440
- glossary_guid : str
2441
- Unique identifier for the glossary
2442
-
2443
- effective_time : str, optional
2444
- If specified, terms are potentially included if they are active at the`effective_time.
2445
- Time format is "YYYY-MM-DDTHH:MM:SS" (ISO 8601)`
2446
- start_from: int, optional defaults to 0
2447
- The page number to start retrieving elements from
2448
- page_size : int, optional defaults to None
2449
- The number of elements to retrieve
2450
- Returns
2451
- -------
2452
- dict
2453
- The glossary definition associated with the glossary_guid
2362
+ """
2454
2363
 
2455
- Raises
2456
- ------
2457
- InvalidParameterException
2458
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
2459
- PropertyServerException
2460
- Raised by the server when an issue arises in processing a valid request.
2461
- NotAuthorizedException
2462
- The principle specified by the user_id does not have authorization for the requested action.
2463
- Notes
2464
- -----
2465
- """
2364
+ validate_guid(glossary_category_guid)
2466
2365
 
2467
- validate_guid(glossary_guid)
2366
+ if page_size is None:
2367
+ page_size = self.page_size
2468
2368
 
2469
- if page_size is None:
2470
- page_size = self.page_size
2369
+ url = (
2370
+ f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/categories/"
2371
+ f"{glossary_category_guid}/terms/retrieve?startFrom={start_from}&pageSize={page_size}")
2471
2372
 
2472
- url = (
2473
- f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/"
2474
- f"{glossary_guid}/terms/retrieve?startFrom={start_from}&pageSize={page_size}"
2475
- )
2373
+ if effective_time is not None:
2374
+ body = {"effectiveTime": effective_time}
2375
+ response = await self._async_make_request("POST", url, body)
2376
+ else:
2377
+ response = await self._async_make_request("POST", url)
2476
2378
 
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)
2379
+ return response.json().get("elementList", "No terms found")
2380
+
2381
+ def get_terms_for_category(self, glossary_category_guid: str, effective_time: str = None, start_from: int = 0,
2382
+ page_size: int = None, ) -> list | str:
2383
+ """Retrieve ALL the glossary terms in a category.
2384
+ The request body also supports the specification of an effective time for the query.
2385
+
2386
+ Async Version.
2387
+
2388
+ Parameters
2389
+ ----------
2390
+ glossary_category_guid : str
2391
+ Unique identifier for the glossary category to retrieve terms from.
2392
+
2393
+ effective_time : str, optional
2394
+ If specified, the terms are returned if they are active at the `effective_time.
2395
+ Time format is "YYYY-MM-DDTHH:MM:SS" (ISO 8601)`.
2396
+ start_from: int, optional defaults to 0
2397
+ The page number to start retrieving elements from
2398
+ page_size : int, optional defaults to None
2399
+ The number of elements to retrieve
2400
+ Returns
2401
+ -------
2402
+ dict
2403
+ The glossary definition associated with the glossary_guid
2404
+
2405
+ Raises
2406
+ ------
2407
+ InvalidParameterException
2408
+ If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
2409
+ PropertyServerException
2410
+ Raised by the server when an issue arises in processing a valid request.
2411
+ NotAuthorizedException
2412
+ The principle specified by the user_id does not have authorization for the requested action.
2413
+ Notes
2414
+ -----
2415
+ """
2416
+ loop = asyncio.get_event_loop()
2417
+ response = loop.run_until_complete(
2418
+ self._async_get_terms_for_category(glossary_category_guid, effective_time, start_from, page_size, ))
2419
+
2420
+ return response
2421
+
2422
+ async def _async_get_terms_for_glossary(self, glossary_guid: str, effective_time: str = None, start_from: int = 0,
2423
+ page_size: int = None, ) -> list | str:
2424
+ """Retrieve the list of glossary terms associated with a glossary.
2425
+ The request body also supports the specification of an effective time for the query.
2426
+ Parameters
2427
+ ----------
2428
+ glossary_guid : str
2429
+ Unique identifier for the glossary
2430
+
2431
+ effective_time : str, optional
2432
+ If specified, terms are potentially included if they are active at the`effective_time.
2433
+ Time format is "YYYY-MM-DDTHH:MM:SS" (ISO 8601)`
2434
+ start_from: int, optional defaults to 0
2435
+ The page number to start retrieving elements from
2436
+ page_size : int, optional defaults to None
2437
+ The number of elements to retrieve
2438
+ Returns
2439
+ -------
2440
+ dict
2441
+ The glossary definition associated with the glossary_guid
2442
+
2443
+ Raises
2444
+ ------
2445
+ InvalidParameterException
2446
+ If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
2447
+ PropertyServerException
2448
+ Raised by the server when an issue arises in processing a valid request.
2449
+ NotAuthorizedException
2450
+ The principle specified by the user_id does not have authorization for the requested action.
2451
+ Notes
2452
+ -----
2453
+ """
2482
2454
 
2483
- return response.json().get("elementList", "No terms found")
2455
+ validate_guid(glossary_guid)
2484
2456
 
2485
- def get_terms_for_glossary(
2486
- self,
2487
- glossary_guid: str,
2488
- effective_time: str = None,
2489
- start_from: int = 0,
2490
- page_size: int = None,
2491
- ) -> list | str:
2492
- """Retrieve the list of glossary terms associated with a glossary.
2493
- The request body also supports the specification of an effective time for the query.
2494
- Parameters
2495
- ----------
2496
- glossary_guid : str
2497
- Unique identifier for the glossary
2498
-
2499
- effective_time : str, optional
2500
- If specified, terms are potentially returned if they are active at the `effective_time`
2501
- Time format is "YYYY-MM-DDTHH:MM:SS" (ISO 8601)
2502
- start_from: int, optional defaults to 0
2503
- The page number to start retrieving elements from
2504
- page_size : int, optional defaults to None
2505
- The number of elements to retrieve
2506
- Returns
2507
- -------
2508
- dict
2509
- The glossary definition associated with the glossary_guid
2457
+ if page_size is None:
2458
+ page_size = self.page_size
2510
2459
 
2511
- Raises
2512
- ------
2513
- InvalidParameterException
2514
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
2515
- PropertyServerException
2516
- Raised by the server when an issue arises in processing a valid request.
2517
- NotAuthorizedException
2518
- The principle specified by the user_id does not have authorization for the requested action.
2519
- Notes
2520
- -----
2521
- """
2522
- loop = asyncio.get_event_loop()
2523
- response = loop.run_until_complete(
2524
- self._async_get_terms_for_glossary(
2525
- glossary_guid, effective_time, start_from, page_size
2526
- )
2527
- )
2460
+ url = (f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/"
2461
+ f"{glossary_guid}/terms/retrieve?startFrom={start_from}&pageSize={page_size}")
2528
2462
 
2529
- return response
2463
+ if effective_time is not None:
2464
+ body = {"effectiveTime": effective_time}
2465
+ response = await self._async_make_request("POST", url, body)
2466
+ else:
2467
+ response = await self._async_make_request("POST", url)
2530
2468
 
2531
- async def _async_get_term_relationships(
2532
- self,
2533
- term_guid: str,
2534
- effective_time: str = None,
2535
- start_from: int = 0,
2536
- page_size: int = None,
2537
- ) -> list | str:
2538
- """This call retrieves details of the glossary terms linked to this glossary term.
2539
- Notice the original org 1 glossary term is linked via the "SourcedFrom" relationship..
2540
- Parameters
2541
- ----------
2542
- term_guid : str
2543
- Unique identifier for the glossary term
2544
-
2545
- effective_time : str, optional
2546
- If specified, term relationships are included if they are active at the `effective_time`.
2547
- Time format is "YYYY-MM-DDTHH:MM:SS" (ISO 8601)
2548
- start_from: int, optional defaults to 0
2549
- The page number to start retrieving elements from
2550
- page_size : int, optional defaults to None
2551
- The number of elements to retrieve
2552
- Returns
2553
- -------
2554
- dict
2555
- The glossary definition associated with the glossary_guid
2469
+ return response.json().get("elementList", "No terms found")
2556
2470
 
2557
- Raises
2558
- ------
2559
- InvalidParameterException
2560
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
2561
- PropertyServerException
2562
- Raised by the server when an issue arises in processing a valid request.
2563
- NotAuthorizedException
2564
- The principle specified by the user_id does not have authorization for the requested action.
2565
- Notes
2566
- -----
2567
- """
2471
+ def get_terms_for_glossary(self, glossary_guid: str, effective_time: str = None, start_from: int = 0,
2472
+ page_size: int = None, ) -> list | str:
2473
+ """Retrieve the list of glossary terms associated with a glossary.
2474
+ The request body also supports the specification of an effective time for the query.
2475
+ Parameters
2476
+ ----------
2477
+ glossary_guid : str
2478
+ Unique identifier for the glossary
2568
2479
 
2569
- validate_guid(term_guid)
2480
+ effective_time : str, optional
2481
+ If specified, terms are potentially returned if they are active at the `effective_time`
2482
+ Time format is "YYYY-MM-DDTHH:MM:SS" (ISO 8601)
2483
+ start_from: int, optional defaults to 0
2484
+ The page number to start retrieving elements from
2485
+ page_size : int, optional defaults to None
2486
+ The number of elements to retrieve
2487
+ Returns
2488
+ -------
2489
+ dict
2490
+ The glossary definition associated with the glossary_guid
2491
+
2492
+ Raises
2493
+ ------
2494
+ InvalidParameterException
2495
+ If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
2496
+ PropertyServerException
2497
+ Raised by the server when an issue arises in processing a valid request.
2498
+ NotAuthorizedException
2499
+ The principle specified by the user_id does not have authorization for the requested action.
2500
+ Notes
2501
+ -----
2502
+ """
2503
+ loop = asyncio.get_event_loop()
2504
+ response = loop.run_until_complete(
2505
+ self._async_get_terms_for_glossary(glossary_guid, effective_time, start_from, page_size))
2506
+
2507
+ return response
2508
+
2509
+ async def _async_get_term_relationships(self, term_guid: str, effective_time: str = None, start_from: int = 0,
2510
+ page_size: int = None, ) -> list | str:
2511
+ """This call retrieves details of the glossary terms linked to this glossary term.
2512
+ Notice the original org 1 glossary term is linked via the "SourcedFrom" relationship..
2513
+ Parameters
2514
+ ----------
2515
+ term_guid : str
2516
+ Unique identifier for the glossary term
2570
2517
 
2571
- if page_size is None:
2572
- page_size = self.page_size
2518
+ effective_time : str, optional
2519
+ If specified, term relationships are included if they are active at the `effective_time`.
2520
+ Time format is "YYYY-MM-DDTHH:MM:SS" (ISO 8601)
2521
+ start_from: int, optional defaults to 0
2522
+ The page number to start retrieving elements from
2523
+ page_size : int, optional defaults to None
2524
+ The number of elements to retrieve
2525
+ Returns
2526
+ -------
2527
+ dict
2528
+ The glossary definition associated with the glossary_guid
2529
+
2530
+ Raises
2531
+ ------
2532
+ InvalidParameterException
2533
+ If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
2534
+ PropertyServerException
2535
+ Raised by the server when an issue arises in processing a valid request.
2536
+ NotAuthorizedException
2537
+ The principle specified by the user_id does not have authorization for the requested action.
2538
+ Notes
2539
+ -----
2540
+ """
2573
2541
 
2574
- url = (
2575
- f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/terms/"
2576
- f"{term_guid}/related-terms?startFrom={start_from}&pageSize={page_size}"
2577
- )
2542
+ validate_guid(term_guid)
2578
2543
 
2579
- if effective_time is not None:
2580
- body = {"effectiveTime": effective_time}
2581
- response = await self._async_make_request("POST", url, body)
2582
- else:
2583
- response = await self._async_make_request("POST", url)
2544
+ if page_size is None:
2545
+ page_size = self.page_size
2584
2546
 
2585
- return response.json().get("elementList", "No terms found")
2586
-
2587
- def get_term_relationships(
2588
- self,
2589
- term_guid: str,
2590
- effective_time: str = None,
2591
- start_from: int = 0,
2592
- page_size: int = None,
2593
- ) -> list | str:
2594
- """This call retrieves details of the glossary terms linked to this glossary term.
2595
- Notice the original org 1 glossary term is linked via the "SourcedFrom" relationship..
2596
- Parameters
2597
- ----------
2598
- term_guid : str
2599
- Unique identifier for the glossary term
2600
-
2601
- effective_time : str, optional
2602
- If specified, term relationships are included if they are active at the `effective_time`.
2603
- Time format is "YYYY-MM-DDTHH:MM:SS" (ISO 8601)
2604
- start_from: int, optional defaults to 0
2605
- The page number to start retrieving elements from
2606
- page_size : int, optional defaults to None
2607
- The number of elements to retrieve
2608
- Returns
2609
- -------
2610
- dict
2611
- The glossary definition associated with the glossary_guid
2547
+ url = (f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/terms/"
2548
+ f"{term_guid}/related-terms?startFrom={start_from}&pageSize={page_size}")
2612
2549
 
2613
- Raises
2614
- ------
2615
- InvalidParameterException
2616
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
2617
- PropertyServerException
2618
- Raised by the server when an issue arises in processing a valid request.
2619
- NotAuthorizedException
2620
- The principle specified by the user_id does not have authorization for the requested action.
2621
- Notes
2622
- -----
2623
- """
2624
- loop = asyncio.get_event_loop()
2625
- response = loop.run_until_complete(
2626
- self._async_get_term_relationships(
2627
- term_guid, effective_time, start_from, page_size
2628
- )
2629
- )
2550
+ if effective_time is not None:
2551
+ body = {"effectiveTime": effective_time}
2552
+ response = await self._async_make_request("POST", url, body)
2553
+ else:
2554
+ response = await self._async_make_request("POST", url)
2630
2555
 
2631
- return response
2632
-
2633
- async def _async_get_glossary_for_term(
2634
- self, term_guid: str, effective_time: str = None
2635
- ) -> dict | str:
2636
- """Retrieve the glossary metadata element for the requested term. The optional request body allows you to
2637
- specify that the glossary element should only be returned if it was effective at a particular time.
2556
+ return response.json().get("elementList", "No terms found")
2638
2557
 
2639
- Async Version.
2640
-
2641
- Parameters
2642
- ----------
2558
+ def get_term_relationships(self, term_guid: str, effective_time: str = None, start_from: int = 0,
2559
+ page_size: int = None, ) -> list | str:
2560
+ """This call retrieves details of the glossary terms linked to this glossary term.
2561
+ Notice the original org 1 glossary term is linked via the "SourcedFrom" relationship..
2562
+ Parameters
2563
+ ----------
2643
2564
  term_guid : str
2644
- The unique identifier for the term.
2645
-
2646
- effective_time : datetime, optional
2647
- If specified, the term information will be retrieved if it is active at the `effective_time`.
2648
- Time format is "YYYY-MM-DDTHH:MM:SS" (ISO 8601)
2649
-
2650
- Returns
2651
- -------
2652
- dict
2653
- The glossary information retrieved for the specified term.
2654
- Raises
2655
- ------
2656
- InvalidParameterException
2657
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
2658
- PropertyServerException
2659
- Raised by the server when an issue arises in processing a valid request.
2660
- NotAuthorizedException
2661
- The principle specified by the user_id does not have authorization for the requested action.
2662
- Notes
2663
- -----
2664
- """
2665
-
2666
- validate_guid(term_guid)
2667
-
2668
- body = {
2669
- "class": "EffectiveTimeQueryRequestBody",
2670
- "effectiveTime": effective_time,
2671
- }
2672
- url = (
2673
- f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/"
2674
- f"for-term/{term_guid}/retrieve"
2675
- )
2676
-
2677
- response = await self._async_make_request("POST", url, body)
2678
- return response.json().get("element", "No glossary found")
2679
-
2680
- def get_glossary_for_term(
2681
- self, term_guid: str, effective_time: str = None
2682
- ) -> dict | str:
2683
- """Retrieve the glossary metadata element for the requested term. The optional request body allows you to
2684
- specify that the glossary element should only be returned if it was effective at a particular time.
2685
-
2686
- Async Version.
2687
-
2688
- Parameters
2689
- ----------
2690
- term_guid : str
2691
- The unique identifier for the term.
2692
-
2693
- effective_time : datetime, optional
2694
- TIf specified, the term information will be retrieved if it is active at the `effective_time`.
2695
- Time format is "YYYY-MM-DDTHH:MM:SS" (ISO 8601).
2696
-
2697
- Returns
2698
- -------
2699
- dict
2700
- The glossary information retrieved for the specified term.
2701
- Raises
2702
- ------
2703
- InvalidParameterException
2704
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
2705
- PropertyServerException
2706
- Raised by the server when an issue arises in processing a valid request.
2707
- NotAuthorizedException
2708
- The principle specified by the user_id does not have authorization for the requested action.
2709
- Notes
2710
- -----
2711
- """
2712
- loop = asyncio.get_event_loop()
2713
- response = loop.run_until_complete(
2714
- self._async_get_glossary_for_term(term_guid, effective_time)
2715
- )
2716
- return response
2565
+ Unique identifier for the glossary term
2717
2566
 
2718
- async def _async_get_terms_by_name(
2719
- self,
2720
- term: str,
2721
- glossary_guid: str = None,
2722
- status_filter: list = [],
2723
- effective_time: str = None,
2724
- for_lineage: bool = False,
2725
- for_duplicate_processing: bool = False,
2726
- start_from: int = 0,
2727
- page_size: int = None,
2728
- ) -> list:
2729
- """Retrieve glossary terms by display name or qualified name. Async Version.
2730
-
2731
- Parameters
2732
- ----------
2733
- term : str
2734
- The term to search for in the glossaries.
2735
- glossary_guid : str, optional
2736
- The GUID of the glossary to search in. If not provided, the search will be performed in all glossaries.
2737
- status_filter : list, optional
2738
- A list of status values to filter the search results. Default is an empty list, which means no filtering.
2739
-
2740
- effective_time : datetime, optional
2741
- If specified, the term information will be retrieved if it is active at the `effective_time`.
2567
+ effective_time : str, optional
2568
+ If specified, term relationships are included if they are active at the `effective_time`.
2742
2569
  Time format is "YYYY-MM-DDTHH:MM:SS" (ISO 8601)
2743
- for_lineage : bool, optional
2744
- Flag to indicate whether the search should include lineage information. Default is False.
2745
- for_duplicate_processing : bool, optional
2746
- Flag to indicate whether the search should include duplicate processing information. Default is False.
2747
- start_from : int, optional
2748
- The index of the first term to retrieve. Default is 0.
2749
- page_size : int, optional
2750
- The number of terms to retrieve per page. If not provided, it will use the default page size.
2751
-
2752
- Returns
2753
- -------
2754
- list
2755
- A list of terms matching the search criteria. If no terms are found, it returns the string "No terms found".
2570
+ start_from: int, optional defaults to 0
2571
+ The page number to start retrieving elements from
2572
+ page_size : int, optional defaults to None
2573
+ The number of elements to retrieve
2574
+ Returns
2575
+ -------
2576
+ dict
2577
+ The glossary definition associated with the glossary_guid
2578
+
2579
+ Raises
2580
+ ------
2581
+ InvalidParameterException
2582
+ If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
2583
+ PropertyServerException
2584
+ Raised by the server when an issue arises in processing a valid request.
2585
+ NotAuthorizedException
2586
+ The principle specified by the user_id does not have authorization for the requested action.
2587
+ Notes
2588
+ -----
2589
+ """
2590
+ loop = asyncio.get_event_loop()
2591
+ response = loop.run_until_complete(
2592
+ self._async_get_term_relationships(term_guid, effective_time, start_from, page_size))
2756
2593
 
2757
- Raises
2758
- ------
2759
- InvalidParameterException
2760
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
2761
- PropertyServerException
2762
- Raised by the server when an issue arises in processing a valid request.
2763
- NotAuthorizedException
2764
- The principle specified by the user_id does not have authorization for the requested action.
2765
- """
2594
+ return response
2766
2595
 
2767
- if page_size is None:
2768
- page_size = self.page_size
2596
+ async def _async_get_glossary_for_term(self, term_guid: str, effective_time: str = None) -> dict | str:
2597
+ """Retrieve the glossary metadata element for the requested term. The optional request body allows you to
2598
+ specify that the glossary element should only be returned if it was effective at a particular time.
2769
2599
 
2770
- validate_name(term)
2600
+ Async Version.
2601
+
2602
+ Parameters
2603
+ ----------
2604
+ term_guid : str
2605
+ The unique identifier for the term.
2606
+
2607
+ effective_time : datetime, optional
2608
+ If specified, the term information will be retrieved if it is active at the `effective_time`.
2609
+ Time format is "YYYY-MM-DDTHH:MM:SS" (ISO 8601)
2610
+
2611
+ Returns
2612
+ -------
2613
+ dict
2614
+ The glossary information retrieved for the specified term.
2615
+ Raises
2616
+ ------
2617
+ InvalidParameterException
2618
+ If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
2619
+ PropertyServerException
2620
+ Raised by the server when an issue arises in processing a valid request.
2621
+ NotAuthorizedException
2622
+ The principle specified by the user_id does not have authorization for the requested action.
2623
+ Notes
2624
+ -----
2625
+ """
2771
2626
 
2772
- for_lineage_s = str(for_lineage).lower()
2773
- for_duplicate_processing_s = str(for_duplicate_processing).lower()
2627
+ validate_guid(term_guid)
2774
2628
 
2775
- body = {
2776
- "class": "GlossaryNameRequestBody",
2777
- "glossaryGUID": glossary_guid,
2778
- "name": term,
2779
- "effectiveTime": effective_time,
2780
- "limitResultsByStatus": status_filter,
2629
+ body = {
2630
+ "class": "EffectiveTimeQueryRequestBody", "effectiveTime": effective_time,
2781
2631
  }
2782
- # body = body_slimmer(body)
2783
-
2784
- url = (
2785
- f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/"
2786
- f"terms/by-name?startFrom={start_from}&pageSize={page_size}&"
2787
- f"&forLineage={for_lineage_s}&forDuplicateProcessing={for_duplicate_processing_s}"
2788
- )
2632
+ url = (f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/"
2633
+ f"for-term/{term_guid}/retrieve")
2789
2634
 
2790
- # print(f"\n\nURL is: \n {url}\n\nBody is: \n{body}")
2635
+ response = await self._async_make_request("POST", url, body)
2636
+ return response.json().get("element", "No glossary found")
2791
2637
 
2792
- response = await self._async_make_request("POST", url, body)
2793
- return response.json().get("elementList", "No terms found")
2794
-
2795
- def get_terms_by_name(
2796
- self,
2797
- term: str,
2798
- glossary_guid: str = None,
2799
- status_filter: list = [],
2800
- effective_time: str = None,
2801
- for_lineage: bool = False,
2802
- for_duplicate_processing: bool = False,
2803
- start_from: int = 0,
2804
- page_size: int = None,
2805
- ) -> list:
2806
- """Retrieve glossary terms by display name or qualified name.
2807
-
2808
- Parameters
2809
- ----------
2810
- term : str
2811
- The term to search for in the glossaries.
2812
- glossary_guid : str, optional
2813
- The GUID of the glossary to search in. If not provided, the search will be performed in all glossaries.
2814
- status_filter : list, optional
2815
- A list of status values to filter the search results. Default is an empty list, which means no filtering.
2816
-
2817
- effective_time : datetime, optional
2818
- If specified, the term information will be retrieved if it is active at the `effective_time`.
2819
- Time format is "YYYY-MM-DDTHH:MM:SS" (ISO 8601)
2820
- for_lineage : bool, optional
2821
- Flag to indicate whether the search should include lineage information. Default is False.
2822
- for_duplicate_processing : bool, optional
2823
- Flag to indicate whether the search should include duplicate processing information. Default is False.
2824
- start_from : int, optional
2825
- The index of the first term to retrieve. Default is 0.
2826
- page_size : int, optional
2827
- The number of terms to retrieve per page. If not provided, it will use the default page size.
2828
-
2829
- Returns
2830
- -------
2831
- list
2832
- A list of terms matching the search criteria. If no terms are found,
2833
- it returns the string "No terms found".
2834
-
2835
- Raises
2836
- ------
2837
- InvalidParameterException
2838
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
2839
- PropertyServerException
2840
- Raised by the server when an issue arises in processing a valid request.
2841
- NotAuthorizedException
2842
- The principle specified by the user_id does not have authorization for the requested action.
2843
- """
2844
- loop = asyncio.get_event_loop()
2845
- response = loop.run_until_complete(
2846
- self._async_get_terms_by_name(
2847
- term,
2848
- glossary_guid,
2849
- status_filter,
2850
- effective_time,
2851
- for_lineage,
2852
- for_duplicate_processing,
2853
- start_from,
2854
- page_size,
2855
- )
2856
- )
2857
- return response
2858
-
2859
- async def _async_get_terms_by_guid(self, term_guid: str, output_format: str = 'JSON') -> dict | str:
2860
- """Retrieve a term using its unique id. Async version.
2861
- Parameters
2862
- ----------
2863
- term_guid : str
2864
- The GUID of the glossary term to retrieve.
2865
- output_format: str, default = 'JSON'
2866
- Type of output to produce:
2867
- JSON - output standard json
2868
- MD - output standard markdown with no preamble
2869
- FORM - output markdown with a preamble for a form
2870
- REPORT - output markdown with a preamble for a report
2871
-
2872
- Returns
2873
- -------
2874
- dict | str
2875
- A dict detailing the glossary term represented by the GUID. If no term is found, the string
2876
- "No term found" will be returned.
2877
-
2878
- Raises
2879
- ------
2880
- InvalidParameterException
2881
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
2882
- PropertyServerException
2883
- Raised by the server when an issue arises in processing a valid request.
2884
- NotAuthorizedException
2885
- The principle specified by the user_id does not have authorization for the requested action.
2886
- """
2887
- output_format = output_format.upper()
2888
- validate_guid(term_guid)
2889
-
2890
- url = (
2891
- f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/terms/"
2892
- f"{term_guid}/retrieve"
2893
- )
2894
- response = await self._async_make_request("POST", url)
2895
- term_element = response.json().get("element", NO_TERMS_FOUND)
2896
- if term_element == NO_TERMS_FOUND:
2897
- return NO_TERMS_FOUND
2898
- if output_format != 'JSON': # return a simplified markdown representation
2899
- return self.generate_terms_md(term_element, "GUID", output_format)
2900
- return response.json().get("element", NO_TERMS_FOUND)
2901
-
2902
-
2903
- def get_terms_by_guid(self, term_guid: str, output_format: str = 'JSON') -> dict | str:
2904
- """Retrieve a term using its unique id. Async version.
2905
- Parameters
2906
- ----------
2907
- term_guid : str
2908
- The GUID of the glossary term to retrieve.
2909
- output_format: str, default = 'JSON'
2910
- Type of output to produce:
2911
- JSON - output standard json
2912
- MD - output standard markdown with no preamble
2913
- FORM - output markdown with a preamble for a form
2914
- REPORT - output markdown with a preamble for a report
2915
- Returns
2916
- -------
2917
- dict | str
2918
- A dict detailing the glossary term represented by the GUID. If no term is found, the string
2919
- "No term found" will be returned.
2920
- Raises
2921
- ------
2922
- InvalidParameterException
2923
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
2924
- PropertyServerException
2925
- Raised by the server when an issue arises in processing a valid request.
2926
- NotAuthorizedException
2927
- The principle specified by the user_id does not have authorization for the requested action.
2928
- """
2929
-
2930
- loop = asyncio.get_event_loop()
2931
- response = loop.run_until_complete(self._async_get_terms_by_guid(term_guid, output_format))
2932
-
2933
- return response
2934
-
2935
- async def _async_get_terms_versions(
2936
- self,
2937
- term_guid: str,
2938
- start_from: int = 0,
2939
- page_size=None,
2940
- ) -> dict | str:
2941
- """Retrieve the versions of a glossary term. Async version.
2942
- Parameters
2943
- ----------
2944
- term_guid : str
2945
- The GUID of the glossary term to retrieve.
2946
-
2947
- start_from : int, optional
2948
- The index of the first term to retrieve. Default is 0.
2949
- page_size : int, optional
2950
- The number of terms to retrieve per page. If not provided, it will use the default page size.
2951
- Returns
2952
- -------
2953
- dict | str
2954
- A dict detailing the glossary term represented by the GUID. If no term is found, the string
2955
- "No term found" will be returned.
2956
-
2957
- Raises
2958
- ------
2959
- InvalidParameterException
2960
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
2961
- PropertyServerException
2962
- Raised by the server when an issue arises in processing a valid request.
2963
- NotAuthorizedException
2964
- The principle specified by the user_id does not have authorization for the requested action.
2965
- """
2966
-
2967
- if page_size is None:
2968
- page_size = self.page_size
2969
-
2970
- validate_guid(term_guid)
2971
-
2972
- url = (
2973
- f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/terms/"
2974
- f"{term_guid}/history?startFrom={start_from}&pageSize={page_size}"
2975
- )
2976
-
2977
- response = await self._async_make_request("POST", url)
2978
- return response.json().get("element", "No term found")
2979
-
2980
- def get_terms_versions(
2981
- self,
2982
- term_guid: str,
2983
- start_from: int = 0,
2984
- page_size=None,
2985
- ) -> dict | str:
2986
- """Retrieve the versions of a glossary term.
2987
- Parameters
2988
- ----------
2989
- term_guid : str
2990
- The GUID of the glossary term to retrieve.
2991
-
2992
- start_from : int, optional
2993
- The index of the first term to retrieve. Default is 0.
2994
- page_size : int, optional
2995
- The number of terms to retrieve per page. If not provided, it will use the default page size.
2996
- Returns
2997
- -------
2998
- dict | str
2999
- A dict detailing the glossary term represented by the GUID. If no term is found, the string
3000
- "No term found" will be returned.
3001
-
3002
- Raises
3003
- ------
3004
- InvalidParameterException
3005
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
3006
- PropertyServerException
3007
- Raised by the server when an issue arises in processing a valid request.
3008
- NotAuthorizedException
3009
- The principle specified by the user_id does not have authorization for the requested action.
3010
- """
3011
-
3012
- loop = asyncio.get_event_loop()
3013
- response = loop.run_until_complete(
3014
- self._async_get_terms_versions(term_guid, start_from, page_size)
3015
- )
3016
-
3017
- return response
3018
-
3019
- async def _async_get_term_revision_logs(
3020
- self,
3021
- term_guid: str,
3022
- start_from: int = 0,
3023
- page_size=None,
3024
- ) -> dict | str:
3025
- """Retrieve the revision log history for a term. Async version.
3026
- Parameters
3027
- ----------
3028
- term_guid : str
3029
- The GUID of the glossary term to retrieve.
3030
-
3031
- start_from : int, optional
3032
- The index of the first term to retrieve. Default is 0.
3033
- page_size : int, optional
3034
- The number of terms to retrieve per page. If not provided, it will use the default page size.
3035
- Returns
3036
- -------
3037
- dict | str
3038
- A dict detailing the glossary term revision log history. If no term is found, the string
3039
- "No log found" will be returned.
3040
-
3041
- Raises
3042
- ------
3043
- InvalidParameterException
3044
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
3045
- PropertyServerException
3046
- Raised by the server when an issue arises in processing a valid request.
3047
- NotAuthorizedException
3048
- The principle specified by the user_id does not have authorization for the requested action.
3049
- """
3050
-
3051
- if page_size is None:
3052
- page_size = self.page_size
3053
-
3054
- validate_guid(term_guid)
3055
-
3056
- url = (
3057
- f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/elements/"
3058
- f"{term_guid}/notes/retrieve?startFrom={start_from}&pageSize={page_size}"
3059
- )
3060
-
3061
- response = await self._async_make_request("POST", url)
3062
- return response.json().get("elementList", "No log found")
3063
-
3064
- def get_term_revision_logs(
3065
- self,
3066
- term_guid: str,
3067
- start_from: int = 0,
3068
- page_size=None,
3069
- ) -> dict | str:
3070
- """Retrieve the revision log history for a term.
3071
- Parameters
3072
- ----------
3073
- term_guid : str
3074
- The GUID of the glossary term to retrieve.
3075
-
3076
- start_from : int, optional
3077
- The index of the first term to retrieve. Default is 0.
3078
- page_size : int, optional
3079
- The number of terms to retrieve per page. If not provided, it will use the default page size.
3080
- Returns
3081
- -------
3082
- dict | str
3083
- A dict detailing the glossary term revision log history. If no term is found, the string
3084
- "No log found" will be returned.
3085
-
3086
- Raises
3087
- ------
3088
- InvalidParameterException
3089
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
3090
- PropertyServerException
3091
- Raised by the server when an issue arises in processing a valid request.
3092
- NotAuthorizedException
3093
- The principle specified by the user_id does not have authorization for the requested action.
3094
- """
3095
-
3096
- loop = asyncio.get_event_loop()
3097
- response = loop.run_until_complete(
3098
- self._async_get_term_revision_logs(term_guid, start_from, page_size)
3099
- )
3100
-
3101
- return response
3102
-
3103
- async def _async_get_term_revision_history(
3104
- self,
3105
- term_revision_log_guid: str,
3106
- start_from: int = 0,
3107
- page_size=None,
3108
- ) -> dict | str:
3109
- """Retrieve the revision history for a glossary term. Async version.
3110
-
3111
- Parameters
3112
- ----------
3113
- term_revision_log_guid : str
3114
- The GUID of the glossary term revision log to retrieve.
3115
-
3116
- start_from : int, optional
3117
- The index of the first term to retrieve. Default is 0.
3118
- page_size : int, optional
3119
- The number of terms to retrieve per page. If not provided, it will use the default page size.
3120
- Returns
3121
- -------
3122
- dict | str
3123
- A dict detailing the glossary term revision history.
3124
-
3125
- Raises
3126
- ------
3127
- InvalidParameterException
3128
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
3129
- PropertyServerException
3130
- Raised by the server when an issue arises in processing a valid request.
3131
- NotAuthorizedException
3132
- The principle specified by the user_id does not have authorization for the requested action.
3133
-
3134
-
3135
- Notes
3136
- -----
3137
- This revision history is created automatically. The text is supplied on the update request.
3138
- If no text is supplied, the value "None" is show.
3139
- """
3140
-
3141
- if page_size is None:
3142
- page_size = self.page_size
3143
-
3144
- validate_guid(term_revision_log_guid)
3145
-
3146
- url = (
3147
- f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/note-logs/"
3148
- f"{term_revision_log_guid}/notes/retrieve?startFrom={start_from}&pageSize={page_size}"
3149
- )
3150
-
3151
- response = await self._async_make_request("POST", url)
3152
- return response.json().get("elementList", "No logs found")
3153
-
3154
- def get_term_revision_history(
3155
- self,
3156
- term_revision_log_guid: str,
3157
- start_from: int = 0,
3158
- page_size=None,
3159
- ) -> dict | str:
3160
- """Retrieve the revision history for a glossary term.
3161
-
3162
- Parameters
3163
- ----------
3164
- term_revision_log_guid : str
3165
- The GUID of the glossary term revision log to retrieve.
3166
-
3167
- start_from : int, optional
3168
- The index of the first term to retrieve. Default is 0.
3169
- page_size : int, optional
3170
- The number of terms to retrieve per page. If not provided, it will use the default page size.
3171
- Returns
3172
- -------
3173
- dict | str
3174
- A dict detailing the glossary term revision history.
3175
-
3176
- Raises
3177
- ------
3178
- InvalidParameterException
3179
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
3180
- PropertyServerException
3181
- Raised by the server when an issue arises in processing a valid request.
3182
- NotAuthorizedException
3183
- The principle specified by the user_id does not have authorization for the requested action.
3184
-
3185
-
3186
- Notes
3187
- -----
3188
- This revision history is created automatically. The text is supplied on the update request.
3189
- If no text is supplied, the value "None" is show.
3190
- """
3191
-
3192
- loop = asyncio.get_event_loop()
3193
- response = loop.run_until_complete(
3194
- self._async_get_term_revision_history(
3195
- term_revision_log_guid, start_from, page_size
3196
- )
3197
- )
3198
-
3199
- return response
2638
+ def get_glossary_for_term(self, term_guid: str, effective_time: str = None) -> dict | str:
2639
+ """Retrieve the glossary metadata element for the requested term. The optional request body allows you to
2640
+ specify that the glossary element should only be returned if it was effective at a particular time.
3200
2641
 
3201
- async def _async_find_glossary_terms(
3202
- self,
3203
- search_string: str,
3204
- glossary_guid: str = None,
3205
- status_filter: list = [],
3206
- effective_time: str = None,
3207
- starts_with: bool = False,
3208
- ends_with: bool = False,
3209
- ignore_case: bool = False,
3210
- for_lineage: bool = False,
3211
- for_duplicate_processing: bool = False,
3212
- start_from: int = 0,
3213
- page_size: int = None,
3214
- output_format: str = "JSON",
3215
- ) -> list | str:
3216
- """Retrieve the list of glossary term metadata elements that contain the search string.
2642
+ Async Version.
2643
+
2644
+ Parameters
2645
+ ----------
2646
+ term_guid : str
2647
+ The unique identifier for the term.
2648
+
2649
+ effective_time : datetime, optional
2650
+ TIf specified, the term information will be retrieved if it is active at the `effective_time`.
2651
+ Time format is "YYYY-MM-DDTHH:MM:SS" (ISO 8601).
2652
+
2653
+ Returns
2654
+ -------
2655
+ dict
2656
+ The glossary information retrieved for the specified term.
2657
+ Raises
2658
+ ------
2659
+ InvalidParameterException
2660
+ If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
2661
+ PropertyServerException
2662
+ Raised by the server when an issue arises in processing a valid request.
2663
+ NotAuthorizedException
2664
+ The principle specified by the user_id does not have authorization for the requested action.
2665
+ Notes
2666
+ -----
2667
+ """
2668
+ loop = asyncio.get_event_loop()
2669
+ response = loop.run_until_complete(self._async_get_glossary_for_term(term_guid, effective_time))
2670
+ return response
2671
+
2672
+ async def _async_get_terms_by_name(self, term: str, glossary_guid: str = None, status_filter: list = [],
2673
+ effective_time: str = None, for_lineage: bool = False, for_duplicate_processing: bool = False,
2674
+ start_from: int = 0, page_size: int = None, ) -> list:
2675
+ """Retrieve glossary terms by display name or qualified name. Async Version.
2676
+
2677
+ Parameters
2678
+ ----------
2679
+ term : str
2680
+ The term to search for in the glossaries.
2681
+ glossary_guid : str, optional
2682
+ The GUID of the glossary to search in. If not provided, the search will be performed in all glossaries.
2683
+ status_filter : list, optional
2684
+ A list of status values to filter the search results. Default is an empty list, which means no filtering.
2685
+
2686
+ effective_time : datetime, optional
2687
+ If specified, the term information will be retrieved if it is active at the `effective_time`.
2688
+ Time format is "YYYY-MM-DDTHH:MM:SS" (ISO 8601)
2689
+ for_lineage : bool, optional
2690
+ Flag to indicate whether the search should include lineage information. Default is False.
2691
+ for_duplicate_processing : bool, optional
2692
+ Flag to indicate whether the search should include duplicate processing information. Default is False.
2693
+ start_from : int, optional
2694
+ The index of the first term to retrieve. Default is 0.
2695
+ page_size : int, optional
2696
+ The number of terms to retrieve per page. If not provided, it will use the default page size.
2697
+
2698
+ Returns
2699
+ -------
2700
+ list
2701
+ A list of terms matching the search criteria. If no terms are found, it returns the string "No terms found".
2702
+
2703
+ Raises
2704
+ ------
2705
+ InvalidParameterException
2706
+ If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
2707
+ PropertyServerException
2708
+ Raised by the server when an issue arises in processing a valid request.
2709
+ NotAuthorizedException
2710
+ The principle specified by the user_id does not have authorization for the requested action.
2711
+ """
3217
2712
 
3218
- Parameters
3219
- ----------
3220
- search_string: str
3221
- Search string to use to find matching glossaries. If the search string is '*' then all glossaries returned.
3222
- glossary_guid str
3223
- Identifier of the glossary to search within. If None, then all glossaries are searched.
3224
- status_filter: list, default = [], optional
3225
- Filters the results by the included Term statuses (such as 'ACTIVE', 'DRAFT'). If not specified,
3226
- the results will not be filtered.
3227
- effective_time: str, [default=None], optional
3228
- If specified, the term information will be retrieved if it is active at the `effective_time`.
3229
- Time format is "YYYY-MM-DDTHH:MM:SS" (ISO 8601)
2713
+ if page_size is None:
2714
+ page_size = self.page_size
3230
2715
 
3231
- If not provided, the server name associated with the instance is used.
3232
- starts_with : bool, [default=False], optional
3233
- Starts with the supplied string.
3234
- ends_with : bool, [default=False], optional
3235
- Ends with the supplied string
3236
- ignore_case : bool, [default=False], optional
3237
- Ignore case when searching
3238
- for_lineage : bool, [default=False], optional
2716
+ validate_name(term)
3239
2717
 
3240
- for_duplicate_processing : bool, [default=False], optional
2718
+ for_lineage_s = str(for_lineage).lower()
2719
+ for_duplicate_processing_s = str(for_duplicate_processing).lower()
3241
2720
 
3242
- start_from: str, [default=0], optional
3243
- Page of results to start from
3244
- page_size : int, optional
3245
- Number of elements to return per page - if None, then default for class will be used.
3246
- output_format: str, default = 'JSON'
3247
- Type of output to produce:
2721
+ body = {
2722
+ "class": "GlossaryNameRequestBody", "glossaryGUID": glossary_guid, "name": term,
2723
+ "effectiveTime": effective_time, "limitResultsByStatus": status_filter,
2724
+ }
2725
+ # body = body_slimmer(body)
2726
+
2727
+ url = (f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/"
2728
+ f"terms/by-name?startFrom={start_from}&pageSize={page_size}&"
2729
+ f"&forLineage={for_lineage_s}&forDuplicateProcessing={for_duplicate_processing_s}")
2730
+
2731
+ # print(f"\n\nURL is: \n {url}\n\nBody is: \n{body}")
2732
+
2733
+ response = await self._async_make_request("POST", url, body)
2734
+ return response.json().get("elementList", "No terms found")
2735
+
2736
+ def get_terms_by_name(self, term: str, glossary_guid: str = None, status_filter: list = [],
2737
+ effective_time: str = None, for_lineage: bool = False, for_duplicate_processing: bool = False,
2738
+ start_from: int = 0, page_size: int = None, ) -> list:
2739
+ """Retrieve glossary terms by display name or qualified name.
2740
+
2741
+ Parameters
2742
+ ----------
2743
+ term : str
2744
+ The term to search for in the glossaries.
2745
+ glossary_guid : str, optional
2746
+ The GUID of the glossary to search in. If not provided, the search will be performed in all glossaries.
2747
+ status_filter : list, optional
2748
+ A list of status values to filter the search results. Default is an empty list, which means no filtering.
2749
+
2750
+ effective_time : datetime, optional
2751
+ If specified, the term information will be retrieved if it is active at the `effective_time`.
2752
+ Time format is "YYYY-MM-DDTHH:MM:SS" (ISO 8601)
2753
+ for_lineage : bool, optional
2754
+ Flag to indicate whether the search should include lineage information. Default is False.
2755
+ for_duplicate_processing : bool, optional
2756
+ Flag to indicate whether the search should include duplicate processing information. Default is False.
2757
+ start_from : int, optional
2758
+ The index of the first term to retrieve. Default is 0.
2759
+ page_size : int, optional
2760
+ The number of terms to retrieve per page. If not provided, it will use the default page size.
2761
+
2762
+ Returns
2763
+ -------
2764
+ list
2765
+ A list of terms matching the search criteria. If no terms are found,
2766
+ it returns the string "No terms found".
2767
+
2768
+ Raises
2769
+ ------
2770
+ InvalidParameterException
2771
+ If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
2772
+ PropertyServerException
2773
+ Raised by the server when an issue arises in processing a valid request.
2774
+ NotAuthorizedException
2775
+ The principle specified by the user_id does not have authorization for the requested action.
2776
+ """
2777
+ loop = asyncio.get_event_loop()
2778
+ response = loop.run_until_complete(
2779
+ self._async_get_terms_by_name(term, glossary_guid, status_filter, effective_time, for_lineage,
2780
+ for_duplicate_processing, start_from, page_size, ))
2781
+ return response
2782
+
2783
+ async def _async_get_term_by_guid(self, term_guid: str, output_format: str = 'JSON') -> dict | str:
2784
+ """Retrieve a term using its unique id. Async version.
2785
+ Parameters
2786
+ ----------
2787
+ term_guid : str
2788
+ The GUID of the glossary term to retrieve.
2789
+ output_format: str, default = 'JSON'
2790
+ Type of output to produce:
3248
2791
  JSON - output standard json
3249
2792
  MD - output standard markdown with no preamble
3250
2793
  FORM - output markdown with a preamble for a form
3251
2794
  REPORT - output markdown with a preamble for a report
3252
2795
 
3253
- Returns
3254
- -------
3255
- List | str
3256
-
3257
- A list of term definitions
3258
-
3259
- Raises
3260
- ------
3261
- InvalidParameterException
3262
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values
3263
- PropertyServerException
3264
- Raised by the server when an issue arises in processing a valid request
3265
- NotAuthorizedException
3266
- The principle specified by the user_id does not have authorization for the requested action
3267
-
3268
- Notes
3269
- -----
3270
- The search string is located in the request body and is interpreted as a plain string.
3271
- The request parameters, startsWith, endsWith and ignoreCase can be used to allow a fuzzy search.
3272
- The request body also supports the specification of a glossaryGUID to restrict the search to within a single
3273
- glossary.
3274
- """
3275
-
3276
- if page_size is None:
3277
- page_size = self.page_size
3278
- if effective_time is None:
3279
- effective_time = datetime.now().isoformat()
3280
- starts_with_s = str(starts_with).lower()
3281
- ends_with_s = str(ends_with).lower()
3282
- ignore_case_s = str(ignore_case).lower()
3283
- for_lineage_s = str(for_lineage).lower()
3284
- for_duplicate_processing_s = str(for_duplicate_processing).lower()
3285
- if search_string == "*":
3286
- search_string = None
2796
+ Returns
2797
+ -------
2798
+ dict | str
2799
+ A dict detailing the glossary term represented by the GUID. If no term is found, the string
2800
+ "No term found" will be returned.
2801
+
2802
+ Raises
2803
+ ------
2804
+ InvalidParameterException
2805
+ If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
2806
+ PropertyServerException
2807
+ Raised by the server when an issue arises in processing a valid request.
2808
+ NotAuthorizedException
2809
+ The principle specified by the user_id does not have authorization for the requested action.
2810
+ """
2811
+ output_format = output_format.upper()
2812
+ validate_guid(term_guid)
2813
+
2814
+ url = (f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/terms/"
2815
+ f"{term_guid}/retrieve")
2816
+ response = await self._async_make_request("POST", url)
2817
+ term_element = response.json().get("element", NO_TERMS_FOUND)
2818
+ if term_element == NO_TERMS_FOUND:
2819
+ return NO_TERMS_FOUND
2820
+ if output_format != 'JSON': # return a simplified markdown representation
2821
+ return self.generate_terms_md(term_element, "GUID", output_format)
2822
+ return response.json().get("element", NO_TERMS_FOUND)
2823
+
2824
+ def get_term_by_guid(self, term_guid: str, output_format: str = 'JSON') -> dict | str:
2825
+ """Retrieve a term using its unique id. Async version.
2826
+ Parameters
2827
+ ----------
2828
+ term_guid : str
2829
+ The GUID of the glossary term to retrieve.
2830
+ output_format: str, default = 'JSON'
2831
+ Type of output to produce:
2832
+ JSON - output standard json
2833
+ MD - output standard markdown with no preamble
2834
+ FORM - output markdown with a preamble for a form
2835
+ REPORT - output markdown with a preamble for a report
2836
+ Returns
2837
+ -------
2838
+ dict | str
2839
+ A dict detailing the glossary term represented by the GUID. If no term is found, the string
2840
+ "No term found" will be returned.
2841
+ Raises
2842
+ ------
2843
+ InvalidParameterException
2844
+ If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
2845
+ PropertyServerException
2846
+ Raised by the server when an issue arises in processing a valid request.
2847
+ NotAuthorizedException
2848
+ The principle specified by the user_id does not have authorization for the requested action.
2849
+ """
3287
2850
 
3288
- # validate_search_string(search_string)
2851
+ loop = asyncio.get_event_loop()
2852
+ response = loop.run_until_complete(self._async_get_terms_by_guid(term_guid, output_format))
2853
+
2854
+ return response
2855
+
2856
+ async def _async_get_term_versions(self, term_guid: str, effective_time: str = None, from_time: str = None,
2857
+ to_time: str = None, oldest_first: bool = False, for_lineage: bool = False,
2858
+ for_duplicate_processing: bool = False, start_from: int = 0, page_size=max_paging_size,
2859
+
2860
+ ) -> list | str:
2861
+ """Retrieve the versions of a glossary term. Async version.
2862
+ Parameters
2863
+ ----------
2864
+ term_guid : str
2865
+ The GUID of the glossary term to retrieve.
2866
+
2867
+ start_from : int, optional
2868
+ The index of the first term to retrieve. Default is 0.
2869
+ page_size : int, optional
2870
+ The number of terms to retrieve per page. If not provided, it will use the default page size.
2871
+ Returns
2872
+ -------
2873
+ list | str
2874
+ A [dict] detailing the glossary term represented by the GUID. If no term is found, the string
2875
+ "No term found" will be returned.
2876
+
2877
+ Raises
2878
+ ------
2879
+ InvalidParameterException
2880
+ If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
2881
+ PropertyServerException
2882
+ Raised by the server when an issue arises in processing a valid request.
2883
+ NotAuthorizedException
2884
+ The principle specified by the user_id does not have authorization for the requested action.
2885
+
2886
+ Args:
2887
+ term_guid:
2888
+ effective_time:
2889
+ from_time:
2890
+ to_time:
2891
+ oldest_first:
2892
+ for_lineage:
2893
+ for_duplicate_processing:
2894
+ start_from:
2895
+ page_size:
2896
+ """
3289
2897
 
3290
- body = {
3291
- "class": "GlossarySearchStringRequestBody",
3292
- "glossaryGUID": glossary_guid,
3293
- "searchString": search_string,
3294
- "effectiveTime": effective_time,
3295
- "limitResultsByStatus": status_filter,
2898
+ body = {
2899
+ "effective_time": effective_time, "fromTime": from_time, "toTime": to_time, "forLineage": for_lineage,
2900
+ "forDuplicateProcessing": for_duplicate_processing
3296
2901
  }
3297
2902
 
3298
- url = (
3299
- f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/"
3300
- f"terms/by-search-string?startFrom={start_from}&pageSize={page_size}&startsWith={starts_with_s}&"
3301
- f"endsWith={ends_with_s}&ignoreCase={ignore_case_s}&forLineage={for_lineage_s}&"
3302
- f"forDuplicateProcessing={for_duplicate_processing_s}"
3303
- )
3304
-
3305
-
3306
- response = await self._async_make_request("POST", url, body_slimmer(body))
3307
- term_elements = response.json().get("elementList", NO_TERMS_FOUND)
3308
- if term_elements == NO_TERMS_FOUND:
3309
- return NO_TERMS_FOUND
3310
- if output_format != "JSON": # return a simplified markdown representation
3311
- return self.generate_terms_md(term_elements, search_string, output_format)
3312
- return response.json().get("elementList", NO_TERMS_FOUND)
3313
-
2903
+ oldest_first_s = str(oldest_first).lower()
2904
+ validate_guid(term_guid)
2905
+
2906
+ url = (f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/terms/"
2907
+ f"{term_guid}/history?startFrom={start_from}&pageSize={page_size}&oldestFirst={oldest_first_s}&"
2908
+ f"forDuplicateProcessing={for_duplicate_processing}&forLineage={for_lineage}")
2909
+
2910
+ response = await self._async_make_request("POST", url, body_slimmer(body))
2911
+ return response.json().get("elementList", "No term found")
2912
+
2913
+ def get_term_versions(self, term_guid: str, effective_time: str = None, from_time: str = None, to_time: str = None,
2914
+ oldest_first: bool = False, for_lineage: bool = False, for_duplicate_processing: bool = False,
2915
+ start_from: int = 0, page_size=max_paging_size, ) -> dict | str:
2916
+ """Retrieve the versions of a glossary term.
2917
+ Parameters
2918
+ ----------
2919
+ term_guid : str
2920
+ The GUID of the glossary term to retrieve.
2921
+
2922
+ start_from : int, optional
2923
+ The index of the first term to retrieve. Default is 0.
2924
+ page_size : int, optional
2925
+ The number of terms to retrieve per page. If not provided, it will use the default page size.
2926
+ Returns
2927
+ -------
2928
+ [dict] | str
2929
+ A [dict] detailing the glossary term represented by the GUID. If no term is found, the string
2930
+ "No term found" will be returned.
2931
+
2932
+ Raises
2933
+ ------
2934
+ InvalidParameterException
2935
+ If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
2936
+ PropertyServerException
2937
+ Raised by the server when an issue arises in processing a valid request.
2938
+ NotAuthorizedException
2939
+ The principle specified by the user_id does not have authorization for the requested action.
2940
+ """
3314
2941
 
3315
- def find_glossary_terms(
3316
- self,
3317
- search_string: str,
3318
- glossary_guid: str = None,
3319
- status_filter: list = [],
3320
- effective_time: str = None,
3321
- starts_with: bool = False,
3322
- ends_with: bool = False,
3323
- ignore_case: bool = False,
3324
- for_lineage: bool = False,
3325
- for_duplicate_processing: bool = False,
3326
- start_from: int = 0,
3327
- page_size: int = None,
3328
- output_format: str = "JSON",
3329
- ) -> list | str:
3330
- """Retrieve the list of glossary term metadata elements that contain the search string.
2942
+ loop = asyncio.get_event_loop()
2943
+ response = loop.run_until_complete(
2944
+ self._async_get_term_versions(term_guid, effective_time, from_time, to_time, oldest_first, for_lineage,
2945
+ for_duplicate_processing, start_from, page_size))
2946
+
2947
+ return response
2948
+
2949
+ async def _async_get_term_revision_logs(self, term_guid: str, start_from: int = 0, page_size=None, ) -> dict | str:
2950
+ """Retrieve the revision log history for a term. Async version.
2951
+ Parameters
2952
+ ----------
2953
+ term_guid : str
2954
+ The GUID of the glossary term to retrieve.
2955
+
2956
+ start_from : int, optional
2957
+ The index of the first term to retrieve. Default is 0.
2958
+ page_size : int, optional
2959
+ The number of terms to retrieve per page. If not provided, it will use the default page size.
2960
+ Returns
2961
+ -------
2962
+ dict | str
2963
+ A dict detailing the glossary term revision log history. If no term is found, the string
2964
+ "No log found" will be returned.
2965
+
2966
+ Raises
2967
+ ------
2968
+ InvalidParameterException
2969
+ If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
2970
+ PropertyServerException
2971
+ Raised by the server when an issue arises in processing a valid request.
2972
+ NotAuthorizedException
2973
+ The principle specified by the user_id does not have authorization for the requested action.
2974
+ """
3331
2975
 
3332
- Parameters
3333
- ----------
3334
- search_string: str
3335
- Search string to use to find matching glossaries. If the search string is '*' then all glossaries
3336
- returned.
3337
- glossary_guid str
3338
- Identifier of the glossary to search within. If None, then all glossaries are searched.
3339
- status_filter: list, default = [], optional
3340
- Filters the results by the included Term statuses (such as 'ACTIVE', 'DRAFT'). If not specified,
3341
- the results will not be filtered.
3342
- effective_time: str, [default=None], optional
3343
- If specified, the term information will be retrieved if it is active at the `effective_time`.
3344
- Time format is "YYYY-MM-DDTHH:MM:SS" (ISO 8601)
2976
+ if page_size is None:
2977
+ page_size = self.page_size
2978
+
2979
+ validate_guid(term_guid)
2980
+
2981
+ url = (f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/elements/"
2982
+ f"{term_guid}/note-logs/retrieve?startFrom={start_from}&pageSize={page_size}")
2983
+
2984
+ response = await self._async_make_request("POST", url)
2985
+ return response.json().get("elementList", "No log found")
2986
+
2987
+ def get_term_revision_logs(self, term_guid: str, start_from: int = 0, page_size=None, ) -> dict | str:
2988
+ """Retrieve the revision log history for a term.
2989
+ Parameters
2990
+ ----------
2991
+ term_guid : str
2992
+ The GUID of the glossary term to retrieve.
2993
+
2994
+ start_from : int, optional
2995
+ The index of the first term to retrieve. Default is 0.
2996
+ page_size : int, optional
2997
+ The number of terms to retrieve per page. If not provided, it will use the default page size.
2998
+ Returns
2999
+ -------
3000
+ dict | str
3001
+ A dict detailing the glossary term revision log history. If no term is found, the string
3002
+ "No log found" will be returned.
3003
+
3004
+ Raises
3005
+ ------
3006
+ InvalidParameterException
3007
+ If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
3008
+ PropertyServerException
3009
+ Raised by the server when an issue arises in processing a valid request.
3010
+ NotAuthorizedException
3011
+ The principle specified by the user_id does not have authorization for the requested action.
3012
+ """
3345
3013
 
3346
- If not provided, the server name associated with the instance is used.
3347
- starts_with : bool, [default=False], optional
3348
- Starts with the supplied string.
3349
- ends_with : bool, [default=False], optional
3350
- Ends with the supplied string
3351
- ignore_case : bool, [default=False], optional
3352
- Ignore case when searching
3353
- for_lineage : bool, [default=False], optional
3014
+ loop = asyncio.get_event_loop()
3015
+ response = loop.run_until_complete(self._async_get_term_revision_logs(term_guid, start_from, page_size))
3016
+
3017
+ return response
3018
+
3019
+ async def _async_get_term_revision_history(self, term_revision_log_guid: str, start_from: int = 0,
3020
+ page_size=None, ) -> dict | str:
3021
+ """Retrieve the revision history for a glossary term. Async version.
3022
+
3023
+ Parameters
3024
+ ----------
3025
+ term_revision_log_guid : str
3026
+ The GUID of the glossary term revision log to retrieve.
3027
+
3028
+ start_from : int, optional
3029
+ The index of the first term to retrieve. Default is 0.
3030
+ page_size : int, optional
3031
+ The number of terms to retrieve per page. If not provided, it will use the default page size.
3032
+ Returns
3033
+ -------
3034
+ dict | str
3035
+ A dict detailing the glossary term revision history.
3036
+
3037
+ Raises
3038
+ ------
3039
+ InvalidParameterException
3040
+ If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
3041
+ PropertyServerException
3042
+ Raised by the server when an issue arises in processing a valid request.
3043
+ NotAuthorizedException
3044
+ The principle specified by the user_id does not have authorization for the requested action.
3045
+
3046
+
3047
+ Notes
3048
+ -----
3049
+ This revision history is created automatically. The text is supplied on the update request.
3050
+ If no text is supplied, the value "None" is show.
3051
+ """
3354
3052
 
3355
- for_duplicate_processing : bool, [default=False], optional
3053
+ if page_size is None:
3054
+ page_size = self.page_size
3055
+
3056
+ validate_guid(term_revision_log_guid)
3057
+
3058
+ url = (f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/note-logs/"
3059
+ f"{term_revision_log_guid}/notes/retrieve?startFrom={start_from}&pageSize={page_size}")
3060
+
3061
+ response = await self._async_make_request("POST", url)
3062
+ return response.json().get("elementList", "No logs found")
3063
+
3064
+ def get_term_revision_history(self, term_revision_log_guid: str, start_from: int = 0,
3065
+ page_size=None, ) -> dict | str:
3066
+ """Retrieve the revision history for a glossary term.
3067
+
3068
+ Parameters
3069
+ ----------
3070
+ term_revision_log_guid : str
3071
+ The GUID of the glossary term revision log to retrieve.
3072
+
3073
+ start_from : int, optional
3074
+ The index of the first term to retrieve. Default is 0.
3075
+ page_size : int, optional
3076
+ The number of terms to retrieve per page. If not provided, it will use the default page size.
3077
+ Returns
3078
+ -------
3079
+ dict | str
3080
+ A dict detailing the glossary term revision history.
3081
+
3082
+ Raises
3083
+ ------
3084
+ InvalidParameterException
3085
+ If the client passes incorrect parameters on the request - such as bad URLs or invalid values.
3086
+ PropertyServerException
3087
+ Raised by the server when an issue arises in processing a valid request.
3088
+ NotAuthorizedException
3089
+ The principle specified by the user_id does not have authorization for the requested action.
3090
+
3091
+
3092
+ Notes
3093
+ -----
3094
+ This revision history is created automatically. The text is supplied on the update request.
3095
+ If no text is supplied, the value "None" is show.
3096
+ """
3356
3097
 
3357
- start_from: str, [default=0], optional
3358
- Page of results to start from
3359
- page_size : int, optional
3360
- Number of elements to return per page - if None, then default for class will be used.
3361
- output_format: str, default = 'JSON'
3362
- Type of output to produce:
3363
- JSON - output standard json
3364
- MD - output standard markdown with no preamble
3365
- FORM - output markdown with a preamble for a form
3366
- REPORT - output markdown with a preamble for a report
3098
+ loop = asyncio.get_event_loop()
3099
+ response = loop.run_until_complete(
3100
+ self._async_get_term_revision_history(term_revision_log_guid, start_from, page_size))
3367
3101
 
3368
- Returns
3369
- -------
3370
- List | str
3102
+ return response
3371
3103
 
3372
- A list of term definitions
3373
3104
 
3374
- Raises
3375
- ------
3376
- InvalidParameterException
3377
- If the client passes incorrect parameters on the request - such as bad URLs or invalid values
3378
- PropertyServerException
3379
- Raised by the server when an issue arises in processing a valid request
3380
- NotAuthorizedException
3381
- The principle specified by the user_id does not have authorization for the requested action
3105
+ def list_full_term_history(self, term_guid: str, output_type: str = "DICT") -> list | str:
3106
+ """
3107
+ Retrieves and formats the entire version history of a specific term in the repository.
3108
+ The version history is either returned as a list of dictionaries or in a Markdown table
3109
+ format.
3110
+
3111
+ The returned history includes details about the creation and update timestamps, user
3112
+ information, and additional glossary term properties such as `displayName`,
3113
+ `qualifiedName`, `description`, and others.
3114
+
3115
+ Parameter
3116
+ ---------
3117
+ term_guid: The unique identifier of the glossary term for which the version
3118
+ history needs to be retrieved.
3119
+ output_type: The format in which the history should be returned. It can be
3120
+ either "DICT" (a list of dictionaries) or "LIST" (a Markdown table).
3121
+ Defaults to "DICT".
3122
+
3123
+ Returns
3124
+ -------
3125
+ list | str: A list of dictionaries representing the version history
3126
+ (if output_type is "DICT"), or a Markdown table of the version details
3127
+ (if output_type is "LIST"). If no history is found, returns a string
3128
+ message "No History Found".
3129
+ """
3130
+ history = self.get_term_versions(term_guid)
3131
+ if type(history) is str:
3132
+ return "No History Found"
3133
+ version_history = []
3134
+ for ver in history:
3135
+ create_time = ver["elementHeader"]["versions"].get("createTime", "---")
3136
+ update_time = ver["elementHeader"]["versions"].get("createTime", "---")
3137
+ created_by = ver["elementHeader"]["versions"].get("createdBy", "---")
3138
+ updated_by = ver["elementHeader"]["versions"].get("updatedBy", "---")
3139
+ version = ver["elementHeader"]["versions"].get("version")
3140
+
3141
+ qualified_name = ver["glossaryTermProperties"].get("qualifiedName", '---')
3142
+ display_name = ver["glossaryTermProperties"].get("displayName", '---')
3143
+ summary = ver["glossaryTermProperties"].get("summary", '---')
3144
+ description = ver["glossaryTermProperties"].get("description", '---')
3145
+ examples = ver["glossaryTermProperties"].get("examples", '---')
3146
+ usage = ver["glossaryTermProperties"].get("usage", '---')
3147
+ version_identifier = ver["glossaryTermProperties"].get("versionIdentifier", '---')
3148
+
3149
+ version_history.append({
3150
+ "version": version, "displayName": display_name, "summary": summary, "created": create_time,
3151
+ "updated": update_time, "createdBy": created_by, "updatedBy": updated_by,
3152
+ "qualifiedName": qualified_name, "description": description, "examples": examples, "usage": usage,
3153
+ "versionIdentifier": version_identifier,
3154
+ })
3155
+ sorted_history = sorted(version_history, key=lambda i: i['version'], reverse=True)
3156
+ if output_type == "DICT":
3157
+ return sorted_history
3158
+ elif output_type == "LIST":
3159
+ # Get the headers from the keys of the first dictionary
3160
+ headers = sorted_history[0].keys()
3161
+
3162
+ # Create the header row
3163
+ header_row = " | ".join(headers)
3164
+ separator_row = " | ".join(["---"] * len(headers)) # Markdown separator row
3165
+
3166
+ # Create the rows for the table
3167
+ rows = []
3168
+ for entry in sorted_history:
3169
+ row = " | ".join(str(entry.get(header, "---")) for header in headers)
3170
+ rows.append(row)
3171
+
3172
+ # Combine everything into a Markdown table string
3173
+ markdown_table = f"{header_row}\n{separator_row}\n" + "\n".join(rows)
3174
+ return markdown_table
3175
+
3176
+ async def _async_find_glossary_terms(self, search_string: str, glossary_guid: str = None, status_filter: list = [],
3177
+ effective_time: str = None, starts_with: bool = False, ends_with: bool = False, ignore_case: bool = False,
3178
+ for_lineage: bool = False, for_duplicate_processing: bool = False, start_from: int = 0,
3179
+ page_size: int = None, output_format: str = "JSON", ) -> list | str:
3180
+ """Retrieve the list of glossary term metadata elements that contain the search string.
3181
+
3182
+ Parameters
3183
+ ----------
3184
+ search_string: str
3185
+ Search string to use to find matching glossaries. If the search string is '*' then all glossaries returned.
3186
+ glossary_guid str
3187
+ Identifier of the glossary to search within. If None, then all glossaries are searched.
3188
+ status_filter: list, default = [], optional
3189
+ Filters the results by the included Term statuses (such as 'ACTIVE', 'DRAFT'). If not specified,
3190
+ the results will not be filtered.
3191
+ effective_time: str, [default=None], optional
3192
+ If specified, the term information will be retrieved if it is active at the `effective_time`.
3193
+ Time format is "YYYY-MM-DDTHH:MM:SS" (ISO 8601)
3194
+
3195
+ If not provided, the server name associated with the instance is used.
3196
+ starts_with : bool, [default=False], optional
3197
+ Starts with the supplied string.
3198
+ ends_with : bool, [default=False], optional
3199
+ Ends with the supplied string
3200
+ ignore_case : bool, [default=False], optional
3201
+ Ignore case when searching
3202
+ for_lineage : bool, [default=False], optional
3203
+
3204
+ for_duplicate_processing : bool, [default=False], optional
3205
+
3206
+ start_from: str, [default=0], optional
3207
+ Page of results to start from
3208
+ page_size : int, optional
3209
+ Number of elements to return per page - if None, then default for class will be used.
3210
+ output_format: str, default = 'JSON'
3211
+ Type of output to produce:
3212
+ JSON - output standard json
3213
+ MD - output standard markdown with no preamble
3214
+ FORM - output markdown with a preamble for a form
3215
+ REPORT - output markdown with a preamble for a report
3216
+
3217
+ Returns
3218
+ -------
3219
+ List | str
3220
+
3221
+ A list of term definitions
3222
+
3223
+ Raises
3224
+ ------
3225
+ InvalidParameterException
3226
+ If the client passes incorrect parameters on the request - such as bad URLs or invalid values
3227
+ PropertyServerException
3228
+ Raised by the server when an issue arises in processing a valid request
3229
+ NotAuthorizedException
3230
+ The principle specified by the user_id does not have authorization for the requested action
3231
+
3232
+ Notes
3233
+ -----
3234
+ The search string is located in the request body and is interpreted as a plain string.
3235
+ The request parameters, startsWith, endsWith and ignoreCase can be used to allow a fuzzy search.
3236
+ The request body also supports the specification of a glossaryGUID to restrict the search to within a single
3237
+ glossary.
3238
+ """
3382
3239
 
3383
- Notes
3384
- -----
3385
- The search string is located in the request body and is interpreted as a plain string.
3386
- The request parameters, startsWith, endsWith and ignoreCase can be used to allow a fuzzy search.
3387
- The request body also supports the specification of a glossaryGUID to restrict the search to within a
3388
- single glossary.
3389
- """
3240
+ if page_size is None:
3241
+ page_size = self.page_size
3242
+ if effective_time is None:
3243
+ effective_time = datetime.now().isoformat()
3244
+ starts_with_s = str(starts_with).lower()
3245
+ ends_with_s = str(ends_with).lower()
3246
+ ignore_case_s = str(ignore_case).lower()
3247
+ for_lineage_s = str(for_lineage).lower()
3248
+ for_duplicate_processing_s = str(for_duplicate_processing).lower()
3249
+ if search_string == "*":
3250
+ search_string = None
3251
+
3252
+ # validate_search_string(search_string)
3253
+
3254
+ body = {
3255
+ "class": "GlossarySearchStringRequestBody", "glossaryGUID": glossary_guid, "searchString": search_string,
3256
+ "effectiveTime": effective_time, "limitResultsByStatus": status_filter,
3257
+ }
3390
3258
 
3391
- loop = asyncio.get_event_loop()
3392
- response = loop.run_until_complete(
3393
- self._async_find_glossary_terms(
3394
- search_string,
3395
- glossary_guid,
3396
- status_filter,
3397
- effective_time,
3398
- starts_with,
3399
- ends_with,
3400
- ignore_case,
3401
- for_lineage,
3402
- for_duplicate_processing,
3403
- start_from,
3404
- page_size,
3405
- output_format
3406
- )
3407
- )
3259
+ url = (f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/"
3260
+ f"terms/by-search-string?startFrom={start_from}&pageSize={page_size}&startsWith={starts_with_s}&"
3261
+ f"endsWith={ends_with_s}&ignoreCase={ignore_case_s}&forLineage={for_lineage_s}&"
3262
+ f"forDuplicateProcessing={for_duplicate_processing_s}")
3408
3263
 
3409
- return response
3264
+ response = await self._async_make_request("POST", url, body_slimmer(body))
3265
+ term_elements = response.json().get("elementList", NO_TERMS_FOUND)
3266
+ if term_elements == NO_TERMS_FOUND:
3267
+ if output_format == 'JSON':
3268
+ return NO_TERMS_FOUND
3269
+ elif output_format in ['MD', 'FORM', 'REPORT', 'LIST']:
3270
+ return "\n# No Terms found.\n"
3271
+ elif output_format == 'DICT':
3272
+ return None
3273
+ if output_format != "JSON": # return a simplified markdown representation
3274
+ return self.generate_terms_md(term_elements, search_string, output_format)
3275
+ return response.json().get("elementList", NO_TERMS_FOUND)
3276
+
3277
+ def find_glossary_terms(self, search_string: str, glossary_guid: str = None, status_filter: list = [],
3278
+ effective_time: str = None, starts_with: bool = False, ends_with: bool = False, ignore_case: bool = False,
3279
+ for_lineage: bool = False, for_duplicate_processing: bool = False, start_from: int = 0,
3280
+ page_size: int = None, output_format: str = "JSON", ) -> list | str:
3281
+ """Retrieve the list of glossary term metadata elements that contain the search string.
3282
+
3283
+ Parameters
3284
+ ----------
3285
+ search_string: str
3286
+ Search string to use to find matching glossaries. If the search string is '*' then all glossaries
3287
+ returned.
3288
+ glossary_guid str
3289
+ Identifier of the glossary to search within. If None, then all glossaries are searched.
3290
+ status_filter: list, default = [], optional
3291
+ Filters the results by the included Term statuses (such as 'ACTIVE', 'DRAFT'). If not specified,
3292
+ the results will not be filtered.
3293
+ effective_time: str, [default=None], optional
3294
+ If specified, the term information will be retrieved if it is active at the `effective_time`.
3295
+ Time format is "YYYY-MM-DDTHH:MM:SS" (ISO 8601)
3296
+
3297
+ If not provided, the server name associated with the instance is used.
3298
+ starts_with : bool, [default=False], optional
3299
+ Starts with the supplied string.
3300
+ ends_with : bool, [default=False], optional
3301
+ Ends with the supplied string
3302
+ ignore_case : bool, [default=False], optional
3303
+ Ignore case when searching
3304
+ for_lineage : bool, [default=False], optional
3305
+
3306
+ for_duplicate_processing : bool, [default=False], optional
3307
+
3308
+ start_from: str, [default=0], optional
3309
+ Page of results to start from
3310
+ page_size : int, optional
3311
+ Number of elements to return per page - if None, then default for class will be used.
3312
+ output_format: str, default = 'JSON'
3313
+ Type of output to produce:
3314
+ JSON - output standard json
3315
+ MD - output standard markdown with no preamble
3316
+ FORM - output markdown with a preamble for a form
3317
+ REPORT - output markdown with a preamble for a report
3318
+
3319
+ Returns
3320
+ -------
3321
+ List | str
3322
+
3323
+ A list of term definitions
3324
+
3325
+ Raises
3326
+ ------
3327
+ InvalidParameterException
3328
+ If the client passes incorrect parameters on the request - such as bad URLs or invalid values
3329
+ PropertyServerException
3330
+ Raised by the server when an issue arises in processing a valid request
3331
+ NotAuthorizedException
3332
+ The principle specified by the user_id does not have authorization for the requested action
3333
+
3334
+ Notes
3335
+ -----
3336
+ The search string is located in the request body and is interpreted as a plain string.
3337
+ The request parameters, startsWith, endsWith and ignoreCase can be used to allow a fuzzy search.
3338
+ The request body also supports the specification of a glossaryGUID to restrict the search to within a
3339
+ single glossary.
3340
+ """
3410
3341
 
3411
- #
3412
- # Feedback
3413
- #
3414
- async def _async_get_comment(
3415
- self,
3416
- commemt_guid: str,
3417
- effective_time: str,
3418
- for_lineage: bool = False,
3419
- for_duplicate_processing: bool = False,
3420
- ) -> dict | list:
3421
- """Retrieve the comment specified by the comment GUID"""
3342
+ loop = asyncio.get_event_loop()
3343
+ response = loop.run_until_complete(
3344
+ self._async_find_glossary_terms(search_string, glossary_guid, status_filter, effective_time, starts_with,
3345
+ ends_with, ignore_case, for_lineage, for_duplicate_processing, start_from, page_size, output_format))
3422
3346
 
3423
- validate_guid(commemt_guid)
3347
+ return response
3424
3348
 
3425
- if effective_time is None:
3426
- effective_time = datetime.now().isoformat()
3349
+ #
3350
+ # Feedback
3351
+ #
3352
+ async def _async_get_comment(self, commemt_guid: str, effective_time: str, for_lineage: bool = False,
3353
+ for_duplicate_processing: bool = False, ) -> dict | list:
3354
+ """Retrieve the comment specified by the comment GUID"""
3427
3355
 
3428
- for_lineage_s = str(for_lineage).lower()
3429
- for_duplicate_processing_s = str(for_duplicate_processing).lower()
3356
+ validate_guid(commemt_guid)
3430
3357
 
3431
- body = {"effective_time": effective_time}
3358
+ if effective_time is None:
3359
+ effective_time = datetime.now().isoformat()
3432
3360
 
3433
- url = (
3434
- f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/comments/"
3435
- f"{commemt_guid}?forLineage={for_lineage_s}&"
3436
- f"forDuplicateProcessing={for_duplicate_processing_s}"
3437
- )
3361
+ for_lineage_s = str(for_lineage).lower()
3362
+ for_duplicate_processing_s = str(for_duplicate_processing).lower()
3438
3363
 
3439
- # print(f"\n\nURL is: \n {url}\n\nBody is: \n{body}")
3364
+ body = {"effective_time": effective_time}
3440
3365
 
3441
- response = await self._async_make_request("POST", url, body)
3442
- return response.json()
3443
-
3444
- async def _async_add_comment_reply(
3445
- self,
3446
- comment_guid: str,
3447
- is_public: bool,
3448
- comment_type: str,
3449
- comment_text: str,
3450
- for_lineage: bool = False,
3451
- for_duplicate_processing: bool = False,
3452
- ) -> str:
3453
- """Reply to a comment"""
3454
-
3455
- validate_guid(comment_guid)
3456
- validate_name(comment_type)
3457
-
3458
- is_public_s = str(is_public).lower()
3459
- for_lineage_s = str(for_lineage).lower()
3460
- for_duplicate_processing_s = str(for_duplicate_processing).lower()
3366
+ url = (f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/comments/"
3367
+ f"{commemt_guid}?forLineage={for_lineage_s}&"
3368
+ f"forDuplicateProcessing={for_duplicate_processing_s}")
3461
3369
 
3462
- body = {
3463
- "class": "CommentRequestBody",
3464
- "commentType": comment_type,
3465
- "commentText": comment_text,
3466
- "isPublic": is_public,
3467
- }
3370
+ # print(f"\n\nURL is: \n {url}\n\nBody is: \n{body}")
3468
3371
 
3469
- url = (
3470
- f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/comments/"
3471
- f"{comment_guid}/replies?isPublic={is_public_s}&forLineage={for_lineage_s}&"
3472
- f"forDuplicateProcessing={for_duplicate_processing_s}"
3473
- )
3372
+ response = await self._async_make_request("POST", url, body)
3373
+ return response.json()
3474
3374
 
3475
- # print(f"\n\nURL is: \n {url}\n\nBody is: \n{body}")
3375
+ async def _async_add_comment_reply(self, comment_guid: str, is_public: bool, comment_type: str, comment_text: str,
3376
+ for_lineage: bool = False, for_duplicate_processing: bool = False, ) -> str:
3377
+ """Reply to a comment"""
3476
3378
 
3477
- response = await self._async_make_request("POST", url, body)
3478
- return response
3379
+ validate_guid(comment_guid)
3380
+ validate_name(comment_type)
3479
3381
 
3480
- async def _async_update_comment(
3481
- self,
3482
- comment_guid: str,
3483
- is_public: bool,
3484
- comment_type: str,
3485
- comment_text: str,
3486
- is_merge_update: bool = False,
3487
- for_lineage: bool = False,
3488
- for_duplicate_processing: bool = False,
3489
- ) -> str:
3490
- """Update the specified comment"""
3491
-
3492
- validate_guid(comment_guid)
3493
- validate_name(comment_type)
3494
-
3495
- is_public_s = str(is_public).lower()
3496
- for_lineage_s = str(for_lineage).lower()
3497
- for_duplicate_processing_s = str(for_duplicate_processing).lower()
3382
+ is_public_s = str(is_public).lower()
3383
+ for_lineage_s = str(for_lineage).lower()
3384
+ for_duplicate_processing_s = str(for_duplicate_processing).lower()
3498
3385
 
3499
- body = {
3500
- "class": "CommentRequestBody",
3501
- "commentType": comment_type,
3502
- "commentText": comment_text,
3503
- "isPublic": is_public,
3386
+ body = {
3387
+ "class": "CommentRequestBody", "commentType": comment_type, "commentText": comment_text,
3388
+ "isPublic": is_public,
3504
3389
  }
3505
3390
 
3506
- url = (
3507
- f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/comments/"
3508
- f"{comment_guid}/replies?isPublic={is_public_s}&forLineage={for_lineage_s}&"
3509
- f"forDuplicateProcessing={for_duplicate_processing_s}"
3510
- )
3391
+ url = (f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/comments/"
3392
+ f"{comment_guid}/replies?isPublic={is_public_s}&forLineage={for_lineage_s}&"
3393
+ f"forDuplicateProcessing={for_duplicate_processing_s}")
3511
3394
 
3512
- # print(f"\n\nURL is: \n {url}\n\nBody is: \n{body}")
3395
+ # print(f"\n\nURL is: \n {url}\n\nBody is: \n{body}")
3513
3396
 
3514
- response = await self._async_make_request("POST", url, body)
3515
- return response
3397
+ response = await self._async_make_request("POST", url, body)
3398
+ return response
3516
3399
 
3517
- async def _async_find_comment(
3518
- self,
3519
- search_string: str,
3520
- glossary_guid: str = None,
3521
- status_filter: list = [],
3522
- effective_time: str = None,
3523
- starts_with: bool = False,
3524
- ends_with: bool = False,
3525
- ignore_case: bool = False,
3526
- for_lineage: bool = False,
3527
- for_duplicate_processing: bool = False,
3528
- start_from: int = 0,
3529
- page_size: int = None,
3530
- ):
3531
- """Find comments by search string"""
3400
+ async def _async_update_comment(self, comment_guid: str, is_public: bool, comment_type: str, comment_text: str,
3401
+ is_merge_update: bool = False, for_lineage: bool = False, for_duplicate_processing: bool = False, ) -> str:
3402
+ """Update the specified comment"""
3532
3403
 
3533
- if page_size is None:
3534
- page_size = self.page_size
3535
- if effective_time is None:
3536
- effective_time = datetime.now().isoformat()
3537
- starts_with_s = str(starts_with).lower()
3538
- ends_with_s = str(ends_with).lower()
3539
- ignore_case_s = str(ignore_case).lower()
3540
- for_lineage_s = str(for_lineage).lower()
3541
- for_duplicate_processing_s = str(for_duplicate_processing).lower()
3542
- if search_string == "*":
3543
- search_string = None
3404
+ validate_guid(comment_guid)
3405
+ validate_name(comment_type)
3544
3406
 
3545
- # validate_search_string(search_string)
3407
+ is_public_s = str(is_public).lower()
3408
+ for_lineage_s = str(for_lineage).lower()
3409
+ for_duplicate_processing_s = str(for_duplicate_processing).lower()
3546
3410
 
3547
- body = {
3548
- "class": "GlossarySearchStringRequestBody",
3549
- "glossaryGUID": glossary_guid,
3550
- "searchString": search_string,
3551
- "effectiveTime": effective_time,
3552
- "limitResultsByStatus": status_filter,
3411
+ body = {
3412
+ "class": "CommentRequestBody", "commentType": comment_type, "commentText": comment_text,
3413
+ "isPublic": is_public,
3553
3414
  }
3554
- # body = body_slimmer(body)
3555
3415
 
3556
- url = (
3557
- f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/"
3558
- f"terms/by-search-string?startFrom={start_from}&pageSize={page_size}&startsWith={starts_with_s}&"
3559
- f"endsWith={ends_with_s}&ignoreCase={ignore_case_s}&forLineage={for_lineage_s}&"
3560
- f"forDuplicateProcessing={for_duplicate_processing_s}"
3561
- )
3416
+ url = (f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/comments/"
3417
+ f"{comment_guid}/replies?isPublic={is_public_s}&forLineage={for_lineage_s}&"
3418
+ f"forDuplicateProcessing={for_duplicate_processing_s}")
3419
+
3420
+ # print(f"\n\nURL is: \n {url}\n\nBody is: \n{body}")
3421
+
3422
+ response = await self._async_make_request("POST", url, body)
3423
+ return response
3424
+
3425
+ async def _async_find_comment(self, search_string: str, glossary_guid: str = None, status_filter: list = [],
3426
+ effective_time: str = None, starts_with: bool = False, ends_with: bool = False, ignore_case: bool = False,
3427
+ for_lineage: bool = False, for_duplicate_processing: bool = False, start_from: int = 0,
3428
+ page_size: int = None, ):
3429
+ """Find comments by search string"""
3430
+
3431
+ if page_size is None:
3432
+ page_size = self.page_size
3433
+ if effective_time is None:
3434
+ effective_time = datetime.now().isoformat()
3435
+ starts_with_s = str(starts_with).lower()
3436
+ ends_with_s = str(ends_with).lower()
3437
+ ignore_case_s = str(ignore_case).lower()
3438
+ for_lineage_s = str(for_lineage).lower()
3439
+ for_duplicate_processing_s = str(for_duplicate_processing).lower()
3440
+ if search_string == "*":
3441
+ search_string = None
3442
+
3443
+ # validate_search_string(search_string)
3444
+
3445
+ body = {
3446
+ "class": "GlossarySearchStringRequestBody", "glossaryGUID": glossary_guid, "searchString": search_string,
3447
+ "effectiveTime": effective_time, "limitResultsByStatus": status_filter,
3448
+ }
3449
+ # body = body_slimmer(body)
3562
3450
 
3563
- # print(f"\n\nURL is: \n {url}\n\nBody is: \n{body}")
3451
+ url = (f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/"
3452
+ f"terms/by-search-string?startFrom={start_from}&pageSize={page_size}&startsWith={starts_with_s}&"
3453
+ f"endsWith={ends_with_s}&ignoreCase={ignore_case_s}&forLineage={for_lineage_s}&"
3454
+ f"forDuplicateProcessing={for_duplicate_processing_s}")
3564
3455
 
3565
- response = await self._async_make_request("POST", url, body)
3566
- return response.json().get("elementList", "No terms found")
3456
+ # print(f"\n\nURL is: \n {url}\n\nBody is: \n{body}")
3457
+
3458
+ response = await self._async_make_request("POST", url, body)
3459
+ return response.json().get("elementList", "No terms found")
3567
3460
 
3568
3461
 
3569
3462
  if __name__ == "__main__":