From 97ef1a96d68f4bd49095303a49c8bfd9b50d729c Mon Sep 17 00:00:00 2001 From: Peter Razumovsky Date: Tue, 18 Aug 2015 17:19:12 +0300 Subject: [PATCH] Add info about refactored handle_delete to doc Add information that now implementing of handle_delete is optional, if it's satisfy required format. Change-Id: I36bf3d8fcd2e15dca8180a6f857056586c89eca9 --- doc/source/pluginguide.rst | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/doc/source/pluginguide.rst b/doc/source/pluginguide.rst index d794b83e2..6e84e2b05 100644 --- a/doc/source/pluginguide.rst +++ b/doc/source/pluginguide.rst @@ -47,7 +47,7 @@ delete The plug-in should delete the physical resource. The base class ``Resource`` implements each of these life cycle methods and -defines one or more handler methods that plug-ins should implement in order +defines one or more handler methods that plug-ins can implement in order to manifest and manage the actual physical resource abstracted by the plug-in. These handler methods will be described in detail in the following sections. @@ -459,6 +459,27 @@ Delete :return: a token containing sufficient data to verify the operations status :raise: any ``Exception`` if the delete operation failed + .. note:: + As of the Liberty release, implementing handle_delete is optional. The + parent resource class can handle the most common pattern for deleting + resources: + + .. code-block:: python + + def handle_delete(self): + if self.resource_id is not None: + try: + self.client()..delete(self.resource_id) + except Exception as ex: + self.client_plugin().ignore_not_found(ex) + return None + return self.resource_id + + For this to work for a particular resource, the `entity` and + `default_client_name` attributes must be overridden in the resource + implementation. For example, `entity` of Ceilometer Alarm should equals + to "alarms" and `default_client_name` to "ceilometer". + .. py:function:: handle_delete_snapshot(self, snapshot) Delete resource snapshot.