diff options
author | Kiran <kiran.mhetre@t-systems.com> | 2023-10-03 10:46:29 +0530 |
---|---|---|
committer | Kiran <kiran.mhetre@t-systems.com> | 2023-10-05 19:44:33 +0530 |
commit | 9676519775c5cac40791fa02071301dbb7974c59 (patch) | |
tree | 33b67d4d947f293cf3ea04a6300e1fb2eb5f8971 /src/onapsdk/aai/business | |
parent | 7f61bdf95398b461581a2b0aec043faa24c94ee2 (diff) |
updated changes for delete functionality for entities and relationship between entities.
Issue-ID: TEST-407
Change-Id: Ie8abaee76af001260ae999d3e56e886b8f449517
Signed-off-by: Kiran <kiran.mhetre@t-systems.com>
Diffstat (limited to 'src/onapsdk/aai/business')
-rw-r--r-- | src/onapsdk/aai/business/customer.py | 22 | ||||
-rw-r--r-- | src/onapsdk/aai/business/line_of_business.py | 15 | ||||
-rw-r--r-- | src/onapsdk/aai/business/owning_entity.py | 16 | ||||
-rw-r--r-- | src/onapsdk/aai/business/platform.py | 8 | ||||
-rw-r--r-- | src/onapsdk/aai/business/project.py | 8 |
5 files changed, 64 insertions, 5 deletions
diff --git a/src/onapsdk/aai/business/customer.py b/src/onapsdk/aai/business/customer.py index cdefd6f..1df1bc2 100644 --- a/src/onapsdk/aai/business/customer.py +++ b/src/onapsdk/aai/business/customer.py @@ -265,8 +265,8 @@ class ServiceSubscription(AaiResource): yield CloudRegion.get_by_id(cloud_owner=cloud_region_data[0], cloud_region_id=cloud_region_data[1]) except ResourceNotFound: - self._logger.error("Can't get cloud region %s %s", cloud_region_data[0], \ - cloud_region_data[1]) + self._logger.error("Can't get cloud region %s %s", cloud_region_data[0], + cloud_region_data[1]) @property def tenants(self) -> Iterator["Tenant"]: @@ -560,7 +560,7 @@ class Customer(AaiResource): ) except ResourceNotFound as exc: self._logger.info( - "Subscriptions are not " \ + "Subscriptions are not " "found for a customer: %s", exc) except APIError as exc: self._logger.error( @@ -590,6 +590,22 @@ class Customer(AaiResource): ) return self.get_service_subscription_by_service_type(service_type) + def delete_subscribed_service(self, service_sub: ServiceSubscription) -> None: + """Delete SDC Service subscription. + + Args: + service_sub (str): Value defined by orchestration to identify this service + across ONAP. + """ + self.send_message( + "DELETE", + "Delete service subscription", + (f"{self.base_url}{self.api_version}/business/customers/" + f"customer/{self.global_customer_id}/service-subscriptions/" + f"service-subscription/{service_sub.service_type}?" + f"resource-version={service_sub.resource_version}") + ) + def delete(self) -> None: """Delete customer. diff --git a/src/onapsdk/aai/business/line_of_business.py b/src/onapsdk/aai/business/line_of_business.py index 61fc0f8..a1b807d 100644 --- a/src/onapsdk/aai/business/line_of_business.py +++ b/src/onapsdk/aai/business/line_of_business.py @@ -16,11 +16,12 @@ from typing import Any, Dict, Iterator from onapsdk.utils.jinja import jinja_env +from onapsdk.aai.mixins.link_to_tenant import AaiResourceLinkToTenantMixin from ..aai_element import AaiResource -class LineOfBusiness(AaiResource): +class LineOfBusiness(AaiResource, AaiResourceLinkToTenantMixin): """Line of business class.""" def __init__(self, name: str, resource_version: str) -> None: @@ -121,3 +122,15 @@ class LineOfBusiness(AaiResource): f"Get {name} line of business", url) return cls(response["line-of-business-name"], response["resource-version"]) + + def delete(self) -> None: + """Delete line of business. + + Sends request to A&AI to delete line of business object. + + """ + self.send_message( + "DELETE", + f"Delete line of business", + f"{self.url}?resource-version={self.resource_version}" + ) diff --git a/src/onapsdk/aai/business/owning_entity.py b/src/onapsdk/aai/business/owning_entity.py index bf1e7c1..ebe9b11 100644 --- a/src/onapsdk/aai/business/owning_entity.py +++ b/src/onapsdk/aai/business/owning_entity.py @@ -21,8 +21,10 @@ from onapsdk.exceptions import ResourceNotFound from ..aai_element import AaiResource +from ..mixins.link_to_tenant import AaiResourceLinkToTenantMixin -class OwningEntity(AaiResource): + +class OwningEntity(AaiResource, AaiResourceLinkToTenantMixin): """Owning entity class.""" def __init__(self, name: str, owning_entity_id: str, resource_version: str) -> None: @@ -152,3 +154,15 @@ class OwningEntity(AaiResource): ) ) return cls.get_by_owning_entity_id(owning_entity_id) + + def delete(self) -> None: + """Delete owning entity. + + Sends request to A&AI to delete owning entity object. + + """ + self.send_message( + "DELETE", + f"Delete owning entity", + f"{self.url}?resource-version={self.resource_version}" + ) diff --git a/src/onapsdk/aai/business/platform.py b/src/onapsdk/aai/business/platform.py index 5c12ba8..f652e32 100644 --- a/src/onapsdk/aai/business/platform.py +++ b/src/onapsdk/aai/business/platform.py @@ -121,3 +121,11 @@ class Platform(AaiResource): f"Get {name} platform", url) return cls(response["platform-name"], response["resource-version"]) + + def delete(self) -> None: + """Delete platform.""" + self.send_message( + "DELETE", + f"Delete platform", + f"{self.url}?resource-version={self.resource_version}" + ) diff --git a/src/onapsdk/aai/business/project.py b/src/onapsdk/aai/business/project.py index 989444a..fcab0e8 100644 --- a/src/onapsdk/aai/business/project.py +++ b/src/onapsdk/aai/business/project.py @@ -121,3 +121,11 @@ class Project(AaiResource): f"Get {name} project", url) return cls(response["project-name"], response["resource-version"]) + + def delete(self) -> None: + """Delete project.""" + self.send_message( + "DELETE", + "Delete project", + f"{self.url}?resource-version={self.resource_version}" + ) |