pyegeria 5.3.5.3__py3-none-any.whl → 5.3.6.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyegeria/commands/cat/freddie_jup.py +124 -0
- pyegeria/commands/cat/freddie_jupyter.py +34 -27
- pyegeria/commands/cat/freddie_md.py +45 -42
- pyegeria/commands/cat/freddie_utils.py +113 -53
- pyegeria/commands/cat/freddies-inbox/freddie_intro.md +221 -0
- pyegeria/commands/cat/freddies-inbox/glossary_creation_experiment.ipynb +341 -0
- pyegeria/commands/cat/freddies-inbox/glossary_exp.md +158 -0
- pyegeria/commands/cat/freddies-outbox/Terms-2025-03-06-13-19-29-Report.md +69 -0
- pyegeria/commands/cat/freddies-outbox/Terms-2025-03-06-13-20-30-Update-Form.md +78 -0
- pyegeria/commands/cat/glossary_creation_experiment.ipynb +235 -0
- pyegeria/commands/cat/list_glossaries.py +40 -1
- pyegeria/commands/cat/list_terms.py +49 -2
- pyegeria/commands/cli/egeria.py +48 -2
- pyegeria/commands/cli/egeria_cat.py +30 -2
- pyegeria/commands/cli/ops_config.py +4 -0
- pyegeria/glossary_browser_omvs.py +123 -10
- pyegeria/glossary_manager_omvs.py +0 -365
- {pyegeria-5.3.5.3.dist-info → pyegeria-5.3.6.2.dist-info}/METADATA +1 -1
- {pyegeria-5.3.5.3.dist-info → pyegeria-5.3.6.2.dist-info}/RECORD +22 -15
- {pyegeria-5.3.5.3.dist-info → pyegeria-5.3.6.2.dist-info}/LICENSE +0 -0
- {pyegeria-5.3.5.3.dist-info → pyegeria-5.3.6.2.dist-info}/WHEEL +0 -0
- {pyegeria-5.3.5.3.dist-info → pyegeria-5.3.6.2.dist-info}/entry_points.txt +0 -0
@@ -10,12 +10,13 @@ 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
|
14
|
-
|
13
|
+
from pyegeria import NO_GLOSSARIES_FOUND, NO_CATEGORIES_FOUND, NO_TERMS_FOUND
|
14
|
+
import json
|
15
15
|
from pyegeria._client import Client
|
16
16
|
from pyegeria._validators import validate_guid, validate_name, validate_search_string
|
17
17
|
from pyegeria.utils import body_slimmer
|
18
18
|
from pyegeria._globals import NO_ELEMENTS_FOUND
|
19
|
+
MD_SEPERATOR = "\n---\n\n"
|
19
20
|
|
20
21
|
class GlossaryBrowser(Client):
|
21
22
|
"""
|
@@ -52,6 +53,79 @@ class GlossaryBrowser(Client):
|
|
52
53
|
|
53
54
|
Client.__init__(self, view_server, platform_url, user_id, user_pwd, token)
|
54
55
|
|
56
|
+
def generate_glossaries_md(self, elements: list, search_string: str, form:bool = True)-> str:
|
57
|
+
if form:
|
58
|
+
elements_md = f"# Update Glossaries Form - created at {datetime.now().strftime('%Y-%m-%d %H:%M')}\n"
|
59
|
+
elements_action = "Update Glossary"
|
60
|
+
else:
|
61
|
+
elements_md = f"# Glossaries Report - created at {datetime.now().strftime('%Y-%m-%d %H:%M')}\n"
|
62
|
+
elements_action = None
|
63
|
+
search_string = search_string if search_string else "All Glossaries"
|
64
|
+
elements_md += f"Glossaries found from the search string: `{search_string}`\n\n"
|
65
|
+
|
66
|
+
for element in elements:
|
67
|
+
guid = element['elementHeader'].get("guid", None)
|
68
|
+
properties = element['glossaryProperties']
|
69
|
+
display_name = properties.get("displayName", None)
|
70
|
+
description = properties.get("description", None)
|
71
|
+
language = properties.get("language", None)
|
72
|
+
usage = properties.get("usage", None)
|
73
|
+
qualified_name = properties.get("qualifiedName", None)
|
74
|
+
|
75
|
+
if form:
|
76
|
+
elements_md += f"# {elements_action}\n\n"
|
77
|
+
elements_md += f"## Glossary Name \n{display_name}\n\n"
|
78
|
+
else:
|
79
|
+
elements_md += f"# Glossary Name: {display_name}\n\n"
|
80
|
+
|
81
|
+
|
82
|
+
elements_md += f"## Description\n{description}\n\n"
|
83
|
+
elements_md += f"## Language\n{language}\n\n"
|
84
|
+
elements_md += f"## Usage\n{usage}\n\n"
|
85
|
+
elements_md += f"## Qualified Name\n{qualified_name}\n\n"
|
86
|
+
elements_md += f"## GUID\n{guid}\n\n"
|
87
|
+
elements_md += MD_SEPERATOR
|
88
|
+
return elements_md
|
89
|
+
|
90
|
+
def generate_terms_md(self, elements: list, search_string: str, form:bool = True)-> str:
|
91
|
+
if form:
|
92
|
+
elements_md = f"# Update terms Form - created at {datetime.now().strftime('%Y-%m-%d %H:%M')}\n"
|
93
|
+
elements_action = "Update Terms"
|
94
|
+
else:
|
95
|
+
elements_md = f"# Glossary Terms Report - created at {datetime.now().strftime('%Y-%m-%d %H:%M')}\n"
|
96
|
+
elements_action = None
|
97
|
+
search_string = search_string if search_string else "All Terms"
|
98
|
+
elements_md += f"Terms found from the search string: `{search_string}`\n\n"
|
99
|
+
|
100
|
+
for element in elements:
|
101
|
+
guid = element['elementHeader'].get("guid", None)
|
102
|
+
element_properties = element['glossaryTermProperties']
|
103
|
+
display_name = element_properties.get("displayName", None)
|
104
|
+
summary = element_properties.get("summary", None)
|
105
|
+
description = element_properties.get("description", None)
|
106
|
+
examples = element_properties.get("examples", None)
|
107
|
+
usage = element_properties.get("usage", None)
|
108
|
+
pub_version = element_properties.get("publishedVersionIdentifier", None)
|
109
|
+
qualified_name = element_properties.get("qualifiedName", None)
|
110
|
+
status = element['elementHeader']['classifications'][0].get('status', None)
|
111
|
+
|
112
|
+
if form:
|
113
|
+
elements_md += f"# {elements_action}\n\n"
|
114
|
+
elements_md += f"## Term Name \n{display_name}\n\n"
|
115
|
+
else:
|
116
|
+
elements_md += f"# Term Name: {display_name}\n\n"
|
117
|
+
|
118
|
+
elements_md += f"## Status\n{status}\n\n"
|
119
|
+
elements_md += f"## Summary\n{summary}\n\n"
|
120
|
+
elements_md += f"## Description\n{description}\n\n"
|
121
|
+
elements_md += f"## Examples\n{examples}\n\n"
|
122
|
+
elements_md += f"## Usage\n{usage}\n\n"
|
123
|
+
elements_md += f"## Published Version\n{pub_version}\n\n"
|
124
|
+
elements_md += f"## Qualified Name\n{qualified_name}\n\n"
|
125
|
+
elements_md += f"## GUID\n{guid}\n\n"
|
126
|
+
elements_md += MD_SEPERATOR
|
127
|
+
return elements_md
|
128
|
+
|
55
129
|
#
|
56
130
|
# Get Valid Values for Enumerations
|
57
131
|
#
|
@@ -193,6 +267,8 @@ class GlossaryBrowser(Client):
|
|
193
267
|
type_name: str = None,
|
194
268
|
start_from: int = 0,
|
195
269
|
page_size: int = None,
|
270
|
+
md: bool = False,
|
271
|
+
form: bool = True
|
196
272
|
) -> list | str:
|
197
273
|
"""Retrieve the list of glossary metadata elements that contain the search string. Async version.
|
198
274
|
The search string is located in the request body and is interpreted as a plain string.
|
@@ -225,6 +301,12 @@ class GlossaryBrowser(Client):
|
|
225
301
|
page_size: int, [default=None]
|
226
302
|
The number of items to return in a single page. If not specified, the default will be taken from
|
227
303
|
the class instance.
|
304
|
+
md: bool, [default=False]
|
305
|
+
If true, a simplified markdown representation of the glossary will be returned
|
306
|
+
form: bool, [default=True]
|
307
|
+
If true and md is true, a form for the glossaries will be returned as a markdown string.
|
308
|
+
If false and md is true, a report for the glossaries will be returned.
|
309
|
+
|
228
310
|
Returns
|
229
311
|
-------
|
230
312
|
List | str
|
@@ -263,7 +345,6 @@ class GlossaryBrowser(Client):
|
|
263
345
|
"typeName": type_name,
|
264
346
|
}
|
265
347
|
body = body_slimmer(body)
|
266
|
-
# print(f"\n\nBody is: \n{body}")
|
267
348
|
|
268
349
|
url = (
|
269
350
|
f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/"
|
@@ -273,7 +354,12 @@ class GlossaryBrowser(Client):
|
|
273
354
|
)
|
274
355
|
|
275
356
|
response = await self._async_make_request("POST", url, body)
|
276
|
-
|
357
|
+
glossary_elements = response.json().get("elementList", NO_GLOSSARIES_FOUND)
|
358
|
+
if glossary_elements == NO_GLOSSARIES_FOUND:
|
359
|
+
return NO_GLOSSARIES_FOUND
|
360
|
+
if md: # return a simplified markdown representation
|
361
|
+
return self.generate_glossaries_md(glossary_elements, search_string,form)
|
362
|
+
return response.json().get("elementList", NO_GLOSSARIES_FOUND)
|
277
363
|
|
278
364
|
def find_glossaries(
|
279
365
|
self,
|
@@ -287,6 +373,8 @@ class GlossaryBrowser(Client):
|
|
287
373
|
type_name: str = None,
|
288
374
|
start_from: int = 0,
|
289
375
|
page_size: int = None,
|
376
|
+
md: bool = False,
|
377
|
+
form: bool = True
|
290
378
|
) -> list | str:
|
291
379
|
"""Retrieve the list of glossary metadata elements that contain the search string.
|
292
380
|
The search string is located in the request body and is interpreted as a plain string.
|
@@ -320,6 +408,11 @@ class GlossaryBrowser(Client):
|
|
320
408
|
page_size: int, [default=None]
|
321
409
|
The number of items to return in a single page. If not specified, the default will be taken from
|
322
410
|
the class instance.
|
411
|
+
md: bool, [default=False]
|
412
|
+
If true, a simplified markdown representation of the glossary will be returned
|
413
|
+
form: bool, [default=True]
|
414
|
+
If true and md is true, a form for the glossaries will be returned as a markdown string.
|
415
|
+
If false and md is true, a report for the glossaries will be returned.
|
323
416
|
Returns
|
324
417
|
-------
|
325
418
|
List | str
|
@@ -350,6 +443,8 @@ class GlossaryBrowser(Client):
|
|
350
443
|
type_name,
|
351
444
|
start_from,
|
352
445
|
page_size,
|
446
|
+
md,
|
447
|
+
form
|
353
448
|
)
|
354
449
|
)
|
355
450
|
|
@@ -2162,6 +2257,8 @@ class GlossaryBrowser(Client):
|
|
2162
2257
|
for_duplicate_processing: bool = False,
|
2163
2258
|
start_from: int = 0,
|
2164
2259
|
page_size: int = None,
|
2260
|
+
md: bool = False,
|
2261
|
+
form: bool = True,
|
2165
2262
|
) -> list | str:
|
2166
2263
|
"""Retrieve the list of glossary term metadata elements that contain the search string.
|
2167
2264
|
|
@@ -2193,6 +2290,11 @@ class GlossaryBrowser(Client):
|
|
2193
2290
|
Page of results to start from
|
2194
2291
|
page_size : int, optional
|
2195
2292
|
Number of elements to return per page - if None, then default for class will be used.
|
2293
|
+
md: bool, [default=False]
|
2294
|
+
If true, a simplified markdown representation of the glossary will be returned
|
2295
|
+
form: bool, [default=True]
|
2296
|
+
If true and md is true, a form for the glossaries will be returned as a markdown string.
|
2297
|
+
If false and md is true, a report for the glossaries will be returned.
|
2196
2298
|
|
2197
2299
|
Returns
|
2198
2300
|
-------
|
@@ -2238,7 +2340,7 @@ class GlossaryBrowser(Client):
|
|
2238
2340
|
"effectiveTime": effective_time,
|
2239
2341
|
"limitResultsByStatus": status_filter,
|
2240
2342
|
}
|
2241
|
-
|
2343
|
+
body = body_slimmer(body)
|
2242
2344
|
|
2243
2345
|
url = (
|
2244
2346
|
f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/"
|
@@ -2247,12 +2349,14 @@ class GlossaryBrowser(Client):
|
|
2247
2349
|
f"forDuplicateProcessing={for_duplicate_processing_s}"
|
2248
2350
|
)
|
2249
2351
|
|
2250
|
-
# print(f"\n\nURL is: \n {url}\n\nBody is: \n{body}")
|
2251
|
-
|
2252
2352
|
response = await self._async_make_request("POST", url, body)
|
2253
|
-
|
2254
|
-
|
2255
|
-
|
2353
|
+
term_elements = response.json().get("elementList", NO_TERMS_FOUND)
|
2354
|
+
if term_elements == NO_TERMS_FOUND:
|
2355
|
+
return NO_TERMS_FOUND
|
2356
|
+
if md: # return a simplified markdown representation
|
2357
|
+
return self.generate_terms_md(term_elements, search_string, form)
|
2358
|
+
return response.json().get("elementList", NO_TERMS_FOUND)
|
2359
|
+
|
2256
2360
|
|
2257
2361
|
def find_glossary_terms(
|
2258
2362
|
self,
|
@@ -2267,6 +2371,8 @@ class GlossaryBrowser(Client):
|
|
2267
2371
|
for_duplicate_processing: bool = False,
|
2268
2372
|
start_from: int = 0,
|
2269
2373
|
page_size: int = None,
|
2374
|
+
md: bool = False,
|
2375
|
+
form: bool = True,
|
2270
2376
|
) -> list | str:
|
2271
2377
|
"""Retrieve the list of glossary term metadata elements that contain the search string.
|
2272
2378
|
|
@@ -2299,6 +2405,11 @@ class GlossaryBrowser(Client):
|
|
2299
2405
|
Page of results to start from
|
2300
2406
|
page_size : int, optional
|
2301
2407
|
Number of elements to return per page - if None, then default for class will be used.
|
2408
|
+
md: bool, [default=False]
|
2409
|
+
If true, a simplified markdown representation of the glossary will be returned
|
2410
|
+
form: bool, [default=True]
|
2411
|
+
If true and md is true, a form for the glossaries will be returned as a markdown string.
|
2412
|
+
If false and md is true, a report for the glossaries will be returned.
|
2302
2413
|
|
2303
2414
|
Returns
|
2304
2415
|
-------
|
@@ -2337,6 +2448,8 @@ class GlossaryBrowser(Client):
|
|
2337
2448
|
for_duplicate_processing,
|
2338
2449
|
start_from,
|
2339
2450
|
page_size,
|
2451
|
+
md,
|
2452
|
+
form,
|
2340
2453
|
)
|
2341
2454
|
)
|
2342
2455
|
|
@@ -303,184 +303,6 @@ class GlossaryManager(GlossaryBrowser):
|
|
303
303
|
# Glossaries
|
304
304
|
#
|
305
305
|
|
306
|
-
async def _async_find_glossaries(
|
307
|
-
self,
|
308
|
-
search_string: str,
|
309
|
-
effective_time: str = None,
|
310
|
-
starts_with: bool = False,
|
311
|
-
ends_with: bool = False,
|
312
|
-
ignore_case: bool = False,
|
313
|
-
for_lineage: bool = False,
|
314
|
-
for_duplicate_processing: bool = False,
|
315
|
-
type_name: str = None,
|
316
|
-
start_from: int = 0,
|
317
|
-
page_size: int = None,
|
318
|
-
output_format: str = "JSON",
|
319
|
-
) -> list | str:
|
320
|
-
"""Retrieve the list of glossary metadata elements that contain the search string. Async version.
|
321
|
-
The search string is located in the request body and is interpreted as a plain string.
|
322
|
-
The request parameters, startsWith, endsWith and ignoreCase can be used to allow a fuzzy search.
|
323
|
-
|
324
|
-
Parameters
|
325
|
-
----------
|
326
|
-
search_string: str,
|
327
|
-
Search string to use to find matching glossaries. If the search string is '*' then all glossaries returned.
|
328
|
-
|
329
|
-
effective_time: str, [default=None], optional
|
330
|
-
Effective time of the query. If not specified will default to any time. Time format is
|
331
|
-
"YYYY-MM-DDTHH:MM:SS" (ISO 8601)
|
332
|
-
|
333
|
-
starts_with : bool, [default=False], optional
|
334
|
-
Starts with the supplied string.
|
335
|
-
ends_with : bool, [default=False], optional
|
336
|
-
Ends with the supplied string
|
337
|
-
ignore_case : bool, [default=False], optional
|
338
|
-
Ignore case when searching
|
339
|
-
for_lineage : bool, [default=False], optional
|
340
|
-
|
341
|
-
for_duplicate_processing : bool, [default=False], optional
|
342
|
-
type_name: str, [default=None], optional
|
343
|
-
An optional parameter indicating the subtype of the glossary to filter by.
|
344
|
-
Values include 'ControlledGlossary', 'EditingGlossary', and 'StagingGlossary'
|
345
|
-
start_from: int, [default=0], optional
|
346
|
-
When multiple pages of results are available, the page number to start from.
|
347
|
-
page_size: int, [default=None]
|
348
|
-
The number of items to return in a single page. If not specified, the default will be taken from
|
349
|
-
the class instance.
|
350
|
-
output_format: str, [default="JSON"]
|
351
|
-
One of JSON or MD for now
|
352
|
-
|
353
|
-
Returns
|
354
|
-
-------
|
355
|
-
List | str
|
356
|
-
|
357
|
-
A list of glossary definitions active in the server.
|
358
|
-
|
359
|
-
Raises
|
360
|
-
------
|
361
|
-
|
362
|
-
InvalidParameterException
|
363
|
-
If the client passes incorrect parameters on the request - such as bad URLs or invalid values
|
364
|
-
PropertyServerException
|
365
|
-
Raised by the server when an issue arises in processing a valid request
|
366
|
-
NotAuthorizedException
|
367
|
-
The principle specified by the user_id does not have authorization for the requested action
|
368
|
-
|
369
|
-
"""
|
370
|
-
|
371
|
-
if page_size is None:
|
372
|
-
page_size = self.page_size
|
373
|
-
starts_with_s = str(starts_with).lower()
|
374
|
-
ends_with_s = str(ends_with).lower()
|
375
|
-
ignore_case_s = str(ignore_case).lower()
|
376
|
-
for_lineage_s = str(for_lineage).lower()
|
377
|
-
for_duplicate_processing_s = str(for_duplicate_processing).lower()
|
378
|
-
|
379
|
-
validate_search_string(search_string)
|
380
|
-
|
381
|
-
if search_string == "*":
|
382
|
-
search_string = None
|
383
|
-
|
384
|
-
body = {
|
385
|
-
"class": "SearchStringRequestBody",
|
386
|
-
"searchString": search_string,
|
387
|
-
"effectiveTime": effective_time,
|
388
|
-
"typeName": type_name,
|
389
|
-
}
|
390
|
-
body = body_slimmer(body)
|
391
|
-
# print(f"\n\nBody is: \n{body}")
|
392
|
-
|
393
|
-
url = (
|
394
|
-
f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/"
|
395
|
-
f"by-search-string?startFrom={start_from}&pageSize={page_size}&startsWith={starts_with_s}&"
|
396
|
-
f"endsWith={ends_with_s}&ignoreCase={ignore_case_s}&forLineage={for_lineage_s}&"
|
397
|
-
f"forDuplicateProcessing={for_duplicate_processing_s}"
|
398
|
-
)
|
399
|
-
|
400
|
-
response = await self._async_make_request("POST", url, body)
|
401
|
-
if output_format == "JSON":
|
402
|
-
return response.json().get("elementList", "No Glossaries found")
|
403
|
-
elif output_format == "MD":
|
404
|
-
pass
|
405
|
-
|
406
|
-
|
407
|
-
def find_glossaries(
|
408
|
-
self,
|
409
|
-
search_string: str,
|
410
|
-
effective_time: str = None,
|
411
|
-
starts_with: bool = False,
|
412
|
-
ends_with: bool = False,
|
413
|
-
ignore_case: bool = False,
|
414
|
-
for_lineage: bool = False,
|
415
|
-
for_duplicate_processing: bool = False,
|
416
|
-
type_name: str = None,
|
417
|
-
start_from: int = 0,
|
418
|
-
page_size: int = None,
|
419
|
-
) -> list | str:
|
420
|
-
"""Retrieve the list of glossary metadata elements that contain the search string.
|
421
|
-
The search string is located in the request body and is interpreted as a plain string.
|
422
|
-
The request parameters, startsWith, endsWith and ignoreCase can be used to allow a fuzzy search.
|
423
|
-
|
424
|
-
Parameters
|
425
|
-
----------
|
426
|
-
search_string: str,
|
427
|
-
Search string to use to find matching glossaries. If the search string is '*' then all glossaries returned.
|
428
|
-
|
429
|
-
effective_time: str, [default=None], optional
|
430
|
-
Effective time of the query. If not specified will default to any time. Time format is
|
431
|
-
"YYYY-MM-DDTHH:MM:SS" (ISO 8601)
|
432
|
-
|
433
|
-
starts_with : bool, [default=False], optional
|
434
|
-
Starts with the supplied string.
|
435
|
-
ends_with : bool, [default=False], optional
|
436
|
-
Ends with the supplied string
|
437
|
-
ignore_case : bool, [default=False], optional
|
438
|
-
Ignore case when searching
|
439
|
-
for_lineage : bool, [default=False], optional
|
440
|
-
Indicates the search is for lineage.
|
441
|
-
for_duplicate_processing : bool, [default=False], optional
|
442
|
-
type_name: str, [default=None], optional
|
443
|
-
An optional parameter indicating the subtype of the glossary to filter by.
|
444
|
-
Values include 'ControlledGlossary', 'EditingGlossary', and 'StagingGlossary'
|
445
|
-
start_from: int, [default=0], optional
|
446
|
-
When multiple pages of results are available, the page number to start from.
|
447
|
-
page_size: int, [default=None]
|
448
|
-
The number of items to return in a single page. If not specified, the default will be taken from
|
449
|
-
the class instance.
|
450
|
-
Returns
|
451
|
-
-------
|
452
|
-
List | str
|
453
|
-
|
454
|
-
A list of glossary definitions active in the server.
|
455
|
-
|
456
|
-
Raises
|
457
|
-
------
|
458
|
-
|
459
|
-
InvalidParameterException
|
460
|
-
If the client passes incorrect parameters on the request - such as bad URLs or invalid values
|
461
|
-
PropertyServerException
|
462
|
-
Raised by the server when an issue arises in processing a valid request
|
463
|
-
NotAuthorizedException
|
464
|
-
The principle specified by the user_id does not have authorization for the requested action
|
465
|
-
|
466
|
-
"""
|
467
|
-
loop = asyncio.get_event_loop()
|
468
|
-
response = loop.run_until_complete(
|
469
|
-
self._async_find_glossaries(
|
470
|
-
search_string,
|
471
|
-
effective_time,
|
472
|
-
starts_with,
|
473
|
-
ends_with,
|
474
|
-
ignore_case,
|
475
|
-
for_lineage,
|
476
|
-
for_duplicate_processing,
|
477
|
-
type_name,
|
478
|
-
start_from,
|
479
|
-
page_size,
|
480
|
-
)
|
481
|
-
)
|
482
|
-
|
483
|
-
return response
|
484
306
|
|
485
307
|
async def _async_get_glossaries_by_name(
|
486
308
|
self,
|
@@ -3610,193 +3432,6 @@ class GlossaryManager(GlossaryBrowser):
|
|
3610
3432
|
|
3611
3433
|
return response
|
3612
3434
|
|
3613
|
-
async def _async_find_glossary_terms(
|
3614
|
-
self,
|
3615
|
-
search_string: str,
|
3616
|
-
glossary_guid: str = None,
|
3617
|
-
status_filter: list = [],
|
3618
|
-
effective_time: str = None,
|
3619
|
-
starts_with: bool = False,
|
3620
|
-
ends_with: bool = False,
|
3621
|
-
ignore_case: bool = True,
|
3622
|
-
for_lineage: bool = False,
|
3623
|
-
for_duplicate_processing: bool = False,
|
3624
|
-
start_from: int = 0,
|
3625
|
-
page_size: int = None,
|
3626
|
-
) -> list | str:
|
3627
|
-
"""Retrieve the list of glossary term metadata elements that contain the search string.
|
3628
|
-
|
3629
|
-
Parameters
|
3630
|
-
----------
|
3631
|
-
search_string: str
|
3632
|
-
Search string to use to find matching glossaries. If the search string is '*' then all glossaries returned.
|
3633
|
-
glossary_guid str
|
3634
|
-
Identifier of the glossary to search within. If None, then all glossaries are searched.
|
3635
|
-
status_filter: list, default = [], optional
|
3636
|
-
Filters the results by the included Term statuses (such as 'ACTIVE', 'DRAFT'). If not specified,
|
3637
|
-
the results will not be filtered.
|
3638
|
-
effective_time: str, [default=None], optional
|
3639
|
-
If specified, the term information will be retrieved if it is active at the `effective_time`.
|
3640
|
-
Time format is "YYYY-MM-DDTHH:MM:SS" (ISO 8601)
|
3641
|
-
|
3642
|
-
starts_with : bool, [default=False], optional
|
3643
|
-
Starts with the supplied string.
|
3644
|
-
ends_with : bool, [default=False], optional
|
3645
|
-
Ends with the supplied string
|
3646
|
-
ignore_case : bool, [default=False], optional
|
3647
|
-
Ignore case when searching
|
3648
|
-
for_lineage : bool, [default=False], optional
|
3649
|
-
|
3650
|
-
for_duplicate_processing : bool, [default=False], optional
|
3651
|
-
|
3652
|
-
start_from: str, [default=0], optional
|
3653
|
-
Page of results to start from
|
3654
|
-
page_size : int, optional
|
3655
|
-
Number of elements to return per page - if None, then default for class will be used.
|
3656
|
-
|
3657
|
-
Returns
|
3658
|
-
-------
|
3659
|
-
List | str
|
3660
|
-
|
3661
|
-
A list of term definitions
|
3662
|
-
|
3663
|
-
Raises
|
3664
|
-
------
|
3665
|
-
InvalidParameterException
|
3666
|
-
If the client passes incorrect parameters on the request - such as bad URLs or invalid values
|
3667
|
-
PropertyServerException
|
3668
|
-
Raised by the server when an issue arises in processing a valid request
|
3669
|
-
NotAuthorizedException
|
3670
|
-
The principle specified by the user_id does not have authorization for the requested action
|
3671
|
-
|
3672
|
-
Notes
|
3673
|
-
-----
|
3674
|
-
The search string is located in the request body and is interpreted as a plain string.
|
3675
|
-
The request parameters, startsWith, endsWith and ignoreCase can be used to allow a fuzzy search.
|
3676
|
-
The request body also supports the specification of a glossaryGUID to restrict the search to within a single glossary.
|
3677
|
-
"""
|
3678
|
-
|
3679
|
-
if page_size is None:
|
3680
|
-
page_size = self.page_size
|
3681
|
-
if effective_time is None:
|
3682
|
-
effective_time = datetime.now().isoformat()
|
3683
|
-
starts_with_s = str(starts_with).lower()
|
3684
|
-
ends_with_s = str(ends_with).lower()
|
3685
|
-
ignore_case_s = str(ignore_case).lower()
|
3686
|
-
for_lineage_s = str(for_lineage).lower()
|
3687
|
-
for_duplicate_processing_s = str(for_duplicate_processing).lower()
|
3688
|
-
if search_string == "*":
|
3689
|
-
search_string = None
|
3690
|
-
|
3691
|
-
# validate_search_string(search_string)
|
3692
|
-
|
3693
|
-
body = {
|
3694
|
-
"class": "GlossarySearchStringRequestBody",
|
3695
|
-
"glossaryGUID": glossary_guid,
|
3696
|
-
"searchString": search_string,
|
3697
|
-
"effectiveTime": effective_time,
|
3698
|
-
"limitResultsByStatus": status_filter,
|
3699
|
-
}
|
3700
|
-
body = body_slimmer(body)
|
3701
|
-
|
3702
|
-
url = (
|
3703
|
-
f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/"
|
3704
|
-
f"terms/by-search-string?startFrom={start_from}&pageSize={page_size}&startsWith={starts_with_s}&"
|
3705
|
-
f"endsWith={ends_with_s}&ignoreCase={ignore_case_s}&forLineage={for_lineage_s}&"
|
3706
|
-
f"forDuplicateProcessing={for_duplicate_processing_s}"
|
3707
|
-
)
|
3708
|
-
|
3709
|
-
# print(f"\n\nURL is: \n {url}\n\nBody is: \n{body}")
|
3710
|
-
|
3711
|
-
response = await self._async_make_request("POST", url, body)
|
3712
|
-
return response.json().get(
|
3713
|
-
"elementList", NO_TERMS_FOUND
|
3714
|
-
) # return response.text
|
3715
|
-
|
3716
|
-
def find_glossary_terms(
|
3717
|
-
self,
|
3718
|
-
search_string: str,
|
3719
|
-
glossary_guid: str = None,
|
3720
|
-
status_filter: list = [],
|
3721
|
-
effective_time: str = None,
|
3722
|
-
starts_with: bool = False,
|
3723
|
-
ends_with: bool = False,
|
3724
|
-
ignore_case: bool = False,
|
3725
|
-
for_lineage: bool = False,
|
3726
|
-
for_duplicate_processing: bool = False,
|
3727
|
-
start_from: int = 0,
|
3728
|
-
page_size: int = None,
|
3729
|
-
) -> list | str:
|
3730
|
-
"""Retrieve the list of glossary term metadata elements that contain the search string.
|
3731
|
-
|
3732
|
-
Parameters
|
3733
|
-
----------
|
3734
|
-
search_string: str
|
3735
|
-
Search string to use to find matching glossaries. If the search string is '*' then all glossaries returned.
|
3736
|
-
glossary_guid str
|
3737
|
-
Identifier of the glossary to search within. If None, then all glossaries are searched.
|
3738
|
-
status_filter: list, default = [], optional
|
3739
|
-
Filters the results by the included Term statuses (such as 'ACTIVE', 'DRAFT'). If not specified,
|
3740
|
-
the results will not be filtered.
|
3741
|
-
effective_time: str, [default=None], optional
|
3742
|
-
If specified, the term information will be retrieved if it is active at the `effective_time`.
|
3743
|
-
Time format is "YYYY-MM-DDTHH:MM:SS" (ISO 8601)
|
3744
|
-
|
3745
|
-
starts_with : bool, [default=False], optional
|
3746
|
-
Starts with the supplied string.
|
3747
|
-
ends_with : bool, [default=False], optional
|
3748
|
-
Ends with the supplied string
|
3749
|
-
ignore_case : bool, [default=False], optional
|
3750
|
-
Ignore case when searching
|
3751
|
-
for_lineage : bool, [default=False], optional
|
3752
|
-
|
3753
|
-
for_duplicate_processing : bool, [default=False], optional
|
3754
|
-
|
3755
|
-
start_from: str, [default=0], optional
|
3756
|
-
Page of results to start from
|
3757
|
-
page_size : int, optional
|
3758
|
-
Number of elements to return per page - if None, then default for class will be used.
|
3759
|
-
|
3760
|
-
Returns
|
3761
|
-
-------
|
3762
|
-
List | str
|
3763
|
-
|
3764
|
-
A list of term definitions
|
3765
|
-
|
3766
|
-
Raises
|
3767
|
-
------
|
3768
|
-
InvalidParameterException
|
3769
|
-
If the client passes incorrect parameters on the request - such as bad URLs or invalid values
|
3770
|
-
PropertyServerException
|
3771
|
-
Raised by the server when an issue arises in processing a valid request
|
3772
|
-
NotAuthorizedException
|
3773
|
-
The principle specified by the user_id does not have authorization for the requested action
|
3774
|
-
|
3775
|
-
Notes
|
3776
|
-
-----
|
3777
|
-
The search string is located in the request body and is interpreted as a plain string.
|
3778
|
-
The request parameters, startsWith, endsWith and ignoreCase can be used to allow a fuzzy search.
|
3779
|
-
The request body also supports the specification of a glossaryGUID to restrict the search to within a single glossary.
|
3780
|
-
"""
|
3781
|
-
|
3782
|
-
loop = asyncio.get_event_loop()
|
3783
|
-
response = loop.run_until_complete(
|
3784
|
-
self._async_find_glossary_terms(
|
3785
|
-
search_string,
|
3786
|
-
glossary_guid,
|
3787
|
-
status_filter,
|
3788
|
-
effective_time,
|
3789
|
-
starts_with,
|
3790
|
-
ends_with,
|
3791
|
-
ignore_case,
|
3792
|
-
for_lineage,
|
3793
|
-
for_duplicate_processing,
|
3794
|
-
start_from,
|
3795
|
-
page_size,
|
3796
|
-
)
|
3797
|
-
)
|
3798
|
-
|
3799
|
-
return response
|
3800
3435
|
|
3801
3436
|
|
3802
3437
|
if __name__ == "__main__":
|