diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/onapsdk/sdc/sdc_element.py | 22 | ||||
-rw-r--r-- | src/onapsdk/sdc/sdc_resource.py | 16 |
2 files changed, 38 insertions, 0 deletions
diff --git a/src/onapsdk/sdc/sdc_element.py b/src/onapsdk/sdc/sdc_element.py index df513b7..b2d27bd 100644 --- a/src/onapsdk/sdc/sdc_element.py +++ b/src/onapsdk/sdc/sdc_element.py @@ -175,6 +175,16 @@ class SdcElement(SdcOnboardable, ABC): """ return "{}/{}".format(cls._base_url(), cls._sdc_path()) + @property + def delete_url(self) -> str: + """Get an url to delete element. + + Returns: + str: Url which can be used to delete SDC element + + """ + return f"{self._get_all_url}/{self.identifier}" + def _copy_object(self, obj: 'SdcElement') -> None: """ Copy relevant properties from object. @@ -225,3 +235,15 @@ class SdcElement(SdcOnboardable, ABC): """ raise NotImplementedError("SdcElement is an abstract class") + + def delete(self) -> None: + """Delete SDC element. + + Send a request to SDC to delete that element. + + """ + self.send_message( + "DELETE", + "Delete SDC element", + self.delete_url + ) diff --git a/src/onapsdk/sdc/sdc_resource.py b/src/onapsdk/sdc/sdc_resource.py index 7e7dbb9..29615db 100644 --- a/src/onapsdk/sdc/sdc_resource.py +++ b/src/onapsdk/sdc/sdc_resource.py @@ -958,3 +958,19 @@ class SdcResource(SdcOnboardable, ABC): # pylint: disable=too-many-instance-att return None msg = f"Can't add resource to {self.origin_type} which is not in DRAFT status" raise StatusError(msg) + + def archive(self) -> None: + """Archive resource.""" + self.send_message( + "POST", + f"Archive {self.name} component", + f"{self.resource_inputs_url}/archive" + ) + + def delete(self) -> None: + """Delete resource.""" + self.send_message( + "DELETE", + f"Delete {self.name} component", + f"{self.resource_inputs_url}" + ) |