Mark the v1 API Client as deprecated

As the v1 API is scheduled for removal, we should warn users

Change-Id: I6e2570db0dd392389cc54aee816ad8b9aee1a0dd
This commit is contained in:
Graham Hayes 2016-06-29 15:54:49 +01:00
parent afa50f4ccf
commit 4570af9773
2 changed files with 23 additions and 1 deletions

View File

@ -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:

View File

@ -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"""