pyegeria 5.3.9.3__py3-none-any.whl → 5.3.9.5__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.
@@ -0,0 +1,4944 @@
1
+ """PDX-License-Identifier: Apache-2.0
2
+ Copyright Contributors to the ODPi Egeria project.
3
+
4
+ This module provides access to the data-designer OMVS module.
5
+
6
+ [data-designer](https://egeria-project.org/services/omvs/data-designer/overview)
7
+
8
+ """
9
+
10
+ import asyncio
11
+
12
+ from httpx import Response
13
+
14
+ from pyegeria._client import Client, max_paging_size
15
+ from pyegeria._globals import NO_ELEMENTS_FOUND
16
+ from pyegeria.utils import body_slimmer
17
+
18
+
19
+ def query_seperator(current_string):
20
+ if current_string == "":
21
+ return "?"
22
+ else:
23
+ return "&"
24
+
25
+
26
+ # ("params are in the form of [(paramName, value), (param2Name, value)] if the value is not None, it will be added to "
27
+ # "the query string")
28
+
29
+
30
+ def query_string(params):
31
+ result = ""
32
+ for i in range(len(params)):
33
+ if params[i][1] is not None:
34
+ result = f"{result}{query_seperator(result)}{params[i][0]}={params[i][1]}"
35
+ return result
36
+
37
+
38
+ def base_path(client, view_server: str):
39
+ return f"{client.platform_url}/servers/{view_server}/api/open-metadata/data-designer"
40
+
41
+
42
+ def extract_mermaid_only(elements) -> list:
43
+ result = []
44
+ if type(elements) is dict:
45
+ return(elements.get('mermaidGraph', '___'))
46
+ for element in elements:
47
+ result.append(element.get('mermaidGraph', '___'))
48
+ return result
49
+
50
+
51
+ def extract_basic_dict(elements: dict) -> list:
52
+ list = []
53
+ body = {}
54
+ if type(elements) is dict:
55
+ body['guid'] = elements['elementHeader']['guid']
56
+ for key in elements['properties']:
57
+ body[key] = elements['properties'][key]
58
+ return body
59
+
60
+ for element in elements:
61
+ body['guid'] = element['elementHeader']['guid']
62
+ for key in element['properties']:
63
+ body[key] = element['properties'][key]
64
+ list.append(body)
65
+ return list
66
+
67
+
68
+ class DataDesigner(Client):
69
+ """DataDesigner is a class that extends the Client class. The Data Designer OMVS provides APIs for
70
+ building specifications for data. This includes common data fields in a data dictionary, data specifications
71
+ for a project and data classes for data quality validation.
72
+ """
73
+
74
+ def __init__(self, view_server_name: str, platform_url: str, user_id: str = None, user_pwd: str = None,
75
+ token: str = None, ):
76
+ self.view_server = view_server_name
77
+ self.platform_url = platform_url
78
+ self.user_id = user_id
79
+ self.user_pwd = user_pwd
80
+ self.metadata_explorer_command_root: str = (
81
+ f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/data-designer")
82
+ Client.__init__(self, view_server_name, platform_url, user_id=user_id, user_pwd=user_pwd, token=token, )
83
+
84
+ #
85
+ # Data Structures
86
+ #
87
+
88
+ async def _async_create_data_structure(self, name: str, description: str, qualified_name: str = None,
89
+ namespace: str = None, version_id: str = None) -> str:
90
+ """
91
+ Create a new data structure from a provided dict body. Async version.
92
+
93
+ Parameters
94
+ ----------
95
+ name : str
96
+ - unique name to search for
97
+ description : str
98
+ - description of the data structure
99
+ qualified_name : str, optional
100
+ - unique name of the data structure, if not provided, one will be generated from the name.
101
+ namespace : str
102
+ - a namespace for the data structure
103
+ version_id : str, optional
104
+ - a version identifier for the data structure
105
+
106
+ Returns
107
+ -------
108
+ str
109
+ The GUID of the element - or "No element found"
110
+
111
+ Raises
112
+ ------
113
+ InvalidParameterException
114
+ one of the parameters is null or invalid or
115
+ PropertyServerException
116
+ There is a problem adding the element properties to the metadata repository or
117
+ UserNotAuthorizedException
118
+ the requesting user is not authorized to issue this request.
119
+ """
120
+ if version_id is None:
121
+ qualified_name = qualified_name or f"DataStructure::{name}"
122
+ else:
123
+ qualified_name = qualified_name or f"DataStructure::{name}::{version_id}"
124
+ if namespace:
125
+ qualified_name = f"{namespace}::{qualified_name}"
126
+
127
+ body = {
128
+ "properties": {
129
+ "class": "DataStructureProperties", "qualifiedName": qualified_name, "displayName": name,
130
+ "description": description, "namespace": namespace, "versionIdentifier": version_id
131
+ }
132
+ }
133
+
134
+ url = f"{base_path(self, self.view_server)}/data-structures"
135
+
136
+ response: Response = await self._async_make_request("POST", url, body_slimmer(body))
137
+ return response.json().get("guid", NO_ELEMENTS_FOUND)
138
+
139
+ def create_data_structure(self, name: str, description: str, qualified_name: str = None, namespace: str = None,
140
+ version_id: str = None) -> str:
141
+ """
142
+ Create a new data structure from a provided dict body.
143
+
144
+ Parameters
145
+ ----------
146
+ name : str
147
+ - unique name to search for
148
+ description : str
149
+ - description of the data structure
150
+ qualified_name : str, optional
151
+ - unique name of the data structure, if not provided, one will be generated from the name.
152
+ namespace : str
153
+ - a namespace for the data structure
154
+ version_id : str, optional
155
+ - a version identifier for the data structure
156
+
157
+ Returns
158
+ -------
159
+ str
160
+ The GUID of the element - or "No element found"
161
+
162
+ Raises
163
+ ------
164
+ InvalidParameterException
165
+ one of the parameters is null or invalid or
166
+ PropertyServerException
167
+ There is a problem adding the element properties to the metadata repository or
168
+ UserNotAuthorizedException
169
+ the requesting user is not authorized to issue this request.
170
+ """
171
+
172
+ loop = asyncio.get_event_loop()
173
+ response = loop.run_until_complete(
174
+ self._async_create_data_structure(name, description, qualified_name, namespace, version_id, ))
175
+ return response
176
+
177
+ async def _async_create_data_structure_w_body(self, body: dict) -> str:
178
+ """
179
+ Create a new data structure with basic parameters. Async version.
180
+
181
+ Parameters
182
+ ----------
183
+ body: dict
184
+ - a dictionary containing the properties of the data structure to be created.
185
+
186
+ Returns
187
+ -------
188
+ str
189
+ The GUID of the element - or "No element found"
190
+
191
+ Raises
192
+ ------
193
+ InvalidParameterException
194
+ one of the parameters is null or invalid or
195
+ PropertyServerException
196
+ There is a problem adding the element properties to the metadata repository or
197
+ UserNotAuthorizedException
198
+ the requesting user is not authorized to issue this request.
199
+
200
+ Note
201
+ ----
202
+
203
+ Full sample body:
204
+
205
+ {
206
+ "class" : "NewDataStructureRequestBody",
207
+ "externalSourceGUID": "add guid here",
208
+ "externalSourceName": "add qualified name here",
209
+ "effectiveTime" : "{{$isoTimestamp}}",
210
+ "forLineage" : false,
211
+ "forDuplicateProcessing" : false,
212
+ "anchorGUID" : "add guid here",
213
+ "isOwnAnchor": false,
214
+ "parentGUID": "add guid here",
215
+ "parentRelationshipTypeName": "add type name here",
216
+ "parentRelationshipProperties": {
217
+ "class": "ElementProperties",
218
+ "propertyValueMap" : {
219
+ "description" : {
220
+ "class": "PrimitiveTypePropertyValue",
221
+ "typeName": "string",
222
+ "primitiveValue" : "New description"
223
+ }
224
+ }
225
+ },
226
+ "parentAtEnd1": false,
227
+ "properties": {
228
+ "class" : "DataStructureProperties",
229
+ "qualifiedName": "add unique name here",
230
+ "displayName": "add short name here",
231
+ "description": "add description here",
232
+ "namespace": "add namespace for this structure",
233
+ "versionIdentifier": "add version for this structure",
234
+ "additionalProperties": {
235
+ "property1" : "propertyValue1",
236
+ "property2" : "propertyValue2"
237
+ },
238
+ "effectiveFrom": "{{$isoTimestamp}}",
239
+ "effectiveTo": "{{$isoTimestamp}}"
240
+ }
241
+ }
242
+
243
+ """
244
+
245
+ url = f"{base_path(self, self.view_server)}/data-structures"
246
+
247
+ response: Response = await self._async_make_request("POST", url, body_slimmer(body))
248
+ return response.json().get("guid", NO_ELEMENTS_FOUND)
249
+
250
+ def create_data_structure_w_body(self, body: dict) -> str:
251
+ """
252
+ Create a new data structure with basic parameters.
253
+
254
+ Parameters
255
+ ----------
256
+ body: dict
257
+ - a dictionary containing the properties of the data structure to be created.
258
+
259
+ Returns
260
+ -------
261
+ str
262
+ The GUID of the element - or "No element found"
263
+
264
+ Raises
265
+ ------
266
+ InvalidParameterException
267
+ one of the parameters is null or invalid or
268
+ PropertyServerException
269
+ There is a problem adding the element properties to the metadata repository or
270
+ UserNotAuthorizedException
271
+ the requesting user is not authorized to issue this request.
272
+
273
+ Note
274
+ ----
275
+
276
+ Full sample body:
277
+
278
+ {
279
+ "class" : "NewDataStructureRequestBody",
280
+ "externalSourceGUID": "add guid here",
281
+ "externalSourceName": "add qualified name here",
282
+ "effectiveTime" : "{{$isoTimestamp}}",
283
+ "forLineage" : false,
284
+ "forDuplicateProcessing" : false,
285
+ "anchorGUID" : "add guid here",
286
+ "isOwnAnchor": false,
287
+ "parentGUID": "add guid here",
288
+ "parentRelationshipTypeName": "add type name here",
289
+ "parentRelationshipProperties": {
290
+ "class": "ElementProperties",
291
+ "propertyValueMap" : {
292
+ "description" : {
293
+ "class": "PrimitiveTypePropertyValue",
294
+ "typeName": "string",
295
+ "primitiveValue" : "New description"
296
+ }
297
+ }
298
+ },
299
+ "parentAtEnd1": false,
300
+ "properties": {
301
+ "class" : "DataStructureProperties",
302
+ "qualifiedName": "add unique name here",
303
+ "displayName": "add short name here",
304
+ "description": "add description here",
305
+ "namespace": "add namespace for this structure",
306
+ "versionIdentifier": "add version for this structure",
307
+ "additionalProperties": {
308
+ "property1" : "propertyValue1",
309
+ "property2" : "propertyValue2"
310
+ },
311
+ "effectiveFrom": "{{$isoTimestamp}}",
312
+ "effectiveTo": "{{$isoTimestamp}}"
313
+ }
314
+ }
315
+
316
+ """
317
+
318
+ loop = asyncio.get_event_loop()
319
+ response = loop.run_until_complete(self._async_create_data_structure_w_body(body, ))
320
+ return response
321
+
322
+ async def _async_create_data_structure_from_template(self, body: dict) -> str:
323
+ """
324
+ Create a new metadata element to represent a data structure using an existing metadata element as a template.
325
+ The template defines additional classifications and relationships that should be added to the new element.
326
+ Async version.
327
+
328
+ Parameters
329
+ ----------
330
+ body: dict
331
+ - a dictionary containing the properties of the data structure to be created.
332
+
333
+ Returns
334
+ -------
335
+ str
336
+ The GUID of the element - or "No element found"
337
+
338
+ Raises
339
+ ------
340
+ InvalidParameterException
341
+ one of the parameters is null or invalid or
342
+ PropertyServerException
343
+ There is a problem adding the element properties to the metadata repository or
344
+ UserNotAuthorizedException
345
+ the requesting user is not authorized to issue this request.
346
+
347
+ Note
348
+ ----
349
+
350
+ Full sample body:
351
+
352
+ {
353
+ "class" : "TemplateRequestBody",
354
+ "externalSourceGUID": "add guid here",
355
+ "externalSourceName": "add qualified name here",
356
+ "effectiveTime" : "{{$isoTimestamp}}",
357
+ "forLineage" : false,
358
+ "forDuplicateProcessing" : false,
359
+ "anchorGUID" : "add guid here",
360
+ "isOwnAnchor": false,
361
+ "parentGUID": "add guid here",
362
+ "parentRelationshipTypeName": "add type name here",
363
+ "parentRelationshipProperties": {
364
+ "class": "ElementProperties",
365
+ "propertyValueMap" : {
366
+ "description" : {
367
+ "class": "PrimitiveTypePropertyValue",
368
+ "typeName": "string",
369
+ "primitiveValue" : "New description"
370
+ }
371
+ }
372
+ },
373
+ "parentAtEnd1": false,
374
+ "templateGUID": "add guid here",
375
+ "replacementProperties": {
376
+ "class": "ElementProperties",
377
+ "propertyValueMap" : {
378
+ "description" : {
379
+ "class": "PrimitiveTypePropertyValue",
380
+ "typeName": "string",
381
+ "primitiveValue" : "New description"
382
+ }
383
+ }
384
+ },
385
+ "placeholderPropertyValues": {
386
+ "placeholder1" : "propertyValue1",
387
+ "placeholder2" : "propertyValue2"
388
+ }
389
+ }
390
+
391
+ """
392
+
393
+ url = f"{base_path(self, self.view_server)}/data-structures/from-template"
394
+
395
+ response: Response = await self._async_make_request("POST", url, body_slimmer(body))
396
+ return response.json().get("guid", NO_ELEMENTS_FOUND)
397
+
398
+ def create_data_structure_from_template(self, body: dict) -> str:
399
+ """
400
+ Create a new metadata element to represent a data structure using an existing metadata element as a template.
401
+ The template defines additional classifications and relationships that should be added to the new element.
402
+
403
+ Parameters
404
+ ----------
405
+ body: dict
406
+ - a dictionary containing the properties of the data structure to be created.
407
+
408
+ Returns
409
+ -------
410
+ str
411
+ The GUID of the element - or "No element found"
412
+
413
+ Raises
414
+ ------
415
+ InvalidParameterException
416
+ one of the parameters is null or invalid or
417
+ PropertyServerException
418
+ There is a problem adding the element properties to the metadata repository or
419
+ UserNotAuthorizedException
420
+ the requesting user is not authorized to issue this request.
421
+
422
+ Note
423
+ ----
424
+
425
+ Full sample body:
426
+
427
+ {
428
+ "class" : "TemplateRequestBody",
429
+ "externalSourceGUID": "add guid here",
430
+ "externalSourceName": "add qualified name here",
431
+ "effectiveTime" : "{{$isoTimestamp}}",
432
+ "forLineage" : false,
433
+ "forDuplicateProcessing" : false,
434
+ "anchorGUID" : "add guid here",
435
+ "isOwnAnchor": false,
436
+ "parentGUID": "add guid here",
437
+ "parentRelationshipTypeName": "add type name here",
438
+ "parentRelationshipProperties": {
439
+ "class": "ElementProperties",
440
+ "propertyValueMap" : {
441
+ "description" : {
442
+ "class": "PrimitiveTypePropertyValue",
443
+ "typeName": "string",
444
+ "primitiveValue" : "New description"
445
+ }
446
+ }
447
+ },
448
+ "parentAtEnd1": false,
449
+ "templateGUID": "add guid here",
450
+ "replacementProperties": {
451
+ "class": "ElementProperties",
452
+ "propertyValueMap" : {
453
+ "description" : {
454
+ "class": "PrimitiveTypePropertyValue",
455
+ "typeName": "string",
456
+ "primitiveValue" : "New description"
457
+ }
458
+ }
459
+ },
460
+ "placeholderPropertyValues": {
461
+ "placeholder1" : "propertyValue1",
462
+ "placeholder2" : "propertyValue2"
463
+ }
464
+ }
465
+
466
+ """
467
+
468
+ loop = asyncio.get_event_loop()
469
+ response = loop.run_until_complete(self._async_create_data_structure_from_template(body, ))
470
+ return response
471
+
472
+ async def _async_update_data_structure_w_body(self, data_struct_guid: str, body: dict,
473
+ replace_all_properties: bool = False) -> None:
474
+ """
475
+ Update the properties of a data structure. Async version.
476
+
477
+ Parameters
478
+ ----------
479
+ data_struct_guid: str
480
+ - the GUID of the data structure to be updated.
481
+ body: dict
482
+ - a dictionary containing the properties of the data structure to be created.
483
+ replace_all_properties: bool, default = False
484
+ - if true, then all properties will be replaced with the new ones. Otherwise, only the specified ones
485
+ will be replaced.
486
+ Returns
487
+ -------
488
+ None
489
+
490
+ Raises
491
+ ------
492
+ InvalidParameterException
493
+ one of the parameters is null or invalid or
494
+ PropertyServerException
495
+ There is a problem adding the element properties to the metadata repository or
496
+ UserNotAuthorizedException
497
+ the requesting user is not authorized to issue this request.
498
+
499
+ Note
500
+ ----
501
+
502
+ Full sample body:
503
+
504
+ {
505
+ "class" : "UpdateDataStructureRequestBody",
506
+ "externalSourceGUID": "add guid here",
507
+ "externalSourceName": "add qualified name here",
508
+ "effectiveTime" : "{{$isoTimestamp}}",
509
+ "forLineage" : false,
510
+ "forDuplicateProcessing" : false,
511
+ "properties": {
512
+ "class" : "DataStructureProperties",
513
+ "qualifiedName": "add unique name here",
514
+ "displayName": "add short name here",
515
+ "description": "add description here",
516
+ "namespace": "add namespace for this structure",
517
+ "versionIdentifier": "add version for this structure",
518
+ "additionalProperties": {
519
+ "property1" : "propertyValue1",
520
+ "property2" : "propertyValue2"
521
+ },
522
+ "effectiveFrom": "{{$isoTimestamp}}",
523
+ "effectiveTo": "{{$isoTimestamp}}"
524
+ }
525
+ }
526
+
527
+ """
528
+ replace_all_properties_s = str(replace_all_properties).lower()
529
+
530
+ url = (f"{base_path(self, self.view_server)}/data-structures/{data_struct_guid}/update?"
531
+ f"replaceAllProperties={replace_all_properties_s}")
532
+
533
+ await self._async_make_request("POST", url, body_slimmer(body))
534
+
535
+ def update_data_structure_w_body(self, data_struct_guid: str, body: dict.get,
536
+ replace_all_properties: bool = False) -> None:
537
+ """
538
+ Update the properties of a data structure.
539
+
540
+ Parameters
541
+ ----------
542
+ data_struct_guid: str
543
+ - the GUID of the data structure to be updated.
544
+ body: dict
545
+ - a dictionary containing the properties of the data structure to be created.
546
+ r replace_all_properties: bool, default = False
547
+ - if true, then all properties will be replaced with the new ones. Otherwise, only the specified ones
548
+ will be replaced.
549
+ Returns
550
+ -------
551
+ None
552
+
553
+ Raises
554
+ ------
555
+ InvalidParameterException
556
+ one of the parameters is null or invalid or
557
+ PropertyServerException
558
+ There is a problem adding the element properties to the metadata repository or
559
+ UserNotAuthorizedException
560
+ the requesting user is not authorized to issue this request.
561
+
562
+ Note
563
+ ----
564
+
565
+ Full sample body:
566
+
567
+ {
568
+ "class" : "UpdateDataStructureRequestBody",
569
+ "externalSourceGUID": "add guid here",
570
+ "externalSourceName": "add qualified name here",
571
+ "effectiveTime" : "{{$isoTimestamp}}",
572
+ "forLineage" : false,
573
+ "forDuplicateProcessing" : false,
574
+ "properties": {
575
+ "class" : "DataStructureProperties",
576
+ "qualifiedName": "add unique name here",
577
+ "displayName": "add short name here",
578
+ "description": "add description here",
579
+ "namespace": "add namespace for this structure",
580
+ "versionIdentifier": "add version for this structure",
581
+ "additionalProperties": {
582
+ "property1" : "propertyValue1",
583
+ "property2" : "propertyValue2"
584
+ },
585
+ "effectiveFrom": "{{$isoTimestamp}}",
586
+ "effectiveTo": "{{$isoTimestamp}}"
587
+ }
588
+ }
589
+
590
+ """
591
+
592
+ loop = asyncio.get_event_loop()
593
+ loop.run_until_complete(
594
+ self._async_update_data_structure_w_body(data_struct_guid, body, replace_all_properties))
595
+
596
+ async def _async_link_member_data_field(self, parent_data_struct_guid: str, member_data_field_guid: str,
597
+ body: dict = None) -> None:
598
+ """
599
+ Connect a data structure to a data class. Async version.
600
+
601
+ Parameters
602
+ ----------
603
+ parent_data_struct_guid: str
604
+ - the GUID of the parent data structure the data class will be connected to.
605
+ member_data_field_guid: str
606
+ - the GUID of the data class to be connected.
607
+ body: dict, optional
608
+ - a dictionary containing additional properties.
609
+
610
+ Returns
611
+ -------
612
+ None
613
+
614
+ Raises
615
+ ------
616
+ InvalidParameterException
617
+ one of the parameters is null or invalid or
618
+ PropertyServerException
619
+ There is a problem adding the element properties to the metadata repository or
620
+ UserNotAuthorizedException
621
+ the requesting user is not authorized to issue this request.
622
+
623
+ Note
624
+ ----
625
+
626
+ Full sample body:
627
+
628
+ {
629
+ "class" : "MemberDataFieldRequestBody",
630
+ "externalSourceGUID": "add guid here",
631
+ "externalSourceName": "add qualified name here",
632
+ "effectiveTime" : "{{$isoTimestamp}}",
633
+ "forLineage" : false,
634
+ "forDuplicateProcessing" : false,
635
+ "properties": {
636
+ "class": "MemberDataFieldProperties",
637
+ "dataFieldPosition": 0,
638
+ "minCardinality": 0,
639
+ "maxCardinality": 0,
640
+ "effectiveFrom": "{{$isoTimestamp}}",
641
+ "effectiveTo": "{{$isoTimestamp}}"
642
+ }
643
+ }
644
+
645
+ """
646
+
647
+ url = (f"{base_path(self, self.view_server)}/data-structures/{parent_data_struct_guid}"
648
+ f"/member-data-fields/{member_data_field_guid}/attach")
649
+
650
+ if body is None:
651
+ await self._async_make_request("POST", url)
652
+ else:
653
+ await self._async_make_request("POST", url, body_slimmer(body))
654
+
655
+ def link_member_data_field(self, parent_data_struct_guid: str, member_data_field_guid: str,
656
+ body: dict = None) -> None:
657
+ """
658
+ Connect a data structure to a data class.
659
+
660
+ Parameters
661
+ ----------
662
+ parent_data_struct_guid: str
663
+ - the GUID of the parent data structure the data class will be connected to.
664
+ member_data_field_guid: str
665
+ - the GUID of the data class to be connected.
666
+ body: dict, optional
667
+ - a dictionary containing additional properties.
668
+
669
+ Returns
670
+ -------
671
+ None
672
+
673
+ Raises
674
+ ------
675
+ InvalidParameterException
676
+ one of the parameters is null or invalid or
677
+ PropertyServerException
678
+ There is a problem adding the element properties to the metadata repository or
679
+ UserNotAuthorizedException
680
+ the requesting user is not authorized to issue this request.
681
+
682
+ Note
683
+ ----
684
+
685
+ Full sample body:
686
+
687
+ {
688
+ "class" : "MemberDataFieldRequestBody",
689
+ "externalSourceGUID": "add guid here",
690
+ "externalSourceName": "add qualified name here",
691
+ "effectiveTime" : "{{$isoTimestamp}}",
692
+ "forLineage" : false,
693
+ "forDuplicateProcessing" : false,
694
+ "properties": {
695
+ "class": "MemberDataFieldProperties",
696
+ "dataFieldPosition": 0,
697
+ "minCardinality": 0,
698
+ "maxCardinality": 0,
699
+ "effectiveFrom": "{{$isoTimestamp}}",
700
+ "effectiveTo": "{{$isoTimestamp}}"
701
+ }
702
+ }
703
+
704
+ """
705
+
706
+ loop = asyncio.get_event_loop()
707
+ loop.run_until_complete(
708
+ self._async_link_member_data_field(parent_data_struct_guid, member_data_field_guid, body))
709
+
710
+ async def _async_detach_member_data_field(self, parent_data_struct_guid: str, member_data_field_guid: str,
711
+ body: dict = None) -> None:
712
+ """
713
+ Detach a data class from a data structure. Request body is optional. Async version.
714
+
715
+ Parameters
716
+ ----------
717
+ parent_data_struct_guid: str
718
+ - the GUID of the parent data structure the data class will be detached from..
719
+ member_data_field_guid: str
720
+ - the GUID of the data class to be disconnected.
721
+ body: dict, optional
722
+ - a dictionary containing additional properties.
723
+
724
+ Returns
725
+ -------
726
+ None
727
+
728
+ Raises
729
+ ------
730
+ InvalidParameterException
731
+ one of the parameters is null or invalid or
732
+ PropertyServerException
733
+ There is a problem adding the element properties to the metadata repository or
734
+ UserNotAuthorizedException
735
+ the requesting user is not authorized to issue this request.
736
+
737
+ Note
738
+ ----
739
+
740
+ Full sample body:
741
+
742
+ {
743
+ "class": "MetadataSourceRequestBody",
744
+ "externalSourceGUID": "add guid here",
745
+ "externalSourceName": "add qualified name here",
746
+ "effectiveTime": "{{$isoTimestamp}}",
747
+ "forLineage": false,
748
+ "forDuplicateProcessing": false
749
+ }
750
+
751
+
752
+ """
753
+
754
+ url = (f"{base_path(self, self.view_server)}/data-structures/{parent_data_struct_guid}"
755
+ f"/member-data-fields/{member_data_field_guid}/detach")
756
+
757
+ if body is None:
758
+ await self._async_make_request("POST", url)
759
+ else:
760
+ await self._async_make_request("POST", url, body_slimmer(body))
761
+
762
+ def detach_member_data_field(self, parent_data_struct_guid: str, member_data_field_guid: str,
763
+ body: dict = None) -> None:
764
+ """
765
+ Detach a data class from a data structure. Request body is optional.
766
+
767
+ Parameters
768
+ ----------
769
+ parent_data_struct_guid: str
770
+ - the GUID of the parent data structure the data class will be detached fromo.
771
+ member_data_field_guid: str
772
+ - the GUID of the data class to be disconnected.
773
+ body: dict, optional
774
+ - a dictionary containing additional properties.
775
+
776
+ Returns
777
+ -------
778
+ None
779
+
780
+ Raises
781
+ ------
782
+ InvalidParameterException
783
+ one of the parameters is null or invalid or
784
+ PropertyServerException
785
+ There is a problem adding the element properties to the metadata repository or
786
+ UserNotAuthorizedException
787
+ the requesting user is not authorized to issue this request.
788
+
789
+ Note
790
+ ----
791
+
792
+ Full sample body:
793
+
794
+ {
795
+ "class": "MetadataSourceRequestBody",
796
+ "externalSourceGUID": "add guid here",
797
+ "externalSourceName": "add qualified name here",
798
+ "effectiveTime": "{{$isoTimestamp}}",
799
+ "forLineage": false,
800
+ "forDuplicateProcessing": false
801
+ }
802
+
803
+ """
804
+
805
+ loop = asyncio.get_event_loop()
806
+ loop.run_until_complete(
807
+ self._async_detach_member_data_field(parent_data_struct_guid, member_data_field_guid, body))
808
+
809
+ async def _async_delete_data_structure(self, data_struct_guid: str, body: dict = None) -> None:
810
+ """
811
+ Delete a data structure. Request body is optional. Async version.
812
+
813
+ Parameters
814
+ ----------
815
+ data_struct_guid: str
816
+ - the GUID of the parent data structure to delete.
817
+ body: dict, optional
818
+ - a dictionary containing additional properties.
819
+
820
+ Returns
821
+ -------
822
+ None
823
+
824
+ Raises
825
+ ------
826
+ InvalidParameterException
827
+ one of the parameters is null or invalid or
828
+ PropertyServerException
829
+ There is a problem adding the element properties to the metadata repository or
830
+ UserNotAuthorizedException
831
+ the requesting user is not authorized to issue this request.
832
+
833
+ Note
834
+ ----
835
+
836
+ Full sample body:
837
+
838
+ {
839
+ "class": "MetadataSourceRequestBody",
840
+ "externalSourceGUID": "add guid here",
841
+ "externalSourceName": "add qualified name here",
842
+ "effectiveTime": "{{$isoTimestamp}}",
843
+ "forLineage": false,
844
+ "forDuplicateProcessing": false
845
+ }
846
+
847
+
848
+ """
849
+
850
+ url = f"{base_path(self, self.view_server)}/data-structures/{data_struct_guid}/delete"
851
+
852
+ if body is None:
853
+ await self._async_make_request("POST", url)
854
+ else:
855
+ await self._async_make_request("POST", url, body_slimmer(body))
856
+
857
+ def delete_data_structure(self, data_struct_guid: str, body: dict = None) -> None:
858
+ """
859
+ Delete a data structure. Request body is optional.
860
+
861
+ Parameters
862
+ ----------
863
+ data_struct_guid: str
864
+ - the GUID of the data structure to delete.
865
+ body: dict, optional
866
+ - a dictionary containing additional properties.
867
+
868
+ Returns
869
+ -------
870
+ None
871
+
872
+ Raises
873
+ ------
874
+ InvalidParameterException
875
+ one of the parameters is null or invalid or
876
+ PropertyServerException
877
+ There is a problem adding the element properties to the metadata repository or
878
+ UserNotAuthorizedException
879
+ the requesting user is not authorized to issue this request.
880
+
881
+ Note
882
+ ----
883
+
884
+ Full sample body:
885
+
886
+ {
887
+ "class": "MetadataSourceRequestBody",
888
+ "externalSourceGUID": "add guid here",
889
+ "externalSourceName": "add qualified name here",
890
+ "effectiveTime": "{{$isoTimestamp}}",
891
+ "forLineage": false,
892
+ "forDuplicateProcessing": false
893
+ }
894
+
895
+ """
896
+
897
+ loop = asyncio.get_event_loop()
898
+ loop.run_until_complete(self._async_delete_data_field(data_struct_guid, body))
899
+
900
+ async def _async_find_all_data_structures(self, start_from: int = 0, page_size: int = max_paging_size,
901
+ output_format: str = "DICT") -> list | str:
902
+ """Returns a list of all known data structures. Async version.
903
+
904
+ Parameters
905
+ ----------
906
+ start_from: int, default = 0
907
+ - index of the list to start from (0 for start).
908
+ page_size
909
+ - maximum number of elements to return.
910
+ output_format: str, default = "DICT"
911
+ - output format of the data structure. Possible values: "DICT", "JSON", "MERMAID".
912
+
913
+ Returns
914
+ -------
915
+ [dict] | str
916
+ Returns a string if no elements are found and a list of dict of elements with the results.
917
+
918
+ Raises
919
+ ------
920
+ InvalidParameterException
921
+ one of the parameters is null or invalid or
922
+ PropertyServerException
923
+ There is a problem adding the element properties to the metadata repository or
924
+ UserNotAuthorizedException
925
+ the requesting user is not authorized to issue this request.
926
+
927
+ """
928
+
929
+ possible_query_params = query_string(
930
+ [("startFrom", start_from), ("pageSize", page_size), ("startsWith", 'false'), ("endsWith", 'false'),
931
+ ("ignoreCase", 'true')])
932
+
933
+ url = (f"{base_path(self, self.view_server)}/data-structures/by-search-string"
934
+ f"{possible_query_params}")
935
+
936
+ response: Response = await self._async_make_request("POST", url)
937
+
938
+ elements = response.json().get("elements", NO_ELEMENTS_FOUND)
939
+ if type(elements) is str:
940
+ return NO_ELEMENTS_FOUND
941
+ if output_format != 'JSON': # return other representations
942
+ return self.generate_data_structure_output(elements, filter, output_format)
943
+ return elements
944
+
945
+ def find_all_data_structures(self, start_from: int = 0, page_size: int = max_paging_size,
946
+ output_format: str = "DICT") -> list | str:
947
+ """ Returns a list of all known data structures.
948
+
949
+ Parameters
950
+ ----------
951
+ start_from: int, default = 0
952
+ - index of the list to start from (0 for start).
953
+ page_size
954
+ - maximum number of elements to return.
955
+ output_format: str, default = "DICT"
956
+ - output format of the data structure. Possible values: "DICT", "JSON", "MERMAID".
957
+
958
+
959
+ Returns
960
+ -------
961
+ [dict] | str
962
+ Returns a string if no elements are found and a list of dict elements with the results.
963
+
964
+ Raises
965
+ ------
966
+ InvalidParameterException
967
+ one of the parameters is null or invalid or
968
+ PropertyServerException
969
+ There is a problem adding the element properties to the metadata repository or
970
+ UserNotAuthorizedException
971
+ the requesting user is not authorized to issue this request.
972
+
973
+ """
974
+
975
+ loop = asyncio.get_event_loop()
976
+ response = loop.run_until_complete(self._async_find_all_data_structures(start_from, page_size, output_format))
977
+ return response
978
+
979
+ async def _async_find_data_structures_w_body(self, body: dict, start_from: int = 0,
980
+ page_size: int = max_paging_size, starts_with: bool = True,
981
+ ends_with: bool = False, ignore_case: bool = True,
982
+ output_format: str = "DICT") -> list | str:
983
+ """ Retrieve the list of data structure metadata elements that contain the search string.
984
+ Async version.
985
+
986
+ Parameters
987
+ ----------
988
+ body: dict
989
+ - A structure containing the search criteria. (example below)
990
+ start_from: int, default = 0
991
+ - index of the list to start from (0 for start).
992
+ page_size
993
+ - maximum number of elements to return.
994
+ starts_with: bool, default = True
995
+ - if True, the search string filters from the beginning of the string.
996
+ ends_with: bool, default = False
997
+ - if True, the search string filters from the end of the string.
998
+ ignore_case: bool, default = True
999
+ - If True, the case of the search string is ignored.
1000
+ output_format: str, default = "DICT"
1001
+ - output format of the data structure. Possible values: "DICT", "JSON", "MERMAID".
1002
+
1003
+ Returns
1004
+ -------
1005
+ [dict] | str
1006
+ Returns a string if no elements are found and a list of dict with the results.
1007
+
1008
+ Raises
1009
+ ------
1010
+ InvalidParameterException
1011
+ one of the parameters is null or invalid or
1012
+ PropertyServerException
1013
+ There is a problem adding the element properties to the metadata repository or
1014
+ UserNotAuthorizedException
1015
+ the requesting user is not authorized to issue this request.
1016
+
1017
+ Notes:
1018
+
1019
+ {
1020
+ "class": "FilterRequestBody",
1021
+ "asOfTime": "{{$isoTimestamp}}",
1022
+ "effectiveTime": "{{$isoTimestamp}}",
1023
+ "forLineage": false,
1024
+ "forDuplicateProcessing : false,
1025
+ "limitResultsByStatus": ["ACTIVE"],
1026
+ "sequencingOrder": "PROPERTY_ASCENDING",
1027
+ "sequencingProperty": "qualifiedName",
1028
+ "filter": ""
1029
+ }
1030
+
1031
+ """
1032
+ starts_with_s = str(starts_with).lower()
1033
+ ends_with_s = str(ends_with).lower()
1034
+ ignore_case_s = str(ignore_case).lower()
1035
+ possible_query_params = query_string(
1036
+ [("startFrom", start_from), ("pageSize", page_size), ("startsWith", starts_with_s),
1037
+ ("endsWith", ends_with_s), ("ignoreCase", ignore_case_s), ])
1038
+
1039
+ url = (f"{base_path(self, self.view_server)}/data-structures/by-search-string"
1040
+ f"{possible_query_params}")
1041
+
1042
+ response: Response = await self._async_make_request("POST", url, body_slimmer(body))
1043
+
1044
+ elements = response.json().get("elements", NO_ELEMENTS_FOUND)
1045
+ if type(elements) is list and len(elements) == 0:
1046
+ return NO_ELEMENTS_FOUND
1047
+ if output_format != 'JSON': # return other representations
1048
+ return self.generate_data_structure_output(elements, filter, output_format)
1049
+ return elements
1050
+
1051
+ def find_data_structures_w_body(self, body: dict, start_from: int = 0, page_size: int = max_paging_size,
1052
+ starts_with: bool = True, ends_with: bool = False, ignore_case: bool = True,
1053
+ output_format: str = "DICT") -> list | str:
1054
+ """ Retrieve the list of data structure metadata elements that contain the search string.
1055
+
1056
+ Parameters
1057
+ ----------
1058
+ body: dict
1059
+ - A structure containing the search criteria. (example below)
1060
+ start_from: int, default = 0
1061
+ - index of the list to start from (0 for start).
1062
+ page_size
1063
+ - maximum number of elements to return.
1064
+ starts_with: bool, default = True
1065
+ - if True, the search string filters from the beginning of the string.
1066
+ ends_with: bool, default = False
1067
+ - if True, the search string filters from the end of the string.
1068
+ ignore_case: bool, default = True
1069
+ - If True, the case of the search string is ignored.
1070
+ output_format: str, default = "DICT"
1071
+ - output format of the data structure. Possible values: "DICT", "JSON", "MERMAID".
1072
+
1073
+ Returns
1074
+ -------
1075
+ [dict] | str
1076
+ Returns a string if no elements are found and a list of dict with the results.
1077
+
1078
+ Raises
1079
+ ------
1080
+ InvalidParameterException
1081
+ one of the parameters is null or invalid or
1082
+ PropertyServerException
1083
+ There is a problem adding the element properties to the metadata repository or
1084
+ UserNotAuthorizedException
1085
+ the requesting user is not authorized to issue this request.
1086
+
1087
+ Notes:
1088
+
1089
+ {
1090
+ "class": "FilterRequestBody",
1091
+ "asOfTime": "{{$isoTimestamp}}",
1092
+ "effectiveTime": "{{$isoTimestamp}}",
1093
+ "forLineage": false,
1094
+ "forDuplicateProcessing : false,
1095
+ "limitResultsByStatus": ["ACTIVE"],
1096
+ "sequencingOrder": "PROPERTY_ASCENDING",
1097
+ "sequencingProperty": "qualifiedName",
1098
+ "filter": ""
1099
+ }
1100
+
1101
+ """
1102
+
1103
+ loop = asyncio.get_event_loop()
1104
+ response = loop.run_until_complete(
1105
+ self._async_find_data_structures_w_body(body, start_from, page_size, starts_with, ends_with, ignore_case,
1106
+ output_format))
1107
+ return response
1108
+
1109
+ async def _async_find_data_structures(self, filter: str, start_from: int = 0, page_size: int = max_paging_size,
1110
+ starts_with: bool = True, ends_with: bool = False, ignore_case: bool = True,
1111
+ output_format: str = "DICT") -> list | str:
1112
+ """ Find the list of data structure metadata elements that contain the search string.
1113
+ Async version.
1114
+
1115
+ Parameters
1116
+ ----------
1117
+ filter: str
1118
+ - search string to filter on.
1119
+ start_from: int, default = 0
1120
+ - index of the list to start from (0 for start).
1121
+ page_size
1122
+ - maximum number of elements to return.
1123
+ starts_with: bool, default = True
1124
+ - if True, the search string filters from the beginning of the string.
1125
+ ends_with: bool, default = False
1126
+ - if True, the search string filters from the end of the string.
1127
+ ignore_case: bool, default = True
1128
+ - If True, the case of the search string is ignored.
1129
+ output_format: str, default = "DICT"
1130
+ - one of "DICT", "MERMAID" or "JSON"
1131
+
1132
+ Returns
1133
+ -------
1134
+ [dict] | str
1135
+ Returns a string if no elements are found and a list of dict with the results.
1136
+
1137
+ Raises
1138
+ ------
1139
+ InvalidParameterException
1140
+ one of the parameters is null or invalid or
1141
+ PropertyServerException
1142
+ There is a problem adding the element properties to the metadata repository or
1143
+ UserNotAuthorizedException
1144
+ the requesting user is not authorized to issue this request.
1145
+
1146
+ """
1147
+
1148
+ body = {"filter": filter}
1149
+
1150
+ possible_query_params = query_string(
1151
+ [("startFrom", start_from), ("pageSize", page_size), ("startsWith", str(starts_with).lower),
1152
+ ("endsWith", str(ends_with).lower()), ("ignoreCase", str(ignore_case).lower()), ])
1153
+
1154
+ url = (f"{base_path(self, self.view_server)}/data-structures/by-search-string"
1155
+ f"{possible_query_params}")
1156
+
1157
+ response: Response = await self._async_make_request("POST", url, body_slimmer(body))
1158
+
1159
+ elements = response.json().get("elements", NO_ELEMENTS_FOUND)
1160
+ if type(elements) is str:
1161
+ return NO_ELEMENTS_FOUND
1162
+
1163
+ if output_format != 'JSON': # return a simplified markdown representation
1164
+ return self.generate_data_structure_output(elements, filter, output_format)
1165
+ return elements
1166
+
1167
+ def find_data_structures(self, filter: str, start_from: int = 0, page_size: int = max_paging_size,
1168
+ starts_with: bool = True, ends_with: bool = False, ignore_case: bool = True,
1169
+ output_format: str = "DICT") -> list | str:
1170
+ """ Retrieve the list of data structure metadata elements that contain the search string filter.
1171
+
1172
+ Parameters
1173
+ ----------
1174
+ filter: str
1175
+ - search string to filter on.
1176
+ start_from: int, default = 0
1177
+ - index of the list to start from (0 for start).
1178
+ page_size
1179
+ - maximum number of elements to return.
1180
+ starts_with: bool, default = True
1181
+ - if True, the search string filters from the beginning of the string.
1182
+ ends_with: bool, default = False
1183
+ - if True, the search string filters from the end of the string.
1184
+ ignore_case: bool, default = True
1185
+ - If True, the case of the search string is ignored.
1186
+ output_format: str, default = "DICT"
1187
+ output_format: str, default = "DICT"
1188
+ - one of "DICT", "MERMAID" or "JSON"
1189
+ Returns
1190
+ -------
1191
+ [dict] | str
1192
+ Returns a string if no elements are found and a list of dict with the results.
1193
+
1194
+ Raises
1195
+ ------
1196
+ InvalidParameterException
1197
+ one of the parameters is null or invalid or
1198
+ PropertyServerException
1199
+ There is a problem adding the element properties to the metadata repository or
1200
+ UserNotAuthorizedException
1201
+ the requesting user is not authorized to issue this request.
1202
+
1203
+
1204
+ """
1205
+
1206
+ loop = asyncio.get_event_loop()
1207
+ response = loop.run_until_complete(
1208
+ self._async_find_data_structures(filter, start_from, page_size, starts_with, ends_with, ignore_case,
1209
+ output_format))
1210
+ return response
1211
+
1212
+ async def _async_get_data_structures_by_name(self, filter: str, body: dict = None, start_from: int = 0,
1213
+ page_size: int = max_paging_size,
1214
+ output_format: str = "DICT") -> list | str:
1215
+ """ Get the list of data structure metadata elements with a matching name to the search string filter.
1216
+ Async version.
1217
+
1218
+ Parameters
1219
+ ----------
1220
+ filter: str
1221
+ - search string to filter on.
1222
+ body: dict, optional
1223
+ - a dictionary containing additional properties for the request.
1224
+ start_from: int, default = 0
1225
+ - index of the list to start from (0 for start).
1226
+ page_size
1227
+ - maximum number of elements to return.
1228
+ output_format: str, default = "DICT"
1229
+ - one of "DICT", "MERMAID" or "JSON"
1230
+ Returns
1231
+ -------
1232
+ [dict] | str
1233
+ Returns a string if no elements are found and a list of dict with the results.
1234
+
1235
+ Raises
1236
+ ------
1237
+ InvalidParameterException
1238
+ one of the parameters is null or invalid or
1239
+ PropertyServerException
1240
+ There is a problem adding the element properties to the metadata repository or
1241
+ UserNotAuthorizedException
1242
+ the requesting user is not authorized to issue this request.
1243
+
1244
+ Notes
1245
+ -----
1246
+ {
1247
+ "class": "FilterRequestBody",
1248
+ "asOfTime": "{{$isoTimestamp}}",
1249
+ "effectiveTime": "{{$isoTimestamp}}",
1250
+ "forLineage": false,
1251
+ "forDuplicateProcessing": false,
1252
+ "limitResultsByStatus": ["ACTIVE"],
1253
+ "sequencingOrder": "PROPERTY_ASCENDING",
1254
+ "sequencingProperty": "qualifiedName",
1255
+ "filter": "Add name here"
1256
+ }
1257
+ """
1258
+ if body is None:
1259
+ body = {"filter": filter}
1260
+
1261
+ possible_query_params = query_string([("startFrom", start_from), ("pageSize", page_size), ])
1262
+
1263
+ url = (f"{base_path(self, self.view_server)}/data-structures/by-name"
1264
+ f"{possible_query_params}")
1265
+
1266
+ response: Response = await self._async_make_request("POST", url, body_slimmer(body))
1267
+
1268
+ elements = response.json().get("elements", NO_ELEMENTS_FOUND)
1269
+ if type(elements) is str:
1270
+ return NO_ELEMENTS_FOUND
1271
+ if output_format != 'JSON': # return other representations
1272
+ return self.generate_data_structure_output(elements, filter, output_format)
1273
+ return elements
1274
+
1275
+ def get_data_structures_by_name(self, filter: str, body: dict = None, start_from: int = 0,
1276
+ page_size: int = max_paging_size, output_format: str = "DICT") -> list | str:
1277
+ """ Get the list of data structure metadata elements with a matching name to the search string filter.
1278
+
1279
+ Parameters
1280
+ ----------
1281
+ filter: str
1282
+ - search string to filter on.
1283
+ body: dict, optional
1284
+ - a dictionary containing additional properties for the request.
1285
+ start_from: int, default = 0
1286
+ - index of the list to start from (0 for start).
1287
+ page_size
1288
+ - maximum number of elements to return.
1289
+ output_format: str, default = "DICT"
1290
+ - one of "DICT", "MERMAID" or "JSON"
1291
+
1292
+ Returns
1293
+ -------
1294
+ [dict] | str
1295
+ Returns a string if no elements are found and a list of dict with the results.
1296
+
1297
+ Raises
1298
+ ------
1299
+ InvalidParameterException
1300
+ one of the parameters is null or invalid or
1301
+ PropertyServerException
1302
+ There is a problem adding the element properties to the metadata repository or
1303
+ UserNotAuthorizedException
1304
+ the requesting user is not authorized to issue this request.
1305
+
1306
+
1307
+ """
1308
+
1309
+ loop = asyncio.get_event_loop()
1310
+ response = loop.run_until_complete(
1311
+ self._async_get_data_structures_by_name(filter, body, start_from, page_size, output_format))
1312
+ return response
1313
+
1314
+ async def _async_get_data_structures_by_guid(self, guid: str, body: dict = None, output_format: str = "DICT") -> list | str:
1315
+ """ Get the data structure metadata elements for the specified GUID.
1316
+ Async version.
1317
+
1318
+ Parameters
1319
+ ----------
1320
+ guid: str
1321
+ - unique identifier of the data structure metadata element.
1322
+ body: dict, optional
1323
+ - optional request body.
1324
+ output_format: str, default = "DICT"
1325
+ - one of "DICT", "MERMAID" or "JSON"
1326
+ Returns
1327
+ -------
1328
+ [dict] | str
1329
+ Returns a string if no elements are found and a list of dict with the results.
1330
+
1331
+ Raises
1332
+ ------
1333
+ InvalidParameterException
1334
+ one of the parameters is null or invalid or
1335
+ PropertyServerException
1336
+ There is a problem adding the element properties to the metadata repository or
1337
+ UserNotAuthorizedException
1338
+ the requesting user is not authorized to issue this request.
1339
+
1340
+ Notes
1341
+ ----
1342
+
1343
+ Optional request body:
1344
+ {
1345
+ "class": "AnyTimeRequestBody",
1346
+ "asOfTime": "{{$isoTimestamp}}",
1347
+ "effectiveTime": "{{$isoTimestamp}}",
1348
+ "forLineage": false,
1349
+ "forDuplicateProcessing": false
1350
+ }
1351
+
1352
+ """
1353
+
1354
+ url = (f"{base_path(self, self.view_server)}/data-structures/{guid}/retrieve")
1355
+ if body:
1356
+ response: Response = await self._async_make_request("POST", url, body_slimmer(body))
1357
+ else:
1358
+ response: Response = await self._async_make_request("POST", url)
1359
+
1360
+ element = response.json().get("element", NO_ELEMENTS_FOUND)
1361
+ if type(element) is str:
1362
+ return NO_ELEMENTS_FOUND
1363
+ if output_format != 'JSON': # return other representations
1364
+ return self.generate_data_structure_output(element, filter, output_format)
1365
+ return element
1366
+
1367
+ def get_data_structures_by_guid(self, guid: str, body: str = None,
1368
+ output_format: str = "DICT") -> list | str:
1369
+ """ Get the data structure metadata element with the specified unique identifier..
1370
+
1371
+ Parameters
1372
+ ----------
1373
+ guid: str
1374
+ - unique identifier of the data structure metadata element.
1375
+ body: dict, optional
1376
+ - optional request body.
1377
+ output_format: str, default = "DICT"
1378
+ - one of "DICT", "MERMAID" or "JSON"
1379
+ Returns
1380
+ -------
1381
+ [dict] | str
1382
+ Returns a string if no elements are found and a list of dict with the results.
1383
+
1384
+ Raises
1385
+ ------
1386
+ InvalidParameterException
1387
+ one of the parameters is null or invalid or
1388
+ PropertyServerException
1389
+ There is a problem adding the element properties to the metadata repository or
1390
+ UserNotAuthorizedException
1391
+ the requesting user is not authorized to issue this request.
1392
+
1393
+ Notes
1394
+ ----
1395
+
1396
+ Optional request body:
1397
+ {
1398
+ "class": "AnyTimeRequestBody",
1399
+ "asOfTime": "{{$isoTimestamp}}",
1400
+ "effectiveTime": "{{$isoTimestamp}}",
1401
+ "forLineage": false,
1402
+ "forDuplicateProcessing": false
1403
+ }
1404
+
1405
+ """
1406
+
1407
+ loop = asyncio.get_event_loop()
1408
+ response = loop.run_until_complete(self._async_get_data_structures_by_guid(guid, body, output_format))
1409
+ return response
1410
+
1411
+ #
1412
+ # Work with Data Fields
1413
+ # https://egeria-project.org/concepts/data-class
1414
+ #
1415
+ async def _async_create_data_field(self, body: dict) -> str:
1416
+ """
1417
+ Create a new data class with parameters defined in the body. Async version.
1418
+
1419
+ Parameters
1420
+ ----------
1421
+ body: dict
1422
+ - a dictionary containing the properties of the data class to be created.
1423
+
1424
+ Returns
1425
+ -------
1426
+ str
1427
+ The GUID of the element - or "No element found"
1428
+
1429
+ Raises
1430
+ ------
1431
+ InvalidParameterException
1432
+ one of the parameters is null or invalid or
1433
+ PropertyServerException
1434
+ There is a problem adding the element properties to the metadata repository or
1435
+ UserNotAuthorizedException
1436
+ the requesting user is not authorized to issue this request.
1437
+
1438
+ Note
1439
+ ----
1440
+ Sample bodies:
1441
+
1442
+ {
1443
+ "class" : "NewDataFieldRequestBody",
1444
+ "externalSourceGUID": "add guid here",
1445
+ "externalSourceName": "add qualified name here",
1446
+ "effectiveTime" : "{{$isoTimestamp}}",
1447
+ "forLineage" : false,
1448
+ "forDuplicateProcessing" : false,
1449
+ "anchorGUID" : "add guid here",
1450
+ "isOwnAnchor": false,
1451
+ "parentGUID": "add guid here",
1452
+ "parentRelationshipTypeName": "add type name here",
1453
+ "parentRelationshipProperties": {
1454
+ "class": "ElementProperties",
1455
+ "propertyValueMap" : {
1456
+ "description" : {
1457
+ "class": "PrimitiveTypePropertyValue",
1458
+ "typeName": "string",
1459
+ "primitiveValue" : "New description"
1460
+ }
1461
+ }
1462
+ },
1463
+ "parentAtEnd1": false,
1464
+ "properties": {
1465
+ "class" : "DataFieldProperties",
1466
+ "qualifiedName": "add unique name here",
1467
+ "displayName": "add short name here",
1468
+ "namespace": "",
1469
+ "description": "add description here",
1470
+ "versionIdentifier": "add version",
1471
+ "aliases": ["alias1", "alias2"],
1472
+ "isDeprecated": false,
1473
+ "isNullable" : false,
1474
+ "defaultValue": "",
1475
+ "dataType": "",
1476
+ "minimumLength": 0,
1477
+ "length": 0,
1478
+ "precision": 0,
1479
+ "orderedValues": false,
1480
+ "sortOrder": "UNSORTED",
1481
+ "additionalProperties": {
1482
+ "property1" : "propertyValue1",
1483
+ "property2" : "propertyValue2"
1484
+ },
1485
+ "effectiveFrom": "{{$isoTimestamp}}",
1486
+ "effectiveTo": "{{$isoTimestamp}}"
1487
+ }
1488
+ }
1489
+ or
1490
+ {
1491
+ "properties": {
1492
+ "class": "DataFieldProperties",
1493
+ "qualifiedName": "add unique name here",
1494
+ "displayName": "add short name here",
1495
+ "namespace": "",
1496
+ "description": "add description here",
1497
+ "versionIdentifier": "add version",
1498
+ "aliases": [
1499
+ "alias1",
1500
+ "alias2"
1501
+ ],
1502
+ "namePatterns": [],
1503
+ "isDeprecated": false,
1504
+ "isNullable": false,
1505
+ "defaultValue": "",
1506
+ "dataType": "",
1507
+ "minimumLength": 0,
1508
+ "length": 0,
1509
+ "precision": 0,
1510
+ "orderedValues": false,
1511
+ "sortOrder": "UNSORTED",
1512
+ "additionalProperties": {
1513
+ "property1": "propertyValue1",
1514
+ "property2": "propertyValue2"
1515
+ }
1516
+ }
1517
+ }
1518
+
1519
+
1520
+ """
1521
+
1522
+ url = f"{base_path(self, self.view_server)}/data-fields"
1523
+
1524
+ response: Response = await self._async_make_request("POST", url, body_slimmer(body))
1525
+ return response.json().get("guid", NO_ELEMENTS_FOUND)
1526
+
1527
+ def create_data_field(self, body: dict) -> str:
1528
+ """
1529
+ Create a new data class with parameters defined in the body..
1530
+
1531
+ Parameters
1532
+ ----------
1533
+ body: dict
1534
+ - a dictionary containing the properties of the data class to be created.
1535
+
1536
+ Returns
1537
+ -------
1538
+ str
1539
+ The GUID of the element - or "No element found"
1540
+
1541
+ Raises
1542
+ ------
1543
+ InvalidParameterException
1544
+ one of the parameters is null or invalid or
1545
+ PropertyServerException
1546
+ There is a problem adding the element properties to the metadata repository or
1547
+ UserNotAuthorizedException
1548
+ the requesting user is not authorized to issue this request.
1549
+
1550
+ Note
1551
+ ----
1552
+
1553
+ Sample bodies:
1554
+
1555
+ {
1556
+ "class" : "NewDataFieldRequestBody",
1557
+ "externalSourceGUID": "add guid here",
1558
+ "externalSourceName": "add qualified name here",
1559
+ "effectiveTime" : "{{$isoTimestamp}}",
1560
+ "forLineage" : false,
1561
+ "forDuplicateProcessing" : false,
1562
+ "anchorGUID" : "add guid here",
1563
+ "isOwnAnchor": false,
1564
+ "parentGUID": "add guid here",
1565
+ "parentRelationshipTypeName": "add type name here",
1566
+ "parentRelationshipProperties": {
1567
+ "class": "ElementProperties",
1568
+ "propertyValueMap" : {
1569
+ "description" : {
1570
+ "class": "PrimitiveTypePropertyValue",
1571
+ "typeName": "string",
1572
+ "primitiveValue" : "New description"
1573
+ }
1574
+ }
1575
+ },
1576
+ "parentAtEnd1": false,
1577
+ "properties": {
1578
+ "class" : "DataFieldProperties",
1579
+ "qualifiedName": "add unique name here",
1580
+ "displayName": "add short name here",
1581
+ "namespace": "",
1582
+ "description": "add description here",
1583
+ "versionIdentifier": "add version",
1584
+ "aliases": ["alias1", "alias2"],
1585
+ "isDeprecated": false,
1586
+ "isNullable" : false,
1587
+ "defaultValue": "",
1588
+ "dataType": "",
1589
+ "minimumLength": 0,
1590
+ "length": 0,
1591
+ "precision": 0,
1592
+ "orderedValues": false,
1593
+ "sortOrder": "UNSORTED",
1594
+ "additionalProperties": {
1595
+ "property1" : "propertyValue1",
1596
+ "property2" : "propertyValue2"
1597
+ },
1598
+ "effectiveFrom": "{{$isoTimestamp}}",
1599
+ "effectiveTo": "{{$isoTimestamp}}"
1600
+ }
1601
+ }
1602
+ or
1603
+ {
1604
+ "properties": {
1605
+ "class": "DataFieldProperties",
1606
+ "qualifiedName": "add unique name here",
1607
+ "displayName": "add short name here",
1608
+ "namespace": "",
1609
+ "description": "add description here",
1610
+ "versionIdentifier": "add version",
1611
+ "aliases": [
1612
+ "alias1",
1613
+ "alias2"
1614
+ ],
1615
+ "namePatterns": [],
1616
+ "isDeprecated": false,
1617
+ "isNullable": false,
1618
+ "defaultValue": "",
1619
+ "dataType": "",
1620
+ "minimumLength": 0,
1621
+ "length": 0,
1622
+ "precision": 0,
1623
+ "orderedValues": false,
1624
+ "sortOrder": "UNSORTED",
1625
+ "additionalProperties": {
1626
+ "property1": "propertyValue1",
1627
+ "property2": "propertyValue2"
1628
+ }
1629
+ }
1630
+ }
1631
+
1632
+
1633
+ """
1634
+
1635
+ loop = asyncio.get_event_loop()
1636
+ response = loop.run_until_complete(self._async_create_data_field(body))
1637
+ return response
1638
+
1639
+ async def _async_create_data_field_from_template(self, body: dict) -> str:
1640
+ """
1641
+ Create a new metadata element to represent a data class using an existing metadata element as a template.
1642
+ The template defines additional classifications and relationships that should be added to the new element.
1643
+ Async version.
1644
+
1645
+ Parameters
1646
+ ----------
1647
+ body: dict
1648
+ - a dictionary containing the properties of the data class to be created.
1649
+
1650
+ Returns
1651
+ -------
1652
+ str
1653
+ The GUID of the element - or "No element found"
1654
+
1655
+ Raises
1656
+ ------
1657
+ InvalidParameterException
1658
+ one of the parameters is null or invalid or
1659
+ PropertyServerException
1660
+ There is a problem adding the element properties to the metadata repository or
1661
+ UserNotAuthorizedException
1662
+ the requesting user is not authorized to issue this request.
1663
+
1664
+ Note
1665
+ ----
1666
+ {
1667
+ "class" : "TemplateRequestBody",
1668
+ "externalSourceGUID": "add guid here",
1669
+ "externalSourceName": "add qualified name here",
1670
+ "effectiveTime" : "{{$isoTimestamp}}",
1671
+ "forLineage" : false,
1672
+ "forDuplicateProcessing" : false,
1673
+ "anchorGUID" : "add guid here",
1674
+ "isOwnAnchor": false,
1675
+ "parentGUID": "add guid here",
1676
+ "parentRelationshipTypeName": "add type name here",
1677
+ "parentRelationshipProperties": {
1678
+ "class": "ElementProperties",
1679
+ "propertyValueMap" : {
1680
+ "description" : {
1681
+ "class": "PrimitiveTypePropertyValue",
1682
+ "typeName": "string",
1683
+ "primitiveValue" : "New description"
1684
+ }
1685
+ }
1686
+ },
1687
+ "parentAtEnd1": false,
1688
+ "templateGUID": "add guid here",
1689
+ "replacementProperties": {
1690
+ "class": "ElementProperties",
1691
+ "propertyValueMap" : {
1692
+ "description" : {
1693
+ "class": "PrimitiveTypePropertyValue",
1694
+ "typeName": "string",
1695
+ "primitiveValue" : "New description"
1696
+ }
1697
+ }
1698
+ },
1699
+ "placeholderPropertyValues": {
1700
+ "placeholder1" : "propertyValue1",
1701
+ "placeholder2" : "propertyValue2"
1702
+ }
1703
+ }
1704
+
1705
+ """
1706
+
1707
+ url = f"{base_path(self, self.view_server)}/data-fields/from-template"
1708
+
1709
+ response: Response = await self._async_make_request("POST", url, body_slimmer(body))
1710
+ return response.json().get("guid", NO_ELEMENTS_FOUND)
1711
+
1712
+ def create_data_field_from_template(self, body: dict) -> str:
1713
+ """
1714
+ Create a new metadata element to represent a data class using an existing metadata element as a template.
1715
+ The template defines additional classifications and relationships that should be added to the new element.
1716
+ Async version.
1717
+
1718
+ Parameters
1719
+ ----------
1720
+ body: dict
1721
+ - a dictionary containing the properties of the data class to be created.
1722
+
1723
+ Returns
1724
+ -------
1725
+ str
1726
+ The GUID of the element - or "No element found"
1727
+
1728
+ Raises
1729
+ ------
1730
+ InvalidParameterException
1731
+ one of the parameters is null or invalid or
1732
+ PropertyServerException
1733
+ There is a problem adding the element properties to the metadata repository or
1734
+ UserNotAuthorizedException
1735
+ the requesting user is not authorized to issue this request.
1736
+
1737
+ Note
1738
+ ----
1739
+ {
1740
+ "class" : "TemplateRequestBody",
1741
+ "externalSourceGUID": "add guid here",
1742
+ "externalSourceName": "add qualified name here",
1743
+ "effectiveTime" : "{{$isoTimestamp}}",
1744
+ "forLineage" : false,
1745
+ "forDuplicateProcessing" : false,
1746
+ "anchorGUID" : "add guid here",
1747
+ "isOwnAnchor": false,
1748
+ "parentGUID": "add guid here",
1749
+ "parentRelationshipTypeName": "add type name here",
1750
+ "parentRelationshipProperties": {
1751
+ "class": "ElementProperties",
1752
+ "propertyValueMap" : {
1753
+ "description" : {
1754
+ "class": "PrimitiveTypePropertyValue",
1755
+ "typeName": "string",
1756
+ "primitiveValue" : "New description"
1757
+ }
1758
+ }
1759
+ },
1760
+ "parentAtEnd1": false,
1761
+ "templateGUID": "add guid here",
1762
+ "replacementProperties": {
1763
+ "class": "ElementProperties",
1764
+ "propertyValueMap" : {
1765
+ "description" : {
1766
+ "class": "PrimitiveTypePropertyValue",
1767
+ "typeName": "string",
1768
+ "primitiveValue" : "New description"
1769
+ }
1770
+ }
1771
+ },
1772
+ "placeholderPropertyValues": {
1773
+ "placeholder1" : "propertyValue1",
1774
+ "placeholder2" : "propertyValue2"
1775
+ }
1776
+ }
1777
+
1778
+ """
1779
+
1780
+ loop = asyncio.get_event_loop()
1781
+ response = loop.run_until_complete(self._async_create_data_field_from_template(body))
1782
+ return response
1783
+
1784
+ async def _async_update_data_field(self, data_field_guid: str, body: dict,
1785
+ replace_all_properties: bool = False) -> None:
1786
+ """
1787
+ Update the properties of a data class. Async version.
1788
+
1789
+ Parameters
1790
+ ----------
1791
+ data_field_guid: str
1792
+ - the GUID of the data class to be updated.
1793
+ body: dict
1794
+ - a dictionary containing the properties of the data structure to be created.
1795
+ replace_all_properties: bool, default = False
1796
+ - if true, then all properties will be replaced with the new ones. Otherwise, only the specified ones
1797
+ will be replaced.
1798
+ Returns
1799
+ -------
1800
+ None
1801
+
1802
+ Raises
1803
+ ------
1804
+ InvalidParameterException
1805
+ one of the parameters is null or invalid or
1806
+ PropertyServerException
1807
+ There is a problem adding the element properties to the metadata repository or
1808
+ UserNotAuthorizedException
1809
+ the requesting user is not authorized to issue this request.
1810
+
1811
+ Note
1812
+ ----
1813
+
1814
+ Full sample body:
1815
+
1816
+ {
1817
+ "class" : "UpdateDataFieldRequestBody",
1818
+ "externalSourceGUID": "add guid here",
1819
+ "externalSourceName": "add qualified name here",
1820
+ "effectiveTime" : "{{$isoTimestamp}}",
1821
+ "forLineage" : false,
1822
+ "forDuplicateProcessing" : false,
1823
+ "properties": {
1824
+ "class" : "DataFieldProperties",
1825
+ "qualifiedName": "add unique name here",
1826
+ "displayName": "add short name here",
1827
+ "namespace": "",
1828
+ "description": "add description here",
1829
+ "versionIdentifier": "add version",
1830
+ "aliases": ["alias1", "alias2"],
1831
+ "namePatterns": [],
1832
+ "isDeprecated": false,
1833
+ "isNullable" : false,
1834
+ "defaultValue": "",
1835
+ "dataType": "",
1836
+ "minimumLength": 0,
1837
+ "length": 0,
1838
+ "precision": 0,
1839
+ "orderedValues": false,
1840
+ "sortOrder": "UNSORTED",
1841
+ "additionalProperties": {
1842
+ "property1" : "propertyValue1",
1843
+ "property2" : "propertyValue2"
1844
+ },
1845
+ "effectiveFrom": "{{$isoTimestamp}}",
1846
+ "effectiveTo": "{{$isoTimestamp}}"
1847
+ }
1848
+ }
1849
+
1850
+ """
1851
+ replace_all_properties_s = str(replace_all_properties).lower()
1852
+
1853
+ url = (f"{base_path(self, self.view_server)}/data-fields/{data_field_guid}/update?"
1854
+ f"replaceAllProperties={replace_all_properties_s}")
1855
+
1856
+ await self._async_make_request("POST", url, body_slimmer(body))
1857
+
1858
+ def update_data_field(self, data_field_guid: str, body: dict.get, replace_all_properties: bool = False) -> None:
1859
+ """
1860
+ Update the properties of a data class.
1861
+
1862
+ Parameters
1863
+ ----------
1864
+ data_field_guid: str
1865
+ - the GUID of the data class to be updated.
1866
+ body: dict
1867
+ - a dictionary containing the properties of the data structure to be created.
1868
+ replace_all_properties: bool, default = False
1869
+ - if true, then all properties will be replaced with the new ones. Otherwise, only the specified ones
1870
+ will be replaced.
1871
+ Returns
1872
+ -------
1873
+ None
1874
+
1875
+ Raises
1876
+ ------
1877
+ InvalidParameterException
1878
+ one of the parameters is null or invalid or
1879
+ PropertyServerException
1880
+ There is a problem adding the element properties to the metadata repository or
1881
+ UserNotAuthorizedException
1882
+ the requesting user is not authorized to issue this request.
1883
+
1884
+ Note
1885
+ ----
1886
+
1887
+ Full sample body:
1888
+
1889
+ {
1890
+ "class" : "UpdateDataFieldRequestBody",
1891
+ "externalSourceGUID": "add guid here",
1892
+ "externalSourceName": "add qualified name here",
1893
+ "effectiveTime" : "{{$isoTimestamp}}",
1894
+ "forLineage" : false,
1895
+ "forDuplicateProcessing" : false,
1896
+ "properties": {
1897
+ "class" : "DataFieldProperties",
1898
+ "qualifiedName": "add unique name here",
1899
+ "displayName": "add short name here",
1900
+ "namespace": "",
1901
+ "description": "add description here",
1902
+ "versionIdentifier": "add version",
1903
+ "aliases": ["alias1", "alias2"],
1904
+ "namePatterns": [],
1905
+ "isDeprecated": false,
1906
+ "isNullable" : false,
1907
+ "defaultValue": "",
1908
+ "dataType": "",
1909
+ "minimumLength": 0,
1910
+ "length": 0,
1911
+ "precision": 0,
1912
+ "orderedValues": false,
1913
+ "sortOrder": "UNSORTED",
1914
+ "additionalProperties": {
1915
+ "property1" : "propertyValue1",
1916
+ "property2" : "propertyValue2"
1917
+ },
1918
+ "effectiveFrom": "{{$isoTimestamp}}",
1919
+ "effectiveTo": "{{$isoTimestamp}}"
1920
+ }
1921
+ }
1922
+ """
1923
+
1924
+ loop = asyncio.get_event_loop()
1925
+ loop.run_until_complete(self._async_update_data_field(data_field_guid, body, replace_all_properties))
1926
+
1927
+ async def _async_link_nested_data_field(self, parent_data_field_guid: str, nested_data_field_guid: str,
1928
+ body: dict = None) -> None:
1929
+ """
1930
+ Connect a nested data class to a data class. Request body is optional. Async version.
1931
+
1932
+ Parameters
1933
+ ----------
1934
+ parent_data_field_guid: str
1935
+ - the GUID of the parent data class the nested data class will be connected to.
1936
+ nested_data_field_guid: str
1937
+ - the GUID of the nested data class to be connected.
1938
+ body: dict, optional
1939
+ - a dictionary containing additional properties.
1940
+
1941
+ Returns
1942
+ -------
1943
+ None
1944
+
1945
+ Raises
1946
+ ------
1947
+ InvalidParameterException
1948
+ one of the parameters is null or invalid or
1949
+ PropertyServerException
1950
+ There is a problem adding the element properties to the metadata repository or
1951
+ UserNotAuthorizedException
1952
+ the requesting user is not authorized to issue this request.
1953
+
1954
+ Note
1955
+ ----
1956
+
1957
+ Full sample body:
1958
+
1959
+ {
1960
+ "class" : "MemberDataFieldRequestBody",
1961
+ "externalSourceGUID": "add guid here",
1962
+ "externalSourceName": "add qualified name here",
1963
+ "effectiveTime" : "{{$isoTimestamp}}",
1964
+ "forLineage" : false,
1965
+ "forDuplicateProcessing" : false,
1966
+ "properties": {
1967
+ "class": "MemberDataFieldProperties",
1968
+ "dataFieldPosition": 0,
1969
+ "minCardinality": 0,
1970
+ "maxCardinality": 0,
1971
+ "effectiveFrom": "{{$isoTimestamp}}",
1972
+ "effectiveTo": "{{$isoTimestamp}}"
1973
+ }
1974
+ }
1975
+
1976
+ """
1977
+
1978
+ url = (f"{base_path(self, self.view_server)}/data-fields/{parent_data_field_guid}"
1979
+ f"/nested-data-fields/{nested_data_field_guid}/attach")
1980
+
1981
+ if body is None:
1982
+ await self._async_make_request("POST", url)
1983
+ else:
1984
+ await self._async_make_request("POST", url, body_slimmer(body))
1985
+
1986
+ def link_nested_data_field(self, parent_data_field_guid: str, nested_data_field_guid: str,
1987
+ body: dict = None) -> None:
1988
+ """
1989
+ Connect a nested data class to a data class. Request body is optional.
1990
+
1991
+ Parameters
1992
+ ----------
1993
+ parent_data_field_guid: str
1994
+ - the GUID of the parent data class the nested data class will be connected to.
1995
+ nested_data_field_guid: str
1996
+ - the GUID of the nested data class to be connected.
1997
+ body: dict, optional
1998
+ - a dictionary containing additional properties.
1999
+
2000
+ Returns
2001
+ -------
2002
+ None
2003
+
2004
+ Raises
2005
+ ------
2006
+ InvalidParameterException
2007
+ one of the parameters is null or invalid or
2008
+ PropertyServerException
2009
+ There is a problem adding the element properties to the metadata repository or
2010
+ UserNotAuthorizedException
2011
+ the requesting user is not authorized to issue this request.
2012
+
2013
+ Note
2014
+ ----
2015
+
2016
+ Full sample body:
2017
+
2018
+ {
2019
+ "class" : "MemberDataFieldRequestBody",
2020
+ "externalSourceGUID": "add guid here",
2021
+ "externalSourceName": "add qualified name here",
2022
+ "effectiveTime" : "{{$isoTimestamp}}",
2023
+ "forLineage" : false,
2024
+ "forDuplicateProcessing" : false,
2025
+ "properties": {
2026
+ "class": "MemberDataFieldProperties",
2027
+ "dataFieldPosition": 0,
2028
+ "minCardinality": 0,
2029
+ "maxCardinality": 0,
2030
+ "effectiveFrom": "{{$isoTimestamp}}",
2031
+ "effectiveTo": "{{$isoTimestamp}}"
2032
+ }
2033
+ }
2034
+
2035
+ """
2036
+
2037
+ loop = asyncio.get_event_loop()
2038
+ loop.run_until_complete(
2039
+ self._async_link_nested_data_field(parent_data_field_guid, nested_data_field_guid, body))
2040
+
2041
+ async def _async_detach_nested_data_field(self, parent_data_field_guid: str, nested_data_field_guid: str,
2042
+ body: dict = None) -> None:
2043
+ """
2044
+ Detach a nested data class from a data class. Request body is optional. Async version.
2045
+
2046
+ Parameters
2047
+ ----------
2048
+ parent_data_field_guid: str
2049
+ - the GUID of the parent data class the data class will be detached from..
2050
+ nested_data_field_guid: str
2051
+ - the GUID of the data class to be disconnected.
2052
+ body: dict, optional
2053
+ - a dictionary containing additional properties.
2054
+
2055
+ Returns
2056
+ -------
2057
+ None
2058
+
2059
+ Raises
2060
+ ------
2061
+ InvalidParameterException
2062
+ one of the parameters is null or invalid or
2063
+ PropertyServerException
2064
+ There is a problem adding the element properties to the metadata repository or
2065
+ UserNotAuthorizedException
2066
+ the requesting user is not authorized to issue this request.
2067
+
2068
+ Note
2069
+ ----
2070
+
2071
+ Full sample body:
2072
+
2073
+ {
2074
+ "class": "MetadataSourceRequestBody",
2075
+ "externalSourceGUID": "add guid here",
2076
+ "externalSourceName": "add qualified name here",
2077
+ "effectiveTime": "{{$isoTimestamp}}",
2078
+ "forLineage": false,
2079
+ "forDuplicateProcessing": false
2080
+ }
2081
+
2082
+
2083
+ """
2084
+
2085
+ url = (f"{base_path(self, self.view_server)}/data-fields/{parent_data_field_guid}"
2086
+ f"/member-data-fields/{nested_data_field_guid}/detach")
2087
+
2088
+ if body is None:
2089
+ await self._async_make_request("POST", url)
2090
+ else:
2091
+ await self._async_make_request("POST", url, body_slimmer(body))
2092
+
2093
+ def detach_nested_data_field(self, parent_data_field_guid: str, nested_data_field_guid: str,
2094
+ body: dict = None) -> None:
2095
+ """
2096
+ Detach a nested data class from a data class. Request body is optional.
2097
+
2098
+ Parameters
2099
+ ----------
2100
+ parent_data_field_guid: str
2101
+ - the GUID of the parent data structure the data class will be detached fromo.
2102
+ nested_data_field_guid: str
2103
+ - the GUID of the data class to be disconnected.
2104
+ body: dict, optional
2105
+ - a dictionary containing additional properties.
2106
+
2107
+ Returns
2108
+ -------
2109
+ None
2110
+
2111
+ Raises
2112
+ ------
2113
+ InvalidParameterException
2114
+ one of the parameters is null or invalid or
2115
+ PropertyServerException
2116
+ There is a problem adding the element properties to the metadata repository or
2117
+ UserNotAuthorizedException
2118
+ the requesting user is not authorized to issue this request.
2119
+
2120
+ Note
2121
+ ----
2122
+
2123
+ Full sample body:
2124
+
2125
+ {
2126
+ "class": "MetadataSourceRequestBody",
2127
+ "externalSourceGUID": "add guid here",
2128
+ "externalSourceName": "add qualified name here",
2129
+ "effectiveTime": "{{$isoTimestamp}}",
2130
+ "forLineage": false,
2131
+ "forDuplicateProcessing": false
2132
+ }
2133
+
2134
+ """
2135
+
2136
+ loop = asyncio.get_event_loop()
2137
+ loop.run_until_complete(
2138
+ self._async_detach_nested_data_field(parent_data_field_guid, nested_data_field_guid, body))
2139
+
2140
+ async def _async_delete_data_field(self, data_field_guid: str, body: dict = None) -> None:
2141
+ """
2142
+ Delete a data class. Request body is optional. Async version.
2143
+
2144
+ Parameters
2145
+ ----------
2146
+ data_field_guid: str
2147
+ - the GUID of the data class to delete.
2148
+ body: dict, optional
2149
+ - a dictionary containing additional properties.
2150
+
2151
+ Returns
2152
+ -------
2153
+ None
2154
+
2155
+ Raises
2156
+ ------
2157
+ InvalidParameterException
2158
+ one of the parameters is null or invalid or
2159
+ PropertyServerException
2160
+ There is a problem adding the element properties to the metadata repository or
2161
+ UserNotAuthorizedException
2162
+ the requesting user is not authorized to issue this request.
2163
+
2164
+ Note
2165
+ ----
2166
+
2167
+ Full sample body:
2168
+
2169
+ {
2170
+ "class": "MetadataSourceRequestBody",
2171
+ "externalSourceGUID": "add guid here",
2172
+ "externalSourceName": "add qualified name here",
2173
+ "effectiveTime": "{{$isoTimestamp}}",
2174
+ "forLineage": false,
2175
+ "forDuplicateProcessing": false
2176
+ }
2177
+
2178
+
2179
+ """
2180
+
2181
+ url = f"{base_path(self, self.view_server)}/data-fields/{data_field_guid}/delete"
2182
+
2183
+ if body is None:
2184
+ await self._async_make_request("POST", url)
2185
+ else:
2186
+ await self._async_make_request("POST", url, body_slimmer(body))
2187
+
2188
+ def delete_data_field(self, data_field_guid: str, body: dict = None) -> None:
2189
+ """
2190
+ Delete a data class. Request body is optional.
2191
+
2192
+ Parameters
2193
+ ----------
2194
+ data_field_guid: str
2195
+ - the GUID of the data class the data class to delete.
2196
+ body: dict, optional
2197
+ - a dictionary containing additional properties.
2198
+
2199
+ Returns
2200
+ -------
2201
+ None
2202
+
2203
+ Raises
2204
+ ------
2205
+ InvalidParameterException
2206
+ one of the parameters is null or invalid or
2207
+ PropertyServerException
2208
+ There is a problem adding the element properties to the metadata repository or
2209
+ UserNotAuthorizedException
2210
+ the requesting user is not authorized to issue this request.
2211
+
2212
+ Note
2213
+ ----
2214
+
2215
+ Full sample body:
2216
+
2217
+ {
2218
+ "class": "MetadataSourceRequestBody",
2219
+ "externalSourceGUID": "add guid here",
2220
+ "externalSourceName": "add qualified name here",
2221
+ "effectiveTime": "{{$isoTimestamp}}",
2222
+ "forLineage": false,
2223
+ "forDuplicateProcessing": false
2224
+ }
2225
+
2226
+ """
2227
+
2228
+ loop = asyncio.get_event_loop()
2229
+ loop.run_until_complete(self._async_delete_data_field(data_field_guid, body))
2230
+
2231
+ async def _async_find_all_data_fields(self, start_from: int = 0, page_size: int = max_paging_size, output_format: str = "DICT") -> list | str:
2232
+ """Returns a list of all known data fields. Async version.
2233
+
2234
+ Parameters
2235
+ ----------
2236
+ start_from: int, default = 0
2237
+ - index of the list to start from (0 for start).
2238
+ page_size
2239
+ - maximum number of elements to return.
2240
+ output_format: str, default = "DICT"
2241
+ - output format of the data structure. Possible values: "DICT", "JSON", "MERMAID".
2242
+
2243
+
2244
+ Returns
2245
+ -------
2246
+ [dict] | str
2247
+ Returns a string if no elements are found and a list of dict elements with the results.
2248
+
2249
+ Raises
2250
+ ------
2251
+ InvalidParameterException
2252
+ one of the parameters is null or invalid or
2253
+ PropertyServerException
2254
+ There is a problem adding the element properties to the metadata repository or
2255
+ UserNotAuthorizedException
2256
+ the requesting user is not authorized to issue this request.
2257
+
2258
+ """
2259
+
2260
+ possible_query_params = query_string(
2261
+ [("startFrom", start_from), ("pageSize", page_size), ("startsWith", 'false'), ("endsWith", 'false'),
2262
+ ("ignoreCase", 'true')])
2263
+
2264
+ url = (f"{base_path(self, self.view_server)}/data-fields/by-search-string"
2265
+ f"{possible_query_params}")
2266
+
2267
+ response: Response = await self._async_make_request("POST", url)
2268
+
2269
+ elements = response.json().get("elements", NO_ELEMENTS_FOUND)
2270
+ if type(elements) is str:
2271
+ return NO_ELEMENTS_FOUND
2272
+ if output_format != 'JSON': # return other representations
2273
+ return self.generate_data_field_output(elements, filter, output_format)
2274
+ return elements
2275
+
2276
+
2277
+ def find_all_data_fields(self, start_from: int = 0, page_size: int = max_paging_size, output_format: str = "DICT") -> list | str:
2278
+ """ Returns a list of all known data fields.
2279
+
2280
+ Parameters
2281
+ ----------
2282
+ start_from: int, default = 0
2283
+ - index of the list to start from (0 for start).
2284
+ page_size
2285
+ - maximum number of elements to return.
2286
+ output_format: str, default = "DICT"
2287
+ - output format of the data structure. Possible values: "DICT", "JSON", "MERMAID".
2288
+
2289
+ Returns
2290
+ -------
2291
+ [dict] | str
2292
+ Returns a string if no elements are found and a list of dict elements with the results.
2293
+
2294
+ Raises
2295
+ ------
2296
+ InvalidParameterException
2297
+ one of the parameters is null or invalid or
2298
+ PropertyServerException
2299
+ There is a problem adding the element properties to the metadata repository or
2300
+ UserNotAuthorizedException
2301
+ the requesting user is not authorized to issue this request.
2302
+
2303
+ """
2304
+
2305
+ loop = asyncio.get_event_loop()
2306
+ response = loop.run_until_complete(self._async_find_all_data_fields(start_from, page_size, output_format))
2307
+ return response
2308
+
2309
+ async def _async_find_data_fields_w_body(self, body: dict, start_from: int = 0, page_size: int = max_paging_size,
2310
+ starts_with: bool = True, ends_with: bool = False,
2311
+ ignore_case: bool = True, output_format: str = "DICT") -> list | str:
2312
+ """ Retrieve the list of data class metadata elements that contain the search string.
2313
+ Async version.
2314
+
2315
+ Parameters
2316
+ ----------
2317
+ body: dict
2318
+ - A structure containing the search criteria. (example below)
2319
+ start_from: int, default = 0
2320
+ - index of the list to start from (0 for start).
2321
+ page_size
2322
+ - maximum number of elements to return.
2323
+ starts_with: bool, default = True
2324
+ - if True, the search string filters from the beginning of the string.
2325
+ ends_with: bool, default = False
2326
+ - if True, the search string filters from the end of the string.
2327
+ ignore_case: bool, default = True
2328
+ - If True, the case of the search string is ignored.
2329
+ output_format: str, default = "DICT"
2330
+ - output format of the data structure. Possible values: "DICT", "JSON", "MERMAID".
2331
+
2332
+
2333
+ Returns
2334
+ -------
2335
+ [dict] | str
2336
+ Returns a string if no elements are found and a list of dict with the results.
2337
+
2338
+ Raises
2339
+ ------
2340
+ InvalidParameterException
2341
+ one of the parameters is null or invalid or
2342
+ PropertyServerException
2343
+ There is a problem adding the element properties to the metadata repository or
2344
+ UserNotAuthorizedException
2345
+ the requesting user is not authorized to issue this request.
2346
+
2347
+ Notes:
2348
+
2349
+ {
2350
+ "class": "FilterRequestBody",
2351
+ "asOfTime": "{{$isoTimestamp}}",
2352
+ "effectiveTime": "{{$isoTimestamp}}",
2353
+ "forLineage": false,
2354
+ "forDuplicateProcessing : false,
2355
+ "limitResultsByStatus": ["ACTIVE"],
2356
+ "sequencingOrder": "PROPERTY_ASCENDING",
2357
+ "sequencingProperty": "qualifiedName",
2358
+ "filter": ""
2359
+ }
2360
+
2361
+ """
2362
+ starts_with_s = str(starts_with).lower()
2363
+ ends_with_s = str(ends_with).lower()
2364
+ ignore_case_s = str(ignore_case).lower()
2365
+ possible_query_params = query_string(
2366
+ [("startFrom", start_from), ("pageSize", page_size), ("startsWith", starts_with_s),
2367
+ ("endsWith", ends_with_s), ("ignoreCase", ignore_case_s), ])
2368
+
2369
+ url = (f"{base_path(self, self.view_server)}/data-fields/by-search-string"
2370
+ f"{possible_query_params}")
2371
+
2372
+ response: Response = await self._async_make_request("POST", url, body_slimmer(body))
2373
+
2374
+ elements = response.json().get("elements", NO_ELEMENTS_FOUND)
2375
+ if type(elements) is str:
2376
+ return NO_ELEMENTS_FOUND
2377
+ if output_format != 'JSON': # return other representations
2378
+ return self.generate_data_field_output(elements, filter, output_format)
2379
+ return elements
2380
+
2381
+ def find_data_fields_w_body(self, body: dict, start_from: int = 0, page_size: int = max_paging_size,
2382
+ starts_with: bool = True, ends_with: bool = False,
2383
+ ignore_case: bool = True, output_format: str = "DICT") -> list | str:
2384
+ """ Retrieve the list of data class metadata elements that contain the search string.
2385
+
2386
+ Parameters
2387
+ ----------
2388
+ body: dict
2389
+ - A structure containing the search criteria. (example below)
2390
+ start_from: int, default = 0
2391
+ - index of the list to start from (0 for start).
2392
+ page_size
2393
+ - maximum number of elements to return.
2394
+ starts_with: bool, default = True
2395
+ - if True, the search string filters from the beginning of the string.
2396
+ ends_with: bool, default = False
2397
+ - if True, the search string filters from the end of the string.
2398
+ ignore_case: bool, default = True
2399
+ - If True, the case of the search string is ignored.
2400
+ output_format: str, default = "DICT"
2401
+ - output format of the data structure. Possible values: "DICT", "JSON", "MERMAID".
2402
+
2403
+
2404
+ Returns
2405
+ -------
2406
+ [dict] | str
2407
+ Returns a string if no elements are found and a list of dict with the results.
2408
+
2409
+ Raises
2410
+ ------
2411
+ InvalidParameterException
2412
+ one of the parameters is null or invalid or
2413
+ PropertyServerException
2414
+ There is a problem adding the element properties to the metadata repository or
2415
+ UserNotAuthorizedException
2416
+ the requesting user is not authorized to issue this request.
2417
+
2418
+ Notes:
2419
+
2420
+ {
2421
+ "class": "FilterRequestBody",
2422
+ "asOfTime": "{{$isoTimestamp}}",
2423
+ "effectiveTime": "{{$isoTimestamp}}",
2424
+ "forLineage": false,
2425
+ "forDuplicateProcessing : false,
2426
+ "limitResultsByStatus": ["ACTIVE"],
2427
+ "sequencingOrder": "PROPERTY_ASCENDING",
2428
+ "sequencingProperty": "qualifiedName",
2429
+ "filter": ""
2430
+ }
2431
+
2432
+ """
2433
+
2434
+ loop = asyncio.get_event_loop()
2435
+ response = loop.run_until_complete(
2436
+ self._async_find_data_fields_w_body(body, start_from, page_size, starts_with,
2437
+ ends_with, ignore_case, output_format))
2438
+ return response
2439
+
2440
+ async def _async_find_data_fields(self, filter: str, start_from: int = 0, page_size: int = max_paging_size,
2441
+ starts_with: bool = True, ends_with: bool = False,
2442
+ ignore_case: bool = True,
2443
+ output_format: str = "DICT") -> list | str:
2444
+ """ Find the list of data class elements that contain the search string.
2445
+ Async version.
2446
+
2447
+ Parameters
2448
+ ----------
2449
+ filter: str
2450
+ - search string to filter on.
2451
+ start_from: int, default = 0
2452
+ - index of the list to start from (0 for start).
2453
+ page_size
2454
+ - maximum number of elements to return.
2455
+ starts_with: bool, default = True
2456
+ - if True, the search string filters from the beginning of the string.
2457
+ ends_with: bool, default = False
2458
+ - if True, the search string filters from the end of the string.
2459
+ ignore_case: bool, default = True
2460
+ - If True, the case of the search string is ignored.
2461
+ output_format: str, default = "DICT"
2462
+ - output format of the data structure. Possible values: "DICT", "JSON", "MERMAID".
2463
+
2464
+
2465
+ Returns
2466
+ -------
2467
+ [dict] | str
2468
+ Returns a string if no elements are found and a list of dict with the results.
2469
+
2470
+ Raises
2471
+ ------
2472
+ InvalidParameterException
2473
+ one of the parameters is null or invalid or
2474
+ PropertyServerException
2475
+ There is a problem adding the element properties to the metadata repository or
2476
+ UserNotAuthorizedException
2477
+ the requesting user is not authorized to issue this request.
2478
+
2479
+ """
2480
+
2481
+ body = {"filter": filter}
2482
+
2483
+ possible_query_params = query_string(
2484
+ [("startFrom", start_from), ("pageSize", page_size), ("startsWith", str(starts_with).lower),
2485
+ ("endsWith", str(ends_with).lower()), ("ignoreCase", str(ignore_case).lower()), ])
2486
+
2487
+ url = (f"{base_path(self, self.view_server)}/data-fields/by-search-string"
2488
+ f"{possible_query_params}")
2489
+
2490
+ response: Response = await self._async_make_request("POST", url, body_slimmer(body))
2491
+
2492
+ elements = response.json().get("elements", NO_ELEMENTS_FOUND)
2493
+ if type(elements) is str:
2494
+ return NO_ELEMENTS_FOUND
2495
+ if output_format != 'JSON': # return other representations
2496
+ return self.generate_data_field_output(elements, filter, output_format)
2497
+ return elements
2498
+
2499
+ def find_data_fields(self, filter: str, start_from: int = 0, page_size: int = max_paging_size,
2500
+ starts_with: bool = True, ends_with: bool = False,
2501
+ ignore_case: bool = True, output_format: str = "DICT") -> list | str:
2502
+ """ Retrieve the list of data fields elements that contain the search string filter.
2503
+
2504
+ Parameters
2505
+ ----------
2506
+ filter: str
2507
+ - search string to filter on.
2508
+ start_from: int, default = 0
2509
+ - index of the list to start from (0 for start).
2510
+ page_size
2511
+ - maximum number of elements to return.
2512
+ starts_with: bool, default = True
2513
+ - if True, the search string filters from the beginning of the string.
2514
+ ends_with: bool, default = False
2515
+ - if True, the search string filters from the end of the string.
2516
+ ignore_case: bool, default = True
2517
+ - If True, the case of the search string is ignored.
2518
+ output_format: str, default = "DICT"
2519
+ - output format of the data structure. Possible values: "DICT", "JSON", "MERMAID".
2520
+
2521
+
2522
+ Returns
2523
+ -------
2524
+ [dict] | str
2525
+ Returns a string if no elements are found and a list of dict with the results.
2526
+
2527
+ Raises
2528
+ ------
2529
+ InvalidParameterException
2530
+ one of the parameters is null or invalid or
2531
+ PropertyServerException
2532
+ There is a problem adding the element properties to the metadata repository or
2533
+ UserNotAuthorizedException
2534
+ the requesting user is not authorized to issue this request.
2535
+
2536
+
2537
+ """
2538
+
2539
+ loop = asyncio.get_event_loop()
2540
+ response = loop.run_until_complete(
2541
+ self._async_find_data_fields(filter, start_from, page_size, starts_with,
2542
+ ends_with, ignore_case, output_format))
2543
+ return response
2544
+
2545
+ async def _async_get_data_fields_by_name(self, filter: str, body: dict = None, start_from: int = 0,
2546
+ page_size: int = max_paging_size,
2547
+ output_format: str = "DICT") -> list | str:
2548
+ """ Get the list of data class metadata elements with a matching name to the search string filter.
2549
+ Async version.
2550
+
2551
+ Parameters
2552
+ ----------
2553
+ filter: str
2554
+ - search string to filter on.
2555
+ body: dict, optional
2556
+ - a dictionary containing additional properties to use in the request.
2557
+ start_from: int, default = 0
2558
+ - index of the list to start from (0 for start).
2559
+ page_size
2560
+ - maximum number of elements to return.
2561
+ output_format: str, default = "DICT"
2562
+ - output format of the data structure. Possible values: "DICT", "JSON", "MERMAID".
2563
+
2564
+
2565
+ Returns
2566
+ -------
2567
+ [dict] | str
2568
+ Returns a string if no elements are found and a list of dict with the results.
2569
+
2570
+ Raises
2571
+ ------
2572
+ InvalidParameterException
2573
+ one of the parameters is null or invalid or
2574
+ PropertyServerException
2575
+ There is a problem adding the element properties to the metadata repository or
2576
+ UserNotAuthorizedException
2577
+ the requesting user is not authorized to issue this request.
2578
+ Notes
2579
+ -----
2580
+
2581
+ {
2582
+ "class": "FilterRequestBody",
2583
+ "asOfTime": "{{$isoTimestamp}}",
2584
+ "effectiveTime": "{{$isoTimestamp}}",
2585
+ "forLineage": false,
2586
+ "forDuplicateProcessing": false,
2587
+ "limitResultsByStatus": ["ACTIVE"],
2588
+ "sequencingOrder": "PROPERTY_ASCENDING",
2589
+ "sequencingProperty": "qualifiedName",
2590
+ "filter": "Add name here"
2591
+ }
2592
+ """
2593
+ if body is None:
2594
+ body = {"filter": filter}
2595
+
2596
+ possible_query_params = query_string([("startFrom", start_from), ("pageSize", page_size), ])
2597
+
2598
+ url = (f"{base_path(self, self.view_server)}/data-fields/by-name"
2599
+ f"{possible_query_params}")
2600
+
2601
+ response: Response = await self._async_make_request("POST", url, body_slimmer(body))
2602
+
2603
+ elements = response.json().get("elements", NO_ELEMENTS_FOUND)
2604
+ if type(elements) is str:
2605
+ return NO_ELEMENTS_FOUND
2606
+ if output_format != 'JSON': # return other representations
2607
+ return self.generate_data_field_output(elements, filter, output_format)
2608
+ return elements
2609
+
2610
+ def get_data_fields_by_name(self, filter: str, body: dict = None, start_from: int = 0,
2611
+ page_size: int = max_paging_size, output_format: str = "DICT") -> list | str:
2612
+ """ Get the list of data class elements with a matching name to the search string filter.
2613
+
2614
+ Parameters
2615
+ ----------
2616
+ filter: str
2617
+ - search string to filter on.
2618
+ body: dict, optional
2619
+ - a dictionary containing additional properties to use in the request.
2620
+ start_from: int, default = 0
2621
+ - index of the list to start from (0 for start).
2622
+ page_size
2623
+ - maximum number of elements to return.
2624
+ output_format: str, default = "DICT"
2625
+ - output format of the data structure. Possible values: "DICT", "JSON", "MERMAID".
2626
+
2627
+
2628
+ Returns
2629
+ -------
2630
+ [dict] | str
2631
+ Returns a string if no elements are found and a list of dict with the results.
2632
+
2633
+ Raises
2634
+ ------
2635
+ InvalidParameterException
2636
+ one of the parameters is null or invalid or
2637
+ PropertyServerException
2638
+ There is a problem adding the element properties to the metadata repository or
2639
+ UserNotAuthorizedException
2640
+ the requesting user is not authorized to issue this request.
2641
+
2642
+ Notes
2643
+ -----
2644
+ {
2645
+ "class": "FilterRequestBody",
2646
+ "asOfTime": "{{$isoTimestamp}}",
2647
+ "effectiveTime": "{{$isoTimestamp}}",
2648
+ "forLineage": false,
2649
+ "forDuplicateProcessing": false,
2650
+ "limitResultsByStatus": ["ACTIVE"],
2651
+ "sequencingOrder": "PROPERTY_ASCENDING",
2652
+ "sequencingProperty": "qualifiedName",
2653
+ "filter": "Add name here"
2654
+ }
2655
+
2656
+
2657
+ """
2658
+
2659
+ loop = asyncio.get_event_loop()
2660
+ response = loop.run_until_complete(self._async_get_data_fields_by_name(filter, body, start_from,
2661
+ page_size, output_format))
2662
+ return response
2663
+
2664
+ async def _async_get_data_field_by_guid(self, guid: str, body: dict = None, output_format: str = "DICT") -> list | str:
2665
+ """ Get the data class elements for the specified GUID.
2666
+ Async version.
2667
+
2668
+ Parameters
2669
+ ----------
2670
+ guid: str
2671
+ - unique identifier of the data class metadata element.
2672
+ body: dict, optional
2673
+ - optional request body.
2674
+ output_format: str, default = "DICT"
2675
+ - output format of the data structure. Possible values: "DICT", "JSON", "MERMAID".
2676
+
2677
+ Returns
2678
+ -------
2679
+ [dict] | str
2680
+ Returns a string if no elements are found and a list of dict with the results.
2681
+
2682
+ Raises
2683
+ ------
2684
+ InvalidParameterException
2685
+ one of the parameters is null or invalid or
2686
+ PropertyServerException
2687
+ There is a problem adding the element properties to the metadata repository or
2688
+ UserNotAuthorizedException
2689
+ the requesting user is not authorized to issue this request.
2690
+
2691
+
2692
+ Notes
2693
+ ----
2694
+
2695
+ Optional request body:
2696
+ {
2697
+ "class": "AnyTimeRequestBody",
2698
+ "asOfTime": "{{$isoTimestamp}}",
2699
+ "effectiveTime": "{{$isoTimestamp}}",
2700
+ "forLineage": false,
2701
+ "forDuplicateProcessing": false
2702
+ }
2703
+
2704
+ """
2705
+
2706
+ url = (f"{base_path(self, self.view_server)}/data-fields/{guid}/retrieve")
2707
+ if body:
2708
+ response: Response = await self._async_make_request("POST", url, body_slimmer(body))
2709
+ else:
2710
+ response: Response = await self._async_make_request("POST", url)
2711
+
2712
+ elements = response.json().get("element", NO_ELEMENTS_FOUND)
2713
+ if type(elements) is str:
2714
+ return NO_ELEMENTS_FOUND
2715
+ if output_format != 'JSON': # return other representations
2716
+ return self.generate_data_field_output(elements, filter, output_format)
2717
+ return elements
2718
+
2719
+ def get_data_field_by_guid(self, guid: str, body: str = None, output_format: str = "DICT") -> list | str:
2720
+ """ Get the data structure metadata element with the specified unique identifier..
2721
+
2722
+ Parameters
2723
+ ----------
2724
+ guid: str
2725
+ - unique identifier of the data structure metadata element.
2726
+ body: dict, optional
2727
+ - optional request body.
2728
+ output_format: str, default = "DICT"
2729
+ - output format of the data structure. Possible values: "DICT", "JSON", "MERMAID".
2730
+
2731
+ Returns
2732
+ -------
2733
+ [dict] | str
2734
+ Returns a string if no elements are found and a list of dict with the results.
2735
+
2736
+ Raises
2737
+ ------
2738
+ InvalidParameterException
2739
+ one of the parameters is null or invalid or
2740
+ PropertyServerException
2741
+ There is a problem adding the element properties to the metadata repository or
2742
+ UserNotAuthorizedException
2743
+ the requesting user is not authorized to issue this request.
2744
+
2745
+ Notes
2746
+ ----
2747
+
2748
+ Optional request body:
2749
+ {
2750
+ "class": "AnyTimeRequestBody",
2751
+ "asOfTime": "{{$isoTimestamp}}",
2752
+ "effectiveTime": "{{$isoTimestamp}}",
2753
+ "forLineage": false,
2754
+ "forDuplicateProcessing": false
2755
+ }
2756
+
2757
+ """
2758
+
2759
+ loop = asyncio.get_event_loop()
2760
+ response = loop.run_until_complete(self._async_get_data_field_by_guid(guid, body, output_format))
2761
+ return response
2762
+
2763
+ ###
2764
+ # =====================================================================================================================
2765
+ # Work with Data Classes
2766
+ # https://egeria-project.org/concepts/data-class
2767
+ #
2768
+ #
2769
+ async def _async_create_data_class(self, body: dict) -> str:
2770
+ """
2771
+ Create a new data class with parameters defined in the body. Async version.
2772
+
2773
+ Parameters
2774
+ ----------
2775
+ body: dict
2776
+ - a dictionary containing the properties of the data class to be created.
2777
+
2778
+ Returns
2779
+ -------
2780
+ str
2781
+ The GUID of the element - or "No element found"
2782
+
2783
+ Raises
2784
+ ------
2785
+ InvalidParameterException
2786
+ one of the parameters is null or invalid or
2787
+ PropertyServerException
2788
+ There is a problem adding the element properties to the metadata repository or
2789
+ UserNotAuthorizedException
2790
+ the requesting user is not authorized to issue this request.
2791
+
2792
+ Note
2793
+ ----
2794
+ Sample bodies:
2795
+
2796
+ {
2797
+ "class" : "NewDataClassRequestBody",
2798
+ "externalSourceGUID": "add guid here",
2799
+ "externalSourceName": "add qualified name here",
2800
+ "effectiveTime" : "{{$isoTimestamp}}",
2801
+ "forLineage" : false,
2802
+ "forDuplicateProcessing" : false,
2803
+ "anchorGUID" : "add guid here",
2804
+ "isOwnAnchor": false,
2805
+ "parentGUID": "add guid here",
2806
+ "parentRelationshipTypeName": "add type name here",
2807
+ "parentRelationshipProperties": {
2808
+ "class": "ElementProperties",
2809
+ "propertyValueMap" : {
2810
+ "description" : {
2811
+ "class": "PrimitiveTypePropertyValue",
2812
+ "typeName": "string",
2813
+ "primitiveValue" : "New description"
2814
+ }
2815
+ }
2816
+ },
2817
+ "parentAtEnd1": false,
2818
+ "properties": {
2819
+ "class" : "DataClassProperties",
2820
+ "qualifiedName": "add unique name here",
2821
+ "displayName": "add short name here",
2822
+ "description": "add description here",
2823
+ "namespace": "add scope of this data class's applicability.",
2824
+ "matchPropertyNames": ["name1", "name2"],
2825
+ "matchThreshold": 0,
2826
+ "specification": "",
2827
+ "specificationDetails": {
2828
+ "property1" : "propertyValue1",
2829
+ "property2" : "propertyValue2"
2830
+ },
2831
+ "dataType": "",
2832
+ "allowsDuplicateValues": true,
2833
+ "isNullable": false,
2834
+ "defaultValue": "",
2835
+ "averageValue": "",
2836
+ "valueList": [],
2837
+ "valueRangeFrom": "",
2838
+ "valueRangeTo": "",
2839
+ "sampleValues": [],
2840
+ "dataPatterns" : [],
2841
+ "additionalProperties": {
2842
+ "property1" : "propertyValue1",
2843
+ "property2" : "propertyValue2"
2844
+ },
2845
+ "effectiveFrom": "{{$isoTimestamp}}",
2846
+ "effectiveTo": "{{$isoTimestamp}}"
2847
+ }
2848
+ }
2849
+ or
2850
+ {
2851
+ "properties": {
2852
+ "class": "DataClassProperties",
2853
+ "qualifiedName": "add unique name here",
2854
+ "displayName": "add short name here",
2855
+ "description": "add description here",
2856
+ "namespace": "add scope of this data class's applicability.",
2857
+ "matchPropertyNames": [
2858
+ "name1",
2859
+ "name2"
2860
+ ],
2861
+ "matchThreshold": 0,
2862
+ "specification": "",
2863
+ "specificationDetails": {
2864
+ "property1": "propertyValue1",
2865
+ "property2": "propertyValue2"
2866
+ },
2867
+ "dataType": "",
2868
+ "allowsDuplicateValues": true,
2869
+ "isNullable": false,
2870
+ "defaultValue": "",
2871
+ "averageValue": "",
2872
+ "valueList": [],
2873
+ "valueRangeFrom": "",
2874
+ "valueRangeTo": "",
2875
+ "sampleValues": [],
2876
+ "dataPatterns": [],
2877
+ "additionalProperties": {
2878
+ "property1": "propertyValue1",
2879
+ "property2": "propertyValue2"
2880
+ }
2881
+ }
2882
+ }
2883
+
2884
+ """
2885
+
2886
+ url = f"{base_path(self, self.view_server)}/data-classes"
2887
+
2888
+ response: Response = await self._async_make_request("POST", url, body_slimmer(body))
2889
+ return response.json().get("guid", NO_ELEMENTS_FOUND)
2890
+
2891
+ def create_data_class(self, body: dict) -> str:
2892
+ """
2893
+ Create a new data class with parameters defined in the body..
2894
+
2895
+ Parameters
2896
+ ----------
2897
+ body: dict
2898
+ - a dictionary containing the properties of the data class to be created.
2899
+
2900
+ Returns
2901
+ -------
2902
+ str
2903
+ The GUID of the element - or "No element found"
2904
+
2905
+ Raises
2906
+ ------
2907
+ InvalidParameterException
2908
+ one of the parameters is null or invalid or
2909
+ PropertyServerException
2910
+ There is a problem adding the element properties to the metadata repository or
2911
+ UserNotAuthorizedException
2912
+ the requesting user is not authorized to issue this request.
2913
+
2914
+ Note
2915
+ ----
2916
+
2917
+ {
2918
+ "class" : "NewDataClassRequestBody",
2919
+ "externalSourceGUID": "add guid here",
2920
+ "externalSourceName": "add qualified name here",
2921
+ "effectiveTime" : "{{$isoTimestamp}}",
2922
+ "forLineage" : false,
2923
+ "forDuplicateProcessing" : false,
2924
+ "anchorGUID" : "add guid here",
2925
+ "isOwnAnchor": false,
2926
+ "parentGUID": "add guid here",
2927
+ "parentRelationshipTypeName": "add type name here",
2928
+ "parentRelationshipProperties": {
2929
+ "class": "ElementProperties",
2930
+ "propertyValueMap" : {
2931
+ "description" : {
2932
+ "class": "PrimitiveTypePropertyValue",
2933
+ "typeName": "string",
2934
+ "primitiveValue" : "New description"
2935
+ }
2936
+ }
2937
+ },
2938
+ "parentAtEnd1": false,
2939
+ "properties": {
2940
+ "class" : "DataClassProperties",
2941
+ "qualifiedName": "add unique name here",
2942
+ "displayName": "add short name here",
2943
+ "description": "add description here",
2944
+ "namespace": "add scope of this data class's applicability.",
2945
+ "matchPropertyNames": ["name1", "name2"],
2946
+ "matchThreshold": 0,
2947
+ "specification": "",
2948
+ "specificationDetails": {
2949
+ "property1" : "propertyValue1",
2950
+ "property2" : "propertyValue2"
2951
+ },
2952
+ "dataType": "",
2953
+ "allowsDuplicateValues": true,
2954
+ "isNullable": false,
2955
+ "defaultValue": "",
2956
+ "averageValue": "",
2957
+ "valueList": [],
2958
+ "valueRangeFrom": "",
2959
+ "valueRangeTo": "",
2960
+ "sampleValues": [],
2961
+ "dataPatterns" : [],
2962
+ "additionalProperties": {
2963
+ "property1" : "propertyValue1",
2964
+ "property2" : "propertyValue2"
2965
+ },
2966
+ "effectiveFrom": "{{$isoTimestamp}}",
2967
+ "effectiveTo": "{{$isoTimestamp}}"
2968
+ }
2969
+ }
2970
+
2971
+ or
2972
+ {
2973
+ "properties": {
2974
+ "class": "DataClassProperties",
2975
+ "qualifiedName": "add unique name here",
2976
+ "displayName": "add short name here",
2977
+ "description": "add description here",
2978
+ "namespace": "add scope of this data class's applicability.",
2979
+ "matchPropertyNames": [
2980
+ "name1",
2981
+ "name2"
2982
+ ],
2983
+ "matchThreshold": 0,
2984
+ "specification": "",
2985
+ "specificationDetails": {
2986
+ "property1": "propertyValue1",
2987
+ "property2": "propertyValue2"
2988
+ },
2989
+ "dataType": "",
2990
+ "allowsDuplicateValues": true,
2991
+ "isNullable": false,
2992
+ "defaultValue": "",
2993
+ "averageValue": "",
2994
+ "valueList": [],
2995
+ "valueRangeFrom": "",
2996
+ "valueRangeTo": "",
2997
+ "sampleValues": [],
2998
+ "dataPatterns": [],
2999
+ "additionalProperties": {
3000
+ "property1": "propertyValue1",
3001
+ "property2": "propertyValue2"
3002
+ }
3003
+ }
3004
+ }
3005
+
3006
+ """
3007
+
3008
+ loop = asyncio.get_event_loop()
3009
+ response = loop.run_until_complete(self._async_create_data_class(body))
3010
+ return response
3011
+
3012
+ async def _async_create_data_class_from_template(self, body: dict) -> str:
3013
+ """
3014
+ Create a new metadata element to represent a data class using an existing metadata element as a template.
3015
+ The template defines additional classifications and relationships that should be added to the new element.
3016
+ Async version.
3017
+
3018
+ Parameters
3019
+ ----------
3020
+ body: dict
3021
+ - a dictionary containing the properties of the data class to be created.
3022
+
3023
+ Returns
3024
+ -------
3025
+ str
3026
+ The GUID of the element - or "No element found"
3027
+
3028
+ Raises
3029
+ ------
3030
+ InvalidParameterException
3031
+ one of the parameters is null or invalid or
3032
+ PropertyServerException
3033
+ There is a problem adding the element properties to the metadata repository or
3034
+ UserNotAuthorizedException
3035
+ the requesting user is not authorized to issue this request.
3036
+
3037
+ Note
3038
+ ----
3039
+ {
3040
+ "class" : "TemplateRequestBody",
3041
+ "externalSourceGUID": "add guid here",
3042
+ "externalSourceName": "add qualified name here",
3043
+ "effectiveTime" : "{{$isoTimestamp}}",
3044
+ "forLineage" : false,
3045
+ "forDuplicateProcessing" : false,
3046
+ "anchorGUID" : "add guid here",
3047
+ "isOwnAnchor": false,
3048
+ "parentGUID": "add guid here",
3049
+ "parentRelationshipTypeName": "add type name here",
3050
+ "parentRelationshipProperties": {
3051
+ "class": "ElementProperties",
3052
+ "propertyValueMap" : {
3053
+ "description" : {
3054
+ "class": "PrimitiveTypePropertyValue",
3055
+ "typeName": "string",
3056
+ "primitiveValue" : "New description"
3057
+ }
3058
+ }
3059
+ },
3060
+ "parentAtEnd1": false,
3061
+ "templateGUID": "add guid here",
3062
+ "replacementProperties": {
3063
+ "class": "ElementProperties",
3064
+ "propertyValueMap" : {
3065
+ "description" : {
3066
+ "class": "PrimitiveTypePropertyValue",
3067
+ "typeName": "string",
3068
+ "primitiveValue" : "New description"
3069
+ }
3070
+ }
3071
+ },
3072
+ "placeholderPropertyValues": {
3073
+ "placeholder1" : "propertyValue1",
3074
+ "placeholder2" : "propertyValue2"
3075
+ }
3076
+ }
3077
+
3078
+ """
3079
+
3080
+ url = f"{base_path(self, self.view_server)}/data-classes/from-template"
3081
+
3082
+ response: Response = await self._async_make_request("POST", url, body_slimmer(body))
3083
+ return response.json().get("guid", NO_ELEMENTS_FOUND)
3084
+
3085
+ def create_data_class_from_template(self, body: dict) -> str:
3086
+ """
3087
+ Create a new metadata element to represent a data class using an existing metadata element as a template.
3088
+ The template defines additional classifications and relationships that should be added to the new element.
3089
+ Async version.
3090
+
3091
+ Parameters
3092
+ ----------
3093
+ body: dict
3094
+ - a dictionary containing the properties of the data class to be created.
3095
+
3096
+ Returns
3097
+ -------
3098
+ str
3099
+ The GUID of the element - or "No element found"
3100
+
3101
+ Raises
3102
+ ------
3103
+ InvalidParameterException
3104
+ one of the parameters is null or invalid or
3105
+ PropertyServerException
3106
+ There is a problem adding the element properties to the metadata repository or
3107
+ UserNotAuthorizedException
3108
+ the requesting user is not authorized to issue this request.
3109
+
3110
+ Note
3111
+ ----
3112
+ {
3113
+ "class" : "TemplateRequestBody",
3114
+ "externalSourceGUID": "add guid here",
3115
+ "externalSourceName": "add qualified name here",
3116
+ "effectiveTime" : "{{$isoTimestamp}}",
3117
+ "forLineage" : false,
3118
+ "forDuplicateProcessing" : false,
3119
+ "anchorGUID" : "add guid here",
3120
+ "isOwnAnchor": false,
3121
+ "parentGUID": "add guid here",
3122
+ "parentRelationshipTypeName": "add type name here",
3123
+ "parentRelationshipProperties": {
3124
+ "class": "ElementProperties",
3125
+ "propertyValueMap" : {
3126
+ "description" : {
3127
+ "class": "PrimitiveTypePropertyValue",
3128
+ "typeName": "string",
3129
+ "primitiveValue" : "New description"
3130
+ }
3131
+ }
3132
+ },
3133
+ "parentAtEnd1": false,
3134
+ "templateGUID": "add guid here",
3135
+ "replacementProperties": {
3136
+ "class": "ElementProperties",
3137
+ "propertyValueMap" : {
3138
+ "description" : {
3139
+ "class": "PrimitiveTypePropertyValue",
3140
+ "typeName": "string",
3141
+ "primitiveValue" : "New description"
3142
+ }
3143
+ }
3144
+ },
3145
+ "placeholderPropertyValues": {
3146
+ "placeholder1" : "propertyValue1",
3147
+ "placeholder2" : "propertyValue2"
3148
+ }
3149
+ }
3150
+ """
3151
+
3152
+ loop = asyncio.get_event_loop()
3153
+ response = loop.run_until_complete(self._async_create_data_class_from_template(body))
3154
+ return response
3155
+
3156
+ async def _async_update_data_class(self, data_class_guid: str, body: dict,
3157
+ replace_all_properties: bool = False) -> None:
3158
+ """
3159
+ Update the properties of a data class. Async version.
3160
+
3161
+ Parameters
3162
+ ----------
3163
+ data_class_guid: str
3164
+ - the GUID of the data class to be updated.
3165
+ body: dict
3166
+ - a dictionary containing the properties of the data structure to be created.
3167
+ replace_all_properties: bool, default = False
3168
+ - if true, then all properties will be replaced with the new ones. Otherwise, only the specified ones
3169
+ will be replaced.
3170
+ Returns
3171
+ -------
3172
+ None
3173
+
3174
+ Raises
3175
+ ------
3176
+ InvalidParameterException
3177
+ one of the parameters is null or invalid or
3178
+ PropertyServerException
3179
+ There is a problem adding the element properties to the metadata repository or
3180
+ UserNotAuthorizedException
3181
+ the requesting user is not authorized to issue this request.
3182
+
3183
+ Note
3184
+ ----
3185
+ Full sample body:
3186
+ {
3187
+ "class" : "UpdateDataClassRequestBody",
3188
+ "externalSourceGUID": "add guid here",
3189
+ "externalSourceName": "add qualified name here",
3190
+ "effectiveTime" : "{{$isoTimestamp}}",
3191
+ "forLineage" : false,
3192
+ "forDuplicateProcessing" : false,
3193
+ "properties": {
3194
+ "class" : "DataClassProperties",
3195
+ "qualifiedName": "add unique name here",
3196
+ "displayName": "add short name here",
3197
+ "description": "add description here",
3198
+ "namespace": "add scope of this data class's applicability.",
3199
+ "matchPropertyNames": ["name1", "name2"],
3200
+ "matchThreshold": 0,
3201
+ "specification": "",
3202
+ "specificationDetails": {
3203
+ "property1" : "propertyValue1",
3204
+ "property2" : "propertyValue2"
3205
+ },
3206
+ "dataType": "",
3207
+ "allowsDuplicateValues": true,
3208
+ "isNullable": false,
3209
+ "defaultValue": "",
3210
+ "averageValue": "",
3211
+ "valueList": [],
3212
+ "valueRangeFrom": "",
3213
+ "valueRangeTo": "",
3214
+ "sampleValues": [],
3215
+ "dataPatterns" : [],
3216
+ "additionalProperties": {
3217
+ "property1" : "propertyValue1",
3218
+ "property2" : "propertyValue2"
3219
+ }
3220
+ }
3221
+ }
3222
+ """
3223
+ replace_all_properties_s = str(replace_all_properties).lower()
3224
+
3225
+ url = (f"{base_path(self, self.view_server)}/data-class/{data_class_guid}/update?"
3226
+ f"replaceAllProperties={replace_all_properties_s}")
3227
+
3228
+ await self._async_make_request("POST", url, body_slimmer(body))
3229
+
3230
+ def update_data_class(self, data_class_guid: str, body: dict.get, replace_all_properties: bool = False) -> None:
3231
+ """
3232
+ Update the properties of a data class.
3233
+
3234
+ Parameters
3235
+ ----------
3236
+ data_class_guid: str
3237
+ - the GUID of the data class to be updated.
3238
+ body: dict
3239
+ - a dictionary containing the properties of the data structure to be created.
3240
+ replace_all_properties: bool, default = False
3241
+ - if true, then all properties will be replaced with the new ones. Otherwise, only the specified ones
3242
+ will be replaced.
3243
+ Returns
3244
+ -------
3245
+ None
3246
+
3247
+ Raises
3248
+ ------
3249
+ InvalidParameterException
3250
+ one of the parameters is null or invalid or
3251
+ PropertyServerException
3252
+ There is a problem adding the element properties to the metadata repository or
3253
+ UserNotAuthorizedException
3254
+ the requesting user is not authorized to issue this request.
3255
+
3256
+ Note
3257
+ ----
3258
+
3259
+ {
3260
+ "class" : "UpdateDataClassRequestBody",
3261
+ "externalSourceGUID": "add guid here",
3262
+ "externalSourceName": "add qualified name here",
3263
+ "effectiveTime" : "{{$isoTimestamp}}",
3264
+ "forLineage" : false,
3265
+ "forDuplicateProcessing" : false,
3266
+ "properties": {
3267
+ "class" : "DataClassProperties",
3268
+ "qualifiedName": "add unique name here",
3269
+ "displayName": "add short name here",
3270
+ "description": "add description here",
3271
+ "namespace": "add scope of this data class's applicability.",
3272
+ "matchPropertyNames": ["name1", "name2"],
3273
+ "matchThreshold": 0,
3274
+ "specification": "",
3275
+ "specificationDetails": {
3276
+ "property1" : "propertyValue1",
3277
+ "property2" : "propertyValue2"
3278
+ },
3279
+ "dataType": "",
3280
+ "allowsDuplicateValues": true,
3281
+ "isNullable": false,
3282
+ "defaultValue": "",
3283
+ "averageValue": "",
3284
+ "valueList": [],
3285
+ "valueRangeFrom": "",
3286
+ "valueRangeTo": "",
3287
+ "sampleValues": [],
3288
+ "dataPatterns" : [],
3289
+ "additionalProperties": {
3290
+ "property1" : "propertyValue1",
3291
+ "property2" : "propertyValue2"
3292
+ }
3293
+ }
3294
+ }
3295
+ """
3296
+
3297
+ loop = asyncio.get_event_loop()
3298
+ loop.run_until_complete(self._async_update_data_class(data_class_guid, body, replace_all_properties))
3299
+
3300
+ async def _async_link_nested_data_class(self, parent_data_class_guid: str, child_data_class_guid: str,
3301
+ body: dict = None) -> None:
3302
+ """
3303
+ Connect two data classes to show that one is used by the other when it is validating (typically a complex
3304
+ data item). Request body is optional. Async version.
3305
+
3306
+ Parameters
3307
+ ----------
3308
+ parent_data_class_guid: str
3309
+ - the GUID of the parent data class the nested data class will be connected to.
3310
+ child_data_class_guid: str
3311
+ - the GUID of the nested data class to be connected.
3312
+ body: dict, optional
3313
+ - a dictionary containing additional properties.
3314
+
3315
+ Returns
3316
+ -------
3317
+ None
3318
+
3319
+ Raises
3320
+ ------
3321
+ InvalidParameterException
3322
+ one of the parameters is null or invalid or
3323
+ PropertyServerException
3324
+ There is a problem adding the element properties to the metadata repository or
3325
+ UserNotAuthorizedException
3326
+ the requesting user is not authorized to issue this request.
3327
+
3328
+ Note
3329
+ ----
3330
+
3331
+ Sample body:
3332
+
3333
+ {
3334
+ "class": "MetadataSourceRequestBody",
3335
+ "externalSourceGUID": "add guid here",
3336
+ "externalSourceName": "add qualified name here",
3337
+ "effectiveTime": "{{$isoTimestamp}}",
3338
+ "forLineage": false,
3339
+ "forDuplicateProcessing": false
3340
+ }
3341
+
3342
+ """
3343
+
3344
+ url = (f"{base_path(self, self.view_server)}/data-classes/{parent_data_class_guid}"
3345
+ f"/nested-data-classes/{child_data_class_guid}/attach")
3346
+
3347
+ if body is None:
3348
+ await self._async_make_request("POST", url)
3349
+ else:
3350
+ await self._async_make_request("POST", url, body_slimmer(body))
3351
+
3352
+ def link_nested_data_class(self, parent_data_class_guid: str, child_data_class_guid: str,
3353
+ body: dict = None) -> None:
3354
+ """
3355
+ Connect a nested data class to a data class. Request body is optional.
3356
+
3357
+ Parameters
3358
+ ----------
3359
+ parent_data_class_guid: str
3360
+ - the GUID of the parent data class the nested data class will be connected to.
3361
+ child_data_class_guid: str
3362
+ - the GUID of the nested data class to be connected.
3363
+ body: dict, optional
3364
+ - a dictionary containing additional properties.
3365
+
3366
+ Returns
3367
+ -------
3368
+ None
3369
+
3370
+ Raises
3371
+ ------
3372
+ InvalidParameterException
3373
+ one of the parameters is null or invalid or
3374
+ PropertyServerException
3375
+ There is a problem adding the element properties to the metadata repository or
3376
+ UserNotAuthorizedException
3377
+ the requesting user is not authorized to issue this request.
3378
+
3379
+ Note
3380
+ ----
3381
+
3382
+ Sample body:
3383
+
3384
+ {
3385
+ "class": "MetadataSourceRequestBody",
3386
+ "externalSourceGUID": "add guid here",
3387
+ "externalSourceName": "add qualified name here",
3388
+ "effectiveTime": "{{$isoTimestamp}}",
3389
+ "forLineage": false,
3390
+ "forDuplicateProcessing": false
3391
+ }
3392
+
3393
+ """
3394
+
3395
+ loop = asyncio.get_event_loop()
3396
+ loop.run_until_complete(self._async_link_nested_data_class(parent_data_class_guid, child_data_class_guid, body))
3397
+
3398
+ async def _async_detach_nested_data_class(self, parent_data_class_guid: str, child_data_class_guid: str,
3399
+ body: dict = None) -> None:
3400
+ """
3401
+ Detach two nested data classes from each other. Request body is optional. Async version.
3402
+
3403
+ Parameters
3404
+ ----------
3405
+ parent_data_class_guid: str
3406
+ - the GUID of the parent data class the data class will be detached from..
3407
+ child_data_class_guid: str
3408
+ - the GUID of the data class to be disconnected.
3409
+ body: dict, optional
3410
+ - a dictionary containing additional properties.
3411
+
3412
+ Returns
3413
+ -------
3414
+ None
3415
+
3416
+ Raises
3417
+ ------
3418
+ InvalidParameterException
3419
+ one of the parameters is null or invalid or
3420
+ PropertyServerException
3421
+ There is a problem adding the element properties to the metadata repository or
3422
+ UserNotAuthorizedException
3423
+ the requesting user is not authorized to issue this request.
3424
+
3425
+ Note
3426
+ ----
3427
+
3428
+ Sample body:
3429
+
3430
+ {
3431
+ "class": "MetadataSourceRequestBody",
3432
+ "externalSourceGUID": "add guid here",
3433
+ "externalSourceName": "add qualified name here",
3434
+ "effectiveTime": "{{$isoTimestamp}}",
3435
+ "forLineage": false,
3436
+ "forDuplicateProcessing": false
3437
+ }
3438
+
3439
+
3440
+ """
3441
+
3442
+ url = (f"{base_path(self, self.view_server)}/data-classes/{parent_data_class_guid}"
3443
+ f"/member-data-classes/{child_data_class_guid}/detach")
3444
+
3445
+ if body is None:
3446
+ await self._async_make_request("POST", url)
3447
+ else:
3448
+ await self._async_make_request("POST", url, body_slimmer(body))
3449
+
3450
+ def detach_nested_data_class(self, parent_data_class_guid: str, child_data_class_guid: str,
3451
+ body: dict = None) -> None:
3452
+ """
3453
+ Detach two nested data classes from each other. Request body is optional.
3454
+
3455
+ Parameters
3456
+ ----------
3457
+ parent_data_class_guid: str
3458
+ - the GUID of the parent data structure the data class will be detached fromo.
3459
+ child_data_class_guid: str
3460
+ - the GUID of the data class to be disconnected.
3461
+ body: dict, optional
3462
+ - a dictionary containing additional properties.
3463
+
3464
+ Returns
3465
+ -------
3466
+ None
3467
+
3468
+ Raises
3469
+ ------
3470
+ InvalidParameterException
3471
+ one of the parameters is null or invalid or
3472
+ PropertyServerException
3473
+ There is a problem adding the element properties to the metadata repository or
3474
+ UserNotAuthorizedException
3475
+ the requesting user is not authorized to issue this request.
3476
+
3477
+ Note
3478
+ ----
3479
+
3480
+ Full sample body:
3481
+
3482
+ {
3483
+ "class": "MetadataSourceRequestBody",
3484
+ "externalSourceGUID": "add guid here",
3485
+ "externalSourceName": "add qualified name here",
3486
+ "effectiveTime": "{{$isoTimestamp}}",
3487
+ "forLineage": false,
3488
+ "forDuplicateProcessing": false
3489
+ }
3490
+
3491
+ """
3492
+
3493
+ loop = asyncio.get_event_loop()
3494
+ loop.run_until_complete(
3495
+ self._async_detach_nested_data_class(parent_data_class_guid, child_data_class_guid, body))
3496
+
3497
+ async def _async_link_specialist_data_class(self, parent_data_class_guid: str, child_data_class_guid: str,
3498
+ body: dict = None) -> None:
3499
+ """
3500
+ Connect two data classes to show that one provides a more specialist evaluation. Request body is optional.
3501
+ Async version.
3502
+
3503
+ Parameters
3504
+ ----------
3505
+ parent_data_class_guid: str
3506
+ - the GUID of the parent data class the nested data class will be connected to.
3507
+ child_data_class_guid: str
3508
+ - the GUID of the nested data class to be connected.
3509
+ body: dict, optional
3510
+ - a dictionary containing additional properties.
3511
+
3512
+ Returns
3513
+ -------
3514
+ None
3515
+
3516
+ Raises
3517
+ ------
3518
+ InvalidParameterException
3519
+ one of the parameters is null or invalid or
3520
+ PropertyServerException
3521
+ There is a problem adding the element properties to the metadata repository or
3522
+ UserNotAuthorizedException
3523
+ the requesting user is not authorized to issue this request.
3524
+
3525
+ Note
3526
+ ----
3527
+
3528
+ Sample body:
3529
+
3530
+ {
3531
+ "class": "MetadataSourceRequestBody",
3532
+ "externalSourceGUID": "add guid here",
3533
+ "externalSourceName": "add qualified name here",
3534
+ "effectiveTime": "{{$isoTimestamp}}",
3535
+ "forLineage": false,
3536
+ "forDuplicateProcessing": false
3537
+ }
3538
+
3539
+ """
3540
+
3541
+ url = (f"{base_path(self, self.view_server)}/data-classes/{parent_data_class_guid}"
3542
+ f"/specialist-data-classes/{child_data_class_guid}/attach")
3543
+
3544
+ if body is None:
3545
+ await self._async_make_request("POST", url)
3546
+ else:
3547
+ await self._async_make_request("POST", url, body_slimmer(body))
3548
+
3549
+ def link_specialist_data_class(self, parent_data_class_guid: str, child_data_class_guid: str,
3550
+ body: dict = None) -> None:
3551
+ """
3552
+ Connect two data classes to show that one provides a more specialist evaluation. Request body is optional.
3553
+
3554
+ Parameters
3555
+ ----------
3556
+ parent_data_class_guid: str
3557
+ - the GUID of the parent data class the nested data class will be connected to.
3558
+ child_data_class_guid: str
3559
+ - the GUID of the nested data class to be connected.
3560
+ body: dict, optional
3561
+ - a dictionary containing additional properties.
3562
+
3563
+ Returns
3564
+ -------
3565
+ None
3566
+
3567
+ Raises
3568
+ ------
3569
+ InvalidParameterException
3570
+ one of the parameters is null or invalid or
3571
+ PropertyServerException
3572
+ There is a problem adding the element properties to the metadata repository or
3573
+ UserNotAuthorizedException
3574
+ the requesting user is not authorized to issue this request.
3575
+
3576
+ Note
3577
+ ----
3578
+
3579
+ Sample body:
3580
+
3581
+ {
3582
+ "class": "MetadataSourceRequestBody",
3583
+ "externalSourceGUID": "add guid here",
3584
+ "externalSourceName": "add qualified name here",
3585
+ "effectiveTime": "{{$isoTimestamp}}",
3586
+ "forLineage": false,
3587
+ "forDuplicateProcessing": false
3588
+ }
3589
+
3590
+ """
3591
+
3592
+ loop = asyncio.get_event_loop()
3593
+ loop.run_until_complete(
3594
+ self._async_link_specialist_data_class(parent_data_class_guid, child_data_class_guid, body))
3595
+
3596
+ async def _async_detach_specialist_data_class(self, parent_data_class_guid: str, child_data_class_guid: str,
3597
+ body: dict = None) -> None:
3598
+ """
3599
+ Detach two data classes from each other. Request body is optional. Async version.
3600
+
3601
+ Parameters
3602
+ ----------
3603
+ parent_data_class_guid: str
3604
+ - the GUID of the parent data class the data class will be detached from..
3605
+ child_data_class_guid: str
3606
+ - the GUID of the data class to be disconnected.
3607
+ body: dict, optional
3608
+ - a dictionary containing additional properties.
3609
+
3610
+ Returns
3611
+ -------
3612
+ None
3613
+
3614
+ Raises
3615
+ ------
3616
+ InvalidParameterException
3617
+ one of the parameters is null or invalid or
3618
+ PropertyServerException
3619
+ There is a problem adding the element properties to the metadata repository or
3620
+ UserNotAuthorizedException
3621
+ the requesting user is not authorized to issue this request.
3622
+
3623
+ Note
3624
+ ----
3625
+
3626
+ Sample body:
3627
+
3628
+ {
3629
+ "class": "MetadataSourceRequestBody",
3630
+ "externalSourceGUID": "add guid here",
3631
+ "externalSourceName": "add qualified name here",
3632
+ "effectiveTime": "{{$isoTimestamp}}",
3633
+ "forLineage": false,
3634
+ "forDuplicateProcessing": false
3635
+ }
3636
+
3637
+
3638
+ """
3639
+
3640
+ url = (f"{base_path(self, self.view_server)}/data-classes/{parent_data_class_guid}"
3641
+ f"/specialist-data-classes/{child_data_class_guid}/detach")
3642
+
3643
+ if body is None:
3644
+ await self._async_make_request("POST", url)
3645
+ else:
3646
+ await self._async_make_request("POST", url, body_slimmer(body))
3647
+
3648
+ def detach_specialist_data_class(self, parent_data_class_guid: str, child_data_class_guid: str,
3649
+ body: dict = None) -> None:
3650
+ """
3651
+ Detach two data classes from each other. Request body is optional.
3652
+
3653
+ Parameters
3654
+ ----------
3655
+ parent_data_class_guid: str
3656
+ - the GUID of the parent data structure the data class will be detached from.
3657
+ child_data_class_guid: str
3658
+ - the GUID of the data class to be disconnected.
3659
+ body: dict, optional
3660
+ - a dictionary containing additional properties.
3661
+
3662
+ Returns
3663
+ -------
3664
+ None
3665
+
3666
+ Raises
3667
+ ------
3668
+ InvalidParameterException
3669
+ one of the parameters is null or invalid or
3670
+ PropertyServerException
3671
+ There is a problem adding the element properties to the metadata repository or
3672
+ UserNotAuthorizedException
3673
+ the requesting user is not authorized to issue this request.
3674
+
3675
+ Note
3676
+ ----
3677
+
3678
+ Full sample body:
3679
+
3680
+ {
3681
+ "class": "MetadataSourceRequestBody",
3682
+ "externalSourceGUID": "add guid here",
3683
+ "externalSourceName": "add qualified name here",
3684
+ "effectiveTime": "{{$isoTimestamp}}",
3685
+ "forLineage": false,
3686
+ "forDuplicateProcessing": false
3687
+ }
3688
+
3689
+ """
3690
+
3691
+ loop = asyncio.get_event_loop()
3692
+ loop.run_until_complete(
3693
+ self._async_detach_specialist_data_class(parent_data_class_guid, child_data_class_guid, body))
3694
+
3695
+ async def _async_delete_data_class(self, data_class_guid: str, body: dict = None) -> None:
3696
+ """
3697
+ Delete a data class. Request body is optional. Async version.
3698
+
3699
+ Parameters
3700
+ ----------
3701
+ data_class_guid: str
3702
+ - the GUID of the data class to delete.
3703
+ body: dict, optional
3704
+ - a dictionary containing additional properties.
3705
+
3706
+ Returns
3707
+ -------
3708
+ None
3709
+
3710
+ Raises
3711
+ ------
3712
+ InvalidParameterException
3713
+ one of the parameters is null or invalid or
3714
+ PropertyServerException
3715
+ There is a problem adding the element properties to the metadata repository or
3716
+ UserNotAuthorizedException
3717
+ the requesting user is not authorized to issue this request.
3718
+
3719
+ Note
3720
+ ----
3721
+
3722
+ Full sample body:
3723
+
3724
+ {
3725
+ "class": "MetadataSourceRequestBody",
3726
+ "externalSourceGUID": "add guid here",
3727
+ "externalSourceName": "add qualified name here",
3728
+ "effectiveTime": "{{$isoTimestamp}}",
3729
+ "forLineage": false,
3730
+ "forDuplicateProcessing": false
3731
+ }
3732
+
3733
+
3734
+ """
3735
+
3736
+ url = f"{base_path(self, self.view_server)}/data-classes/{data_class_guid}/delete"
3737
+
3738
+ if body is None:
3739
+ await self._async_make_request("POST", url)
3740
+ else:
3741
+ await self._async_make_request("POST", url, body_slimmer(body))
3742
+
3743
+ def delete_data_class(self, data_class_guid: str, body: dict = None) -> None:
3744
+ """
3745
+ Delete a data class. Request body is optional.
3746
+
3747
+ Parameters
3748
+ ----------
3749
+ data_class_guid: str
3750
+ - the GUID of the data class the data class to delete.
3751
+ body: dict, optional
3752
+ - a dictionary containing additional properties.
3753
+
3754
+ Returns
3755
+ -------
3756
+ None
3757
+
3758
+ Raises
3759
+ ------
3760
+ InvalidParameterException
3761
+ one of the parameters is null or invalid or
3762
+ PropertyServerException
3763
+ There is a problem adding the element properties to the metadata repository or
3764
+ UserNotAuthorizedException
3765
+ the requesting user is not authorized to issue this request.
3766
+
3767
+ Note
3768
+ ----
3769
+
3770
+ Full sample body:
3771
+
3772
+ {
3773
+ "class": "MetadataSourceRequestBody",
3774
+ "externalSourceGUID": "add guid here",
3775
+ "externalSourceName": "add qualified name here",
3776
+ "effectiveTime": "{{$isoTimestamp}}",
3777
+ "forLineage": false,
3778
+ "forDuplicateProcessing": false
3779
+ }
3780
+
3781
+ """
3782
+
3783
+ loop = asyncio.get_event_loop()
3784
+ loop.run_until_complete(self._async_delete_data_class(data_class_guid, body))
3785
+
3786
+ async def _async_find_all_data_classes(self, start_from: int = 0,
3787
+ page_size: int = max_paging_size, output_format: str = "DICT") -> list | str:
3788
+ """ Returns a list of all data classes. Async version.
3789
+
3790
+ Parameters
3791
+ ----------
3792
+ start_from: int, default = 0
3793
+ - index of the list to start from (0 for start).
3794
+ page_size
3795
+ - maximum number of elements to return.
3796
+ output_format: str, default = "DICT"
3797
+ - output format of the data structure. Possible values: "DICT", "JSON", "MERMAID".
3798
+
3799
+
3800
+ Returns
3801
+ -------
3802
+ [dict] | str
3803
+ Returns a string if no elements are found and a list of dict elements with the results.
3804
+
3805
+ Raises
3806
+ ------
3807
+ InvalidParameterException
3808
+ one of the parameters is null or invalid or
3809
+ PropertyServerException
3810
+ There is a problem adding the element properties to the metadata repository or
3811
+ UserNotAuthorizedException
3812
+ the requesting user is not authorized to issue this request.
3813
+
3814
+ """
3815
+
3816
+ possible_query_params = query_string(
3817
+ [("startFrom", start_from), ("pageSize", page_size), ("startsWith", 'false'), ("endsWith", 'false'),
3818
+ ("ignoreCase", 'true')])
3819
+
3820
+ url = (f"{base_path(self, self.view_server)}/data-classes/by-search-string"
3821
+ f"{possible_query_params}")
3822
+
3823
+ response: Response = await self._async_make_request("POST", url)
3824
+
3825
+ elements = response.json().get("elements", NO_ELEMENTS_FOUND)
3826
+ if type(elements) is str:
3827
+ return NO_ELEMENTS_FOUND
3828
+ if output_format != 'JSON': # return other representations
3829
+ return self.generate_data_class_output(elements, filter, output_format)
3830
+ return elements
3831
+
3832
+ def find_all_data_classes(self, start_from: int = 0, page_size: int = max_paging_size,
3833
+ output_format: str = "DICT") -> list | str:
3834
+ """ Returns a list of all data classes.
3835
+
3836
+ Parameters
3837
+ ----------
3838
+ start_from: int, default = 0
3839
+ - index of the list to start from (0 for start).
3840
+ page_size
3841
+ - maximum number of elements to return.
3842
+ output_format: str, default = "DICT"
3843
+ - output format of the data structure. Possible values: "DICT", "JSON", "MERMAID".
3844
+
3845
+
3846
+ Returns
3847
+ -------
3848
+ [dict] | str
3849
+ Returns a string if no elements are found and a list of dict elements with the results.
3850
+
3851
+ Raises
3852
+ ------
3853
+ InvalidParameterException
3854
+ one of the parameters is null or invalid or
3855
+ PropertyServerException
3856
+ There is a problem adding the element properties to the metadata repository or
3857
+ UserNotAuthorizedException
3858
+ the requesting user is not authorized to issue this request.
3859
+
3860
+ """
3861
+
3862
+ loop = asyncio.get_event_loop()
3863
+ response = loop.run_until_complete(self._async_find_all_data_classes(start_from, page_size,
3864
+ output_format))
3865
+ return response
3866
+
3867
+ async def _async_find_data_classes_w_body(self, body: dict, start_from: int = 0, page_size: int = max_paging_size,
3868
+ starts_with: bool = True, ends_with: bool = False,
3869
+ ignore_case: bool = True,
3870
+ output_format: str = "DICT") -> list | str:
3871
+ """ Retrieve the list of data class metadata elements that contain the search string.
3872
+ Async version.
3873
+
3874
+ Parameters
3875
+ ----------
3876
+ body: dict
3877
+ - A structure containing the search criteria. (example below)
3878
+ start_from: int, default = 0
3879
+ - index of the list to start from (0 for start).
3880
+ page_size
3881
+ - maximum number of elements to return.
3882
+ starts_with: bool, default = True
3883
+ - if True, the search string filters from the beginning of the string.
3884
+ ends_with: bool, default = False
3885
+ - if True, the search string filters from the end of the string.
3886
+ ignore_case: bool, default = True
3887
+ - If True, the case of the search string is ignored.
3888
+ output_format: str, default = "DICT"
3889
+ - output format of the data structure. Possible values: "DICT", "JSON", "MERMAID".
3890
+
3891
+
3892
+ Returns
3893
+ -------
3894
+ [dict] | str
3895
+ Returns a string if no elements are found and a list of dict with the results.
3896
+
3897
+ Raises
3898
+ ------
3899
+ InvalidParameterException
3900
+ one of the parameters is null or invalid or
3901
+ PropertyServerException
3902
+ There is a problem adding the element properties to the metadata repository or
3903
+ UserNotAuthorizedException
3904
+ the requesting user is not authorized to issue this request.
3905
+
3906
+ Notes:
3907
+
3908
+ {
3909
+ "class": "FilterRequestBody",
3910
+ "asOfTime": "{{$isoTimestamp}}",
3911
+ "effectiveTime": "{{$isoTimestamp}}",
3912
+ "forLineage": false,
3913
+ "forDuplicateProcessing : false,
3914
+ "limitResultsByStatus": ["ACTIVE"],
3915
+ "sequencingOrder": "PROPERTY_ASCENDING",
3916
+ "sequencingProperty": "qualifiedName",
3917
+ "filter": ""
3918
+ }
3919
+
3920
+ """
3921
+ starts_with_s = str(starts_with).lower()
3922
+ ends_with_s = str(ends_with).lower()
3923
+ ignore_case_s = str(ignore_case).lower()
3924
+ possible_query_params = query_string(
3925
+ [("startFrom", start_from), ("pageSize", page_size), ("startsWith", starts_with_s),
3926
+ ("endsWith", ends_with_s), ("ignoreCase", ignore_case_s), ])
3927
+
3928
+ url = (f"{base_path(self, self.view_server)}/data-classes/by-search-string"
3929
+ f"{possible_query_params}")
3930
+
3931
+ response: Response = await self._async_make_request("POST", url, body_slimmer(body))
3932
+
3933
+ elements = response.json().get("elements", NO_ELEMENTS_FOUND)
3934
+ if type(elements) is str:
3935
+ return NO_ELEMENTS_FOUND
3936
+ if output_format != 'JSON': # return other representations
3937
+ return self.generate_data_class_output(elements, filter, output_format)
3938
+ return elements
3939
+
3940
+ def find_data_classes_w_body(self, body: dict, start_from: int = 0, page_size: int = max_paging_size,
3941
+ starts_with: bool = True, ends_with: bool = False,
3942
+ ignore_case: bool = True, output_format: str = "DICT") -> list | str:
3943
+ """ Retrieve the list of data class metadata elements that contain the search string.
3944
+
3945
+ Parameters
3946
+ ----------
3947
+ body: dict
3948
+ - A structure containing the search criteria. (example below)
3949
+ start_from: int, default = 0
3950
+ - index of the list to start from (0 for start).
3951
+ page_size
3952
+ - maximum number of elements to return.
3953
+ starts_with: bool, default = True
3954
+ - if True, the search string filters from the beginning of the string.
3955
+ ends_with: bool, default = False
3956
+ - if True, the search string filters from the end of the string.
3957
+ ignore_case: bool, default = True
3958
+ - If True, the case of the search string is ignored.
3959
+ output_format: str, default = "DICT"
3960
+ - output format of the data structure. Possible values: "DICT", "JSON", "MERMAID".
3961
+
3962
+
3963
+ Returns
3964
+ -------
3965
+ [dict] | str
3966
+ Returns a string if no elements are found and a list of dict with the results.
3967
+
3968
+ Raises
3969
+ ------
3970
+ InvalidParameterException
3971
+ one of the parameters is null or invalid or
3972
+ PropertyServerException
3973
+ There is a problem adding the element properties to the metadata repository or
3974
+ UserNotAuthorizedException
3975
+ the requesting user is not authorized to issue this request.
3976
+
3977
+ Notes:
3978
+
3979
+ {
3980
+ "class": "FilterRequestBody",
3981
+ "asOfTime": "{{$isoTimestamp}}",
3982
+ "effectiveTime": "{{$isoTimestamp}}",
3983
+ "forLineage": false,
3984
+ "forDuplicateProcessing : false,
3985
+ "limitResultsByStatus": ["ACTIVE"],
3986
+ "sequencingOrder": "PROPERTY_ASCENDING",
3987
+ "sequencingProperty": "qualifiedName",
3988
+ "filter": ""
3989
+ }
3990
+
3991
+ """
3992
+
3993
+ loop = asyncio.get_event_loop()
3994
+ response = loop.run_until_complete(
3995
+ self._async_find_data_classes_w_body(body, start_from, page_size, starts_with,
3996
+ ends_with, ignore_case, output_format))
3997
+ return response
3998
+
3999
+ async def _async_find_data_classes(self, filter: str, start_from: int = 0, page_size: int = max_paging_size,
4000
+ starts_with: bool = True, ends_with: bool = False,
4001
+ ignore_case: bool = True,
4002
+ output_format: str = "DICT") -> list | str:
4003
+ """ Find the list of data class elements that contain the search string.
4004
+ Async version.
4005
+
4006
+ Parameters
4007
+ ----------
4008
+ filter: str
4009
+ - search string to filter on.
4010
+ start_from: int, default = 0
4011
+ - index of the list to start from (0 for start).
4012
+ page_size
4013
+ - maximum number of elements to return.
4014
+ starts_with: bool, default = True
4015
+ - if True, the search string filters from the beginning of the string.
4016
+ ends_with: bool, default = False
4017
+ - if True, the search string filters from the end of the string.
4018
+ ignore_case: bool, default = True
4019
+ - If True, the case of the search string is ignored.
4020
+ output_format: str, default = "DICT"
4021
+ - output format of the data structure. Possible values: "DICT", "JSON", "MERMAID".
4022
+
4023
+
4024
+ Returns
4025
+ -------
4026
+ [dict] | str
4027
+ Returns a string if no elements are found and a list of dict with the results.
4028
+
4029
+ Raises
4030
+ ------
4031
+ InvalidParameterException
4032
+ one of the parameters is null or invalid or
4033
+ PropertyServerException
4034
+ There is a problem adding the element properties to the metadata repository or
4035
+ UserNotAuthorizedException
4036
+ the requesting user is not authorized to issue this request.
4037
+
4038
+ """
4039
+
4040
+ body = {"filter": filter}
4041
+
4042
+ possible_query_params = query_string(
4043
+ [("startFrom", start_from), ("pageSize", page_size), ("startsWith", str(starts_with).lower),
4044
+ ("endsWith", str(ends_with).lower()), ("ignoreCase", str(ignore_case).lower()), ])
4045
+
4046
+ url = (f"{base_path(self, self.view_server)}/data-classes/by-search-string"
4047
+ f"{possible_query_params}")
4048
+
4049
+ response: Response = await self._async_make_request("POST", url, body_slimmer(body))
4050
+
4051
+ elements = response.json().get("elements", NO_ELEMENTS_FOUND)
4052
+ if type(elements) is str:
4053
+ return NO_ELEMENTS_FOUND
4054
+ if output_format != 'JSON': # return other representations
4055
+ return self.generate_data_class_output(elements, filter, output_format)
4056
+ return elements
4057
+
4058
+ def find_data_classes(self, filter: str, start_from: int = 0, page_size: int = max_paging_size,
4059
+ starts_with: bool = True, ends_with: bool = False,
4060
+ ignore_case: bool = True, output_format: str = "DICT") -> list | str:
4061
+ """ Retrieve the list of data fields elements that contain the search string filter.
4062
+
4063
+ Parameters
4064
+ ----------
4065
+ filter: str
4066
+ - search string to filter on.
4067
+ start_from: int, default = 0
4068
+ - index of the list to start from (0 for start).
4069
+ page_size
4070
+ - maximum number of elements to return.
4071
+ starts_with: bool, default = True
4072
+ - if True, the search string filters from the beginning of the string.
4073
+ ends_with: bool, default = False
4074
+ - if True, the search string filters from the end of the string.
4075
+ ignore_case: bool, default = True
4076
+ - If True, the case of the search string is ignored.
4077
+ output_format: str, default = "DICT"
4078
+ - output format of the data structure. Possible values: "DICT", "JSON", "MERMAID".
4079
+
4080
+
4081
+ Returns
4082
+ -------
4083
+ [dict] | str
4084
+ Returns a string if no elements are found and a list of dict with the results.
4085
+
4086
+ Raises
4087
+ ------
4088
+ InvalidParameterException
4089
+ one of the parameters is null or invalid or
4090
+ PropertyServerException
4091
+ There is a problem adding the element properties to the metadata repository or
4092
+ UserNotAuthorizedException
4093
+ the requesting user is not authorized to issue this request.
4094
+
4095
+
4096
+ """
4097
+
4098
+ loop = asyncio.get_event_loop()
4099
+ response = loop.run_until_complete(
4100
+ self._async_find_data_classes(filter, start_from, page_size, starts_with,
4101
+ ends_with, ignore_case, output_format))
4102
+ return response
4103
+
4104
+ async def _async_get_data_classes_by_name(self, filter: str, body: dict = None, start_from: int = 0,
4105
+ page_size: int = max_paging_size, output_format: str = "DICT") -> list | str:
4106
+ """ Get the list of data class metadata elements with a matching name to the search string filter.
4107
+ Async version.
4108
+
4109
+ Parameters
4110
+ ----------
4111
+ filter: str
4112
+ - search string to filter on.
4113
+ body: dict, optional
4114
+ - a dictionary containing additional properties to use in the request.
4115
+ start_from: int, default = 0
4116
+ - index of the list to start from (0 for start).
4117
+ page_size
4118
+ - maximum number of elements to return.
4119
+ output_format: str, default = "DICT"
4120
+ - output format of the data structure. Possible values: "DICT", "JSON", "MERMAID".
4121
+
4122
+
4123
+ Returns
4124
+ -------
4125
+ [dict] | str
4126
+ Returns a string if no elements are found and a list of dict with the results.
4127
+
4128
+ Raises
4129
+ ------
4130
+ InvalidParameterException
4131
+ one of the parameters is null or invalid or
4132
+ PropertyServerException
4133
+ There is a problem adding the element properties to the metadata repository or
4134
+ UserNotAuthorizedException
4135
+ the requesting user is not authorized to issue this request.
4136
+ Notes
4137
+ -----
4138
+
4139
+ {
4140
+ "class": "FilterRequestBody",
4141
+ "asOfTime": "{{$isoTimestamp}}",
4142
+ "effectiveTime": "{{$isoTimestamp}}",
4143
+ "forLineage": false,
4144
+ "forDuplicateProcessing": false,
4145
+ "limitResultsByStatus": ["ACTIVE"],
4146
+ "sequencingOrder": "PROPERTY_ASCENDING",
4147
+ "sequencingProperty": "qualifiedName",
4148
+ "filter": "Add name here"
4149
+ }
4150
+ """
4151
+ if body is None:
4152
+ body = {"filter": filter}
4153
+
4154
+ possible_query_params = query_string([("startFrom", start_from), ("pageSize", page_size), ])
4155
+
4156
+ url = (f"{base_path(self, self.view_server)}/data-classes/by-name"
4157
+ f"{possible_query_params}")
4158
+
4159
+ response: Response = await self._async_make_request("POST", url, body_slimmer(body))
4160
+
4161
+ elements = response.json().get("elements", NO_ELEMENTS_FOUND)
4162
+ if type(elements) is str:
4163
+ return NO_ELEMENTS_FOUND
4164
+ if output_format != 'JSON': # return other representations
4165
+ return self.generate_data_class_output(elements, filter, output_format)
4166
+ return elements
4167
+
4168
+ def get_data_classes_by_name(self, filter: str, body: dict = None, start_from: int = 0,
4169
+ page_size: int = max_paging_size, output_format: str = "DICT") -> list | str:
4170
+ """ Get the list of data class elements with a matching name to the search string filter.
4171
+
4172
+ Parameters
4173
+ ----------
4174
+ filter: str
4175
+ - search string to filter on.
4176
+ body: dict, optional
4177
+ - a dictionary containing additional properties to use in the request.
4178
+ start_from: int, default = 0
4179
+ - index of the list to start from (0 for start).
4180
+ page_size
4181
+ - maximum number of elements to return.
4182
+ output_format: str, default = "DICT"
4183
+ - output format of the data structure. Possible values: "DICT", "JSON", "MERMAID".
4184
+
4185
+
4186
+ Returns
4187
+ -------
4188
+ [dict] | str
4189
+ Returns a string if no elements are found and a list of dict with the results.
4190
+
4191
+ Raises
4192
+ ------
4193
+ InvalidParameterException
4194
+ one of the parameters is null or invalid or
4195
+ PropertyServerException
4196
+ There is a problem adding the element properties to the metadata repository or
4197
+ UserNotAuthorizedException
4198
+ the requesting user is not authorized to issue this request.
4199
+
4200
+ Notes
4201
+ -----
4202
+ {
4203
+ "class": "FilterRequestBody",
4204
+ "asOfTime": "{{$isoTimestamp}}",
4205
+ "effectiveTime": "{{$isoTimestamp}}",
4206
+ "forLineage": false,
4207
+ "forDuplicateProcessing": false,
4208
+ "limitResultsByStatus": ["ACTIVE"],
4209
+ "sequencingOrder": "PROPERTY_ASCENDING",
4210
+ "sequencingProperty": "qualifiedName",
4211
+ "filter": "Add name here"
4212
+ }
4213
+
4214
+
4215
+ """
4216
+
4217
+ loop = asyncio.get_event_loop()
4218
+ response = loop.run_until_complete(self._async_get_data_classes_by_name(filter, body, start_from,
4219
+ page_size, output_format))
4220
+ return response
4221
+
4222
+ async def _async_get_data_class_by_guid(self, guid: str, body: dict = None ,output_format: str = "DICT") -> list | str:
4223
+ """ Get the data class elements for the specified GUID.
4224
+ Async version.
4225
+
4226
+ Parameters
4227
+ ----------
4228
+ guid: str
4229
+ - unique identifier of the data class metadata element.
4230
+ body: dict, optional
4231
+ - optional request body.
4232
+ output_format: str, default = "DICT"
4233
+ - output format of the data structure. Possible values: "DICT", "JSON", "MERMAID".
4234
+
4235
+ Returns
4236
+ -------
4237
+ [dict] | str
4238
+ Returns a string if no elements are found and a list of dict with the results.
4239
+
4240
+ Raises
4241
+ ------
4242
+ InvalidParameterException
4243
+ one of the parameters is null or invalid or
4244
+ PropertyServerException
4245
+ There is a problem adding the element properties to the metadata repository or
4246
+ UserNotAuthorizedException
4247
+ the requesting user is not authorized to issue this request.
4248
+
4249
+ Notes
4250
+ ----
4251
+
4252
+ Optional request body:
4253
+ {
4254
+ "class": "AnyTimeRequestBody",
4255
+ "asOfTime": "{{$isoTimestamp}}",
4256
+ "effectiveTime": "{{$isoTimestamp}}",
4257
+ "forLineage": false,
4258
+ "forDuplicateProcessing": false
4259
+ }
4260
+
4261
+ """
4262
+
4263
+ url = (f"{base_path(self, self.view_server)}/data-classes/{guid}/retrieve")
4264
+ if body:
4265
+ response: Response = await self._async_make_request("POST", url, body_slimmer(body))
4266
+ else:
4267
+ response: Response = await self._async_make_request("POST", url)
4268
+
4269
+ elements = response.json().get("elements", NO_ELEMENTS_FOUND)
4270
+ if type(elements) is str:
4271
+ return NO_ELEMENTS_FOUND
4272
+ if output_format != 'JSON': # return other representations
4273
+ return self.generate_data_class_output(elements, filter, output_format)
4274
+ return elements
4275
+
4276
+ def get_data_class_by_guid(self, guid: str, body: str = None, output_format: str = "DICT") -> list | str:
4277
+ """ Get the data structure metadata element with the specified unique identifier..
4278
+
4279
+ Parameters
4280
+ ----------
4281
+ guid: str
4282
+ - unique identifier of the data structure metadata element.
4283
+ body: dict, optional
4284
+ - optional request body.
4285
+ output_format: str, default = "DICT"
4286
+ - output format of the data structure. Possible values: "DICT", "JSON", "MERMAID".
4287
+
4288
+ Returns
4289
+ -------
4290
+ [dict] | str
4291
+ Returns a string if no elements are found and a list of dict with the results.
4292
+
4293
+ Raises
4294
+ ------
4295
+ InvalidParameterException
4296
+ one of the parameters is null or invalid or
4297
+ PropertyServerException
4298
+ There is a problem adding the element properties to the metadata repository or
4299
+ UserNotAuthorizedException
4300
+ the requesting user is not authorized to issue this request.
4301
+
4302
+ Notes
4303
+ ----
4304
+
4305
+ Optional request body:
4306
+ {
4307
+ "class": "AnyTimeRequestBody",
4308
+ "asOfTime": "{{$isoTimestamp}}",
4309
+ "effectiveTime": "{{$isoTimestamp}}",
4310
+ "forLineage": false,
4311
+ "forDuplicateProcessing": false
4312
+ }
4313
+
4314
+ """
4315
+
4316
+ loop = asyncio.get_event_loop()
4317
+ response = loop.run_until_complete(self._async_get_data_class_by_guid(guid, body, output_format))
4318
+ return response
4319
+
4320
+ ###
4321
+ # =====================================================================================================================
4322
+ # Assembling a data specification
4323
+ # https://egeria-project.org/concepts/data-specification
4324
+ #
4325
+ async def _async_link_data_class_definition(self, data_definition_guid: str, data_class_guid: str,
4326
+ body: dict = None) -> None:
4327
+ """
4328
+ Connect an element that is part of a data design to a data class to show that the data class should be used as
4329
+ the specification for the data values when interpreting the data definition. Request body is optional.
4330
+ Async version
4331
+ Parameters
4332
+ ----------
4333
+ data_definition_guid: str
4334
+ - the GUID of the data class definition to link.
4335
+ data_class_guid: str
4336
+ - the GUID of the data class to be connected.
4337
+ body: dict, optional
4338
+ - a dictionary containing additional properties.
4339
+
4340
+ Returns
4341
+ -------
4342
+ None
4343
+
4344
+ Raises
4345
+ ------
4346
+ InvalidParameterException
4347
+ one of the parameters is null or invalid or
4348
+ PropertyServerException
4349
+ There is a problem adding the element properties to the metadata repository or
4350
+ UserNotAuthorizedException
4351
+ the requesting user is not authorized to issue this request.
4352
+
4353
+ Note
4354
+ ----
4355
+
4356
+ Sample body:
4357
+
4358
+ {
4359
+ "class": "MetadataSourceRequestBody",
4360
+ "externalSourceGUID": "add guid here",
4361
+ "externalSourceName": "add qualified name here",
4362
+ "effectiveTime": "{{$isoTimestamp}}",
4363
+ "forLineage": false,
4364
+ "forDuplicateProcessing": false
4365
+ }
4366
+
4367
+ """
4368
+
4369
+ url = (f"{base_path(self, self.view_server)}/data-definitions/{data_definition_guid}"
4370
+ f"/data-class-definition/{data_class_guid}/attach")
4371
+
4372
+ if body is None:
4373
+ await self._async_make_request("POST", url)
4374
+ else:
4375
+ await self._async_make_request("POST", url, body_slimmer(body))
4376
+
4377
+ def link_data_class_definition(self, data_definition_guid: str, data_class_guid: str, body: dict = None) -> None:
4378
+ """
4379
+ Connect an element that is part of a data design to a data class to show that the data class should be used as
4380
+ the specification for the data values when interpreting the data definition. Request body is optional.
4381
+ Async version
4382
+ Parameters
4383
+ ----------
4384
+ data_definition_guid: str
4385
+ - the GUID of the data class definition to link.
4386
+ data_class_guid: str
4387
+ - the GUID of the data class to be connected.
4388
+ body: dict, optional
4389
+ - a dictionary containing additional properties.
4390
+
4391
+ Returns
4392
+ -------
4393
+ None
4394
+
4395
+ Raises
4396
+ ------
4397
+ InvalidParameterException
4398
+ one of the parameters is null or invalid or
4399
+ PropertyServerException
4400
+ There is a problem adding the element properties to the metadata repository or
4401
+ UserNotAuthorizedException
4402
+ the requesting user is not authorized to issue this request.
4403
+
4404
+ Note
4405
+ ----
4406
+
4407
+ Sample body:
4408
+
4409
+ {
4410
+ "class": "MetadataSourceRequestBody",
4411
+ "externalSourceGUID": "add guid here",
4412
+ "externalSourceName": "add qualified name here",
4413
+ "effectiveTime": "{{$isoTimestamp}}",
4414
+ "forLineage": false,
4415
+ "forDuplicateProcessing": false
4416
+ }
4417
+
4418
+ """
4419
+
4420
+ loop = asyncio.get_event_loop()
4421
+ loop.run_until_complete(self._async_link_data_class_definition(data_definition_guid, data_class_guid, body))
4422
+
4423
+ async def _async_detach_data_class_definition(self, data_definition_guid: str, data_class_guid: str,
4424
+ body: dict = None) -> None:
4425
+ """
4426
+ Detach a data definition from a data class. Request body is optional. Async version.
4427
+
4428
+ Parameters
4429
+ ----------
4430
+ data_definition_guid: str
4431
+ - the GUID of the data class definition.
4432
+ data_class_guid: str
4433
+ - the GUID of the data class to be disconnected.
4434
+ body: dict, optional
4435
+ - a dictionary containing additional properties.
4436
+
4437
+ Returns
4438
+ -------
4439
+ None
4440
+
4441
+ Raises
4442
+ ------
4443
+ InvalidParameterException
4444
+ one of the parameters is null or invalid or
4445
+ PropertyServerException
4446
+ There is a problem adding the element properties to the metadata repository or
4447
+ UserNotAuthorizedException
4448
+ the requesting user is not authorized to issue this request.
4449
+
4450
+ Note
4451
+ ----
4452
+
4453
+ Sample body:
4454
+
4455
+ {
4456
+ "class": "MetadataSourceRequestBody",
4457
+ "externalSourceGUID": "add guid here",
4458
+ "externalSourceName": "add qualified name here",
4459
+ "effectiveTime": "{{$isoTimestamp}}",
4460
+ "forLineage": false,
4461
+ "forDuplicateProcessing": false
4462
+ }
4463
+
4464
+
4465
+ """
4466
+
4467
+ url = (f"{base_path(self, self.view_server)}/data-definitions/{data_definition_guid}"
4468
+ f"/data-class-definition/{data_class_guid}/detach")
4469
+
4470
+ if body is None:
4471
+ await self._async_make_request("POST", url)
4472
+ else:
4473
+ await self._async_make_request("POST", url, body_slimmer(body))
4474
+
4475
+ def detach_data_class_definition(self, data_definition_guid: str, data_class_guid: str, body: dict = None) -> None:
4476
+ """
4477
+ Detach a data definition from a data class. Request body is optional.
4478
+
4479
+ Parameters
4480
+ ----------
4481
+ data_definition_guid: str
4482
+ - the GUID of the data class definition.
4483
+ data_class_guid: str
4484
+ - the GUID of the data class to be disconnected.
4485
+ body: dict, optional
4486
+ - a dictionary containing additional properties.
4487
+
4488
+ Returns
4489
+ -------
4490
+ None
4491
+
4492
+ Raises
4493
+ ------
4494
+ InvalidParameterException
4495
+ one of the parameters is null or invalid or
4496
+ PropertyServerException
4497
+ There is a problem adding the element properties to the metadata repository or
4498
+ UserNotAuthorizedException
4499
+ the requesting user is not authorized to issue this request.
4500
+
4501
+ Note
4502
+ ----
4503
+
4504
+ Sample body:
4505
+
4506
+ {
4507
+ "class": "MetadataSourceRequestBody",
4508
+ "externalSourceGUID": "add guid here",
4509
+ "externalSourceName": "add qualified name here",
4510
+ "effectiveTime": "{{$isoTimestamp}}",
4511
+ "forLineage": false,
4512
+ "forDuplicateProcessing": false
4513
+ }
4514
+
4515
+
4516
+ """
4517
+
4518
+ loop = asyncio.get_event_loop()
4519
+ loop.run_until_complete(self._async_detach_data_class_definition(data_definition_guid, data_class_guid, body))
4520
+
4521
+ async def _async_link_semantic_definition(self, data_definition_guid: str, glossary_term_guid: str,
4522
+ body: dict = None) -> None:
4523
+ """
4524
+ Connect an element that is part of a data design to a glossary term to show that the term should be used as
4525
+ the semantic definition for the data values when interpreting the data definition. Request body is optional.
4526
+ Async version
4527
+
4528
+ Parameters
4529
+ ----------
4530
+ data_definition_guid: str
4531
+ - the GUID of the data class definition to link.
4532
+ glossary_term_guid: str
4533
+ - the GUID of the glossary term to be connected.
4534
+ body: dict, optional
4535
+ - a dictionary containing additional properties.
4536
+
4537
+ Returns
4538
+ -------
4539
+ None
4540
+
4541
+ Raises
4542
+ ------
4543
+ InvalidParameterException
4544
+ one of the parameters is null or invalid or
4545
+ PropertyServerException
4546
+ There is a problem adding the element properties to the metadata repository or
4547
+ UserNotAuthorizedException
4548
+ the requesting user is not authorized to issue this request.
4549
+
4550
+ Note
4551
+ ----
4552
+
4553
+ Sample body:
4554
+
4555
+ {
4556
+ "class": "MetadataSourceRequestBody",
4557
+ "externalSourceGUID": "add guid here",
4558
+ "externalSourceName": "add qualified name here",
4559
+ "effectiveTime": "{{$isoTimestamp}}",
4560
+ "forLineage": false,
4561
+ "forDuplicateProcessing": false
4562
+ }
4563
+
4564
+ """
4565
+
4566
+ url = (f"{base_path(self, self.view_server)}/data-definitions/{data_definition_guid}"
4567
+ f"/semantic-definition/{glossary_term_guid}/attach")
4568
+
4569
+ if body is None:
4570
+ await self._async_make_request("POST", url)
4571
+ else:
4572
+ await self._async_make_request("POST", url, body_slimmer(body))
4573
+
4574
+ def link_semantic_definition(self, data_definition_guid: str, glossary_term_guid: str, body: dict = None) -> None:
4575
+ """
4576
+ Connect an element that is part of a data design to a glossary term to show that the term should be used as
4577
+ the semantic definition for the data values when interpreting the data definition. Request body is optional.
4578
+ Async version
4579
+
4580
+ Parameters
4581
+ ----------
4582
+ data_definition_guid: str
4583
+ - the GUID of the data class definition to link.
4584
+ glossary_term_guid: str
4585
+ - the GUID of the glossary term to be connected.
4586
+ body: dict, optional
4587
+ - a dictionary containing additional properties.
4588
+
4589
+ Returns
4590
+ -------
4591
+ None
4592
+
4593
+ Raises
4594
+ ------
4595
+ InvalidParameterException
4596
+ one of the parameters is null or invalid or
4597
+ PropertyServerException
4598
+ There is a problem adding the element properties to the metadata repository or
4599
+ UserNotAuthorizedException
4600
+ the requesting user is not authorized to issue this request.
4601
+
4602
+ Note
4603
+ ----
4604
+
4605
+ Sample body:
4606
+
4607
+ {
4608
+ "class": "MetadataSourceRequestBody",
4609
+ "externalSourceGUID": "add guid here",
4610
+ "externalSourceName": "add qualified name here",
4611
+ "effectiveTime": "{{$isoTimestamp}}",
4612
+ "forLineage": false,
4613
+ "forDuplicateProcessing": false
4614
+ }
4615
+
4616
+ """
4617
+
4618
+ loop = asyncio.get_event_loop()
4619
+ loop.run_until_complete(self._async_link_semantic_definition(data_definition_guid, glossary_term_guid, body))
4620
+
4621
+ async def _async_detach_semantic_definition(self, data_definition_guid: str, glossary_term_guid: str,
4622
+ body: dict = None) -> None:
4623
+ """
4624
+ Detach a data definition from a glossary term. Request body is optional. Async version.
4625
+
4626
+ Parameters
4627
+ ----------
4628
+ data_definition_guid: str
4629
+ - the GUID of the data class definition.
4630
+ glossary_term_guid: str
4631
+ - the GUID of the glossary term to be disconnected.
4632
+ body: dict, optional
4633
+ - a dictionary containing additional properties.
4634
+
4635
+ Returns
4636
+ -------
4637
+ None
4638
+
4639
+ Raises
4640
+ ------
4641
+ InvalidParameterException
4642
+ one of the parameters is null or invalid or
4643
+ PropertyServerException
4644
+ There is a problem adding the element properties to the metadata repository or
4645
+ UserNotAuthorizedException
4646
+ the requesting user is not authorized to issue this request.
4647
+
4648
+ Note
4649
+ ----
4650
+
4651
+ Sample body:
4652
+
4653
+ {
4654
+ "class": "MetadataSourceRequestBody",
4655
+ "externalSourceGUID": "add guid here",
4656
+ "externalSourceName": "add qualified name here",
4657
+ "effectiveTime": "{{$isoTimestamp}}",
4658
+ "forLineage": false,
4659
+ "forDuplicateProcessing": false
4660
+ }
4661
+
4662
+
4663
+ """
4664
+
4665
+ url = (f"{base_path(self, self.view_server)}/data-definitions/{data_definition_guid}"
4666
+ f"/semantic-definition/{glossary_term_guid}/detach")
4667
+
4668
+ if body is None:
4669
+ await self._async_make_request("POST", url)
4670
+ else:
4671
+ await self._async_make_request("POST", url, body_slimmer(body))
4672
+
4673
+ def detach_semantic_definition(self, data_definition_guid: str, glossary_term_guid: str, body: dict = None) -> None:
4674
+ """
4675
+ Detach a data definition from a glossary term. Request body is optional.
4676
+
4677
+ Parameters
4678
+ ----------
4679
+ data_definition_guid: str
4680
+ - the GUID of the data class definition.
4681
+ glossary_term_guid: str
4682
+ - the GUID of the glossary term to be disconnected.
4683
+ body: dict, optional
4684
+ - a dictionary containing additional properties.
4685
+
4686
+ Returns
4687
+ -------
4688
+ None
4689
+
4690
+ Raises
4691
+ ------
4692
+ InvalidParameterException
4693
+ one of the parameters is null or invalid or
4694
+ PropertyServerException
4695
+ There is a problem adding the element properties to the metadata repository or
4696
+ UserNotAuthorizedException
4697
+ the requesting user is not authorized to issue this request.
4698
+
4699
+ Note
4700
+ ----
4701
+
4702
+ Sample body:
4703
+
4704
+ {
4705
+ "class": "MetadataSourceRequestBody",
4706
+ "externalSourceGUID": "add guid here",
4707
+ "externalSourceName": "add qualified name here",
4708
+ "effectiveTime": "{{$isoTimestamp}}",
4709
+ "forLineage": false,
4710
+ "forDuplicateProcessing": false
4711
+ }
4712
+
4713
+
4714
+ """
4715
+
4716
+ loop = asyncio.get_event_loop()
4717
+ loop.run_until_complete(self._async_detach_semantic_definition(data_definition_guid, glossary_term_guid, body))
4718
+
4719
+ async def _async_link_certification_type_to_data_structure(self, certification_type_guid: str,
4720
+ data_structure_guid: str, body: dict = None) -> None:
4721
+ """
4722
+ Connect a certification type to a data structure to guide the survey action service (that checks the data
4723
+ quality of a data resource as part of certifying it with the supplied certification type) to the definition
4724
+ of the data structure to use as a specification of how the data should be both structured and (if data
4725
+ classes are attached to the associated data fields using the DataClassDefinition relationship) contain the
4726
+ valid values. Request body is optional.
4727
+ Async version
4728
+
4729
+ Parameters
4730
+ ----------
4731
+ certification_type_guid: str
4732
+ - the GUID of the certification type to link.
4733
+ data_structure_guid: str
4734
+ - the GUID of the data structure to be connected.
4735
+ body: dict, optional
4736
+ - a dictionary containing additional properties.
4737
+
4738
+ Returns
4739
+ -------
4740
+ None
4741
+
4742
+ Raises
4743
+ ------
4744
+ InvalidParameterException
4745
+ one of the parameters is null or invalid or
4746
+ PropertyServerException
4747
+ There is a problem adding the element properties to the metadata repository or
4748
+ UserNotAuthorizedException
4749
+ the requesting user is not authorized to issue this request.
4750
+
4751
+ Note
4752
+ ----
4753
+
4754
+ Sample body:
4755
+
4756
+ {
4757
+ "class": "MetadataSourceRequestBody",
4758
+ "externalSourceGUID": "add guid here",
4759
+ "externalSourceName": "add qualified name here",
4760
+ "effectiveTime": "{{$isoTimestamp}}",
4761
+ "forLineage": false,
4762
+ "forDuplicateProcessing": false
4763
+ }
4764
+
4765
+ """
4766
+
4767
+ url = (f"{base_path(self, self.view_server)}/certification-types/{certification_type_guid}"
4768
+ f"/data-structure-definition/{data_structure_guid}/attach")
4769
+
4770
+ if body is None:
4771
+ await self._async_make_request("POST", url)
4772
+ else:
4773
+ await self._async_make_request("POST", url, body_slimmer(body))
4774
+
4775
+ def link_certification_type_to_data_structure(self, certification_type_guid: str, data_structure_guid: str,
4776
+ body: dict = None) -> None:
4777
+ """
4778
+ Connect a certification type to a data structure to guide the survey action service (that checks the data
4779
+ quality of a data resource as part of certifying it with the supplied certification type) to the definition
4780
+ of the data structure to use as a specification of how the data should be both structured and (if data
4781
+ classes are attached to the associated data fields using the DataClassDefinition relationship) contain the
4782
+ valid values. Request body is optional.
4783
+
4784
+ Parameters
4785
+ ----------
4786
+ certification_type_guid: str
4787
+ - the GUID of the certification type to link.
4788
+ data_structure_guid: str
4789
+ - the GUID of the data structure to be connected.
4790
+ body: dict, optional
4791
+ - a dictionary containing additional properties.
4792
+
4793
+ Returns
4794
+ -------
4795
+ None
4796
+
4797
+ Raises
4798
+ ------
4799
+ InvalidParameterException
4800
+ one of the parameters is null or invalid or
4801
+ PropertyServerException
4802
+ There is a problem adding the element properties to the metadata repository or
4803
+ UserNotAuthorizedException
4804
+ the requesting user is not authorized to issue this request.
4805
+
4806
+ Note
4807
+ ----
4808
+
4809
+ Sample body:
4810
+
4811
+ {
4812
+ "class": "MetadataSourceRequestBody",
4813
+ "externalSourceGUID": "add guid here",
4814
+ "externalSourceName": "add qualified name here",
4815
+ "effectiveTime": "{{$isoTimestamp}}",
4816
+ "forLineage": false,
4817
+ "forDuplicateProcessing": false
4818
+ }
4819
+
4820
+ """
4821
+
4822
+ loop = asyncio.get_event_loop()
4823
+ loop.run_until_complete(
4824
+ self._async_link_certification_type_to_data_structure(certification_type_guid, data_structure_guid, body))
4825
+
4826
+ async def _async_detach_certification_type_from_data_structure(self, certification_type_guid: str,
4827
+ data_structure_guid: str, body: dict = None) -> None:
4828
+ """
4829
+ Detach a data structure from a certification type. Request body is optional. Async version.
4830
+
4831
+ Parameters
4832
+ ----------
4833
+ certification_type_guid: str
4834
+ - the GUID of the certification type to link.
4835
+ data_structure_guid: str
4836
+ - the GUID of the data structure to be connected.
4837
+ body: dict, optional
4838
+ - a dictionary containing additional properties.
4839
+
4840
+ Returns
4841
+ -------
4842
+ None
4843
+
4844
+ Raises
4845
+ ------
4846
+ InvalidParameterException
4847
+ one of the parameters is null or invalid or
4848
+ PropertyServerException
4849
+ There is a problem adding the element properties to the metadata repository or
4850
+ UserNotAuthorizedException
4851
+ the requesting user is not authorized to issue this request.
4852
+
4853
+ Note
4854
+ ----
4855
+
4856
+ Sample body:
4857
+
4858
+ {
4859
+ "class": "MetadataSourceRequestBody",
4860
+ "externalSourceGUID": "add guid here",
4861
+ "externalSourceName": "add qualified name here",
4862
+ "effectiveTime": "{{$isoTimestamp}}",
4863
+ "forLineage": false,
4864
+ "forDuplicateProcessing": false
4865
+ }
4866
+
4867
+ """
4868
+
4869
+ url = (f"{base_path(self, self.view_server)}/certification-stypes/{certification_type_guid}"
4870
+ f"/data-structure-definition/{data_structure_guid}/detach")
4871
+
4872
+ if body is None:
4873
+ await self._async_make_request("POST", url)
4874
+ else:
4875
+ await self._async_make_request("POST", url, body_slimmer(body))
4876
+
4877
+ def detach_certification_type_from_data_structure(self, certification_type_guid: str, data_structure_guid: str,
4878
+ body: dict = None) -> None:
4879
+ """
4880
+ Detach a data structure from a certification type. Request body is optional.
4881
+
4882
+ Parameters
4883
+ ----------
4884
+ certification_type_guid: str
4885
+ - the GUID of the certification type to link.
4886
+ data_structure_guid: str
4887
+ - the GUID of the data structure to be connected.
4888
+ body: dict, optional
4889
+ - a dictionary containing additional properties.
4890
+
4891
+ Returns
4892
+ -------
4893
+ None
4894
+
4895
+ Raises
4896
+ ------
4897
+ InvalidParameterException
4898
+ one of the parameters is null or invalid or
4899
+ PropertyServerException
4900
+ There is a problem adding the element properties to the metadata repository or
4901
+ UserNotAuthorizedException
4902
+ the requesting user is not authorized to issue this request.
4903
+
4904
+ Note
4905
+ ----
4906
+
4907
+ Sample body:
4908
+
4909
+ {
4910
+ "class": "MetadataSourceRequestBody",
4911
+ "externalSourceGUID": "add guid here",
4912
+ "externalSourceName": "add qualified name here",
4913
+ "effectiveTime": "{{$isoTimestamp}}",
4914
+ "forLineage": false,
4915
+ "forDuplicateProcessing": false
4916
+ }
4917
+
4918
+ """
4919
+
4920
+ loop = asyncio.get_event_loop()
4921
+ loop.run_until_complete(
4922
+ self._async_detach_certification_type_from_data_structure(certification_type_guid, data_structure_guid,
4923
+ body))
4924
+
4925
+ def generate_basic_structured_output(self, elements, filter, output_format) -> str | list:
4926
+ match output_format:
4927
+ case "MERMAID":
4928
+ return extract_mermaid_only(elements)
4929
+ case "DICT":
4930
+ return extract_basic_dict(elements)
4931
+ case _:
4932
+ return None
4933
+
4934
+ def generate_data_structure_output(self, elements, filter, output_format) -> str | list:
4935
+ return self.generate_basic_structured_output(elements, filter, output_format)
4936
+
4937
+ def generate_data_class_output(self, elements, filter, output_format) -> str | list:
4938
+ return self.generate_basic_structured_output(elements, filter, output_format)
4939
+
4940
+ def generate_data_field_output(self, elements, filter, output_format) -> str | list:
4941
+ return self.generate_basic_structured_output(elements, filter, output_format)
4942
+
4943
+ if __name__ == "__main__":
4944
+ print("Data Designer")