pyegeria 5.3.8.4__py3-none-any.whl → 5.3.8.6__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.
@@ -2327,1137 +2327,1137 @@ class GlossaryBrowser(Client):
2327
2327
  # Terms
2328
2328
  #
2329
2329
 
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.
2334
-
2335
- Async Version.
2336
-
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
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.
2334
+
2335
+ Async Version.
2336
+
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.
2361
+
2362
+ """
2363
+
2364
+ validate_guid(glossary_category_guid)
2365
+
2366
+ if page_size is None:
2367
+ page_size = self.page_size
2368
+
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}")
2372
+
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)
2378
+
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
+ """
2454
+
2455
+ validate_guid(glossary_guid)
2456
+
2457
+ if page_size is None:
2458
+ page_size = self.page_size
2459
+
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}")
2462
+
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)
2468
+
2469
+ return response.json().get("elementList", "No terms found")
2470
+
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
2479
+
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
2517
+
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
+ """
2541
+
2542
+ validate_guid(term_guid)
2543
+
2544
+ if page_size is None:
2545
+ page_size = self.page_size
2546
+
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}")
2549
+
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)
2555
+
2556
+ return response.json().get("elementList", "No terms found")
2557
+
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
+ ----------
2564
+ term_guid : str
2565
+ Unique identifier for the glossary term
2566
+
2567
+ effective_time : str, optional
2568
+ If specified, term relationships are included if they are active at the `effective_time`.
2569
+ Time format is "YYYY-MM-DDTHH:MM:SS" (ISO 8601)
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))
2593
+
2594
+ return response
2595
+
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.
2599
+
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`.
2343
2609
  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.
2361
2610
 
2362
- """
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
+ """
2626
+
2627
+ validate_guid(term_guid)
2628
+
2629
+ body = {
2630
+ "class": "EffectiveTimeQueryRequestBody", "effectiveTime": effective_time,
2631
+ }
2632
+ url = (f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/"
2633
+ f"for-term/{term_guid}/retrieve")
2634
+
2635
+ response = await self._async_make_request("POST", url, body)
2636
+ return response.json().get("element", "No glossary found")
2637
+
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.
2641
+
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
+ """
2712
+
2713
+ if page_size is None:
2714
+ page_size = self.page_size
2715
+
2716
+ validate_name(term)
2717
+
2718
+ for_lineage_s = str(for_lineage).lower()
2719
+ for_duplicate_processing_s = str(for_duplicate_processing).lower()
2720
+
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:
2791
+ JSON - output standard json
2792
+ MD - output standard markdown with no preamble
2793
+ FORM - output markdown with a preamble for a form
2794
+ REPORT - output markdown with a preamble for a report
2795
+
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
+ """
2850
+
2851
+ loop = asyncio.get_event_loop()
2852
+ response = loop.run_until_complete(self._async_get_term_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
+ """
2897
+
2898
+ body = {
2899
+ "effective_time": effective_time, "fromTime": from_time, "toTime": to_time, "forLineage": for_lineage,
2900
+ "forDuplicateProcessing": for_duplicate_processing
2901
+ }
2902
+
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.
2363
2931
 
2364
- validate_guid(glossary_category_guid)
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
+ """
2365
2941
 
2366
- if page_size is None:
2367
- page_size = self.page_size
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))
2368
2946
 
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}")
2947
+ return response
2372
2948
 
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)
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.
2378
2955
 
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
- """
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
+ """
2454
2975
 
2455
- validate_guid(glossary_guid)
2976
+ if page_size is None:
2977
+ page_size = self.page_size
2456
2978
 
2457
- if page_size is None:
2458
- page_size = self.page_size
2979
+ validate_guid(term_guid)
2459
2980
 
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}")
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}")
2462
2983
 
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
2984
  response = await self._async_make_request("POST", url)
2985
+ return response.json().get("elementList", "No log found")
2468
2986
 
2469
- return response.json().get("elementList", "No terms found")
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.
2470
2993
 
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
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.
2479
3003
 
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
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
+ """
2517
3013
 
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
- """
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
2541
3018
 
2542
- validate_guid(term_guid)
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.
2543
3022
 
2544
- if page_size is None:
2545
- page_size = self.page_size
3023
+ Parameters
3024
+ ----------
3025
+ term_revision_log_guid : str
3026
+ The GUID of the glossary term revision log to retrieve.
2546
3027
 
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}")
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
+ """
3052
+
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}")
2549
3060
 
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
3061
  response = await self._async_make_request("POST", url)
