From 4570af9773fe56187efd9b848590b3f6e3d00131 Mon Sep 17 00:00:00 2001 From: Graham Hayes Date: Wed, 29 Jun 2016 15:54:49 +0100 Subject: [PATCH] Mark the v1 API Client as deprecated As the v1 API is scheduled for removal, we should warn users Change-Id: I6e2570db0dd392389cc54aee816ad8b9aee1a0dd --- designateclient/cli/base.py | 14 +++++++++++++- designateclient/v1/__init__.py | 10 ++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/designateclient/cli/base.py b/designateclient/cli/base.py index bf5a894..0ff36f4 100644 --- a/designateclient/cli/base.py +++ b/designateclient/cli/base.py @@ -14,6 +14,7 @@ # License for the specific language governing permissions and limitations # under the License. import abc +import warnings from cliff.command import Command as CliffCommand from cliff.lister import Lister @@ -29,6 +30,17 @@ from designateclient.v1 import Client @six.add_metaclass(abc.ABCMeta) class Command(CliffCommand): def run(self, parsed_args): + + warnings.simplefilter('once', category=DeprecationWarning) + warnings.warn( + 'The "designate" CLI is being deprecated in favour of the ' + '"openstack" CLI plugin. All designate API v2 commands are ' + 'implemented there. When the v1 API is removed this CLI will ' + 'stop functioning', + DeprecationWarning) + warnings.resetwarnings() + warnings.simplefilter('ignore', category=DeprecationWarning) + self.client = Client( region_name=self.app.options.os_region_name, service_type=self.app.options.os_service_type, @@ -37,7 +49,7 @@ class Command(CliffCommand): all_tenants=self.app.options.all_tenants, edit_managed=self.app.options.edit_managed, endpoint=self.app.options.os_endpoint) - + warnings.resetwarnings() try: return super(Command, self).run(parsed_args) except exceptions.RemoteError as e: diff --git a/designateclient/v1/__init__.py b/designateclient/v1/__init__.py index 8fb0001..2474a4e 100644 --- a/designateclient/v1/__init__.py +++ b/designateclient/v1/__init__.py @@ -13,6 +13,7 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. +from debtcollector import removals from stevedore import extension from designateclient import exceptions @@ -20,6 +21,15 @@ from designateclient import utils from designateclient import version +@removals.removed_class( + 'designateclient.v1.Client', + replacement='designateclient.v2.client.Client', + message='Designate v1 API is being retired, and the v1 Client class will ' + 'stop functioning. Please update code to the ' + 'designateclient.v2.client.Client class. The API is deprecated', + version='2.2.0', + removal_version='?', + stacklevel=3) class Client(object): """Client for the Designate v1 API"""