pyegeria 5.4.7.4__py3-none-any.whl → 5.4.7.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.
- commands/ops/__init__.py +0 -2
- commands/ops/list_catalog_targets.py +0 -1
- commands/ops/load_archive.py +3 -3
- commands/tech/__init__.py +0 -2
- pyegeria/__init__.py +3 -3
- pyegeria/_client_new.py +386 -172
- pyegeria/automated_curation.py +777 -787
- pyegeria/classification_manager.py +2413 -837
- pyegeria/external_references.py +1 -1
- pyegeria/full_omag_server_config.py +1 -1
- pyegeria/project_manager.py +8 -0
- pyegeria/reference_data.py +4 -0
- {pyegeria-5.4.7.4.dist-info → pyegeria-5.4.7.5.dist-info}/METADATA +1 -1
- {pyegeria-5.4.7.4.dist-info → pyegeria-5.4.7.5.dist-info}/RECORD +18 -18
- {pyegeria-5.4.7.4.dist-info → pyegeria-5.4.7.5.dist-info}/WHEEL +0 -0
- {pyegeria-5.4.7.4.dist-info → pyegeria-5.4.7.5.dist-info}/entry_points.txt +0 -0
- {pyegeria-5.4.7.4.dist-info → pyegeria-5.4.7.5.dist-info}/licenses/LICENSE +0 -0
- {pyegeria-5.4.7.4.dist-info → pyegeria-5.4.7.5.dist-info}/top_level.txt +0 -0
pyegeria/automated_curation.py
CHANGED
@@ -10,16 +10,25 @@ import asyncio
|
|
10
10
|
import datetime
|
11
11
|
|
12
12
|
from httpx import Response
|
13
|
-
|
13
|
+
from loguru import logger
|
14
|
+
from pydantic import HttpUrl
|
15
|
+
from pyegeria._globals import NO_ELEMENTS_FOUND
|
14
16
|
from pyegeria._client_new import Client2
|
17
|
+
from pyegeria._validators import validate_guid, validate_name, validate_search_string
|
15
18
|
# from pyegeria._exceptions import (
|
16
19
|
# InvalidParameterException,
|
17
20
|
# PropertyServerException,
|
18
21
|
# UserNotAuthorizedException,
|
19
22
|
# )
|
20
|
-
from pyegeria.models import GetRequestBody, FilterRequestBody
|
23
|
+
from pyegeria.models import GetRequestBody, FilterRequestBody, SearchStringRequestBody
|
21
24
|
from pyegeria.utils import body_slimmer
|
22
|
-
from pyegeria.
|
25
|
+
from pyegeria._output_formats import select_output_format_set, get_output_format_type_match
|
26
|
+
from pyegeria.output_formatter import (
|
27
|
+
generate_output,
|
28
|
+
_extract_referenceable_properties,
|
29
|
+
populate_columns_from_properties,
|
30
|
+
get_required_relationships,
|
31
|
+
)
|
23
32
|
|
24
33
|
|
25
34
|
class AutomatedCuration(Client2):
|
@@ -54,6 +63,350 @@ class AutomatedCuration(Client2):
|
|
54
63
|
Client2.__init__(self, view_server, platform_url, user_id, user_pwd, token=token)
|
55
64
|
self.curation_command_root = f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/automated-curation"
|
56
65
|
|
66
|
+
# Default entity label used by the output formatter for Technology Types
|
67
|
+
self.TECH_TYPE_ENTITY_LABEL = "TechType"
|
68
|
+
self.GOV_ACTION_TYPE_LABEL = "GovActionType"
|
69
|
+
self.CATALOG_TARGET_LABEL = "CatalogTarget"
|
70
|
+
self.ENGINE_ACTION_LABEL = "EngineAction"
|
71
|
+
self.GOV_ACTION_PROCESS_LABEL = "GovActionProcess"
|
72
|
+
|
73
|
+
def _extract_tech_type_properties(self, element: dict, columns_struct: dict) -> dict:
|
74
|
+
"""
|
75
|
+
Extract properties from a technology type element and populate the provided columns_struct.
|
76
|
+
Tolerant to missing fields.
|
77
|
+
"""
|
78
|
+
# Populate direct properties first
|
79
|
+
col_data = populate_columns_from_properties(element, columns_struct)
|
80
|
+
columns_list = col_data.get("formats", {}).get("columns", [])
|
81
|
+
|
82
|
+
# Referenceable header extraction (GUID, qualifiedName, displayName, etc.)
|
83
|
+
header_props = _extract_referenceable_properties(element)
|
84
|
+
for column in columns_list:
|
85
|
+
key = column.get("key")
|
86
|
+
if key in header_props:
|
87
|
+
column["value"] = header_props.get(key)
|
88
|
+
elif isinstance(key, str) and key.lower() == "guid":
|
89
|
+
column["value"] = header_props.get("GUID")
|
90
|
+
|
91
|
+
# Try common category/type fields
|
92
|
+
category = (
|
93
|
+
element.get("properties", {}).get("category")
|
94
|
+
or element.get("elementProperties", {}).get("category")
|
95
|
+
or element.get("elementType", {}).get("typeName")
|
96
|
+
or ""
|
97
|
+
)
|
98
|
+
for column in columns_list:
|
99
|
+
if column.get("key") in ("category", "type_name"):
|
100
|
+
column["value"] = category
|
101
|
+
|
102
|
+
# Classification names if present
|
103
|
+
class_names = []
|
104
|
+
for c in (element.get("elementHeader", {}).get("classifications") or []):
|
105
|
+
name = c.get("classificationName")
|
106
|
+
if name:
|
107
|
+
class_names.append(name)
|
108
|
+
if class_names:
|
109
|
+
for column in columns_list:
|
110
|
+
if column.get("key") == "classifications":
|
111
|
+
column["value"] = ", ".join(class_names)
|
112
|
+
break
|
113
|
+
|
114
|
+
# Relationship-driven fields (generic handling)
|
115
|
+
col_data = get_required_relationships(element, col_data)
|
116
|
+
|
117
|
+
# Mermaid graph support if present
|
118
|
+
mermaid_val = element.get("mermaidGraph", "") or ""
|
119
|
+
for column in columns_list:
|
120
|
+
if column.get("key") == "mermaid":
|
121
|
+
column["value"] = mermaid_val
|
122
|
+
break
|
123
|
+
|
124
|
+
return col_data
|
125
|
+
|
126
|
+
def _generate_tech_type_output(
|
127
|
+
self,
|
128
|
+
elements: dict | list[dict],
|
129
|
+
filter: str | None,
|
130
|
+
element_type_name: str | None,
|
131
|
+
output_format: str = "DICT",
|
132
|
+
output_format_set: dict | str | None = None,
|
133
|
+
) -> str | list[dict]:
|
134
|
+
"""Generate output for technology types in the specified format."""
|
135
|
+
entity_type = element_type_name or self.TECH_TYPE_ENTITY_LABEL
|
136
|
+
|
137
|
+
# Resolve output format set
|
138
|
+
get_additional_props_func = None
|
139
|
+
if output_format_set:
|
140
|
+
if isinstance(output_format_set, str):
|
141
|
+
output_formats = select_output_format_set(output_format_set, output_format)
|
142
|
+
else:
|
143
|
+
output_formats = get_output_format_type_match(output_format_set, output_format)
|
144
|
+
elif element_type_name:
|
145
|
+
output_formats = select_output_format_set(element_type_name, output_format)
|
146
|
+
else:
|
147
|
+
output_formats = select_output_format_set(entity_type, output_format)
|
148
|
+
|
149
|
+
if output_formats is None:
|
150
|
+
output_formats = select_output_format_set("Default", output_format)
|
151
|
+
|
152
|
+
# Optional hook for extra server calls to enrich rows
|
153
|
+
get_additional_props_name = (
|
154
|
+
output_formats.get("get_additional_props", {}).get("function") if output_formats else None
|
155
|
+
)
|
156
|
+
if isinstance(get_additional_props_name, str):
|
157
|
+
parts = get_additional_props_name.split(".")
|
158
|
+
method_name = parts[-1] if parts else None
|
159
|
+
if method_name and hasattr(self, method_name):
|
160
|
+
get_additional_props_func = getattr(self, method_name)
|
161
|
+
|
162
|
+
return generate_output(
|
163
|
+
elements,
|
164
|
+
filter,
|
165
|
+
entity_type,
|
166
|
+
output_format,
|
167
|
+
self._extract_tech_type_properties,
|
168
|
+
get_additional_props_func,
|
169
|
+
output_formats,
|
170
|
+
)
|
171
|
+
|
172
|
+
def _extract_gov_action_type_properties(self, element: dict, columns_struct: dict) -> dict:
|
173
|
+
col_data = populate_columns_from_properties(element, columns_struct)
|
174
|
+
columns_list = col_data.get("formats", {}).get("columns", [])
|
175
|
+
header_props = _extract_referenceable_properties(element)
|
176
|
+
for column in columns_list:
|
177
|
+
key = column.get("key")
|
178
|
+
if key in header_props:
|
179
|
+
column["value"] = header_props.get(key)
|
180
|
+
elif isinstance(key, str) and key.lower() == "guid":
|
181
|
+
column["value"] = header_props.get("GUID")
|
182
|
+
col_data = get_required_relationships(element, col_data)
|
183
|
+
mermaid_val = element.get("mermaidGraph", "") or ""
|
184
|
+
for column in columns_list:
|
185
|
+
if column.get("key") == "mermaid":
|
186
|
+
column["value"] = mermaid_val
|
187
|
+
break
|
188
|
+
return col_data
|
189
|
+
|
190
|
+
def _generate_gov_action_type_output(self, elements: dict | list[dict], filter: str | None,
|
191
|
+
element_type_name: str | None, output_format: str = "DICT",
|
192
|
+
output_format_set: dict | str | None = None) -> str | list[dict]:
|
193
|
+
entity_type = element_type_name or self.GOV_ACTION_TYPE_LABEL
|
194
|
+
get_additional_props_func = None
|
195
|
+
if output_format_set:
|
196
|
+
if isinstance(output_format_set, str):
|
197
|
+
output_formats = select_output_format_set(output_format_set, output_format)
|
198
|
+
else:
|
199
|
+
output_formats = get_output_format_type_match(output_format_set, output_format)
|
200
|
+
elif element_type_name:
|
201
|
+
output_formats = select_output_format_set(element_type_name, output_format)
|
202
|
+
else:
|
203
|
+
output_formats = select_output_format_set(entity_type, output_format)
|
204
|
+
if output_formats is None:
|
205
|
+
output_formats = select_output_format_set("Default", output_format)
|
206
|
+
get_additional_props_name = (
|
207
|
+
output_formats.get("get_additional_props", {}).get("function") if output_formats else None
|
208
|
+
)
|
209
|
+
if isinstance(get_additional_props_name, str):
|
210
|
+
method_name = get_additional_props_name.split(".")[-1]
|
211
|
+
if hasattr(self, method_name):
|
212
|
+
get_additional_props_func = getattr(self, method_name)
|
213
|
+
return generate_output(
|
214
|
+
elements,
|
215
|
+
filter,
|
216
|
+
entity_type,
|
217
|
+
output_format,
|
218
|
+
self._extract_gov_action_type_properties,
|
219
|
+
get_additional_props_func,
|
220
|
+
output_formats,
|
221
|
+
)
|
222
|
+
|
223
|
+
def _extract_catalog_target_properties(self, element: dict, columns_struct: dict) -> dict:
|
224
|
+
col_data = populate_columns_from_properties(element, columns_struct)
|
225
|
+
columns_list = col_data.get("formats", {}).get("columns", [])
|
226
|
+
header_props = _extract_referenceable_properties(element)
|
227
|
+
for column in columns_list:
|
228
|
+
key = column.get("key")
|
229
|
+
if key in header_props:
|
230
|
+
column["value"] = header_props.get(key)
|
231
|
+
elif isinstance(key, str) and key.lower() == "guid":
|
232
|
+
column["value"] = header_props.get("GUID")
|
233
|
+
col_data = get_required_relationships(element, col_data)
|
234
|
+
mermaid_val = element.get("mermaidGraph", "") or ""
|
235
|
+
for column in columns_list:
|
236
|
+
if column.get("key") == "mermaid":
|
237
|
+
column["value"] = mermaid_val
|
238
|
+
break
|
239
|
+
return col_data
|
240
|
+
|
241
|
+
def _generate_catalog_target_output(self, elements: dict | list[dict], filter: str | None,
|
242
|
+
element_type_name: str | None, output_format: str = "DICT",
|
243
|
+
output_format_set: dict | str | None = None) -> str | list[dict]:
|
244
|
+
entity_type = element_type_name or self.CATALOG_TARGET_LABEL
|
245
|
+
get_additional_props_func = None
|
246
|
+
if output_format_set:
|
247
|
+
if isinstance(output_format_set, str):
|
248
|
+
output_formats = select_output_format_set(output_format_set, output_format)
|
249
|
+
else:
|
250
|
+
output_formats = get_output_format_type_match(output_format_set, output_format)
|
251
|
+
elif element_type_name:
|
252
|
+
output_formats = select_output_format_set(element_type_name, output_format)
|
253
|
+
else:
|
254
|
+
output_formats = select_output_format_set(entity_type, output_format)
|
255
|
+
if output_formats is None:
|
256
|
+
output_formats = select_output_format_set("Default", output_format)
|
257
|
+
return generate_output(
|
258
|
+
elements,
|
259
|
+
filter,
|
260
|
+
entity_type,
|
261
|
+
output_format,
|
262
|
+
self._extract_catalog_target_properties,
|
263
|
+
None,
|
264
|
+
output_formats,
|
265
|
+
)
|
266
|
+
|
267
|
+
def _extract_engine_action_properties(self, element: dict, columns_struct: dict) -> dict:
|
268
|
+
col_data = populate_columns_from_properties(element, columns_struct)
|
269
|
+
columns_list = col_data.get("formats", {}).get("columns", [])
|
270
|
+
header_props = _extract_referenceable_properties(element)
|
271
|
+
for col in columns_list:
|
272
|
+
key = col.get("key")
|
273
|
+
if key in header_props:
|
274
|
+
col["value"] = header_props.get(key)
|
275
|
+
elif isinstance(key, str) and key.lower() == "guid":
|
276
|
+
col["value"] = header_props.get("GUID")
|
277
|
+
# EngineAction specifics: status, process_name, received_guards, completion_guards, request_type
|
278
|
+
status = (
|
279
|
+
element.get("properties", {}).get("status")
|
280
|
+
or element.get("elementProperties", {}).get("status")
|
281
|
+
or element.get("status")
|
282
|
+
)
|
283
|
+
process_name = (
|
284
|
+
element.get("properties", {}).get("processName")
|
285
|
+
or element.get("elementProperties", {}).get("processName")
|
286
|
+
or element.get("processName")
|
287
|
+
)
|
288
|
+
req_type = (
|
289
|
+
element.get("properties", {}).get("requestType")
|
290
|
+
or element.get("elementProperties", {}).get("requestType")
|
291
|
+
or element.get("requestType")
|
292
|
+
)
|
293
|
+
rec_guards = element.get("receivedGuards") or element.get("received_guards") or []
|
294
|
+
comp_guards = element.get("completionGuards") or element.get("completion_guards") or []
|
295
|
+
# assign to columns if present
|
296
|
+
for col in columns_list:
|
297
|
+
key = col.get("key")
|
298
|
+
if key == "status":
|
299
|
+
col["value"] = status
|
300
|
+
elif key in ("process_name", "processName"):
|
301
|
+
col["value"] = process_name
|
302
|
+
elif key in ("request_type", "requestType"):
|
303
|
+
col["value"] = req_type
|
304
|
+
elif key in ("received_guards", "receivedGuards"):
|
305
|
+
col["value"] = ", ".join(map(str, rec_guards)) if isinstance(rec_guards, list) else rec_guards
|
306
|
+
elif key in ("completion_guards", "completionGuards"):
|
307
|
+
col["value"] = ", ".join(map(str, comp_guards)) if isinstance(comp_guards, list) else comp_guards
|
308
|
+
col_data = get_required_relationships(element, col_data)
|
309
|
+
mermaid_val = element.get("mermaidGraph", "") or ""
|
310
|
+
for col in columns_list:
|
311
|
+
if col.get("key") == "mermaid":
|
312
|
+
col["value"] = mermaid_val
|
313
|
+
break
|
314
|
+
return col_data
|
315
|
+
|
316
|
+
def _generate_engine_action_output(self, elements: dict | list[dict], filter: str | None,
|
317
|
+
element_type_name: str | None, output_format: str = "DICT",
|
318
|
+
output_format_set: dict | str | None = None) -> str | list[dict]:
|
319
|
+
entity_type = element_type_name or self.ENGINE_ACTION_LABEL
|
320
|
+
get_additional_props_func = None
|
321
|
+
if output_format_set:
|
322
|
+
if isinstance(output_format_set, str):
|
323
|
+
output_formats = select_output_format_set(output_format_set, output_format)
|
324
|
+
else:
|
325
|
+
output_formats = get_output_format_type_match(output_format_set, output_format)
|
326
|
+
elif element_type_name:
|
327
|
+
output_formats = select_output_format_set(element_type_name, output_format)
|
328
|
+
else:
|
329
|
+
output_formats = select_output_format_set(entity_type, output_format)
|
330
|
+
if output_formats is None:
|
331
|
+
output_formats = select_output_format_set("Default", output_format)
|
332
|
+
get_additional_props_name = (
|
333
|
+
output_formats.get("get_additional_props", {}).get("function") if output_formats else None
|
334
|
+
)
|
335
|
+
if isinstance(get_additional_props_name, str):
|
336
|
+
method_name = get_additional_props_name.split(".")[-1]
|
337
|
+
if hasattr(self, method_name):
|
338
|
+
get_additional_props_func = getattr(self, method_name)
|
339
|
+
return generate_output(
|
340
|
+
elements,
|
341
|
+
filter,
|
342
|
+
entity_type,
|
343
|
+
output_format,
|
344
|
+
self._extract_engine_action_properties,
|
345
|
+
get_additional_props_func,
|
346
|
+
output_formats,
|
347
|
+
)
|
348
|
+
|
349
|
+
def _extract_gov_action_process_properties(self, element: dict, columns_struct: dict) -> dict:
|
350
|
+
col_data = populate_columns_from_properties(element, columns_struct)
|
351
|
+
columns_list = col_data.get("formats", {}).get("columns", [])
|
352
|
+
header_props = _extract_referenceable_properties(element)
|
353
|
+
for col in columns_list:
|
354
|
+
key = col.get("key")
|
355
|
+
if key in header_props:
|
356
|
+
col["value"] = header_props.get(key)
|
357
|
+
elif isinstance(key, str) and key.lower() == "guid":
|
358
|
+
col["value"] = header_props.get("GUID")
|
359
|
+
# GAP specifics: processStatus, elementTypeName, stepCount
|
360
|
+
proc_status = (
|
361
|
+
element.get("properties", {}).get("processStatus")
|
362
|
+
or element.get("elementProperties", {}).get("processStatus")
|
363
|
+
or element.get("processStatus")
|
364
|
+
)
|
365
|
+
step_count = (
|
366
|
+
element.get("properties", {}).get("stepCount")
|
367
|
+
or element.get("elementProperties", {}).get("stepCount")
|
368
|
+
or element.get("stepCount")
|
369
|
+
)
|
370
|
+
for col in columns_list:
|
371
|
+
key = col.get("key")
|
372
|
+
if key in ("process_status", "processStatus"):
|
373
|
+
col["value"] = proc_status
|
374
|
+
elif key == "stepCount":
|
375
|
+
col["value"] = step_count
|
376
|
+
col_data = get_required_relationships(element, col_data)
|
377
|
+
mermaid_val = element.get("mermaidGraph", "") or ""
|
378
|
+
for col in columns_list:
|
379
|
+
if col.get("key") == "mermaid":
|
380
|
+
col["value"] = mermaid_val
|
381
|
+
break
|
382
|
+
return col_data
|
383
|
+
|
384
|
+
def _generate_gov_action_process_output(self, elements: dict | list[dict], filter: str | None,
|
385
|
+
element_type_name: str | None, output_format: str = "DICT",
|
386
|
+
output_format_set: dict | str | None = None) -> str | list[dict]:
|
387
|
+
entity_type = element_type_name or self.GOV_ACTION_PROCESS_LABEL
|
388
|
+
get_additional_props_func = None
|
389
|
+
if output_format_set:
|
390
|
+
if isinstance(output_format_set, str):
|
391
|
+
output_formats = select_output_format_set(output_format_set, output_format)
|
392
|
+
else:
|
393
|
+
output_formats = get_output_format_type_match(output_format_set, output_format)
|
394
|
+
elif element_type_name:
|
395
|
+
output_formats = select_output_format_set(element_type_name, output_format)
|
396
|
+
else:
|
397
|
+
output_formats = select_output_format_set(entity_type, output_format)
|
398
|
+
if output_formats is None:
|
399
|
+
output_formats = select_output_format_set("Default", output_format)
|
400
|
+
return generate_output(
|
401
|
+
elements,
|
402
|
+
filter,
|
403
|
+
entity_type,
|
404
|
+
output_format,
|
405
|
+
self._extract_gov_action_process_properties,
|
406
|
+
None,
|
407
|
+
output_formats,
|
408
|
+
)
|
409
|
+
|
57
410
|
async def _async_create_elem_from_template(self, body: dict) -> str:
|
58
411
|
"""Create a new metadata element from a template. Async version.
|
59
412
|
Parameters
|
@@ -148,7 +501,6 @@ class AutomatedCuration(Client2):
|
|
148
501
|
)
|
149
502
|
return response
|
150
503
|
|
151
|
-
|
152
504
|
async def _async_create_kafka_server_element_from_template(
|
153
505
|
self,
|
154
506
|
kafka_server: str,
|
@@ -379,7 +731,7 @@ class AutomatedCuration(Client2):
|
|
379
731
|
"class": "TemplateRequestBody",
|
380
732
|
"templateGUID": template_guid,
|
381
733
|
"isOwnAnchor": True,
|
382
|
-
"allowRetrieve"
|
734
|
+
"allowRetrieve": True,
|
383
735
|
"placeholderPropertyValues": {
|
384
736
|
"fileName": file_name,
|
385
737
|
"fileType": file_type,
|
@@ -1386,8 +1738,9 @@ class AutomatedCuration(Client2):
|
|
1386
1738
|
# Engine Actions
|
1387
1739
|
#
|
1388
1740
|
async def _async_get_engine_actions(
|
1389
|
-
self, start_from: int = 0, page_size: int = 0, body: dict | GetRequestBody = None
|
1390
|
-
|
1741
|
+
self, start_from: int = 0, page_size: int = 0, body: dict | GetRequestBody = None,
|
1742
|
+
output_format: str = "JSON", output_format_set: str | dict = "EngineAction"
|
1743
|
+
) -> list | str:
|
1391
1744
|
"""Retrieve the engine actions that are known to the server. Async version.
|
1392
1745
|
Parameters
|
1393
1746
|
----------
|
@@ -1428,11 +1781,15 @@ class AutomatedCuration(Client2):
|
|
1428
1781
|
# return await self._async_get_guid_request(url, "EngineAction", _generate_default_output,
|
1429
1782
|
# output_format="JSON", output_format_set="Referenceable", body=body )
|
1430
1783
|
response = await self._async_make_request("GET", url)
|
1431
|
-
|
1784
|
+
elements = response.json().get("elements", "No element found")
|
1785
|
+
# Apply formatter if not raw JSON requested
|
1786
|
+
return self._generate_engine_action_output(elements, None, self.ENGINE_ACTION_LABEL,
|
1787
|
+
output_format=output_format, output_format_set=output_format_set)
|
1432
1788
|
|
1433
1789
|
def get_engine_actions(
|
1434
|
-
self, start_from: int = 0, page_size: int = 0, body: dict | GetRequestBody = None
|
1435
|
-
|
1790
|
+
self, start_from: int = 0, page_size: int = 0, body: dict | GetRequestBody = None,
|
1791
|
+
output_format: str = "JSON", output_format_set: str | dict = "EngineAction"
|
1792
|
+
) -> list | str:
|
1436
1793
|
"""Retrieve the engine actions that are known to the server.
|
1437
1794
|
Parameters
|
1438
1795
|
----------
|
@@ -1467,7 +1824,8 @@ class AutomatedCuration(Client2):
|
|
1467
1824
|
"""
|
1468
1825
|
loop = asyncio.get_event_loop()
|
1469
1826
|
response = loop.run_until_complete(
|
1470
|
-
self._async_get_engine_actions(start_from, page_size, body
|
1827
|
+
self._async_get_engine_actions(start_from, page_size, body,
|
1828
|
+
output_format=output_format, output_format_set=output_format_set)
|
1471
1829
|
)
|
1472
1830
|
return response
|
1473
1831
|
|
@@ -1585,7 +1943,8 @@ class AutomatedCuration(Client2):
|
|
1585
1943
|
return
|
1586
1944
|
|
1587
1945
|
async def _async_get_active_engine_actions(
|
1588
|
-
self, start_from: int = 0, page_size: int = 0
|
1946
|
+
self, start_from: int = 0, page_size: int = 0,
|
1947
|
+
output_format: str = "JSON", output_format_set: str | dict = "EngineAction"
|
1589
1948
|
) -> list | str:
|
1590
1949
|
"""Retrieve the engine actions that are still in process. Async Version.
|
1591
1950
|
|
@@ -1617,10 +1976,13 @@ class AutomatedCuration(Client2):
|
|
1617
1976
|
)
|
1618
1977
|
|
1619
1978
|
response = await self._async_make_request("GET", url)
|
1620
|
-
|
1979
|
+
elements = response.json().get("elements", "no actions")
|
1980
|
+
return self._generate_engine_action_output(elements, None, self.ENGINE_ACTION_LABEL,
|
1981
|
+
output_format=output_format, output_format_set=output_format_set)
|
1621
1982
|
|
1622
1983
|
def get_active_engine_actions(
|
1623
|
-
self, start_from: int = 0, page_size: int = 0
|
1984
|
+
self, start_from: int = 0, page_size: int = 0,
|
1985
|
+
output_format: str = "JSON", output_format_set: str | dict = "EngineAction"
|
1624
1986
|
) -> list | str:
|
1625
1987
|
"""Retrieve the engine actions that are still in process.
|
1626
1988
|
|
@@ -1647,7 +2009,8 @@ class AutomatedCuration(Client2):
|
|
1647
2009
|
"""
|
1648
2010
|
loop = asyncio.get_event_loop()
|
1649
2011
|
response = loop.run_until_complete(
|
1650
|
-
self._async_get_active_engine_actions(start_from, page_size
|
2012
|
+
self._async_get_active_engine_actions(start_from, page_size,
|
2013
|
+
output_format=output_format, output_format_set=output_format_set)
|
1651
2014
|
)
|
1652
2015
|
return response
|
1653
2016
|
|
@@ -1740,6 +2103,8 @@ class AutomatedCuration(Client2):
|
|
1740
2103
|
ignore_case: bool = False,
|
1741
2104
|
start_from: int = 0,
|
1742
2105
|
page_size: int = 0,
|
2106
|
+
output_format: str = "JSON",
|
2107
|
+
output_format_set: str | dict = "EngineAction",
|
1743
2108
|
) -> list | str:
|
1744
2109
|
"""Retrieve the list of engine action metadata elements that contain the search string. Async Version.
|
1745
2110
|
Parameters
|
@@ -1781,17 +2146,24 @@ class AutomatedCuration(Client2):
|
|
1781
2146
|
validate_search_string(search_string)
|
1782
2147
|
if search_string == "*":
|
1783
2148
|
search_string = None
|
1784
|
-
starts_with_s = str(starts_with).lower()
|
1785
|
-
ends_with_s = str(ends_with).lower()
|
1786
|
-
ignore_case_s = str(ignore_case).lower()
|
1787
2149
|
|
1788
|
-
url = (
|
1789
|
-
|
1790
|
-
|
2150
|
+
url = str(HttpUrl(f"{self.curation_command_root}/assets/by-search-string"))
|
2151
|
+
return await self._async_find_request(
|
2152
|
+
url,
|
2153
|
+
_type=self.ENGINE_ACTION_LABEL,
|
2154
|
+
search_string=search_string,
|
2155
|
+
_gen_output=self._generate_engine_action_output,
|
2156
|
+
classification_names=None,
|
2157
|
+
metadata_element_types=["EngineAction"],
|
2158
|
+
starts_with=starts_with,
|
2159
|
+
ends_with=ends_with,
|
2160
|
+
ignore_case=ignore_case,
|
2161
|
+
start_from=start_from,
|
2162
|
+
page_size=page_size,
|
2163
|
+
output_format=output_format,
|
2164
|
+
output_format_set=output_format_set,
|
2165
|
+
body=None,
|
1791
2166
|
)
|
1792
|
-
body = {"class": "SearchStringRequestBody", "name": search_string}
|
1793
|
-
response = await self._async_make_request("POST", url, body)
|
1794
|
-
return response.json().get("elements", "no actions")
|
1795
2167
|
|
1796
2168
|
def find_engine_actions(
|
1797
2169
|
self,
|
@@ -1801,6 +2173,8 @@ class AutomatedCuration(Client2):
|
|
1801
2173
|
ignore_case: bool = False,
|
1802
2174
|
start_from: int = 0,
|
1803
2175
|
page_size: int = 0,
|
2176
|
+
output_format: str = "JSON",
|
2177
|
+
output_format_set: str | dict = "EngineAction",
|
1804
2178
|
) -> list | str:
|
1805
2179
|
"""Retrieve the list of engine action metadata elements that contain the search string.
|
1806
2180
|
Parameters
|
@@ -1848,6 +2222,8 @@ class AutomatedCuration(Client2):
|
|
1848
2222
|
ignore_case,
|
1849
2223
|
start_from,
|
1850
2224
|
page_size,
|
2225
|
+
output_format=output_format,
|
2226
|
+
output_format_set=output_format_set,
|
1851
2227
|
)
|
1852
2228
|
)
|
1853
2229
|
return response
|
@@ -1856,790 +2232,239 @@ class AutomatedCuration(Client2):
|
|
1856
2232
|
# Governance action processes
|
1857
2233
|
#
|
1858
2234
|
|
1859
|
-
async def _async_get_governance_action_process_by_guid(
|
1860
|
-
self, process_guid: str
|
1861
|
-
) -> dict | str:
|
1862
|
-
"""Retrieve the governance action process metadata element with the supplied unique identifier. Async Version.
|
1863
2235
|
|
1864
|
-
|
1865
|
-
|
1866
|
-
|
1867
|
-
|
2236
|
+
async def _async_initiate_gov_action_process(
|
2237
|
+
self,
|
2238
|
+
action_type_qualified_name: str,
|
2239
|
+
request_source_guids: [str] = None,
|
2240
|
+
action_targets: list = None,
|
2241
|
+
start_time: datetime = None,
|
2242
|
+
request_parameters: dict = None,
|
2243
|
+
orig_service_name: str = None,
|
2244
|
+
orig_engine_name: str = None,
|
2245
|
+
) -> str:
|
2246
|
+
"""Using the named governance action process as a template, initiate a chain of engine actions. Async version.
|
1868
2247
|
|
2248
|
+
Parameters
|
2249
|
+
----------
|
2250
|
+
action_type_qualified_name: str
|
2251
|
+
- unique name for the governance process
|
2252
|
+
request_source_guids: [str], optional
|
2253
|
+
- request source elements for the resulting governance action service
|
2254
|
+
action_targets: [str], optional
|
2255
|
+
-list of action target names to GUIDs for the resulting governance action service
|
2256
|
+
start_time: datetime, optional
|
2257
|
+
- time to start the process
|
2258
|
+
request_parameters: [str], optional
|
2259
|
+
- parameters passed into the process
|
2260
|
+
orig_service_name: str, optional
|
2261
|
+
- unique name of the requesting governance service (if initiated by a governance engine)
|
2262
|
+
orig_engine_name: str, optional
|
2263
|
+
- optional unique name of the governance engine (if initiated by a governance engine).
|
1869
2264
|
|
1870
|
-
Returns
|
2265
|
+
Returns
|
1871
2266
|
-------
|
1872
|
-
|
2267
|
+
Unique id (guid) of the newly started governance engine process
|
1873
2268
|
|
1874
|
-
Raises
|
2269
|
+
Raises
|
1875
2270
|
------
|
1876
|
-
|
1877
|
-
this exception is raised with details from the response content.
|
1878
|
-
PropertyServerException: If the API response indicates a server side error.
|
1879
|
-
UserNotAuthorizedException:
|
2271
|
+
PyegeriaException
|
1880
2272
|
"""
|
1881
2273
|
|
1882
|
-
|
1883
|
-
|
1884
|
-
url = (
|
1885
|
-
f"{self.curation_command_root}/"
|
1886
|
-
f"governance-action-processes/{process_guid}"
|
2274
|
+
start_time: datetime = (
|
2275
|
+
datetime.datetime.now() if start_time is None else start_time
|
1887
2276
|
)
|
1888
2277
|
|
1889
|
-
|
1890
|
-
|
2278
|
+
url = f"{self.curation_command_root}/governance-action-processes/initiate"
|
2279
|
+
body = {
|
2280
|
+
"class": "GovernanceActionProcessRequestBody",
|
2281
|
+
"processQualifiedName": action_type_qualified_name,
|
2282
|
+
"requestSourceGUIDs": request_source_guids,
|
2283
|
+
"actionTargets": action_targets,
|
2284
|
+
"startTime": int(start_time.timestamp() * 1000),
|
2285
|
+
"requestParameters": request_parameters,
|
2286
|
+
"originatorServiceName": orig_service_name,
|
2287
|
+
"originatorEngineName": orig_engine_name,
|
2288
|
+
}
|
2289
|
+
new_body = body_slimmer(body)
|
2290
|
+
response = await self._async_make_request("POST", url, new_body)
|
2291
|
+
return response.json().get("guid", "Action not initiated")
|
1891
2292
|
|
1892
|
-
def
|
1893
|
-
|
2293
|
+
def initiate_gov_action_process(
|
2294
|
+
self,
|
2295
|
+
action_type_qualified_name: str,
|
2296
|
+
request_source_guids: [str] = None,
|
2297
|
+
action_targets: [str] = None,
|
2298
|
+
start_time: datetime = None,
|
2299
|
+
request_parameters: dict = None,
|
2300
|
+
orig_service_name: str = None,
|
2301
|
+
orig_engine_name: str = None,
|
2302
|
+
) -> str:
|
2303
|
+
"""Using the named governance action process as a template, initiate a chain of engine actions.
|
1894
2304
|
|
1895
|
-
Parameters
|
2305
|
+
Parameters
|
1896
2306
|
----------
|
1897
|
-
|
1898
|
-
|
2307
|
+
action_type_qualified_name: str
|
2308
|
+
- unique name for the governance process
|
2309
|
+
request_source_guids: [str], optional
|
2310
|
+
- request source elements for the resulting governance action service
|
2311
|
+
action_targets: [str], optional
|
2312
|
+
-list of action target names to GUIDs for the resulting governance action service
|
2313
|
+
start_time: datetime, optional
|
2314
|
+
- time to start the process
|
2315
|
+
request_parameters: [str], optional
|
2316
|
+
- parameters passed into the process
|
2317
|
+
orig_service_name: str, optional
|
2318
|
+
- unique name of the requesting governance service (if initiated by a governance engine)
|
2319
|
+
orig_engine_name: str, optional
|
2320
|
+
- optional unique name of the governance engine (if initiated by a governance engine).
|
1899
2321
|
|
1900
|
-
Returns
|
2322
|
+
Returns
|
1901
2323
|
-------
|
1902
|
-
|
2324
|
+
Unique id (guid) of the newly started governance engine process
|
1903
2325
|
|
1904
|
-
Raises
|
2326
|
+
Raises
|
1905
2327
|
------
|
1906
|
-
|
1907
|
-
this exception is raised with details from the response content.
|
1908
|
-
PropertyServerException: If the API response indicates a server side error.
|
1909
|
-
UserNotAuthorizedException:
|
2328
|
+
PyegeriaException
|
1910
2329
|
"""
|
1911
2330
|
loop = asyncio.get_event_loop()
|
1912
2331
|
response = loop.run_until_complete(
|
1913
|
-
self.
|
2332
|
+
self._async_initiate_gov_action_process(
|
2333
|
+
action_type_qualified_name,
|
2334
|
+
request_source_guids,
|
2335
|
+
action_targets,
|
2336
|
+
start_time,
|
2337
|
+
request_parameters,
|
2338
|
+
orig_service_name,
|
2339
|
+
orig_engine_name,
|
2340
|
+
)
|
1914
2341
|
)
|
1915
2342
|
return response
|
1916
2343
|
|
1917
|
-
|
1918
|
-
|
1919
|
-
|
1920
|
-
|
1921
|
-
|
2344
|
+
|
2345
|
+
|
2346
|
+
async def _async_initiate_gov_action_type(
|
2347
|
+
self,
|
2348
|
+
action_type_qualified_name: str,
|
2349
|
+
request_source_guids: [str],
|
2350
|
+
action_targets: list,
|
2351
|
+
start_time: datetime = None,
|
2352
|
+
request_parameters: dict = None,
|
2353
|
+
orig_service_name: str = None,
|
2354
|
+
orig_engine_name: str = None,
|
2355
|
+
) -> str:
|
2356
|
+
"""Using the named governance action type as a template, initiate an engine action. Async version.
|
2357
|
+
|
1922
2358
|
Parameters
|
1923
2359
|
----------
|
1924
|
-
|
1925
|
-
|
2360
|
+
action_type_qualified_name: str
|
2361
|
+
- unique name for the governance process
|
2362
|
+
request_source_guids: [str]
|
2363
|
+
- request source elements for the resulting governance action service
|
2364
|
+
action_targets: [str]
|
2365
|
+
-list of action target names to GUIDs for the resulting governance action service
|
2366
|
+
start_time: datetime, default = None
|
2367
|
+
- time to start the process, no earlier than start time. None means now.
|
2368
|
+
request_parameters: [str]
|
2369
|
+
- parameters passed into the process
|
2370
|
+
orig_service_name: str
|
2371
|
+
- unique name of the requesting governance service (if initiated by a governance engine)
|
2372
|
+
orig_engine_name: str
|
2373
|
+
- optional unique name of the governance engine (if initiated by a governance engine).
|
1926
2374
|
|
1927
2375
|
Returns
|
1928
2376
|
-------
|
1929
|
-
|
1930
|
-
A dictionary representing the graph of the governance action process, or the string "no actions"
|
1931
|
-
if no actions are found.
|
1932
|
-
Raises:
|
1933
|
-
------
|
1934
|
-
InvalidParameterException: If the API response indicates an error (non-200 status code),
|
1935
|
-
this exception is raised with details from the response content.
|
1936
|
-
PropertyServerException: If the API response indicates a server side error.
|
1937
|
-
UserNotAuthorizedException:
|
2377
|
+
Unique id (guid) of the newly started governance engine process
|
1938
2378
|
|
2379
|
+
Raises
|
2380
|
+
------
|
2381
|
+
PyegeriaException
|
1939
2382
|
"""
|
1940
2383
|
|
1941
|
-
|
1942
|
-
|
1943
|
-
|
1944
|
-
|
1945
|
-
|
1946
|
-
|
2384
|
+
url = f"{self.curation_command_root}/governance-action-types/initiate"
|
2385
|
+
start = int(start_time.timestamp() * 1000) if start_time else None
|
2386
|
+
body = {
|
2387
|
+
"class": "InitiateGovernanceActionTypeRequestBody",
|
2388
|
+
"governanceActionTypeQualifiedName": action_type_qualified_name,
|
2389
|
+
"requestSourceGUIDs": request_source_guids,
|
2390
|
+
"actionTargets": action_targets,
|
2391
|
+
"startDate": start,
|
2392
|
+
"requestParameters": request_parameters,
|
2393
|
+
"originatorServiceName": orig_service_name,
|
2394
|
+
"originatorEngineName": orig_engine_name,
|
2395
|
+
}
|
2396
|
+
new_body = body_slimmer(body)
|
2397
|
+
response = await self._async_make_request("POST", url, new_body)
|
2398
|
+
return response.json().get("guid", "Action not initiated")
|
1947
2399
|
|
1948
|
-
|
1949
|
-
|
2400
|
+
def initiate_gov_action_type(
|
2401
|
+
self,
|
2402
|
+
action_type_qualified_name: str,
|
2403
|
+
request_source_guids: [str],
|
2404
|
+
action_targets: list,
|
2405
|
+
start_time: datetime = None,
|
2406
|
+
request_parameters: dict = None,
|
2407
|
+
orig_service_name: str = None,
|
2408
|
+
orig_engine_name: str = None,
|
2409
|
+
) -> str:
|
2410
|
+
"""Using the named governance action type as a template, initiate an engine action.
|
1950
2411
|
|
1951
|
-
def get_gov_action_process_graph(self, process_guid: str) -> dict | str:
|
1952
|
-
"""Retrieve the governance action process metadata element with the supplied unique
|
1953
|
-
identifier along with the flow definition describing its implementation.
|
1954
2412
|
Parameters
|
1955
2413
|
----------
|
1956
|
-
|
1957
|
-
|
2414
|
+
action_type_qualified_name: str
|
2415
|
+
- unique name for the governance process
|
2416
|
+
request_source_guids: [str]
|
2417
|
+
- request source elements for the resulting governance action service
|
2418
|
+
action_targets: [str]
|
2419
|
+
-list of action target names to GUIDs for the resulting governance action service
|
2420
|
+
start_time: datetime, default = None
|
2421
|
+
- time to start the process, no earlier than start time. None means now.
|
2422
|
+
request_parameters: [str]
|
2423
|
+
- parameters passed into the process
|
2424
|
+
orig_service_name: str
|
2425
|
+
- unique name of the requesting governance service (if initiated by a governance engine)
|
2426
|
+
orig_engine_name: str
|
2427
|
+
- optional unique name of the governance engine (if initiated by a governance engine).
|
1958
2428
|
|
1959
2429
|
Returns
|
1960
2430
|
-------
|
1961
|
-
|
1962
|
-
A dictionary representing the graph of the governance action process, or the string "no actions"
|
1963
|
-
if no actions are found.
|
1964
|
-
Raises:
|
1965
|
-
------
|
1966
|
-
InvalidParameterException: If the API response indicates an error (non-200 status code),
|
1967
|
-
this exception is raised with details from the response content.
|
1968
|
-
PropertyServerException: If the API response indicates a server side error.
|
1969
|
-
UserNotAuthorizedException:
|
2431
|
+
Unique id (guid) of the newly started governance engine process
|
1970
2432
|
|
1971
|
-
|
2433
|
+
Raises
|
2434
|
+
------
|
2435
|
+
PyegeriaException """
|
1972
2436
|
loop = asyncio.get_event_loop()
|
1973
2437
|
response = loop.run_until_complete(
|
1974
|
-
self.
|
2438
|
+
self._async_initiate_gov_action_type(
|
2439
|
+
action_type_qualified_name,
|
2440
|
+
request_source_guids,
|
2441
|
+
action_targets,
|
2442
|
+
start_time,
|
2443
|
+
request_parameters,
|
2444
|
+
orig_service_name,
|
2445
|
+
orig_engine_name,
|
2446
|
+
)
|
1975
2447
|
)
|
1976
2448
|
return response
|
1977
2449
|
|
1978
|
-
|
1979
|
-
|
1980
|
-
|
1981
|
-
|
1982
|
-
|
1983
|
-
|
1984
|
-
"""Retrieve the list of governance action process metadata elements with a matching qualified or display name.
|
1985
|
-
There are no wildcards supported on this request. Async Version.
|
2450
|
+
#
|
2451
|
+
# Initiate surveys
|
2452
|
+
#
|
2453
|
+
|
2454
|
+
async def _async_initiate_survey(self, survey_name: str, resource_guid: str) -> str:
|
2455
|
+
"""Initiate a survey of the survey_name on the target resource. Async Version.
|
1986
2456
|
|
1987
2457
|
Parameters
|
1988
2458
|
----------
|
1989
|
-
|
1990
|
-
The name of the
|
1991
|
-
|
1992
|
-
|
1993
|
-
The index to start retrieving engine actions from. If not provided, the default value will be used.
|
1994
|
-
page_size : int, optional
|
1995
|
-
The maximum number of engine actions to retrieve in a single request. If not provided, the default
|
1996
|
-
global maximum paging size will be used.
|
2459
|
+
survey_name: str
|
2460
|
+
The name of the survey to initiate.
|
2461
|
+
resource_guid : str
|
2462
|
+
The GUID of the resource to be surveyed.
|
1997
2463
|
|
1998
2464
|
Returns
|
1999
2465
|
-------
|
2000
|
-
|
2001
|
-
|
2002
|
-
or "no actions" if no engine actions were found with the given name.
|
2003
|
-
Raises:
|
2004
|
-
------
|
2005
|
-
PyegeriaException """
|
2006
|
-
|
2007
|
-
validate_name(name)
|
2008
|
-
|
2009
|
-
url = (
|
2010
|
-
f"{self.curation_command_root}/governance-action-processes/"
|
2011
|
-
f"by-name"
|
2012
|
-
)
|
2013
|
-
body = {"filter": name}
|
2014
|
-
response = await self._async_make_request("POST", url, body)
|
2015
|
-
return response.json().get("elements", "no actions")
|
2016
|
-
|
2017
|
-
def get_gov_action_processes_by_name(
|
2018
|
-
self,
|
2019
|
-
name: str,
|
2020
|
-
start_from: int = 0,
|
2021
|
-
page_size: int = 0,
|
2022
|
-
) -> list | str:
|
2023
|
-
"""Retrieve the list of governance action process metadata elements with a matching qualified or display name.
|
2024
|
-
There are no wildcards supported on this request.
|
2025
|
-
|
2026
|
-
Parameters
|
2027
|
-
----------
|
2028
|
-
name : str
|
2029
|
-
The name of the engine action to retrieve.
|
2030
|
-
|
2031
|
-
start_from : int, optional
|
2032
|
-
The index to start retrieving engine actions from. If not provided, the default value will be used.
|
2033
|
-
page_size : int, optional
|
2034
|
-
The maximum number of engine actions to retrieve in a single request. If not provided, the default global
|
2035
|
-
maximum paging size will be used.
|
2036
|
-
|
2037
|
-
Returns
|
2038
|
-
-------
|
2039
|
-
list of dict | str
|
2040
|
-
A list of dictionaries representing the retrieved engine actions,
|
2041
|
-
or "no actions" if no engine actions were found with the given name.
|
2042
|
-
Raises:
|
2043
|
-
------
|
2044
|
-
PyegeriaException """
|
2045
|
-
loop = asyncio.get_event_loop()
|
2046
|
-
response = loop.run_until_complete(
|
2047
|
-
self._async_get_gov_action_processes_by_name(name, start_from, page_size)
|
2048
|
-
)
|
2049
|
-
return response
|
2050
|
-
|
2051
|
-
async def _async_find_gov_action_processes(
|
2052
|
-
self,
|
2053
|
-
search_string: str,
|
2054
|
-
starts_with: bool = False,
|
2055
|
-
ends_with: bool = False,
|
2056
|
-
ignore_case: bool = False,
|
2057
|
-
start_from: int = 0,
|
2058
|
-
page_size: int = 0,
|
2059
|
-
) -> list | str:
|
2060
|
-
"""Retrieve the list of governance action process metadata elements that contain the search string. Async ver.
|
2061
|
-
|
2062
|
-
Parameters
|
2063
|
-
----------
|
2064
|
-
search_string : str
|
2065
|
-
The string used for searching engine actions by name.
|
2066
|
-
|
2067
|
-
|
2068
|
-
|
2069
|
-
starts_with : bool, optional
|
2070
|
-
Whether to search engine actions that start with the given search string. Default is False.
|
2071
|
-
|
2072
|
-
ends_with : bool, optional
|
2073
|
-
Whether to search engine actions that end with the given search string. Default is False.
|
2074
|
-
|
2075
|
-
ignore_case : bool, optional
|
2076
|
-
Whether to ignore case while searching engine actions. Default is False.
|
2077
|
-
|
2078
|
-
start_from : int, optional
|
2079
|
-
The index from which to start fetching the engine actions. Default is 0.
|
2080
|
-
|
2081
|
-
page_size : int, optional
|
2082
|
-
The maximum number of engine actions to fetch in a single request. Default is `0`.
|
2083
|
-
|
2084
|
-
Returns
|
2085
|
-
-------
|
2086
|
-
List[dict] or str
|
2087
|
-
A list of dictionaries representing the governance action processes found based on the search query.
|
2088
|
-
If no actions are found, returns the string "no actions".
|
2089
|
-
|
2090
|
-
Raises:
|
2091
|
-
------
|
2092
|
-
PyegeriaException """
|
2093
|
-
|
2094
|
-
validate_search_string(search_string)
|
2095
|
-
if search_string == "*":
|
2096
|
-
search_string = None
|
2097
|
-
starts_with_s = str(starts_with).lower()
|
2098
|
-
ends_with_s = str(ends_with).lower()
|
2099
|
-
ignore_case_s = str(ignore_case).lower()
|
2100
|
-
|
2101
|
-
url = (
|
2102
|
-
f"{self.curation_command_root}/governance-action-processes/"
|
2103
|
-
f"by-search-string"
|
2104
|
-
)
|
2105
|
-
|
2106
|
-
if search_string:
|
2107
|
-
body = {"filter": search_string}
|
2108
|
-
response = await self._async_make_request("POST", url, body)
|
2109
|
-
else:
|
2110
|
-
response = await self._async_make_request("POST", url)
|
2111
|
-
|
2112
|
-
return response.json().get("elements", "no actions")
|
2113
|
-
|
2114
|
-
def find_gov_action_processes(
|
2115
|
-
self,
|
2116
|
-
search_string: str = "*",
|
2117
|
-
starts_with: bool = False,
|
2118
|
-
ends_with: bool = False,
|
2119
|
-
ignore_case: bool = False,
|
2120
|
-
start_from: int = 0,
|
2121
|
-
page_size: int = 0,
|
2122
|
-
) -> list | str:
|
2123
|
-
"""Retrieve the list of governance action process metadata elements that contain the search string.
|
2124
|
-
|
2125
|
-
Parameters
|
2126
|
-
----------
|
2127
|
-
search_string : str
|
2128
|
-
The string used for searching engine actions by name.
|
2129
|
-
|
2130
|
-
|
2131
|
-
|
2132
|
-
starts_with : bool, optional
|
2133
|
-
Whether to search engine actions that start with the given search string. Default is False.
|
2134
|
-
|
2135
|
-
ends_with : bool, optional
|
2136
|
-
Whether to search engine actions that end with the given search string. Default is False.
|
2137
|
-
|
2138
|
-
ignore_case : bool, optional
|
2139
|
-
Whether to ignore case while searching engine actions. Default is False.
|
2140
|
-
|
2141
|
-
start_from : int, optional
|
2142
|
-
The index from which to start fetching the engine actions. Default is 0.
|
2143
|
-
|
2144
|
-
page_size : int, optional
|
2145
|
-
The maximum number of engine actions to fetch in a single request. Default is `0`.
|
2146
|
-
|
2147
|
-
Returns
|
2148
|
-
-------
|
2149
|
-
List[dict] or str
|
2150
|
-
A list of dictionaries representing the governance action processes found based on the search query.
|
2151
|
-
If no actions are found, returns the string "no actions".
|
2152
|
-
|
2153
|
-
Raises:
|
2154
|
-
------
|
2155
|
-
PyegeriaException """
|
2156
|
-
|
2157
|
-
loop = asyncio.get_event_loop()
|
2158
|
-
response = loop.run_until_complete(
|
2159
|
-
self._async_find_gov_action_processes(
|
2160
|
-
search_string,
|
2161
|
-
starts_with,
|
2162
|
-
ends_with,
|
2163
|
-
ignore_case,
|
2164
|
-
start_from,
|
2165
|
-
page_size,
|
2166
|
-
)
|
2167
|
-
)
|
2168
|
-
return response
|
2169
|
-
|
2170
|
-
async def _async_initiate_gov_action_process(
|
2171
|
-
self,
|
2172
|
-
action_type_qualified_name: str,
|
2173
|
-
request_source_guids: [str] = None,
|
2174
|
-
action_targets: list = None,
|
2175
|
-
start_time: datetime = None,
|
2176
|
-
request_parameters: dict = None,
|
2177
|
-
orig_service_name: str = None,
|
2178
|
-
orig_engine_name: str = None,
|
2179
|
-
) -> str:
|
2180
|
-
"""Using the named governance action process as a template, initiate a chain of engine actions. Async version.
|
2181
|
-
|
2182
|
-
Parameters
|
2183
|
-
----------
|
2184
|
-
action_type_qualified_name: str
|
2185
|
-
- unique name for the governance process
|
2186
|
-
request_source_guids: [str], optional
|
2187
|
-
- request source elements for the resulting governance action service
|
2188
|
-
action_targets: [str], optional
|
2189
|
-
-list of action target names to GUIDs for the resulting governance action service
|
2190
|
-
start_time: datetime, optional
|
2191
|
-
- time to start the process
|
2192
|
-
request_parameters: [str], optional
|
2193
|
-
- parameters passed into the process
|
2194
|
-
orig_service_name: str, optional
|
2195
|
-
- unique name of the requesting governance service (if initiated by a governance engine)
|
2196
|
-
orig_engine_name: str, optional
|
2197
|
-
- optional unique name of the governance engine (if initiated by a governance engine).
|
2198
|
-
|
2199
|
-
Returns
|
2200
|
-
-------
|
2201
|
-
Unique id (guid) of the newly started governance engine process
|
2202
|
-
|
2203
|
-
Raises
|
2204
|
-
------
|
2205
|
-
PyegeriaException
|
2206
|
-
"""
|
2207
|
-
|
2208
|
-
start_time: datetime = (
|
2209
|
-
datetime.datetime.now() if start_time is None else start_time
|
2210
|
-
)
|
2211
|
-
|
2212
|
-
url = f"{self.curation_command_root}/governance-action-processes/initiate"
|
2213
|
-
body = {
|
2214
|
-
"class": "GovernanceActionProcessRequestBody",
|
2215
|
-
"processQualifiedName": action_type_qualified_name,
|
2216
|
-
"requestSourceGUIDs": request_source_guids,
|
2217
|
-
"actionTargets": action_targets,
|
2218
|
-
"startTime": int(start_time.timestamp() * 1000),
|
2219
|
-
"requestParameters": request_parameters,
|
2220
|
-
"originatorServiceName": orig_service_name,
|
2221
|
-
"originatorEngineName": orig_engine_name,
|
2222
|
-
}
|
2223
|
-
new_body = body_slimmer(body)
|
2224
|
-
response = await self._async_make_request("POST", url, new_body)
|
2225
|
-
return response.json().get("guid", "Action not initiated")
|
2226
|
-
|
2227
|
-
def initiate_gov_action_process(
|
2228
|
-
self,
|
2229
|
-
action_type_qualified_name: str,
|
2230
|
-
request_source_guids: [str] = None,
|
2231
|
-
action_targets: [str] = None,
|
2232
|
-
start_time: datetime = None,
|
2233
|
-
request_parameters: dict = None,
|
2234
|
-
orig_service_name: str = None,
|
2235
|
-
orig_engine_name: str = None,
|
2236
|
-
) -> str:
|
2237
|
-
"""Using the named governance action process as a template, initiate a chain of engine actions.
|
2238
|
-
|
2239
|
-
Parameters
|
2240
|
-
----------
|
2241
|
-
action_type_qualified_name: str
|
2242
|
-
- unique name for the governance process
|
2243
|
-
request_source_guids: [str], optional
|
2244
|
-
- request source elements for the resulting governance action service
|
2245
|
-
action_targets: [str], optional
|
2246
|
-
-list of action target names to GUIDs for the resulting governance action service
|
2247
|
-
start_time: datetime, optional
|
2248
|
-
- time to start the process
|
2249
|
-
request_parameters: [str], optional
|
2250
|
-
- parameters passed into the process
|
2251
|
-
orig_service_name: str, optional
|
2252
|
-
- unique name of the requesting governance service (if initiated by a governance engine)
|
2253
|
-
orig_engine_name: str, optional
|
2254
|
-
- optional unique name of the governance engine (if initiated by a governance engine).
|
2255
|
-
|
2256
|
-
Returns
|
2257
|
-
-------
|
2258
|
-
Unique id (guid) of the newly started governance engine process
|
2259
|
-
|
2260
|
-
Raises
|
2261
|
-
------
|
2262
|
-
PyegeriaException
|
2263
|
-
"""
|
2264
|
-
loop = asyncio.get_event_loop()
|
2265
|
-
response = loop.run_until_complete(
|
2266
|
-
self._async_initiate_gov_action_process(
|
2267
|
-
action_type_qualified_name,
|
2268
|
-
request_source_guids,
|
2269
|
-
action_targets,
|
2270
|
-
start_time,
|
2271
|
-
request_parameters,
|
2272
|
-
orig_service_name,
|
2273
|
-
orig_engine_name,
|
2274
|
-
)
|
2275
|
-
)
|
2276
|
-
return response
|
2277
|
-
|
2278
|
-
async def _async_get_gov_action_types_by_guid(
|
2279
|
-
self, gov_action_type_guid: str
|
2280
|
-
) -> dict | str:
|
2281
|
-
"""Retrieve the governance action type metadata element with the supplied unique identifier. Async version.
|
2282
|
-
|
2283
|
-
Parameters:
|
2284
|
-
----------
|
2285
|
-
gov_action_type_guid: str
|
2286
|
-
The GUID (Globally Unique Identifier) of the governance action type to retrieve.
|
2287
|
-
|
2288
|
-
Returns:
|
2289
|
-
-------
|
2290
|
-
dict: The JSON representation of the governance action type element.
|
2291
|
-
|
2292
|
-
Raises:
|
2293
|
-
------
|
2294
|
-
InvalidParameterException: If the API response indicates an error (non-200 status code),
|
2295
|
-
this exception is raised with details from the response content.
|
2296
|
-
PropertyServerException: If the API response indicates a server side error.
|
2297
|
-
UserNotAuthorizedException:
|
2298
|
-
"""
|
2299
|
-
|
2300
|
-
validate_guid(gov_action_type_guid)
|
2301
|
-
|
2302
|
-
url = (
|
2303
|
-
f"{self.curation_command_root}/"
|
2304
|
-
f"governance-action-types/{gov_action_type_guid}"
|
2305
|
-
)
|
2306
|
-
|
2307
|
-
response = await self._async_make_request("GET", url)
|
2308
|
-
return response.json().get("element", "no actions")
|
2309
|
-
|
2310
|
-
def get_gov_action_types_by_guid(self, gov_action_type_guid: str) -> dict | str:
|
2311
|
-
"""Retrieve the governance action type metadata element with the supplied unique identifier.
|
2312
|
-
|
2313
|
-
Parameters:
|
2314
|
-
----------
|
2315
|
-
gov_action_type_guid: str
|
2316
|
-
The GUID (Globally Unique Identifier) of the governance action type to retrieve.
|
2317
|
-
|
2318
|
-
Returns:
|
2319
|
-
-------
|
2320
|
-
dict: The JSON representation of the governance action type element.
|
2321
|
-
|
2322
|
-
Raises:
|
2323
|
-
------
|
2324
|
-
InvalidParameterException: If the API response indicates an error (non-200 status code),
|
2325
|
-
this exception is raised with details from the response content.
|
2326
|
-
PropertyServerException: If the API response indicates a server side error.
|
2327
|
-
UserNotAuthorizedException:
|
2328
|
-
"""
|
2329
|
-
loop = asyncio.get_event_loop()
|
2330
|
-
response = loop.run_until_complete(
|
2331
|
-
self._async_get_gov_action_types_by_guid(gov_action_type_guid)
|
2332
|
-
)
|
2333
|
-
return response
|
2334
|
-
|
2335
|
-
async def _async_get_gov_action_types_by_name(
|
2336
|
-
self,
|
2337
|
-
action_type_name,
|
2338
|
-
start_from: int = 0,
|
2339
|
-
page_size: int = 0,
|
2340
|
-
) -> list | str:
|
2341
|
-
"""Retrieve the list of governance action type metadata elements with a matching qualified or display name.
|
2342
|
-
There are no wildcards supported on this request. Async version.
|
2343
|
-
|
2344
|
-
Parameters:
|
2345
|
-
----------
|
2346
|
-
action_type_name: str
|
2347
|
-
The name of the governance action type to retrieve.
|
2348
|
-
|
2349
|
-
Returns:
|
2350
|
-
-------
|
2351
|
-
dict: The JSON representation of the governance action type element.
|
2352
|
-
|
2353
|
-
Raises:
|
2354
|
-
------
|
2355
|
-
InvalidParameterException: If the API response indicates an error (non-200 status code),
|
2356
|
-
this exception is raised with details from the response content.
|
2357
|
-
PropertyServerException: If the API response indicates a server side error.
|
2358
|
-
UserNotAuthorizedException:
|
2359
|
-
"""
|
2360
|
-
|
2361
|
-
validate_name(action_type_name)
|
2362
|
-
|
2363
|
-
url = (
|
2364
|
-
f"{self.curation_command_root}/"
|
2365
|
-
f"governance-action-types/by-name"
|
2366
|
-
)
|
2367
|
-
|
2368
|
-
body = {"filter": action_type_name}
|
2369
|
-
|
2370
|
-
response = await self._async_make_request("POST", url, body)
|
2371
|
-
return response.json().get("elements", "no actions")
|
2372
|
-
|
2373
|
-
def get_gov_action_types_by_name(
|
2374
|
-
self,
|
2375
|
-
action_type_name,
|
2376
|
-
start_from: int = 0,
|
2377
|
-
page_size: int = 0,
|
2378
|
-
) -> list | str:
|
2379
|
-
"""Retrieve the list of governance action type metadata elements with a matching qualified or display name.
|
2380
|
-
There are no wildcards supported on this request. Async version.
|
2381
|
-
|
2382
|
-
Parameters:
|
2383
|
-
----------
|
2384
|
-
action_type_name: str
|
2385
|
-
The name of the governance action type to retrieve.
|
2386
|
-
|
2387
|
-
Returns:
|
2388
|
-
-------
|
2389
|
-
dict: The JSON representation of the governance action type element.
|
2390
|
-
|
2391
|
-
Raises:
|
2392
|
-
------
|
2393
|
-
InvalidParameterException: If the API response indicates an error (non-200 status code),
|
2394
|
-
this exception is raised with details from the response content.
|
2395
|
-
PropertyServerException: If the API response indicates a server side error.
|
2396
|
-
UserNotAuthorizedException:
|
2397
|
-
"""
|
2398
|
-
loop = asyncio.get_event_loop()
|
2399
|
-
response = loop.run_until_complete(
|
2400
|
-
self._async_get_gov_action_types_by_name(
|
2401
|
-
action_type_name, start_from, page_size
|
2402
|
-
)
|
2403
|
-
)
|
2404
|
-
return response
|
2405
|
-
|
2406
|
-
async def _async_find_gov_action_types(
|
2407
|
-
self,
|
2408
|
-
search_string: str = "*",
|
2409
|
-
starts_with: bool = False,
|
2410
|
-
ends_with: bool = False,
|
2411
|
-
ignore_case: bool = True,
|
2412
|
-
start_from: int = 0,
|
2413
|
-
page_size: int = 0,
|
2414
|
-
) -> list | str:
|
2415
|
-
"""Retrieve the list of governance action type metadata elements that contain the search string.
|
2416
|
-
Async Version.
|
2417
|
-
|
2418
|
-
Parameters
|
2419
|
-
----------
|
2420
|
-
search_string : str
|
2421
|
-
The string used for searching engine actions by name.
|
2422
|
-
|
2423
|
-
|
2424
|
-
|
2425
|
-
starts_with : bool, optional
|
2426
|
-
Whether to search engine actions that start with the given search string. Default is False.
|
2427
|
-
|
2428
|
-
ends_with : bool, optional
|
2429
|
-
Whether to search engine actions that end with the given search string. Default is False.
|
2430
|
-
|
2431
|
-
ignore_case : bool, optional
|
2432
|
-
Whether to ignore case while searching engine actions. Default is False.
|
2433
|
-
|
2434
|
-
start_from : int, optional
|
2435
|
-
The index from which to start fetching the engine actions. Default is 0.
|
2436
|
-
|
2437
|
-
page_size : int, optional
|
2438
|
-
The maximum number of engine actions to fetch in a single request. Default is `0`.
|
2439
|
-
|
2440
|
-
Returns
|
2441
|
-
-------
|
2442
|
-
List[dict] or str
|
2443
|
-
A list of dictionaries representing the governance action types found based on the search query.
|
2444
|
-
If no actions are found, returns the string "no action types".
|
2445
|
-
|
2446
|
-
Raises
|
2447
|
-
------
|
2448
|
-
PyegeriaException
|
2449
|
-
"""
|
2450
|
-
|
2451
|
-
validate_search_string(search_string)
|
2452
|
-
if search_string == "*":
|
2453
|
-
search_string = None
|
2454
|
-
starts_with_s = str(starts_with).lower()
|
2455
|
-
ends_with_s = str(ends_with).lower()
|
2456
|
-
ignore_case_s = str(ignore_case).lower()
|
2457
|
-
|
2458
|
-
url = (
|
2459
|
-
f"{self.curation_command_root}/governance-action-types/"
|
2460
|
-
f"by-search-string"
|
2461
|
-
)
|
2462
|
-
body = {"filter": search_string}
|
2463
|
-
response = await self._async_make_request("POST", url, body)
|
2464
|
-
return response.json().get("elements", "no action types")
|
2465
|
-
|
2466
|
-
def find_gov_action_types(
|
2467
|
-
self,
|
2468
|
-
search_string: str = "*",
|
2469
|
-
starts_with: bool = False,
|
2470
|
-
ends_with: bool = False,
|
2471
|
-
ignore_case: bool = False,
|
2472
|
-
start_from: int = 0,
|
2473
|
-
page_size: int = 0,
|
2474
|
-
) -> list | str:
|
2475
|
-
"""Retrieve the list of governance action type metadata elements that contain the search string.
|
2476
|
-
|
2477
|
-
Parameters
|
2478
|
-
----------
|
2479
|
-
search_string : str
|
2480
|
-
The string used for searching engine actions by name.
|
2481
|
-
|
2482
|
-
|
2483
|
-
starts_with : bool, optional
|
2484
|
-
Whether to search engine actions that start with the given search string. Default is False.
|
2485
|
-
|
2486
|
-
ends_with : bool, optional
|
2487
|
-
Whether to search engine actions that end with the given search string. Default is False.
|
2488
|
-
|
2489
|
-
ignore_case : bool, optional
|
2490
|
-
Whether to ignore case while searching engine actions. Default is False.
|
2491
|
-
|
2492
|
-
start_from : int, optional
|
2493
|
-
The index from which to start fetching the engine actions. Default is 0.
|
2494
|
-
|
2495
|
-
page_size : int, optional
|
2496
|
-
The maximum number of engine actions to fetch in a single request. Default is `0`.
|
2497
|
-
|
2498
|
-
Returns
|
2499
|
-
-------
|
2500
|
-
List[dict] or str
|
2501
|
-
A list of dictionaries representing the governance action types found based on the search query.
|
2502
|
-
If no actions are found, returns the string "no action types".
|
2503
|
-
|
2504
|
-
Raises
|
2505
|
-
------
|
2506
|
-
PyegeriaException
|
2507
|
-
"""
|
2508
|
-
loop = asyncio.get_event_loop()
|
2509
|
-
response = loop.run_until_complete(
|
2510
|
-
self._async_find_gov_action_types(
|
2511
|
-
search_string,
|
2512
|
-
starts_with,
|
2513
|
-
ends_with,
|
2514
|
-
ignore_case,
|
2515
|
-
start_from,
|
2516
|
-
page_size,
|
2517
|
-
)
|
2518
|
-
)
|
2519
|
-
return response
|
2520
|
-
|
2521
|
-
async def _async_initiate_gov_action_type(
|
2522
|
-
self,
|
2523
|
-
action_type_qualified_name: str,
|
2524
|
-
request_source_guids: [str],
|
2525
|
-
action_targets: list,
|
2526
|
-
start_time: datetime = None,
|
2527
|
-
request_parameters: dict = None,
|
2528
|
-
orig_service_name: str = None,
|
2529
|
-
orig_engine_name: str = None,
|
2530
|
-
) -> str:
|
2531
|
-
"""Using the named governance action type as a template, initiate an engine action. Async version.
|
2532
|
-
|
2533
|
-
Parameters
|
2534
|
-
----------
|
2535
|
-
action_type_qualified_name: str
|
2536
|
-
- unique name for the governance process
|
2537
|
-
request_source_guids: [str]
|
2538
|
-
- request source elements for the resulting governance action service
|
2539
|
-
action_targets: [str]
|
2540
|
-
-list of action target names to GUIDs for the resulting governance action service
|
2541
|
-
start_time: datetime, default = None
|
2542
|
-
- time to start the process, no earlier than start time. None means now.
|
2543
|
-
request_parameters: [str]
|
2544
|
-
- parameters passed into the process
|
2545
|
-
orig_service_name: str
|
2546
|
-
- unique name of the requesting governance service (if initiated by a governance engine)
|
2547
|
-
orig_engine_name: str
|
2548
|
-
- optional unique name of the governance engine (if initiated by a governance engine).
|
2549
|
-
|
2550
|
-
Returns
|
2551
|
-
-------
|
2552
|
-
Unique id (guid) of the newly started governance engine process
|
2553
|
-
|
2554
|
-
Raises
|
2555
|
-
------
|
2556
|
-
PyegeriaException
|
2557
|
-
"""
|
2558
|
-
|
2559
|
-
url = f"{self.curation_command_root}/governance-action-types/initiate"
|
2560
|
-
start = int(start_time.timestamp() * 1000) if start_time else None
|
2561
|
-
body = {
|
2562
|
-
"class": "InitiateGovernanceActionTypeRequestBody",
|
2563
|
-
"governanceActionTypeQualifiedName": action_type_qualified_name,
|
2564
|
-
"requestSourceGUIDs": request_source_guids,
|
2565
|
-
"actionTargets": action_targets,
|
2566
|
-
"startDate": start,
|
2567
|
-
"requestParameters": request_parameters,
|
2568
|
-
"originatorServiceName": orig_service_name,
|
2569
|
-
"originatorEngineName": orig_engine_name,
|
2570
|
-
}
|
2571
|
-
new_body = body_slimmer(body)
|
2572
|
-
response = await self._async_make_request("POST", url, new_body)
|
2573
|
-
return response.json().get("guid", "Action not initiated")
|
2574
|
-
|
2575
|
-
def initiate_gov_action_type(
|
2576
|
-
self,
|
2577
|
-
action_type_qualified_name: str,
|
2578
|
-
request_source_guids: [str],
|
2579
|
-
action_targets: list,
|
2580
|
-
start_time: datetime = None,
|
2581
|
-
request_parameters: dict = None,
|
2582
|
-
orig_service_name: str = None,
|
2583
|
-
orig_engine_name: str = None,
|
2584
|
-
) -> str:
|
2585
|
-
"""Using the named governance action type as a template, initiate an engine action.
|
2586
|
-
|
2587
|
-
Parameters
|
2588
|
-
----------
|
2589
|
-
action_type_qualified_name: str
|
2590
|
-
- unique name for the governance process
|
2591
|
-
request_source_guids: [str]
|
2592
|
-
- request source elements for the resulting governance action service
|
2593
|
-
action_targets: [str]
|
2594
|
-
-list of action target names to GUIDs for the resulting governance action service
|
2595
|
-
start_time: datetime, default = None
|
2596
|
-
- time to start the process, no earlier than start time. None means now.
|
2597
|
-
request_parameters: [str]
|
2598
|
-
- parameters passed into the process
|
2599
|
-
orig_service_name: str
|
2600
|
-
- unique name of the requesting governance service (if initiated by a governance engine)
|
2601
|
-
orig_engine_name: str
|
2602
|
-
- optional unique name of the governance engine (if initiated by a governance engine).
|
2603
|
-
|
2604
|
-
Returns
|
2605
|
-
-------
|
2606
|
-
Unique id (guid) of the newly started governance engine process
|
2607
|
-
|
2608
|
-
Raises
|
2609
|
-
------
|
2610
|
-
PyegeriaException """
|
2611
|
-
loop = asyncio.get_event_loop()
|
2612
|
-
response = loop.run_until_complete(
|
2613
|
-
self._async_initiate_gov_action_type(
|
2614
|
-
action_type_qualified_name,
|
2615
|
-
request_source_guids,
|
2616
|
-
action_targets,
|
2617
|
-
start_time,
|
2618
|
-
request_parameters,
|
2619
|
-
orig_service_name,
|
2620
|
-
orig_engine_name,
|
2621
|
-
)
|
2622
|
-
)
|
2623
|
-
return response
|
2624
|
-
|
2625
|
-
#
|
2626
|
-
# Initiate surveys
|
2627
|
-
#
|
2628
|
-
|
2629
|
-
async def _async_initiate_survey(self, survey_name: str, resource_guid: str) -> str:
|
2630
|
-
"""Initiate a survey of the survey_name on the target resource. Async Version.
|
2631
|
-
|
2632
|
-
Parameters
|
2633
|
-
----------
|
2634
|
-
survey_name: str
|
2635
|
-
The name of the survey to initiate.
|
2636
|
-
resource_guid : str
|
2637
|
-
The GUID of the resource to be surveyed.
|
2638
|
-
|
2639
|
-
Returns
|
2640
|
-
-------
|
2641
|
-
str
|
2642
|
-
The GUID of the initiated action or "Action not initiated" if the action was not initiated.
|
2466
|
+
str
|
2467
|
+
The GUID of the initiated action or "Action not initiated" if the action was not initiated.
|
2643
2468
|
|
2644
2469
|
"""
|
2645
2470
|
|
@@ -3101,6 +2926,8 @@ class AutomatedCuration(Client2):
|
|
3101
2926
|
integ_connector_guid: str,
|
3102
2927
|
start_from: int = 0,
|
3103
2928
|
page_size: int = 0,
|
2929
|
+
output_format: str = "JSON",
|
2930
|
+
output_format_set: str | dict = "CatalogTarget",
|
3104
2931
|
) -> list | str:
|
3105
2932
|
"""Retrieve the details of the metadata elements identified as catalog targets with an integration connector.
|
3106
2933
|
Async version.
|
@@ -3129,13 +2956,20 @@ class AutomatedCuration(Client2):
|
|
3129
2956
|
)
|
3130
2957
|
|
3131
2958
|
response = await self._async_make_request("GET", url)
|
3132
|
-
|
2959
|
+
elements = response.json().get("elements", "no targets")
|
2960
|
+
if isinstance(elements, str):
|
2961
|
+
return elements
|
2962
|
+
return self._generate_catalog_target_output(elements, None, self.CATALOG_TARGET_LABEL,
|
2963
|
+
output_format=output_format,
|
2964
|
+
output_format_set=output_format_set)
|
3133
2965
|
|
3134
2966
|
def get_catalog_targets(
|
3135
2967
|
self,
|
3136
2968
|
integ_connector_guid: str,
|
3137
2969
|
start_from: int = 0,
|
3138
2970
|
page_size: int = 0,
|
2971
|
+
output_format: str = "JSON",
|
2972
|
+
output_format_set: str | dict = "CatalogTarget",
|
3139
2973
|
) -> list | str:
|
3140
2974
|
"""Retrieve the details of the metadata elements identified as catalog targets with an integration connector.
|
3141
2975
|
|
@@ -3157,11 +2991,16 @@ class AutomatedCuration(Client2):
|
|
3157
2991
|
|
3158
2992
|
loop = asyncio.get_event_loop()
|
3159
2993
|
response = loop.run_until_complete(
|
3160
|
-
self._async_get_catalog_targets(integ_connector_guid, start_from, page_size
|
2994
|
+
self._async_get_catalog_targets(integ_connector_guid, start_from, page_size,
|
2995
|
+
output_format=output_format,
|
2996
|
+
output_format_set=output_format_set)
|
3161
2997
|
)
|
3162
2998
|
return response
|
3163
2999
|
|
3164
|
-
async def _async_get_catalog_target(self, relationship_guid: str
|
3000
|
+
async def _async_get_catalog_target(self, relationship_guid: str,
|
3001
|
+
output_format: str = "JSON",
|
3002
|
+
output_format_set: str | dict = "CatalogTarget",
|
3003
|
+
body: dict | GetRequestBody = None) -> dict | str:
|
3165
3004
|
"""Retrieve a specific catalog target associated with an integration connector. Further Information:
|
3166
3005
|
https://egeria-project.org/concepts/integration-connector/ . Async version.
|
3167
3006
|
|
@@ -3184,12 +3023,21 @@ class AutomatedCuration(Client2):
|
|
3184
3023
|
|
3185
3024
|
validate_guid(relationship_guid)
|
3186
3025
|
|
3187
|
-
url = f"{self.curation_command_root}/catalog-targets/{relationship_guid}"
|
3188
|
-
|
3189
|
-
|
3190
|
-
|
3026
|
+
url = str(HttpUrl(f"{self.curation_command_root}/catalog-targets/{relationship_guid}"))
|
3027
|
+
response = await self._async_get_guid_request(
|
3028
|
+
url,
|
3029
|
+
_type=self.CATALOG_TARGET_LABEL,
|
3030
|
+
_gen_output=self._generate_catalog_target_output,
|
3031
|
+
output_format=output_format,
|
3032
|
+
output_format_set=output_format_set,
|
3033
|
+
body=body,
|
3034
|
+
)
|
3035
|
+
return response
|
3191
3036
|
|
3192
|
-
def get_catalog_target(self, relationship_guid: str
|
3037
|
+
def get_catalog_target(self, relationship_guid: str,
|
3038
|
+
output_format: str = "JSON",
|
3039
|
+
output_format_set: str | dict = "CatalogTarget",
|
3040
|
+
body: dict | GetRequestBody = None) -> dict | str:
|
3193
3041
|
"""Retrieve a specific catalog target associated with an integration connector. Further Information:
|
3194
3042
|
https://egeria-project.org/concepts/integration-connector/ .
|
3195
3043
|
|
@@ -3212,7 +3060,10 @@ class AutomatedCuration(Client2):
|
|
3212
3060
|
|
3213
3061
|
loop = asyncio.get_event_loop()
|
3214
3062
|
response = loop.run_until_complete(
|
3215
|
-
self._async_get_catalog_target(relationship_guid
|
3063
|
+
self._async_get_catalog_target(relationship_guid,
|
3064
|
+
output_format=output_format,
|
3065
|
+
output_format_set=output_format_set,
|
3066
|
+
body=body)
|
3216
3067
|
)
|
3217
3068
|
return response
|
3218
3069
|
|
@@ -3597,7 +3448,9 @@ class AutomatedCuration(Client2):
|
|
3597
3448
|
return response
|
3598
3449
|
|
3599
3450
|
async def _async_get_technology_type_detail(self, type_name: str, template_only: bool = False,
|
3600
|
-
body: dict | FilterRequestBody = None
|
3451
|
+
body: dict | FilterRequestBody = None,
|
3452
|
+
output_format: str = "JSON",
|
3453
|
+
output_format_set: str | dict = "TechType") -> list | str:
|
3601
3454
|
"""Retrieve the details of the named technology type. This name should be the name of the technology type
|
3602
3455
|
and contain no wild cards. Async version.
|
3603
3456
|
Parameters
|
@@ -3642,20 +3495,32 @@ class AutomatedCuration(Client2):
|
|
3642
3495
|
"""
|
3643
3496
|
|
3644
3497
|
# validate_name(type_name)
|
3645
|
-
url = f"{self.curation_command_root}/technology-types/by-name"
|
3498
|
+
url = str(HttpUrl(f"{self.curation_command_root}/technology-types/by-name"))
|
3646
3499
|
if body is None:
|
3647
3500
|
classified_elements = ["Template"] if template_only else []
|
3648
3501
|
body = {
|
3649
3502
|
"class": "FilterRequestBody",
|
3650
3503
|
"filter": type_name,
|
3651
|
-
"includeOnlyClassifiedElements": classified_elements
|
3504
|
+
"includeOnlyClassifiedElements": classified_elements,
|
3652
3505
|
}
|
3653
|
-
|
3654
|
-
|
3655
|
-
|
3506
|
+
response = await self._async_get_name_request(
|
3507
|
+
url,
|
3508
|
+
_type=self.TECH_TYPE_ENTITY_LABEL,
|
3509
|
+
_gen_output=self._generate_tech_type_output,
|
3510
|
+
filter_string=type_name,
|
3511
|
+
classification_names=classified_elements if template_only else None,
|
3512
|
+
start_from=0,
|
3513
|
+
page_size=0,
|
3514
|
+
output_format=output_format,
|
3515
|
+
output_format_set=output_format_set,
|
3516
|
+
body=body,
|
3517
|
+
)
|
3518
|
+
return response
|
3656
3519
|
|
3657
3520
|
def get_technology_type_detail(self, type_name: str, template_only: bool = False,
|
3658
|
-
body: dict | FilterRequestBody = None
|
3521
|
+
body: dict | FilterRequestBody = None,
|
3522
|
+
output_format: str = "JSON",
|
3523
|
+
output_format_set: str | dict = "TechType") -> list | str:
|
3659
3524
|
"""Retrieve the details of the named technology type. This name should be the name of the technology type
|
3660
3525
|
and contain no wild cards.
|
3661
3526
|
Parameters
|
@@ -3701,7 +3566,9 @@ class AutomatedCuration(Client2):
|
|
3701
3566
|
|
3702
3567
|
loop = asyncio.get_event_loop()
|
3703
3568
|
response = loop.run_until_complete(
|
3704
|
-
self._async_get_technology_type_detail(type_name, template_only=template_only, body=body
|
3569
|
+
self._async_get_technology_type_detail(type_name, template_only=template_only, body=body,
|
3570
|
+
output_format=output_format,
|
3571
|
+
output_format_set=output_format_set)
|
3705
3572
|
)
|
3706
3573
|
return response
|
3707
3574
|
|
@@ -3720,7 +3587,7 @@ class AutomatedCuration(Client2):
|
|
3720
3587
|
)
|
3721
3588
|
return response
|
3722
3589
|
|
3723
|
-
async def
|
3590
|
+
async def async_find_technology_types(
|
3724
3591
|
self,
|
3725
3592
|
search_string: str = "*",
|
3726
3593
|
start_from: int = 0,
|
@@ -3728,6 +3595,8 @@ class AutomatedCuration(Client2):
|
|
3728
3595
|
starts_with: bool = False,
|
3729
3596
|
ends_with: bool = False,
|
3730
3597
|
ignore_case: bool = True,
|
3598
|
+
output_format: str = "JSON",
|
3599
|
+
output_format_set: str | dict = "TechType"
|
3731
3600
|
) -> list | str:
|
3732
3601
|
"""Retrieve the list of technology types that contain the search string. Async version.
|
3733
3602
|
|
@@ -3765,10 +3634,6 @@ class AutomatedCuration(Client2):
|
|
3765
3634
|
For more information see: https://egeria-project.org/concepts/deployed-implementation-type
|
3766
3635
|
"""
|
3767
3636
|
|
3768
|
-
starts_with_s = str(starts_with).lower()
|
3769
|
-
ends_with_s = str(ends_with).lower()
|
3770
|
-
ignore_case_s = str(ignore_case).lower()
|
3771
|
-
validate_name(search_string)
|
3772
3637
|
if search_string == "*":
|
3773
3638
|
search_string = None
|
3774
3639
|
|
@@ -3790,7 +3655,17 @@ class AutomatedCuration(Client2):
|
|
3790
3655
|
}
|
3791
3656
|
|
3792
3657
|
response = await self._async_make_request("POST", url, body)
|
3793
|
-
|
3658
|
+
elements = response.json().get("elements", NO_ELEMENTS_FOUND)
|
3659
|
+
if type(elements) is str:
|
3660
|
+
logger.info(NO_ELEMENTS_FOUND)
|
3661
|
+
return NO_ELEMENTS_FOUND
|
3662
|
+
|
3663
|
+
if output_format.upper() != 'JSON': # return a simplified markdown representation
|
3664
|
+
# logger.info(f"Found elements, output format: {output_format} and output_format_set: {output_format_set}")
|
3665
|
+
return self._generate_tech_type_output(elements, search_string, "TechType",
|
3666
|
+
output_format, output_format_set)
|
3667
|
+
return elements
|
3668
|
+
|
3794
3669
|
|
3795
3670
|
def find_technology_types(
|
3796
3671
|
self,
|
@@ -3800,6 +3675,122 @@ class AutomatedCuration(Client2):
|
|
3800
3675
|
starts_with: bool = False,
|
3801
3676
|
ends_with: bool = False,
|
3802
3677
|
ignore_case: bool = True,
|
3678
|
+
output_format: str = "JSON",
|
3679
|
+
output_format_set: str | dict = "TechType",
|
3680
|
+
) -> list | str:
|
3681
|
+
"""Retrieve the list of technology types that contain the search string. Async version.
|
3682
|
+
|
3683
|
+
Parameters:
|
3684
|
+
----------
|
3685
|
+
type_name: str
|
3686
|
+
The technology type we are looking for.
|
3687
|
+
|
3688
|
+
Returns:
|
3689
|
+
-------
|
3690
|
+
[dict] | str: List of elements describing the technology - or "no tech found" if not found.
|
3691
|
+
|
3692
|
+
Raises:
|
3693
|
+
------
|
3694
|
+
InvalidParameterException: If the API response indicates an error (non-200 status code),
|
3695
|
+
this exception is raised with details from the response content.
|
3696
|
+
PropertyServerException: If the API response indicates a server side error.
|
3697
|
+
UserNotAuthorizedException:
|
3698
|
+
|
3699
|
+
Notes
|
3700
|
+
-----
|
3701
|
+
For more information see: https://egeria-project.org/concepts/deployed-implementation-type
|
3702
|
+
"""
|
3703
|
+
|
3704
|
+
loop = asyncio.get_event_loop()
|
3705
|
+
response = loop.run_until_complete(
|
3706
|
+
self.async_find_technology_types(
|
3707
|
+
search_string,
|
3708
|
+
start_from,
|
3709
|
+
page_size,
|
3710
|
+
starts_with,
|
3711
|
+
ends_with,
|
3712
|
+
ignore_case,
|
3713
|
+
output_format,
|
3714
|
+
output_format_set
|
3715
|
+
)
|
3716
|
+
)
|
3717
|
+
return response
|
3718
|
+
|
3719
|
+
async def async_find_technology_types_body(
|
3720
|
+
self,
|
3721
|
+
search_string: str = "*",
|
3722
|
+
start_from: int = 0,
|
3723
|
+
page_size: int = 0,
|
3724
|
+
starts_with: bool = False,
|
3725
|
+
ends_with: bool = False,
|
3726
|
+
ignore_case: bool = True,
|
3727
|
+
output_format: str = "JSON",
|
3728
|
+
output_format_set: str | dict = "TechType",
|
3729
|
+
body: dict | SearchStringRequestBody = None
|
3730
|
+
) -> list | str:
|
3731
|
+
"""Retrieve the list of technology types that contain the search string. Async version.
|
3732
|
+
|
3733
|
+
Parameters:
|
3734
|
+
----------
|
3735
|
+
type_name: str
|
3736
|
+
The technology type we are looking for.
|
3737
|
+
starts_with : bool, optional
|
3738
|
+
Whether to search engine actions that start with the given search string. Default is False.
|
3739
|
+
|
3740
|
+
ends_with : bool, optional
|
3741
|
+
Whether to search engine actions that end with the given search string. Default is False.
|
3742
|
+
|
3743
|
+
ignore_case : bool, optional
|
3744
|
+
Whether to ignore case while searching engine actions. Default is True.
|
3745
|
+
|
3746
|
+
start_from : int, optional
|
3747
|
+
The index from which to start fetching the engine actions. Default is 0.
|
3748
|
+
|
3749
|
+
page_size : int, optional
|
3750
|
+
The maximum number of engine actions to fetch in a single request. Default is `0`.
|
3751
|
+
body: dict | SearchStringRequestBody, optional
|
3752
|
+
Full request body, if provided, overrides other parameters.
|
3753
|
+
|
3754
|
+
Returns:
|
3755
|
+
-------
|
3756
|
+
[dict] | str: List of elements describing the technology - or "no tech found" if not found.
|
3757
|
+
|
3758
|
+
Raises:
|
3759
|
+
------
|
3760
|
+
InvalidParameterException: If the API response indicates an error (non-200 status code),
|
3761
|
+
this exception is raised with details from the response content.
|
3762
|
+
PropertyServerException: If the API response indicates a server side error.
|
3763
|
+
UserNotAuthorizedException:
|
3764
|
+
|
3765
|
+
Notes
|
3766
|
+
-----
|
3767
|
+
For more information see: https://egeria-project.org/concepts/deployed-implementation-type
|
3768
|
+
"""
|
3769
|
+
|
3770
|
+
if search_string == "*":
|
3771
|
+
search_string = None
|
3772
|
+
|
3773
|
+
url = str(HttpUrl(f"{self.curation_command_root}/technology-types/by-search-string"))
|
3774
|
+
response = await self._async_find_request(url, _type="TechType", search_string=search_string,
|
3775
|
+
_gen_output=self._generate_tech_type_output,
|
3776
|
+
classification_names=None,
|
3777
|
+
metadata_element_types='ValidMetadataValue',
|
3778
|
+
starts_with=starts_with, ends_with=ends_with, ignore_case=ignore_case,
|
3779
|
+
start_from=start_from, page_size=page_size,
|
3780
|
+
output_format=output_format, output_format_set=output_format_set,
|
3781
|
+
body=body)
|
3782
|
+
|
3783
|
+
return response
|
3784
|
+
|
3785
|
+
|
3786
|
+
def find_technology_types_body(
|
3787
|
+
self,
|
3788
|
+
search_string: str = "*",
|
3789
|
+
start_from: int = 0,
|
3790
|
+
page_size: int = 0,
|
3791
|
+
starts_with: bool = False,
|
3792
|
+
ends_with: bool = False,
|
3793
|
+
ignore_case: bool = True,
|
3803
3794
|
) -> list | str:
|
3804
3795
|
"""Retrieve the list of technology types that contain the search string. Async version.
|
3805
3796
|
|
@@ -3826,7 +3817,7 @@ class AutomatedCuration(Client2):
|
|
3826
3817
|
|
3827
3818
|
loop = asyncio.get_event_loop()
|
3828
3819
|
response = loop.run_until_complete(
|
3829
|
-
self.
|
3820
|
+
self.async_find_technology_types_body(
|
3830
3821
|
search_string,
|
3831
3822
|
start_from,
|
3832
3823
|
page_size,
|
@@ -3838,16 +3829,16 @@ class AutomatedCuration(Client2):
|
|
3838
3829
|
return response
|
3839
3830
|
|
3840
3831
|
async def _async_get_all_technology_types(
|
3841
|
-
self, start_from: int = 0, page_size: int = 0
|
3832
|
+
self, start_from: int = 0, page_size: int = 0, output_format: str = "JSON", output_format_set: str = "TechType"
|
3842
3833
|
) -> list | str:
|
3843
3834
|
"""Get all technology types - async version"""
|
3844
|
-
return await self._async_find_technology_types("*", start_from, page_size)
|
3835
|
+
return await self._async_find_technology_types("*", start_from, page_size, output_format, output_format_set)
|
3845
3836
|
|
3846
3837
|
def get_all_technology_types(
|
3847
|
-
self, start_from: int = 0, page_size: int = 0
|
3838
|
+
self, start_from: int = 0, page_size: int = 0, output_format: str = "JSON", output_format_set: str = "TechType"
|
3848
3839
|
) -> list | str:
|
3849
3840
|
"""Get all technology types"""
|
3850
|
-
return self.find_technology_types("*", start_from, page_size)
|
3841
|
+
return self.find_technology_types("*", start_from, page_size, output_format, output_format_set)
|
3851
3842
|
|
3852
3843
|
def print_engine_action_summary(self, governance_action: dict):
|
3853
3844
|
"""print_governance_action_summary
|
@@ -4014,6 +4005,5 @@ class AutomatedCuration(Client2):
|
|
4014
4005
|
return response
|
4015
4006
|
|
4016
4007
|
|
4017
|
-
|
4018
4008
|
if __name__ == "__main__":
|
4019
4009
|
print("Main-Automated Curation")
|