3062
+ return response.json().get("elementList", "No logs found")
2555
3063
 
2556
- return response.json().get("elementList", "No terms found")
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.
2557
3067
 
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
- ----------
2564
- term_guid : str
2565
- Unique identifier for the glossary term
3068
+ Parameters
3069
+ ----------
3070
+ term_revision_log_guid : str
3071
+ The GUID of the glossary term revision log to retrieve.
2566
3072
 
2567
- effective_time : str, optional
2568
- If specified, term relationships are included if they are active at the `effective_time`.
2569
- Time format is "YYYY-MM-DDTHH:MM:SS" (ISO 8601)
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))
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.
2593
3090
 
2594
- return response
2595
3091
 
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.
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
+ """
2599
3097
 
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
- """
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))
2626
3101
 
2627
- validate_guid(term_guid)
3102
+ return response
2628
3103
 
2629
- body = {
2630
- "class": "EffectiveTimeQueryRequestBody", "effectiveTime": effective_time,
2631
- }
2632
- url = (f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/glossary-browser/glossaries/"
2633
- f"for-term/{term_guid}/retrieve")
2634
3104
 
2635
- response = await self._async_make_request("POST", url, body)
2636
- return response.json().get("element", "No glossary found")
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.
2637
3110
 
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.
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.
2641
3114
 
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
- """
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".
2712
3122
 
2713
- if page_size is None:
2714
- page_size = self.page_size
2715
-
2716
- validate_name(term)
2717
-
2718
- for_lineage_s = str(for_lineage).lower()
2719
- for_duplicate_processing_s = str(for_duplicate_processing).lower()
2720
-
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:
2791
- JSON - output standard json
2792
- MD - output standard markdown with no preamble
2793
- FORM - output markdown with a preamble for a form
2794
- REPORT - output markdown with a preamble for a report
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.
2795
3181
 
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:
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:
2832
3212
  JSON - output standard json
2833
3213
  MD - output standard markdown with no preamble
2834
3214
  FORM - output markdown with a preamble for a form
2835
3215
  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
- """
2850
3216
 
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
- """
3217
+ Returns
3218
+ -------
3219
+ List | str
2897
3220
 
2898
- body = {
2899
- "effective_time": effective_time, "fromTime": from_time, "toTime": to_time, "forLineage": for_lineage,
2900
- "forDuplicateProcessing": for_duplicate_processing
2901
- }
2902
-
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
- """
3221
+ A list of term definitions
2941
3222
 
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
- """
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
2975
3231
 
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
- """
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
+ """
3013
3239
 
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
- """
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
3052
3251
 
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
- """
3252
+ # validate_search_string(search_string)
3097
3253
 
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))
3254
+ body = {
3255
+ "class": "GlossarySearchStringRequestBody", "glossaryGUID": glossary_guid, "searchString": search_string,
3256
+ "effectiveTime": effective_time, "limitResultsByStatus": status_filter,
3257
+ }
3101
3258
 
3102
- return response
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}")
3103
3263
 
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)
3104
3276
 
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
- """
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.
3239
3282
 
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
- }
3258
-
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}")
3263
-
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
- """
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
+ """
3341
3341
 
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))
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))
3346
3346
 
3347
- return response
3347
+ return response
3348
3348
 
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"""
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"""
3355
3355
 
3356
- validate_guid(commemt_guid)
3356
+ validate_guid(commemt_guid)
3357
3357
 
3358
- if effective_time is None:
3359
- effective_time = datetime.now().isoformat()
3358
+ if effective_time is None:
3359
+ effective_time = datetime.now().isoformat()
3360
3360
 
