pyegeria 0.8.4.8__py3-none-any.whl → 0.8.4.10__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.
@@ -431,17 +431,159 @@ class ClassificationManager(Client):
431
431
  )
432
432
  return response
433
433
 
434
+ async def _async_get_element_by_guid(
435
+ self,
436
+ element_guid: str,
437
+ effective_time: str = None,
438
+ for_lineage: bool = None,
439
+ for_duplicate_processing: bool = None,
440
+ server_name: str = None,
441
+ time_out: int = default_time_out,
442
+ ) -> dict | str:
443
+ """
444
+ Retrieve element by its unique identifier. Async version.
445
+
446
+ https://egeria-project.org/types/
447
+
448
+ Parameters
449
+ ----------
450
+ element_guid: str
451
+ - unique identifier for the element
452
+ effective_time: str, default = None
453
+ - Time format is "YYYY-MM-DDTHH:MM:SS" (ISO 8601)
454
+ for_lineage: bool, default is set by server
455
+ - determines if elements classified as Memento should be returned - normally false
456
+ for_duplicate_processing: bool, default is set by server
457
+ - Normally false. Set true when the caller is part of a deduplication function
458
+ server_name: str, default = None
459
+ - name of the server instances for this request.
460
+ time_out: int, default = default_time_out
461
+ - http request timeout for this request
462
+
463
+ Returns
464
+ -------
465
+ dict | str
466
+ Returns a string if no elements found; otherwise a dict of the element.
467
+
468
+ Raises
469
+ ------
470
+ InvalidParameterException
471
+ one of the parameters is null or invalid or
472
+ PropertyServerException
473
+ There is a problem adding the element properties to the metadata repository or
474
+ UserNotAuthorizedException
475
+ the requesting user is not authorized to issue this request.
476
+ """
477
+ if server_name is None:
478
+ server_name = self.server_name
479
+
480
+ possible_query_params = query_string(
481
+ [
482
+ ("forLineage", for_lineage),
483
+ ("forDuplicateProcessing", for_duplicate_processing),
484
+ ]
485
+ )
486
+
487
+ body = {
488
+ "class": "EffectiveTimeQueryRequestBody",
489
+ "effectiveTime": effective_time,
490
+ }
491
+
492
+ url = f"{base_path(self, server_name)}/elements/{element_guid}{possible_query_params}"
493
+
494
+ response: Response = await self._async_make_request(
495
+ "POST", url, body_slimmer(body), time_out=time_out
496
+ )
497
+
498
+ elements = response.json().get("elements", "No elements found")
499
+ if type(elements) is list:
500
+ if len(elements) == 0:
501
+ return "No elements found"
502
+ return elements
503
+
504
+ def get_element_by_guid(
505
+ self,
506
+ element_guid: str,
507
+ effective_time: str = None,
508
+ for_lineage: bool = None,
509
+ for_duplicate_processing: bool = None,
510
+ server_name: str = None,
511
+ time_out: int = default_time_out,
512
+ ) -> dict | str:
513
+ """
514
+ Retrieve element by its unique identifier.
515
+
516
+ https://egeria-project.org/types/
517
+
518
+ Parameters
519
+ ----------
520
+ element_guid: str
521
+ - unique identifier for the element
522
+ effective_time: str, default = None
523
+ - Time format is "YYYY-MM-DDTHH:MM:SS" (ISO 8601)
524
+ for_lineage: bool, default is set by server
525
+ - determines if elements classified as Memento should be returned - normally false
526
+ for_duplicate_processing: bool, default is set by server
527
+ - Normally false. Set true when the caller is part of a deduplication function
528
+ server_name: str, default = None
529
+ - name of the server instances for this request.
530
+ time_out: int, default = default_time_out
531
+ - http request timeout for this request
532
+
533
+ Returns
534
+ -------
535
+ dict | str
536
+ Returns a string if no elements found; otherwise a dict of the element.
537
+
538
+ Raises
539
+ ------
540
+ InvalidParameterException
541
+ one of the parameters is null or invalid or
542
+ PropertyServerException
543
+ There is a problem adding the element properties to the metadata repository or
544
+ UserNotAuthorizedException
545
+ the requesting user is not authorized to issue this request.
546
+ """
547
+
548
+ loop = asyncio.get_event_loop()
549
+ response = loop.run_until_complete(
550
+ self._async_get_element_by_guid(
551
+ element_guid,
552
+ effective_time,
553
+ for_lineage,
554
+ for_duplicate_processing,
555
+ server_name,
556
+ time_out,
557
+ )
558
+ )
559
+ return response
560
+
434
561
  async def _async_get_guid_for_name(
435
- self, name: str, server_name: str = None, time_out: int = default_time_out
562
+ self,
563
+ name: str,
564
+ property_name: str = None,
565
+ for_lineage: bool = None,
566
+ for_duplicate_processing: bool = None,
567
+ effective_time: str = None,
568
+ server_name: str = None,
569
+ time_out: int = default_time_out,
436
570
  ) -> list | str:
