summaryrefslogtreecommitdiffstats
path: root/awxkit
diff options
context:
space:
mode:
authorRyan Petrello <rpetrell@redhat.com>2019-10-16 18:03:16 +0200
committerRyan Petrello <rpetrell@redhat.com>2019-10-16 21:26:59 +0200
commitc8a29bac66b292abaa144f5a1b92bd10fdef8ee5 (patch)
tree93cfd97c5d189b4b34fe201901f7b5f56a903e68 /awxkit
parentMerge pull request #5020 from ryanpetrello/devel (diff)
downloadawx-c8a29bac66b292abaa144f5a1b92bd10fdef8ee5.tar.xz
awx-c8a29bac66b292abaa144f5a1b92bd10fdef8ee5.zip
warn about endpoint deprecation in the CLI
Diffstat (limited to 'awxkit')
-rwxr-xr-xawxkit/awxkit/cli/client.py8
-rw-r--r--awxkit/awxkit/cli/options.py10
2 files changed, 15 insertions, 3 deletions
diff --git a/awxkit/awxkit/cli/client.py b/awxkit/awxkit/cli/client.py
index ed7408f177..6ccef0f12f 100755
--- a/awxkit/awxkit/cli/client.py
+++ b/awxkit/awxkit/cli/client.py
@@ -15,7 +15,7 @@ from .format import (add_authentication_arguments,
from .options import ResourceOptionsParser, UNIQUENESS_RULES
from .resource import parse_resource, is_control_resource
from awxkit import api, config, utils, exceptions, WSClient # noqa
-from awxkit.cli.utils import HelpfulArgumentParser, cprint, disable_color
+from awxkit.cli.utils import HelpfulArgumentParser, cprint, disable_color, colored
from awxkit.awx.utils import uses_sessions # noqa
@@ -233,6 +233,12 @@ class CLI(object):
# parse the action from OPTIONS
parser = ResourceOptionsParser(self.v2, page, self.resource, subparsers)
+ if parser.deprecated:
+ description = 'This resource has been deprecated and will be removed in a future release.'
+ if not from_sphinx:
+ description = colored(description, 'yellow')
+ self.subparsers[self.resource].description = description
+
if from_sphinx:
# Our Sphinx plugin runs `parse_action` for *every* available
# resource + action in the API so that it can generate usage
diff --git a/awxkit/awxkit/cli/options.py b/awxkit/awxkit/cli/options.py
index 5156482df9..c303154827 100644
--- a/awxkit/awxkit/cli/options.py
+++ b/awxkit/awxkit/cli/options.py
@@ -68,6 +68,8 @@ def pk_or_name(v2, model_name, value, page=None):
class ResourceOptionsParser(object):
+ deprecated = False
+
def __init__(self, v2, page, resource, parser):
"""Used to submit an OPTIONS request to the appropriate endpoint
and apply the appropriate argparse arguments
@@ -94,9 +96,13 @@ class ResourceOptionsParser(object):
self.handle_custom_actions()
def get_allowed_options(self):
- self.allowed_options = self.page.connection.options(
+ options = self.page.connection.options(
self.page.endpoint + '1/'
- ).headers.get('Allow', '').split(', ')
+ )
+ warning = options.headers.get('Warning', '')
+ if '299' in warning and 'deprecated' in warning:
+ self.deprecated = True
+ self.allowed_options = options.headers.get('Allow', '').split(', ')
def build_list_actions(self):
action_map = {