3361
- for_lineage_s = str(for_lineage).lower()
3362
- for_duplicate_processing_s = str(for_duplicate_processing).lower()
3361
+ for_lineage_s = str(for_lineage).lower()
3362
+ for_duplicate_processing_s = str(for_duplicate_processing).lower()
3363
3363
 
3364
- body = {"effective_time": effective_time}
3364
+ body = {"effective_time": effective_time}
3365
3365
 
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}")
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}")
3369
3369
 
3370
- # print(f"\n\nURL is: \n {url}\n\nBody is: \n{body}")
3370
+ # print(f"\n\nURL is: \n {url}\n\nBody is: \n{body}")
3371
3371
 
3372
- response = await self._async_make_request("POST", url, body)
3373
- return response.json()
3372
+ response = await self._async_make_request("POST", url, body)
3373
+ return response.json()
3374
3374
 
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"""
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"""
3378
3378
 
3379
- validate_guid(comment_guid)
3380
- validate_name(comment_type)
3379
+ validate_guid(comment_guid)
3380
+ validate_name(comment_type)
3381
3381
 
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()
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()
3385
3385
 
3386
- body = {
3387
- "class": "CommentRequestBody", "commentType": comment_type, "commentText": comment_text,
3388
- "isPublic": is_public,
3389
- }
3386
+ body = {
3387
+ "class": "CommentRequestBody", "commentType": comment_type, "commentText": comment_text,
3388
+ "isPublic": is_public,
3389
+ }
3390
3390
 
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}")
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}")
3394
3394
 
3395
- # 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}")
3396
3396
 
3397
- response = await self._async_make_request("POST", url, body)
3398
- return response
3397
+ response = await self._async_make_request("POST", url, body)
3398
+ return response
3399
3399
 
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"""
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"""
3403
3403
 
3404
- validate_guid(comment_guid)
3405
- validate_name(comment_type)
3404
+ validate_guid(comment_guid)
3405
+ validate_name(comment_type)
3406
3406
 
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()
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()
3410
3410
 
3411
- body = {
3412
- "class": "CommentRequestBody", "commentType": comment_type, "commentText": comment_text,
3413
- "isPublic": is_public,
3414
- }
3411
+ body = {
3412
+ "class": "CommentRequestBody", "commentType": comment_type, "commentText": comment_text,
3413
+ "isPublic": is_public,
3414
+ }
3415
3415
 
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}")
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
3419
 
3420
- # print(f"\n\nURL is: \n {url}\n\nBody is: \n{body}")
3420
+ # print(f"\n\nURL is: \n {url}\n\nBody is: \n{body}")
3421
3421
 
3422
- response = await self._async_make_request("POST", url, body)
3423
- return response
3422
+ response = await self._async_make_request("POST", url, body)
3423
+ return response
3424
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"""
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
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
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
3442
 
3443
- # validate_search_string(search_string)
3443
+ # validate_search_string(search_string)
3444
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)
3445
+ body = {
3446
+ "class": "GlossarySearchStringRequestBody", "glossaryGUID": glossary_guid, "searchString": search_string,
3447
+ "effectiveTime": effective_time, "limitResultsByStatus": status_filter,
3448
+ }
3449
+ # body = body_slimmer(body)
3450
3450
 
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}")
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}")
3455
3455
 
3456
- # print(f"\n\nURL is: \n {url}\n\nBody is: \n{body}")
3456
+ # print(f"\n\nURL is: \n {url}\n\nBody is: \n{body}")
3457
3457
 
3458
- response = await self._async_make_request("POST", url, body)
3459
- return response.json().get("elementList", "No terms found")
3458
+ response = await self._async_make_request("POST", url, body)
3459
+ return response.json().get("elementList", "No terms found")
3460
3460
 
3461
3461
 
3462
3462
  if __name__ == "__main__":
3463
- print("Main-Glosssary Browser")
3463
+ print("Main-Glossary Browser")