437
571
  """
438
- Retrieve the guid associated with the supplied element name.
572
+ Retrieve the guid associated with the supplied unique element name.
439
573
  If more than one element returned, an exception is thrown. Async version.
440
574
 
441
575
  Parameters
442
576
  ----------
443
577
  name: str
444
578
  - element name to be searched.
579
+ property_name: str, optional
580
+ - optional name of property to search. If not specified, defaults to qualifiedName
581
+ for_lineage: bool, default is set by server
582
+ - determines if elements classified as Memento should be returned - normally false
583
+ for_duplicate_processing: bool, default is set by server
584
+ - Normally false. Set true when the caller is part of a deduplication function
585
+ effective_time: str, default = None
586
+ - Time format is "YYYY-MM-DDTHH:MM:SS" (ISO 8601)
445
587
  server_name: str, default = None
446
588
  - name of the server instances for this request.
447
589
  time_out: int, default = default_time_out
@@ -463,11 +605,32 @@ class ClassificationManager(Client):
463
605
  """
464
606
  if server_name is None:
465
607
  server_name = self.server_name
466
- property_name = ["name", "qualifiedName", "title"]
467
- elements = await self._async_get_elements_by_property_value(
468
- name, property_name, None
608
+ property_name = "qualifiedName" if property_name is None else property_name
609
+
610
+ possible_query_params = query_string(
611
+ [
612
+ ("forLineage", for_lineage),
613
+ ("forDuplicateProcessing", for_duplicate_processing),
614
+ ]
615
+ )
616
+
617
+ body = {
618
+ "class": "NameRequestBody",
619
+ "name": name,
620
+ "forLineage": for_lineage,
621
+ "forDuplicateProcessing": for_duplicate_processing,
622
+ "namePropertyName": property_name,
623
+ "effectiveTime": effective_time,
624
+ }
625
+
626
+ url = f"{base_path(self, server_name)}/elements/guid-by-unique-name{possible_query_params}"
627
+
628
+ response: Response = await self._async_make_request(
629
+ "POST", url, body_slimmer(body), time_out=time_out
469
630
  )
470
631
 
632
+ elements = response.json().get("elements", "No elements found")
633
+
471
634
  if type(elements) is list:
472
635
  if len(elements) == 0:
473
636
  return "No elements found"
@@ -478,16 +641,31 @@ class ClassificationManager(Client):
478
641
  return elements
479
642
 
480
643
  def get_guid_for_name(
481
- self, name: str, server_name: str = None, time_out: int = default_time_out
644
+ self,
645
+ name: str,
646
+ property_name: str = None,
647
+ for_lineage: bool = None,
648
+ for_duplicate_processing: bool = None,
649
+ effective_time: str = None,
650
+ server_name: str = None,
651
+ time_out: int = default_time_out,
482
652
  ) -> list | str:
483
653
  """
484
- Retrieve the guid associated with the supplied element name.
654
+ Retrieve the guid associated with the supplied unique element name.
485
655
  If more than one element returned, an exception is thrown.
486
656
 
487
657
  Parameters
488
658
  ----------
489
659
  name: str
490
660
  - element name to be searched.
661
+ property_name: str, optional
662
+ - optional name of property to search. If not specified, defaults to qualifiedName
663
+ for_lineage: bool, default is set by server
664
+ - determines if elements classified as Memento should be returned - normally false
665
+ for_duplicate_processing: bool, default is set by server
666
+ - Normally false. Set true when the caller is part of a deduplication function
667
+ effective_time: str, default = None
668
+ - Time format is "YYYY-MM-DDTHH:MM:SS" (ISO 8601)
491
669
  server_name: str, default = None
492
670
  - name of the server instances for this request.
493
671
  time_out: int, default = default_time_out
@@ -510,7 +688,15 @@ class ClassificationManager(Client):
510
688
 
511
689
  loop = asyncio.get_event_loop()
512
690
  response = loop.run_until_complete(
513
- self._async_get_guid_for_name(name, server_name, time_out)
691
+ self._async_get_guid_for_name(
692
+ name,
693
+ property_name,
694
+ for_lineage,
695
+ for_duplicate_processing,
696
+ effective_time,
697
+ server_name,
698
+ time_out,
699
+ )
514
700
  )
515
701
  return response
516
702
 
@@ -4199,7 +4385,7 @@ class ClassificationManager(Client):
4199
4385
  time_out: int = default_time_out,
4200
4386
  ) -> None:
4201
4387
  """
4202
- Add or replace the security tags for an element. Async versuib,
4388
+ Add or replace the security tags for an element. Async version,
4203
4389
 
4204
4390
  Security Tags: https://egeria-project.org/types/4/0423-Security-Definitions/
4205
4391
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyegeria
3
- Version: 0.8.4.8
3
+ Version: 0.8.4.10
4
4
  Summary: A python client for Egeria
5
5
  Home-page: https://github.com/odpi/egeria-python
6
6
  License: Apache 2.0
@@ -1,5 +1,3 @@
1
- examples/doc_samples/Create_Collection_Sample.py,sha256=ibKo0wNaF1D1s8XNR37508bZBRq7aaxKjdIdme-JzcE,11071
2
- examples/doc_samples/Create_Sustainability_Collection_Sample.py,sha256=adM5lYFIodAhu91ece1aXz322MTP4ZKCjqIFbs4Ldcc,4232
3
1
  examples/widgets/cat/README.md,sha256=-aaAnIT2fcfU63vajgB-RzQk4l4yFdhkyVfSaTPiqRY,967
4
2
  examples/widgets/cat/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
3
  examples/widgets/cat/get_asset_graph.py,sha256=5YwgV4D1_R9pptPJuIFbPOjWpZBnfPiEan33_To75TE,11194
@@ -72,7 +70,7 @@ pyegeria/_validators.py,sha256=DQuMsATRGxGSBtOrVtXlCgWXGhj6Nh-uqPtCsrUGLxk,12703
72
70
  pyegeria/action_author_omvs.py,sha256=LbJ8dTHrjy2OHvP1sHCCIRgRU2AD3IV-49kB1UCoQPc,6451
73
71
  pyegeria/asset_catalog_omvs.py,sha256=GzTYJjeXh3rY5Ykok0ZcJ3H1bGyQcubI0ZWjFF78iCU,24335
74
72
  pyegeria/automated_curation_omvs.py,sha256=DhSrDX_uS0SfmzRRNi1Th0jmdQa9N4S42mIunxrih9s,150418
75
- pyegeria/classification_manager_omvs.py,sha256=8QIjjFb-dVYySFnccp6sSe6TyEPhML0b-rAl1DXOh-c,186203
73
+ pyegeria/classification_manager_omvs.py,sha256=fBwizYyAWsKOlKbZZSc-MQODbh2QeI0Fb9OWFBXTEy8,193022
76
74
  pyegeria/collection_manager_omvs.py,sha256=C8cfgGsx6MpG1Nds3JahyqXel8zpb-9iwXsXCAuzmg0,109717
77
75
  pyegeria/core_omag_server_config.py,sha256=_GstDYb6XYNCt59l1mMxTR8EoUvwlBi3RK93wKvrcWk,93730
78
76
  pyegeria/create_tech_guid_lists.py,sha256=RYRWdXm2bhCMkbUlOdMJ8cKZnamJvSkY5XMK2RjLX4M,4631
@@ -94,8 +92,8 @@ pyegeria/runtime_manager_omvs.py,sha256=OlrJ3xO7-qYZcHS0YKWo57QLt5x_CZ1bOVcrNRlm
94
92
  pyegeria/server_operations.py,sha256=ciH890hYT85YQ6OpByn4w7s3a7TtvWZpIG5rkRqbcI0,16766
95
93
  pyegeria/utils.py,sha256=1h6bwveadd6GpbnGLTmqPBmBk68QvxdjGTI9RfbrgKY,5415
96
94
  pyegeria/valid_metadata_omvs.py,sha256=6Hc4g9BOS8w1ILfTG3_A1tfIX3HLtpgZZvcC-z9GePU,36185
97
- pyegeria-0.8.4.8.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
98
- pyegeria-0.8.4.8.dist-info/METADATA,sha256=Yq4MD8UdO5pOeE_nc3guYEfhwBDb9LlEe1Hq3k216xM,2819
99
- pyegeria-0.8.4.8.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
100
- pyegeria-0.8.4.8.dist-info/entry_points.txt,sha256=5Q9bDxIqPgdhd3lDnzdRSCYy9hZtNm_BL49bcmbBpGQ,3808
101
- pyegeria-0.8.4.8.dist-info/RECORD,,
95
+ pyegeria-0.8.4.10.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
96
+ pyegeria-0.8.4.10.dist-info/METADATA,sha256=BPTty0no9lQnyZ-mU2HLwnPgymucRhjNpgibX6bFMiI,2820
97
+ pyegeria-0.8.4.10.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
98
+ pyegeria-0.8.4.10.dist-info/entry_points.txt,sha256=5Q9bDxIqPgdhd3lDnzdRSCYy9hZtNm_BL49bcmbBpGQ,3808
99
+ pyegeria-0.8.4.10.dist-info/RECORD,,
@@ -1,320 +0,0 @@
1
- """
2
- SPDX-License-Identifier: Apache-2.0
3
- Copyright Contributors to the ODPi Egeria project.
4
-
5
- This sample creates the collection structure show in https://egeria-project.org/types/0/0021-Collections
6
-
7
- """
8
-
9
- import time
10
-
11
- from rich import print
12
- from rich.console import Console
13
-
14
- from pyegeria import (
15
- CollectionManager,
16
- InvalidParameterException,
17
- PropertyServerException,
18
- UserNotAuthorizedException,
19
- )
20
-
21
- view_server = "view-server"
22
- platform_url = "https://localhost:9443"
23
- user = "erinoverview"
24
- console = Console(width=200)
25
-
26
- try:
27
- c_client = CollectionManager(view_server, platform_url, user_id=user)
28
-
29
- token = c_client.create_egeria_bearer_token(user, "secret")
30
- start_time = time.perf_counter()
31
-
32
- # Create a Data Products Root collection
33
- anchor_guid = None
34
- parent_guid = None
35
- parent_relationship_type_name = None
36
- parent_at_end1 = False
37
- display_name = "Digital Products Root"
38
- description = "This is the root catalog for digital products"
39
- collection_type = "Digital Products Root"
40
- is_own_anchor = True
41
-
42
- response = c_client.create_root_collection(
43
- anchor_guid,
44
- parent_guid,
45
- parent_relationship_type_name,
46
- parent_at_end1,
47
- display_name,
48
- description,
49
- collection_type,
50
- is_own_anchor,
51
- )
52
- # Create first folder for Agriculture Insights
53
- parent_guid = response
54
- parent_relationship_type_name = "CollectionMembership"
55
- display_name = "Agriculture Insights Collection"
56
- description = "A folder for agricultural insights data product collections"
57
- collection_type = "Digital Product Marketplace"
58
-
59
- folder1 = c_client.create_folder_collection(
60
- None,
61
- parent_guid,
62
- parent_relationship_type_name,
63
- True,
64
- display_name,
65
- description,
66
- collection_type,
67
- True,
68
- "DATE_CREATED",
69
- None,
70
- )
71
- print(f"\n\n created a folder with guid {folder1}")
72
- # create second folder for Earth Observations
73
- display_name = "Earth Observation Data Collection"
74
- description = "A folder for Earth Observation data product collections"
75
-
76
- folder2 = c_client.create_folder_collection(
77
- None,
78
- parent_guid,
79
- parent_relationship_type_name,
80
- True,
81
- display_name,
82
- description,
83
- collection_type,
84
- True,
85
- "DATE_CREATED",
86
- None,
87
- )
88
- print(f"\n\n created a folder with guid {folder2}")
89
-
90
- # create a digital product, child of folder 1, for Land Use products
91
- parent_guid = folder1
92
- parent_relationship_type_name = "CollectionMembership"
93
- display_name = "Land Use Classification"
94
- description = "Land use classification assets"
95
- collection_type = "Digital Product"
96
- classification_name = "Digital Product"
97
- body_3 = {
98
- "class": "NewDigitalProductRequestBody",
99
- "isOwnAnchor": True,
100
- "parentGUID": parent_guid,
101
- "parentRelationshipTypeName": parent_relationship_type_name,
102
- "parentAtEnd1": True,
103
- "collectionProperties": {
104
- "class": "CollectionProperties",
105
- "qualifiedName": f"{classification_name}-{display_name}-{time.asctime()}",
106
- "name": display_name,
107
- "description": description,
108
- "collectionType": collection_type,
109
- "collectionOrdering": "DATE_CREATED",
110
- },
111
- "digitalProductProperties": {
112
- "class": "DigitalProductProperties",
113
- "productStatus": "ACTIVE",
114
- "productName": "Land Use Classifications",
115
- "productType": "Geospatial Data Assets",
116
- "description": "Land use classification assets",
117
- "introductionDate": "2023-12-01",
118
- "maturity": "Nacent",
119
- "serviceLife": "3 years",
120
- "currentVersion": "V.5",
121
- "nextVersionDate": "2024-12-01",
122
- "withdrawDate": "2030-01-01",
123
- "additionalProperties": {
124
- "thought_id": "a guid",
125
- "license": "cc-by-sa",
126
- },
127
- },
128
- }
129
- folder3 = c_client.create_digital_product(body_3)
130
- print(f"\n\n created a collection with guid {folder3}")
131
-
132
- # create a fourth collection, a digital product, child of folder 2, for Landsat 8
133
- parent_guid = folder2
134
- display_name = "Landsat 8"
135
- description = "Landsat 8 data products"
136
-
137
- body_4 = {
138
- "class": "NewDigitalProductRequestBody",
139
- "isOwnAnchor": True,
140
- "parentGUID": parent_guid,
141
- "parentRelationshipTypeName": parent_relationship_type_name,
142
- "parentAtEnd1": True,
143
- "collectionProperties": {
144
- "class": "CollectionProperties",
145
- "qualifiedName": f"{classification_name}-{display_name}-{time.asctime()}",
146
- "name": display_name,
147
- "description": description,
148
- "collectionType": collection_type,
149
- "collectionOrdering": "DATE_CREATED",
150
- },
151
- "digitalProductProperties": {
152
- "class": "DigitalProductProperties",
153
- "productStatus": "ACTIVE",
154
- "productName": "Landsat 8 Imagery",
155
- "productType": "Geospatial Data Assets",
156
- "description": description,
157
- "introductionDate": "2024-01-01",
158
- "maturity": "Mature",
159
- "serviceLife": "3 years",
160
- "currentVersion": "V1.5",
161
- "nextVersion": "2024-06-01",
162
- "withdrawDate": "2030-01-01",
163
- "additionalProperties": {
164
- "thought_id": "a guid",
165
- "license": "cc-by-sa",
166
- },
167
- },
168
- }
169
- folder4 = c_client.create_digital_product(body_4)
170
- print(f"\n\n created a collection with guid {folder4}")
171
-
172
- # Now create a 5th collection for sentinel 2 data
173
- parent_guid = folder2
174
- display_name = "Sentinel 2"
175
- description = "Sentinel 2 products"
176
- parent_relationship_type_name = "CollectionMembership"
177
- collection_type = "Digital Product Marketplace"
178
-
179
- folder5 = c_client.create_folder_collection(
180
- None,
181
- parent_guid,
182
- parent_relationship_type_name,
183
- True,
184
- display_name,
185
- description,
186
- collection_type,
187
- True,
188
- "DATE_CREATED",
189
- None,
190
- )
191
- # Create a DigitalProduct for Level-1B
192
- parent_guid = folder5
193
- display_name = "Sentinel 2 - Level 1B"
194
- description = "Level 1B of Sentinel 2"
195
-
196
- body_6 = {
197
- "class": "NewDigitalProductRequestBody",
198
- "anchor_guid": parent_guid,
199
- "isOwnAnchor": False,
200
- "parentGUID": parent_guid,
201
- "parentRelationshipTypeName": parent_relationship_type_name,
202
- "parentAtEnd1": True,
203
- "collectionProperties": {
204
- "class": "CollectionProperties",
205
- "qualifiedName": f"{classification_name}-{display_name}-{time.asctime()}",
206
- "name": display_name,
207
- "description": description,
208
- "collectionType": collection_type,
209
- "collectionOrdering": "DATE_CREATED",
210
- },
211
- "digitalProductProperties": {
212
- "class": "DigitalProductProperties",
213
- "productStatus": "ACTIVE",
214
- "productName": "Sentinel 2 - Level 1B",
215
- "productType": "Geospatial Data Assets",
216
- "description": description,
217
- "introductionDate": "2024-01-01",
218
- "maturity": "Mature",
219
- "serviceLife": "3 years",
220
- "currentVersion": "V1.5",
221
- "nextVersion": "2024-06-01",
222
- "withdrawDate": "2030-01-01",
223
- "additionalProperties": {
224
- "thought_id": "a guid",
225
- "license": "cc-by-sa",
226
- },
227
- },
228
- }
229
- folder6 = c_client.create_digital_product(body_6)
230
- print(f"\n\n created a collection with guid {folder6}")
231
-
232
- # now lets create a digital product for - Level - 1c
233
- parent_guid = folder5
234
- display_name = "Sentinel 2 - Level 1C"
235
- description = "Level 1C of Sentinel 2"
236
- body_7 = {
237
- "class": "NewDigitalProductRequestBody",
238
- "anchor_guid": parent_guid,
239
- "isOwnAnchor": False,
240
- "parentGUID": parent_guid,
241
- "parentRelationshipTypeName": parent_relationship_type_name,
242
- "parentAtEnd1": True,
243
- "collectionProperties": {
244
- "class": "CollectionProperties",
245
- "qualifiedName": f"{classification_name}-{display_name}-{time.asctime()}",
246
- "name": display_name,
247
- "description": description,
248
- "collectionType": collection_type,
249
- "collectionOrdering": "DATE_CREATED",
250
- },
251
- "digitalProductProperties": {
252
- "class": "DigitalProductProperties",
253
- "productStatus": "ACTIVE",
254
- "productName": "Sentinel 2 - Level 1B",
255
- "productType": "Geospatial Data Assets",
256
- "description": description,
257
- "introductionDate": "2024-01-01",
258
- "maturity": "Mature",
259
- "serviceLife": "3 years",
260
- "currentVersion": "V1.5",
261
- "nextVersion": "2024-06-01",
262
- "withdrawDate": "2030-01-01",
263
- "additionalProperties": {
264
- "thought_id": "a guid",
265
- "license": "cc-by-sa",
266
- },
267
- },
268
- }
269
- folder7 = c_client.create_digital_product(body_7)
270
- print(f"\n\n created a collection with guid {folder7}")
271
-
272
- # now let's create a digital product for - Level - 2A
273
- parent_guid = folder5
274
- display_name = "Sentinel 2 - Level 2A"
275
- description = "Level 2A of Sentinel 2"
276
- body_8 = {
277
- "class": "NewDigitalProductRequestBody",
278
- "anchor_guid": parent_guid,
279
- "isOwnAnchor": False,
280
- "parentGUID": parent_guid,
281
- "parentRelationshipTypeName": parent_relationship_type_name,
282
- "parentAtEnd1": True,
283
- "collectionProperties": {
284
- "class": "CollectionProperties",
285
- "qualifiedName": f"{classification_name}-{display_name}-{time.asctime()}",
286
- "name": display_name,
287
- "description": description,
288
- "collectionType": collection_type,
289
- "collectionOrdering": "DATE_CREATED",
290
- },
291
- "digitalProductProperties": {
292
- "class": "DigitalProductProperties",
293
- "productStatus": "ACTIVE",
294
- "productName": "Sentinel 2 - Level 1B",
295
- "productType": "Geospatial Data Assets",
296
- "description": description,
297
- "introductionDate": "2024-01-01",
298
- "maturity": "Mature",
299
- "serviceLife": "3 years",
300
- "currentVersion": "V1.5",
301
- "nextVersion": "2024-06-01",
302
- "withdrawDate": "2030-01-01",
303
- "additionalProperties": {
304
- "thought_id": "a guid",
305
- "license": "cc-by-sa",
306
- },
307
- },
308
- }
309
- folder8 = c_client.create_digital_product(body_8)
310
- print(f"\n\n created a collection with guid {folder8}")
311
-
312
- except (
313
- InvalidParameterException,
314
- PropertyServerException,
315
- UserNotAuthorizedException,
316
- ) as e:
317
- console.print_exception(show_locals=True)
318
-
319
- finally:
320
- c_client.close_session()
@@ -1,149 +0,0 @@
1
- """
2
- SPDX-License-Identifier: Apache-2.0
3
- Copyright Contributors to the ODPi Egeria project.
4
-
5
- This sample creates a collection structure for a sustainability reporting project. It is
6
- simplistic but shows how we can set up a collection hierarchy that can hold different kinds of
7
- assets.
8
-
9
- """
10
-
11
- import time
12
-
13
- from rich import print
14
- from rich.console import Console
15
-
16
- from pyegeria import (
17
- CollectionManager,
18
- InvalidParameterException,
19
- PropertyServerException,
20
- UserNotAuthorizedException,
21
- )
22
-
23
- view_server = "view-server"
24
- platform_url = "https://localhost:9443"
25
- user = "erinoverview"
26
- console = Console()
27
-
28
- try:
29
- c_client = CollectionManager(view_server, platform_url, user_id=user)
30
-
31
- token = c_client.create_egeria_bearer_token(user, "secret")
32
- start_time = time.perf_counter()
33
-
34
- # Create a root collection for the sustainability project
35
- parent_guid = None
36
- parent_relationship_type_name = None
37
- display_name = "Root Sustainability Collection"
38
- description = "The root collection for our sustainability reporting project."
39
- collection_type = "Sustainability Collection"
40
-
41
- root = c_client.create_root_collection(
42
- None,
43
- parent_guid,
44
- parent_relationship_type_name,
45
- False,
46
- display_name,
47
- description,
48
- collection_type,
49
- True,
50
- )
51
- print(f"\n\n created a root with guid {root}")
52
- # create a folder for Scope 1 Emissions
53
- anchor_guid = root
54
- parent_guid = root
55
- parent_relationship_type_name = "CollectionMembership"
56
- display_name = "Scope 1 Emissions"
57
- description = "A folder for information about scope 1 emissions."
58
- collection_type = "Sustainability Collection"
59
-
60
- scope1_folder = c_client.create_folder_collection(
61
- anchor_guid,
62
- parent_guid,
63
- parent_relationship_type_name,
64
- True,
65
- display_name,
66
- description,
67
- collection_type,
68
- False,
69
- "DATE_CREATED",
70
- None,
71
- )
72
- print(f"\n\n created scope1_folder with guid {scope1_folder}")
73
-
74
- # create a folder for Scope 2 Emissions.
75
- anchor_guid = root
76
- parent_guid = root
77
- parent_relationship_type_name = "CollectionMembership"
78
- display_name = "Scope 2 Emissions"
79
- description = "A folder for information about scope 2 emissions."
80
- collection_type = "Sustainability Collection"
81
-
82
- scope2_folder = c_client.create_folder_collection(
83
- anchor_guid,
84
- parent_guid,
85
- parent_relationship_type_name,
86
- True,
87
- display_name,
88
- description,
89
- collection_type,
90
- False,
91
- "DATE_CREATED",
92
- None,
93
- )
94
- print(f"\n\n created scope2_folder with guid {scope2_folder}")
95
-
96
- # create a folder for Scope 3 Emissions.
97
- anchor_guid = root
98
- parent_guid = root
99
- parent_relationship_type_name = "CollectionMembership"
100
- display_name = "Scope 3 Emissions"
101
- description = "A folder for information about scope 3 emissions."
102
- collection_type = "Sustainability Collection"
103
-
104
- scope3_folder = c_client.create_folder_collection(
105
- anchor_guid,
106
- parent_guid,
107
- parent_relationship_type_name,
108
- True,
109
- display_name,
110
- description,
111
- collection_type,
112
- False,
113
- "DATE_CREATED",
114
- None,
115
- )
116
- print(f"\n\n created scope3_folder with guid {scope3_folder}")
117
-
118
- # create a folder for Business Travel Emissions.
119
- anchor_guid = root
120
- parent_guid = scope3_folder
121
- parent_relationship_type_name = "CollectionMembership"
122
- display_name = "Business Travel Emissions"
123
- description = "A folder for information about scope 3 business travel emissions."
124
- collection_type = "Sustainability Collection"
125
-
126
- travel_folder = c_client.create_folder_collection(
127
- anchor_guid,
128
- parent_guid,
129
- parent_relationship_type_name,
130
- True,
131
- display_name,
132
- description,
133
- collection_type,
134
- False,
135
- "DATE_CREATED",
136
- None,
137
- )
138
- print(f"\n\n created travel_folder with guid {travel_folder}")
139
-
140
-
141
- except (
142
- InvalidParameterException,
143
- PropertyServerException,
144
- UserNotAuthorizedException,
145
- ) as e:
146
- console.print_exception(show_locals=True)
147
-
148
- finally:
149
- c_client.close_session()