pyegeria 0.3.7__py3-none-any.whl → 0.3.9__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyegeria/Xasset_catalog_omvs.py +539 -0
- pyegeria/Xfeedback_manager_omvs.py +251 -0
- pyegeria/Xglossary_manager_omvs.py +3001 -0
- pyegeria/Xloaded_resources_omvs.py +91 -0
- pyegeria/__init__.py +6 -9
- pyegeria/_client.py +4 -6
- pyegeria/{gov_engine.py → _deprecated_gov_engine.py} +2 -59
- pyegeria/_exceptions.py +5 -6
- pyegeria/_globals.py +1 -1
- pyegeria/automated_curation_omvs.py +320 -315
- pyegeria/collection_manager_omvs.py +187 -248
- pyegeria/core_omag_server_config.py +1 -5
- pyegeria/full_omag_server_config.py +53 -83
- pyegeria/glossary_browser_omvs.py +2208 -0
- pyegeria/my_profile_omvs.py +8 -12
- pyegeria/platform_services.py +0 -3
- pyegeria/project_manager_omvs.py +9 -15
- pyegeria/registered_info.py +12 -52
- pyegeria/server_operations.py +1 -5
- pyegeria/valid_metadata_omvs.py +11 -23
- pyegeria-0.3.9.data/scripts/Create_Collection_Sample.py +292 -0
- pyegeria-0.3.9.data/scripts/Create_Sustainability_Collection_Sample.py +115 -0
- pyegeria-0.3.9.data/scripts/coco_status.py +98 -0
- {pyegeria-0.3.7.data → pyegeria-0.3.9.data}/scripts/collection_viewer.py +12 -31
- {pyegeria-0.3.7.data → pyegeria-0.3.9.data}/scripts/engine_action_status.py +14 -30
- {pyegeria-0.3.7.data → pyegeria-0.3.9.data}/scripts/find_todos.py +12 -41
- pyegeria-0.3.9.data/scripts/get_registered_services.py +135 -0
- {pyegeria-0.3.7.data → pyegeria-0.3.9.data}/scripts/get_relationship_types.py +16 -35
- {pyegeria-0.3.7.data → pyegeria-0.3.9.data}/scripts/glossary_view.py +2 -2
- {pyegeria-0.3.7.data → pyegeria-0.3.9.data}/scripts/gov_engine_status.py +0 -1
- {pyegeria-0.3.7.data → pyegeria-0.3.9.data}/scripts/list_asset_types.py +3 -25
- {pyegeria-0.3.7.data → pyegeria-0.3.9.data}/scripts/my_todos.py +1 -1
- {pyegeria-0.3.7.data → pyegeria-0.3.9.data}/scripts/open_todos.py +3 -24
- {pyegeria-0.3.7.data → pyegeria-0.3.9.data}/scripts/project_list_viewer.py +12 -26
- {pyegeria-0.3.7.data → pyegeria-0.3.9.data}/scripts/server_status.py +1 -20
- {pyegeria-0.3.7.data → pyegeria-0.3.9.data}/scripts/view_my_profile.py +8 -34
- {pyegeria-0.3.7.dist-info → pyegeria-0.3.9.dist-info}/METADATA +1 -3
- pyegeria-0.3.9.dist-info/RECORD +49 -0
- pyegeria/glossary_omvs.py +0 -789
- pyegeria-0.3.7.dist-info/RECORD +0 -41
- /pyegeria/{governance_author.py → Xaction_author_omvs.py} +0 -0
- {pyegeria-0.3.7.data → pyegeria-0.3.9.data}/scripts/get_tech_details.py +0 -0
- {pyegeria-0.3.7.data → pyegeria-0.3.9.data}/scripts/get_tech_types.py +0 -0
- {pyegeria-0.3.7.data → pyegeria-0.3.9.data}/scripts/integration_daemon_status.py +0 -0
- {pyegeria-0.3.7.data → pyegeria-0.3.9.data}/scripts/multi-server_status.py +0 -0
- {pyegeria-0.3.7.data → pyegeria-0.3.9.data}/scripts/server_status_widget.py +0 -0
- {pyegeria-0.3.7.dist-info → pyegeria-0.3.9.dist-info}/LICENSE +0 -0
- {pyegeria-0.3.7.dist-info → pyegeria-0.3.9.dist-info}/WHEEL +0 -0
- {pyegeria-0.3.7.dist-info → pyegeria-0.3.9.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,292 @@
|
|
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 CollectionManager, InvalidParameterException, PropertyServerException, UserNotAuthorizedException
|
15
|
+
|
16
|
+
view_server = 'view-server'
|
17
|
+
platform_url = 'https://localhost:9443'
|
18
|
+
user = 'erinoverview'
|
19
|
+
console = Console()
|
20
|
+
|
21
|
+
try:
|
22
|
+
c_client = CollectionManager(view_server, platform_url,
|
23
|
+
user_id=user)
|
24
|
+
|
25
|
+
token = c_client.create_egeria_bearer_token(user, "secret")
|
26
|
+
start_time = time.perf_counter()
|
27
|
+
|
28
|
+
# Create a Data Products Root collection
|
29
|
+
anchor_guid = None
|
30
|
+
parent_guid = None
|
31
|
+
parent_relationship_type_name = None
|
32
|
+
parent_at_end1 = False
|
33
|
+
display_name = "Digital Products Root"
|
34
|
+
description = "This is the root catalog for digital products"
|
35
|
+
collection_type = "Digital Products Root"
|
36
|
+
is_own_anchor = True
|
37
|
+
|
38
|
+
response = c_client.create_root_collection(anchor_guid, parent_guid,
|
39
|
+
parent_relationship_type_name, parent_at_end1,
|
40
|
+
display_name, description, collection_type,
|
41
|
+
is_own_anchor)
|
42
|
+
# Create first folder for Agriculture Insights
|
43
|
+
parent_guid = "97bbfe07-6696-4550-bf8b-6b577d25bef0"
|
44
|
+
parent_relationship_type_name = "CollectionMembership"
|
45
|
+
display_name = "Agriculture Insights Collection"
|
46
|
+
description = "A folder for agricultural insights data product collections"
|
47
|
+
collection_type = "Digital Product Marketplace"
|
48
|
+
|
49
|
+
folder1 = c_client.create_folder_collection(None, parent_guid,
|
50
|
+
parent_relationship_type_name,
|
51
|
+
True, display_name, description,
|
52
|
+
collection_type, True, "DATE_CREATED",
|
53
|
+
None
|
54
|
+
)
|
55
|
+
print(f"\n\n created a folder with guid {folder1}")
|
56
|
+
# create second folder for Earth Observations
|
57
|
+
display_name = "Earth Observation Data Collection"
|
58
|
+
description = "A folder for Earth Observation data product collections"
|
59
|
+
|
60
|
+
folder2 = c_client.create_folder_collection(None, parent_guid,
|
61
|
+
parent_relationship_type_name,
|
62
|
+
True, display_name, description,
|
63
|
+
collection_type, True, "DATE_CREATED",
|
64
|
+
None
|
65
|
+
)
|
66
|
+
print(f"\n\n created a folder with guid {folder2}")
|
67
|
+
|
68
|
+
# create a digital product, child of folder 1, for Land Use products
|
69
|
+
parent_guid = folder1
|
70
|
+
parent_relationship_type_name = "CollectionMembership"
|
71
|
+
display_name = "Land Use Classification"
|
72
|
+
description = "Land use classification assets"
|
73
|
+
collection_type = "Digital Product"
|
74
|
+
classification_name = "Digital Product"
|
75
|
+
body_3 = {
|
76
|
+
"class": "NewDigitalProductRequestBody",
|
77
|
+
"isOwnAnchor": True,
|
78
|
+
"parentGUID": parent_guid,
|
79
|
+
"parentRelationshipTypeName": parent_relationship_type_name,
|
80
|
+
"parentAtEnd1": True,
|
81
|
+
"collectionProperties": {
|
82
|
+
"class": "CollectionProperties",
|
83
|
+
"qualifiedName": f"{classification_name}-{display_name}-{time.asctime()}",
|
84
|
+
"name": display_name,
|
85
|
+
"description": description,
|
86
|
+
"collectionType": collection_type,
|
87
|
+
"collectionOrdering": "DATE_CREATED",
|
88
|
+
},
|
89
|
+
"digitalProductProperties": {
|
90
|
+
"class": "DigitalProductProperties",
|
91
|
+
"productStatus": "ACTIVE",
|
92
|
+
"productName": "Land Use Classifications",
|
93
|
+
"productType": "Geospatial Data Assets",
|
94
|
+
"description": "Land use classification assets",
|
95
|
+
"introductionDate": "2023-12-01",
|
96
|
+
"maturity": "Nacent",
|
97
|
+
"serviceLife": "3 years",
|
98
|
+
"currentVersion": "V.5",
|
99
|
+
"nextVersionDate": "2024-12-01",
|
100
|
+
"withdrawDate": "2030-01-01",
|
101
|
+
"additionalProperties": {
|
102
|
+
"thought_id": "a guid",
|
103
|
+
"license": "cc-by-sa",
|
104
|
+
}
|
105
|
+
}
|
106
|
+
}
|
107
|
+
folder3 = c_client.create_digital_product(body_3)
|
108
|
+
print(f"\n\n created a collection with guid {folder3}")
|
109
|
+
|
110
|
+
# create a fourth collection, a digital product, child of folder 2, for Landsat 8
|
111
|
+
parent_guid = folder2
|
112
|
+
display_name = "Landsat 8"
|
113
|
+
description = "Landsat 8 data products"
|
114
|
+
|
115
|
+
body_4 = {
|
116
|
+
"class": "NewDigitalProductRequestBody",
|
117
|
+
"isOwnAnchor": True,
|
118
|
+
"parentGUID": parent_guid,
|
119
|
+
"parentRelationshipTypeName": parent_relationship_type_name,
|
120
|
+
"parentAtEnd1": True,
|
121
|
+
"collectionProperties": {
|
122
|
+
"class": "CollectionProperties",
|
123
|
+
"qualifiedName": f"{classification_name}-{display_name}-{time.asctime()}",
|
124
|
+
"name": display_name,
|
125
|
+
"description": description,
|
126
|
+
"collectionType": collection_type,
|
127
|
+
"collectionOrdering": "DATE_CREATED",
|
128
|
+
},
|
129
|
+
"digitalProductProperties": {
|
130
|
+
"class": "DigitalProductProperties",
|
131
|
+
"productStatus": "ACTIVE",
|
132
|
+
"productName": "Landsat 8 Imagery",
|
133
|
+
"productType": "Geospatial Data Assets",
|
134
|
+
"description": description,
|
135
|
+
"introductionDate": "2024-01-01",
|
136
|
+
"maturity": "Mature",
|
137
|
+
"serviceLife": "3 years",
|
138
|
+
"currentVersion": "V1.5",
|
139
|
+
"nextVersion": "2024-06-01",
|
140
|
+
"withdrawDate": "2030-01-01",
|
141
|
+
"additionalProperties": {
|
142
|
+
"thought_id": "a guid",
|
143
|
+
"license": "cc-by-sa",
|
144
|
+
}
|
145
|
+
}
|
146
|
+
}
|
147
|
+
folder4 = c_client.create_digital_product(body_4)
|
148
|
+
print(f"\n\n created a collection with guid {folder4}")
|
149
|
+
|
150
|
+
# Now create a 5th collection for sentinel 2 data
|
151
|
+
parent_guid = folder2
|
152
|
+
display_name = "Sentinel 2"
|
153
|
+
description = "Sentinel 2 products"
|
154
|
+
parent_relationship_type_name = "CollectionMembership"
|
155
|
+
collection_type = "Digital Product Marketplace"
|
156
|
+
|
157
|
+
folder5 = c_client.create_folder_collection(None, parent_guid,
|
158
|
+
parent_relationship_type_name,
|
159
|
+
True, display_name, description,
|
160
|
+
collection_type, True, "DATE_CREATED",
|
161
|
+
None
|
162
|
+
)
|
163
|
+
# Create a DigitalProduct for Level-1B
|
164
|
+
parent_guid = folder5
|
165
|
+
display_name = "Sentinel 2 - Level 1B"
|
166
|
+
description = "Level 1B of Sentinel 2"
|
167
|
+
|
168
|
+
body_6 = {
|
169
|
+
"class": "NewDigitalProductRequestBody",
|
170
|
+
"anchor_guid": parent_guid,
|
171
|
+
"isOwnAnchor": False,
|
172
|
+
"parentGUID": parent_guid,
|
173
|
+
"parentRelationshipTypeName": parent_relationship_type_name,
|
174
|
+
"parentAtEnd1": True,
|
175
|
+
"collectionProperties": {
|
176
|
+
"class": "CollectionProperties",
|
177
|
+
"qualifiedName": f"{classification_name}-{display_name}-{time.asctime()}",
|
178
|
+
"name": display_name,
|
179
|
+
"description": description,
|
180
|
+
"collectionType": collection_type,
|
181
|
+
"collectionOrdering": "DATE_CREATED",
|
182
|
+
},
|
183
|
+
"digitalProductProperties": {
|
184
|
+
"class": "DigitalProductProperties",
|
185
|
+
"productStatus": "ACTIVE",
|
186
|
+
"productName": "Sentinel 2 - Level 1B",
|
187
|
+
"productType": "Geospatial Data Assets",
|
188
|
+
"description": description,
|
189
|
+
"introductionDate": "2024-01-01",
|
190
|
+
"maturity": "Mature",
|
191
|
+
"serviceLife": "3 years",
|
192
|
+
"currentVersion": "V1.5",
|
193
|
+
"nextVersion": "2024-06-01",
|
194
|
+
"withdrawDate": "2030-01-01",
|
195
|
+
"additionalProperties": {
|
196
|
+
"thought_id": "a guid",
|
197
|
+
"license": "cc-by-sa",
|
198
|
+
}
|
199
|
+
}
|
200
|
+
}
|
201
|
+
folder6 = c_client.create_digital_product(body_6)
|
202
|
+
print(f"\n\n created a collection with guid {folder6}")
|
203
|
+
|
204
|
+
# now lets create a digital product for - Level - 1c
|
205
|
+
parent_guid = folder5
|
206
|
+
display_name = "Sentinel 2 - Level 1C"
|
207
|
+
description = "Level 1C of Sentinel 2"
|
208
|
+
body_7 = {
|
209
|
+
"class": "NewDigitalProductRequestBody",
|
210
|
+
"anchor_guid": parent_guid,
|
211
|
+
"isOwnAnchor": False,
|
212
|
+
"parentGUID": parent_guid,
|
213
|
+
"parentRelationshipTypeName": parent_relationship_type_name,
|
214
|
+
"parentAtEnd1": True,
|
215
|
+
"collectionProperties": {
|
216
|
+
"class": "CollectionProperties",
|
217
|
+
"qualifiedName": f"{classification_name}-{display_name}-{time.asctime()}",
|
218
|
+
"name": display_name,
|
219
|
+
"description": description,
|
220
|
+
"collectionType": collection_type,
|
221
|
+
"collectionOrdering": "DATE_CREATED",
|
222
|
+
},
|
223
|
+
"digitalProductProperties": {
|
224
|
+
"class": "DigitalProductProperties",
|
225
|
+
"productStatus": "ACTIVE",
|
226
|
+
"productName": "Sentinel 2 - Level 1B",
|
227
|
+
"productType": "Geospatial Data Assets",
|
228
|
+
"description": description,
|
229
|
+
"introductionDate": "2024-01-01",
|
230
|
+
"maturity": "Mature",
|
231
|
+
"serviceLife": "3 years",
|
232
|
+
"currentVersion": "V1.5",
|
233
|
+
"nextVersion": "2024-06-01",
|
234
|
+
"withdrawDate": "2030-01-01",
|
235
|
+
"additionalProperties": {
|
236
|
+
"thought_id": "a guid",
|
237
|
+
"license": "cc-by-sa",
|
238
|
+
}
|
239
|
+
}
|
240
|
+
}
|
241
|
+
folder7 = c_client.create_digital_product(body_7)
|
242
|
+
print(f"\n\n created a collection with guid {folder7}")
|
243
|
+
|
244
|
+
# now let's create a digital product for - Level - 2A
|
245
|
+
parent_guid = folder5
|
246
|
+
display_name = "Sentinel 2 - Level 2A"
|
247
|
+
description = "Level 2A of Sentinel 2"
|
248
|
+
body_8 = {
|
249
|
+
"class": "NewDigitalProductRequestBody",
|
250
|
+
"anchor_guid": parent_guid,
|
251
|
+
"isOwnAnchor": False,
|
252
|
+
"parentGUID": parent_guid,
|
253
|
+
"parentRelationshipTypeName": parent_relationship_type_name,
|
254
|
+
"parentAtEnd1": True,
|
255
|
+
"collectionProperties": {
|
256
|
+
"class": "CollectionProperties",
|
257
|
+
"qualifiedName": f"{classification_name}-{display_name}-{time.asctime()}",
|
258
|
+
"name": display_name,
|
259
|
+
"description": description,
|
260
|
+
"collectionType": collection_type,
|
261
|
+
"collectionOrdering": "DATE_CREATED",
|
262
|
+
},
|
263
|
+
"digitalProductProperties": {
|
264
|
+
"class": "DigitalProductProperties",
|
265
|
+
"productStatus": "ACTIVE",
|
266
|
+
"productName": "Sentinel 2 - Level 1B",
|
267
|
+
"productType": "Geospatial Data Assets",
|
268
|
+
"description": description,
|
269
|
+
"introductionDate": "2024-01-01",
|
270
|
+
"maturity": "Mature",
|
271
|
+
"serviceLife": "3 years",
|
272
|
+
"currentVersion": "V1.5",
|
273
|
+
"nextVersion": "2024-06-01",
|
274
|
+
"withdrawDate": "2030-01-01",
|
275
|
+
"additionalProperties": {
|
276
|
+
"thought_id": "a guid",
|
277
|
+
"license": "cc-by-sa",
|
278
|
+
}
|
279
|
+
}
|
280
|
+
}
|
281
|
+
folder8 = c_client.create_digital_product(body_8)
|
282
|
+
print(f"\n\n created a collection with guid {folder8}")
|
283
|
+
|
284
|
+
except (
|
285
|
+
InvalidParameterException,
|
286
|
+
PropertyServerException,
|
287
|
+
UserNotAuthorizedException
|
288
|
+
) as e:
|
289
|
+
console.print_exception(show_locals=True)
|
290
|
+
|
291
|
+
finally:
|
292
|
+
c_client.close_session()
|
@@ -0,0 +1,115 @@
|
|
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 CollectionManager, InvalidParameterException, PropertyServerException, UserNotAuthorizedException
|
17
|
+
|
18
|
+
view_server = 'view-server'
|
19
|
+
platform_url = 'https://localhost:9443'
|
20
|
+
user = 'erinoverview'
|
21
|
+
console = Console()
|
22
|
+
|
23
|
+
try:
|
24
|
+
c_client = CollectionManager(view_server, platform_url,
|
25
|
+
user_id=user)
|
26
|
+
|
27
|
+
token = c_client.create_egeria_bearer_token(user, "secret")
|
28
|
+
start_time = time.perf_counter()
|
29
|
+
|
30
|
+
# Create a root collection for the sustainability project
|
31
|
+
parent_guid = None
|
32
|
+
parent_relationship_type_name = None
|
33
|
+
display_name = "Root Sustainability Collection"
|
34
|
+
description = "The root collection for our sustainability reporting project."
|
35
|
+
collection_type = "Sustainability Collection"
|
36
|
+
|
37
|
+
root = c_client.create_root_collection(None, parent_guid,
|
38
|
+
parent_relationship_type_name,
|
39
|
+
False, display_name, description,
|
40
|
+
collection_type, True)
|
41
|
+
print(f"\n\n created a root with guid {root}")
|
42
|
+
# create a folder for Scope 1 Emissions
|
43
|
+
anchor_guid = root
|
44
|
+
parent_guid = root
|
45
|
+
parent_relationship_type_name = "CollectionMembership"
|
46
|
+
display_name = "Scope 1 Emissions"
|
47
|
+
description = "A folder for information about scope 1 emissions."
|
48
|
+
collection_type = "Sustainability Collection"
|
49
|
+
|
50
|
+
scope1_folder = c_client.create_folder_collection(anchor_guid, parent_guid,
|
51
|
+
parent_relationship_type_name,
|
52
|
+
True, display_name, description,
|
53
|
+
collection_type, False, "DATE_CREATED",
|
54
|
+
None
|
55
|
+
)
|
56
|
+
print(f"\n\n created scope1_folder with guid {scope1_folder}")
|
57
|
+
|
58
|
+
# create a folder for Scope 2 Emissions.
|
59
|
+
anchor_guid = root
|
60
|
+
parent_guid = root
|
61
|
+
parent_relationship_type_name = "CollectionMembership"
|
62
|
+
display_name = "Scope 2 Emissions"
|
63
|
+
description = "A folder for information about scope 2 emissions."
|
64
|
+
collection_type = "Sustainability Collection"
|
65
|
+
|
66
|
+
scope2_folder = c_client.create_folder_collection(anchor_guid, parent_guid,
|
67
|
+
parent_relationship_type_name,
|
68
|
+
True, display_name, description,
|
69
|
+
collection_type, False, "DATE_CREATED",
|
70
|
+
None
|
71
|
+
)
|
72
|
+
print(f"\n\n created scope2_folder with guid {scope2_folder}")
|
73
|
+
|
74
|
+
# create a folder for Scope 3 Emissions.
|
75
|
+
anchor_guid = root
|
76
|
+
parent_guid = root
|
77
|
+
parent_relationship_type_name = "CollectionMembership"
|
78
|
+
display_name = "Scope 3 Emissions"
|
79
|
+
description = "A folder for information about scope 3 emissions."
|
80
|
+
collection_type = "Sustainability Collection"
|
81
|
+
|
82
|
+
scope3_folder = c_client.create_folder_collection(anchor_guid, parent_guid,
|
83
|
+
parent_relationship_type_name,
|
84
|
+
True, display_name, description,
|
85
|
+
collection_type, False, "DATE_CREATED",
|
86
|
+
None
|
87
|
+
)
|
88
|
+
print(f"\n\n created scope3_folder with guid {scope3_folder}")
|
89
|
+
|
90
|
+
# create a folder for Business Travel Emissions.
|
91
|
+
anchor_guid = root
|
92
|
+
parent_guid = scope3_folder
|
93
|
+
parent_relationship_type_name = "CollectionMembership"
|
94
|
+
display_name = "Business Travel Emissions"
|
95
|
+
description = "A folder for information about scope 3 business travel emissions."
|
96
|
+
collection_type = "Sustainability Collection"
|
97
|
+
|
98
|
+
travel_folder = c_client.create_folder_collection(anchor_guid, parent_guid,
|
99
|
+
parent_relationship_type_name,
|
100
|
+
True, display_name, description,
|
101
|
+
collection_type, False, "DATE_CREATED",
|
102
|
+
None
|
103
|
+
)
|
104
|
+
print(f"\n\n created travel_folder with guid {travel_folder}")
|
105
|
+
|
106
|
+
|
107
|
+
except (
|
108
|
+
InvalidParameterException,
|
109
|
+
PropertyServerException,
|
110
|
+
UserNotAuthorizedException
|
111
|
+
) as e:
|
112
|
+
console.print_exception(show_locals=True)
|
113
|
+
|
114
|
+
finally:
|
115
|
+
c_client.close_session()
|
@@ -0,0 +1,98 @@
|
|
1
|
+
#!python
|
2
|
+
"""
|
3
|
+
SPDX-License-Identifier: Apache-2.0
|
4
|
+
Copyright Contributors to the ODPi Egeria project.
|
5
|
+
|
6
|
+
Unit tests for the Utils helper functions using the Pytest framework.
|
7
|
+
|
8
|
+
|
9
|
+
A simple server status display for the Coco Pharmaceuticals Configuration
|
10
|
+
"""
|
11
|
+
|
12
|
+
import argparse
|
13
|
+
import time
|
14
|
+
|
15
|
+
from rich import box
|
16
|
+
from rich import print
|
17
|
+
from rich.layout import Layout
|
18
|
+
from rich.live import Live
|
19
|
+
from rich.panel import Panel
|
20
|
+
from rich.table import Table
|
21
|
+
|
22
|
+
from pyegeria._exceptions import (
|
23
|
+
InvalidParameterException,
|
24
|
+
PropertyServerException,
|
25
|
+
UserNotAuthorizedException,
|
26
|
+
print_exception_response,
|
27
|
+
)
|
28
|
+
from pyegeria.server_operations import ServerOps
|
29
|
+
|
30
|
+
disable_ssl_warnings = True
|
31
|
+
|
32
|
+
|
33
|
+
def test_display_status(server: str, url: str, username: str):
|
34
|
+
layout = Layout()
|
35
|
+
print(layout)
|
36
|
+
|
37
|
+
print(layout)
|
38
|
+
p_client1 = ServerOps("Core Catalog", "https://localhost:9443", username)
|
39
|
+
p_client2 = ServerOps('Datalake Catalog', "https://localhost:9444", username)
|
40
|
+
p_client3 = ServerOps('DevCatalog', "https://localhost:9445", username)
|
41
|
+
|
42
|
+
def generate_table(p_client) -> Table:
|
43
|
+
"""Make a new table."""
|
44
|
+
table = Table(
|
45
|
+
title=f"Server Status for Platform - {time.asctime()}",
|
46
|
+
# style = "black on grey66",
|
47
|
+
header_style="white on dark_blue",
|
48
|
+
caption=f"Server Status for Platform - '{url}'",
|
49
|
+
# show_lines=True,
|
50
|
+
)
|
51
|
+
|
52
|
+
table.add_column("Known Server")
|
53
|
+
table.add_column("Status")
|
54
|
+
|
55
|
+
known_server_list = p_client.get_known_servers()
|
56
|
+
active_server_list = p_client.get_active_server_list()
|
57
|
+
if len(known_server_list) == 0:
|
58
|
+
return table
|
59
|
+
|
60
|
+
for server in known_server_list:
|
61
|
+
if server in active_server_list:
|
62
|
+
status = "Active"
|
63
|
+
else:
|
64
|
+
status = "Inactive"
|
65
|
+
|
66
|
+
table.add_row(server,
|
67
|
+
"[red]Inactive" if status == "Inactive" else "[green]Active",
|
68
|
+
)
|
69
|
+
return table
|
70
|
+
|
71
|
+
try:
|
72
|
+
layout.split_row(
|
73
|
+
Layout(Panel(generate_table(p_client1), box.ROUNDED)),
|
74
|
+
Layout(Panel(generate_table(p_client2), box.ROUNDED)),
|
75
|
+
Layout(Panel(generate_table(p_client3), box.ROUNDED))
|
76
|
+
)
|
77
|
+
with Live(layout, refresh_per_second=4, screen=True) as live:
|
78
|
+
while True:
|
79
|
+
time.sleep(2)
|
80
|
+
live.update(layout)
|
81
|
+
|
82
|
+
except (InvalidParameterException, PropertyServerException, UserNotAuthorizedException) as e:
|
83
|
+
print_exception_response(e)
|
84
|
+
assert e.related_http_code != "200", "Invalid parameters"
|
85
|
+
|
86
|
+
|
87
|
+
if __name__ == "__main__":
|
88
|
+
parser = argparse.ArgumentParser()
|
89
|
+
parser.add_argument("--server", help="Name of the server to display status for")
|
90
|
+
parser.add_argument("--url", help="URL Platform to connect to")
|
91
|
+
parser.add_argument("--userid", help="User Id")
|
92
|
+
args = parser.parse_args()
|
93
|
+
|
94
|
+
server = args.server if args.server is not None else "active-metadata-store"
|
95
|
+
url = args.url if args.url is not None else "https://cray.local:9443"
|
96
|
+
userid = args.userid if args.userid is not None else 'garygeeke'
|
97
|
+
|
98
|
+
test_display_status(server, url, userid)
|
@@ -7,43 +7,25 @@ A simple viewer for collections - provide the root and we display the hierarchy
|
|
7
7
|
|
8
8
|
"""
|
9
9
|
|
10
|
-
import time
|
11
10
|
import argparse
|
12
11
|
|
13
|
-
from rich
|
14
|
-
from rich.
|
12
|
+
from rich import print
|
13
|
+
from rich.panel import Panel
|
15
14
|
from rich.prompt import Prompt
|
16
|
-
|
17
|
-
from pyegeria._exceptions import (
|
18
|
-
InvalidParameterException,
|
19
|
-
PropertyServerException,
|
20
|
-
UserNotAuthorizedException,
|
21
|
-
print_exception_response,
|
22
|
-
)
|
23
|
-
from rich.table import Table
|
24
|
-
from rich.live import Live
|
25
15
|
from rich.text import Text
|
26
16
|
from rich.tree import Tree
|
27
|
-
from rich.markdown import Markdown
|
28
17
|
|
29
|
-
from rich import print
|
30
|
-
from rich.console import Group
|
31
|
-
from rich.panel import Panel
|
32
|
-
from rich import box, align
|
33
|
-
from rich.layout import Layout
|
34
|
-
import rich
|
35
18
|
from pyegeria import CollectionManager, UserNotAuthorizedException, PropertyServerException, InvalidParameterException
|
19
|
+
from pyegeria._exceptions import (
|
20
|
+
print_exception_response,
|
21
|
+
)
|
36
22
|
|
37
23
|
disable_ssl_warnings = True
|
38
24
|
|
39
|
-
platform = "https://127.0.0.1:9443"
|
40
|
-
user = "erinoverview"
|
41
|
-
view_server = "view-server"
|
42
25
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
def walk_collection_hierarchy(collection_client: CollectionManager, root_collection_name: str, tree: Tree) -> Tree:
|
26
|
+
def collection_viewer(root: str, server_name: str, platform_url: str, user: str):
|
27
|
+
""" A simple collection viewer"""
|
28
|
+
def walk_collection_hierarchy(collection_client: CollectionManager, root_collection_name: str, tree: Tree) -> None:
|
47
29
|
"""Recursively build a Tree with collection contents."""
|
48
30
|
members = collection_client.get_member_list(root_collection_name)
|
49
31
|
if members:
|
@@ -56,7 +38,7 @@ def collection_viewer(root: str, server_name:str, platform_url:str, user:str):
|
|
56
38
|
text_collection_type = Text(f"* Collection Type: {member['collectionType']}", "cyan")
|
57
39
|
text_description = Text(f"* Description: {member['description']}", "cyan")
|
58
40
|
p = Panel.fit(f"[white]{text_collection_name}[green]\n{text_qualified_name}\n{text_guid}\n"
|
59
|
-
|
41
|
+
f"{text_collection_type}\n{text_description}")
|
60
42
|
tt = tree.add(p, style=style)
|
61
43
|
|
62
44
|
children = collection_client.get_collection_members(member['guid'])
|
@@ -64,14 +46,13 @@ def collection_viewer(root: str, server_name:str, platform_url:str, user:str):
|
|
64
46
|
branch = tt.add(f"[bold magenta]Members", style=style, guide_style=style)
|
65
47
|
walk_collection_hierarchy(collection_client, member['qualifiedName'], branch),
|
66
48
|
|
67
|
-
|
68
49
|
try:
|
69
50
|
tree = Tree(f"[bold bright green]{root}", guide_style="bold bright_blue")
|
70
|
-
c_client = CollectionManager(
|
51
|
+
c_client = CollectionManager(server_name, platform_url,
|
71
52
|
user_id=user)
|
72
53
|
|
73
54
|
token = c_client.create_egeria_bearer_token(user, "secret")
|
74
|
-
walk_collection_hierarchy(c_client,root,tree)
|
55
|
+
walk_collection_hierarchy(c_client, root, tree)
|
75
56
|
print(tree)
|
76
57
|
|
77
58
|
except (
|
@@ -95,4 +76,4 @@ if __name__ == "__main__":
|
|
95
76
|
userid = args.userid if args.userid is not None else 'erinoverview'
|
96
77
|
|
97
78
|
root_collection = Prompt.ask("Enter the Root Collection to start from:", default="Digital Products Root")
|
98
|
-
collection_viewer(root_collection,server, url, userid)
|
79
|
+
collection_viewer(root_collection, server, url, userid)
|