|
11 | 11 | import asyncio |
12 | 12 | from typing import Optional |
13 | 13 |
|
| 14 | +from pyegeria import CollectionManager |
14 | 15 | from pyegeria._server_client import ServerClient |
15 | 16 | from pyegeria._exceptions import PyegeriaInvalidParameterException |
16 | 17 | from pyegeria._globals import NO_GUID_RETURNED |
|
24 | 25 | NewClassificationRequestBody, |
25 | 26 | DeleteClassificationRequestBody |
26 | 27 | ) |
| 28 | + |
27 | 29 | from pyegeria.utils import dynamic_catch, body_slimmer |
28 | 30 | from loguru import logger |
29 | 31 |
|
30 | 32 | EGERIA_LOCAL_QUALIFIER = app_settings.User_Profile.egeria_local_qualifier |
31 | 33 |
|
32 | 34 |
|
33 | | -class DigitalBusiness(ServerClient): |
| 35 | +class DigitalBusiness(CollectionManager): |
34 | 36 | """ |
35 | 37 | Manage business capabilities, their lifecycle, and their digital support relationships. |
36 | 38 |
|
@@ -116,13 +118,13 @@ def _prepare_body(self, body: Optional[dict | NewElementRequestBody | UpdateElem |
116 | 118 | @dynamic_catch |
117 | 119 | async def _async_create_business_capability( |
118 | 120 | self, |
119 | | - body: Optional[dict | NewElementRequestBody] = None, |
| 121 | + body: Optional[dict | NewElementRequestBody], |
120 | 122 | ) -> str: |
121 | 123 | """Create a new business capability collection. Async version. |
122 | 124 |
|
123 | 125 | Parameters |
124 | 126 | ---------- |
125 | | - body : dict | NewElementRequestBody, optional |
| 127 | + body : dict | NewElementRequestBody |
126 | 128 | Request body containing business capability properties. |
127 | 129 |
|
128 | 130 | Returns |
@@ -162,18 +164,18 @@ async def _async_create_business_capability( |
162 | 164 | "forDuplicateProcessing" : false, |
163 | 165 | } |
164 | 166 | """ |
165 | | - url = f"{self.digital_business_command_root}/business-capabilities" |
| 167 | + url = f"{self.digital_business_command_root}/collections" |
166 | 168 | return await self._async_create_element_body_request(url, ["BusinessCapabilityProperties"], body) |
167 | 169 |
|
168 | 170 | def create_business_capability( |
169 | 171 | self, |
170 | | - body: Optional[dict | NewElementRequestBody] = None, |
| 172 | + body: Optional[dict | NewElementRequestBody], |
171 | 173 | ) -> str: |
172 | 174 | """Create a new business capability collection. Sync version. |
173 | 175 |
|
174 | 176 | Parameters |
175 | 177 | ---------- |
176 | | - body : dict | NewElementRequestBody, optional |
| 178 | + body : dict | NewElementRequestBody |
177 | 179 | Request body containing business capability properties. |
178 | 180 |
|
179 | 181 | Returns |
@@ -218,7 +220,7 @@ async def _async_update_business_capability( |
218 | 220 | PyegeriaNotAuthorizedException |
219 | 221 | If the user is not authorized for the requested action. |
220 | 222 | """ |
221 | | - url = f"{self.digital_business_command_root}/business-capabilities/{business_capability_guid}/update" |
| 223 | + url = f"{self.digital_business_command_root}/collections/{business_capability_guid}/update" |
222 | 224 | await self._async_update_element_body_request(url, ["BusinessCapabilityProperties"], body) |
223 | 225 |
|
224 | 226 | def update_business_capability( |
@@ -282,7 +284,7 @@ async def _async_delete_business_capability( |
282 | 284 | PyegeriaNotAuthorizedException |
283 | 285 | If the user is not authorized for the requested action. |
284 | 286 | """ |
285 | | - url = f"{self.digital_business_command_root}/business-capabilities/{business_capability_guid}/delete" |
| 287 | + url = f"{self.digital_business_command_root}/collections/{business_capability_guid}/delete" |
286 | 288 | await self._async_delete_element_request(url, body, cascade) |
287 | 289 |
|
288 | 290 | def delete_business_capability( |
@@ -354,11 +356,11 @@ async def _async_get_business_capability_by_guid( |
354 | 356 | PyegeriaNotAuthorizedException |
355 | 357 | If the user is not authorized for the requested action. |
356 | 358 | """ |
357 | | - url = f"{self.digital_business_command_root}/business-capabilities/{business_capability_guid}/retrieve" |
| 359 | + url = f"{self.digital_business_command_root}/collections/{business_capability_guid}/retrieve" |
358 | 360 | response = await self._async_get_guid_request( |
359 | 361 | url, |
360 | 362 | _type="BusinessCapability", |
361 | | - _gen_output=None, |
| 363 | + _gen_output=self._generate_collection_output, |
362 | 364 | output_format=output_format, |
363 | 365 | report_spec=report_spec, |
364 | 366 | body=body, |
@@ -442,11 +444,11 @@ async def _async_get_business_capabilities_by_name( |
442 | 444 | PyegeriaException |
443 | 445 | If there are issues in communications, message format, or Egeria errors. |
444 | 446 | """ |
445 | | - url = f"{self.digital_business_command_root}/business-capabilities/by-name" |
| 447 | + url = f"{self.digital_business_command_root}/collections/by-name" |
446 | 448 | response = await self._async_get_name_request( |
447 | 449 | url, |
448 | 450 | _type="BusinessCapability", |
449 | | - _gen_output=None, |
| 451 | + _gen_output=self._generate_collection_output, |
450 | 452 | filter_string=filter_string, |
451 | 453 | classification_names=classification_names, |
452 | 454 | start_from=start_from, |
@@ -511,8 +513,8 @@ async def _async_find_business_capabilities( |
511 | 513 | ends_with: bool = False, |
512 | 514 | ignore_case: bool = True, |
513 | 515 | anchor_domain: Optional[str] = None, |
514 | | - metadata_element_type: Optional[str] = None, |
515 | | - metadata_element_subtype: Optional[str] = None, |
| 516 | + metadata_element_type: Optional[str] = "BusinessCapability", |
| 517 | + metadata_element_subtype: Optional[list[str]] = None, |
516 | 518 | skip_relationships: Optional[list[str]] = None, |
517 | 519 | include_only_relationships: Optional[list[str]] = None, |
518 | 520 | skip_classified_elements: Optional[list[str]] = None, |
@@ -594,11 +596,11 @@ async def _async_find_business_capabilities( |
594 | 596 | PyegeriaException |
595 | 597 | If there are issues in communications, message format, or Egeria errors. |
596 | 598 | """ |
597 | | - url = f"{self.digital_business_command_root}/business-capabilities/by-search-string" |
| 599 | + url = f"{self.digital_business_command_root}/collections/by-search-string" |
598 | 600 | response = await self._async_find_request( |
599 | 601 | url, |
600 | 602 | _type="BusinessCapability", |
601 | | - _gen_output=None, |
| 603 | + _gen_output=self._generate_collection_output, |
602 | 604 | search_string=search_string, |
603 | 605 | starts_with=starts_with, |
604 | 606 | ends_with=ends_with, |
@@ -633,8 +635,8 @@ def find_business_capabilities( |
633 | 635 | ends_with: bool = False, |
634 | 636 | ignore_case: bool = True, |
635 | 637 | anchor_domain: Optional[str] = None, |
636 | | - metadata_element_type: Optional[str] = None, |
637 | | - metadata_element_subtype: Optional[str] = None, |
| 638 | + metadata_element_type: Optional[str] = "BusinessCapability", |
| 639 | + metadata_element_subtype: Optional[list[str]] = None, |
638 | 640 | skip_relationships: Optional[list[str]] = None, |
639 | 641 | include_only_relationships: Optional[list[str]] = None, |
640 | 642 | skip_classified_elements: Optional[list[str]] = None, |
@@ -718,14 +720,14 @@ def find_business_capabilities( |
718 | 720 | """ |
719 | 721 | loop = asyncio.get_event_loop() |
720 | 722 | return loop.run_until_complete( |
721 | | - self._async_find_business_capabilities( |
722 | | - search_string, starts_with, ends_with, ignore_case, anchor_domain, |
723 | | - metadata_element_type, metadata_element_subtype, skip_relationships, |
724 | | - include_only_relationships, skip_classified_elements, include_only_classified_elements, |
725 | | - graph_query_depth, governance_zone_filter, as_of_time, effective_time, |
726 | | - relationship_page_size, limit_results_by_status, sequencing_order, |
727 | | - sequencing_property, start_from, page_size, output_format, report_spec, body |
728 | | - ) |
| 723 | + self._async_find_business_capabilities(search_string, starts_with, ends_with, ignore_case, anchor_domain, |
| 724 | + metadata_element_type, metadata_element_subtype, skip_relationships, |
| 725 | + include_only_relationships, skip_classified_elements, |
| 726 | + include_only_classified_elements, graph_query_depth, |
| 727 | + governance_zone_filter, as_of_time, effective_time, |
| 728 | + relationship_page_size, limit_results_by_status, sequencing_order, |
| 729 | + sequencing_property, start_from, page_size, output_format, |
| 730 | + report_spec, body) |
729 | 731 | ) |
730 | 732 |
|
731 | 733 | # |
|
0 commit comments