From 74f19994c75e08a869eca9ac7aac4e109549a5b0 Mon Sep 17 00:00:00 2001 From: Martin Levy Date: Sun, 21 May 2023 10:25:41 -0700 Subject: [PATCH] remove --api option and leave --openapi in place --- CloudFlare/cloudflare.py | 7 ------- Makefile | 13 ------------- README.md | 2 +- cli4/cli4.py | 13 ++----------- cli4/dump.py | 7 ++----- 5 files changed, 5 insertions(+), 37 deletions(-) diff --git a/CloudFlare/cloudflare.py b/CloudFlare/cloudflare.py index e364087..de656dd 100644 --- a/CloudFlare/cloudflare.py +++ b/CloudFlare/cloudflare.py @@ -539,13 +539,6 @@ def _call_unwrapped(self, method, headers, parts, identifiers, params, data, fil result = response_data return result - def api_from_web(self): - """ Cloudflare v4 API""" - - # base url isn't enough; we need less - url = '/'.join(self.base_url.split('/')[0:3]) - return self._read_from_web(url) - def api_from_openapi(self, url): """ Cloudflare v4 API""" diff --git a/Makefile b/Makefile index 4bbfcba..8d094fc 100644 --- a/Makefile +++ b/Makefile @@ -92,19 +92,6 @@ sign: lint: $(PYLINT) CloudFlare cli4 -api: - @tmp=/tmp/_$$$$_ ; \ - $(PYTHON) -m cli4 --dump | sort > $$tmp.1 ; \ - $(PYTHON) -m cli4 --api | sed -e 's/^[A-Z][A-Z]* *//' -e 's/?.*//' -e 's/\/:[a-z][A-Za-z_]*/\/:id/g' -e 's/\/:[a-z][A-Za-z_]*}/\/:id/g' -e 's/:id\/:id/:id/' -e 's/\/:id$$//' -e 's/\/:id$$//' -e 's/\/:id ;/ ;/' -e 's/\/$$//' | sort -u > $$tmp.2 ; \ - egrep -v '; deprecated' < $$tmp.2 | diff $$tmp.1 - > $$tmp.3 ; \ - echo "In code:" ; \ - egrep '< ' < $$tmp.3 | sed -e 's/< / /' | sort | tee $$tmp.4 ; \ - echo "In docs:" ; \ - egrep '> ' < $$tmp.3 | sed -e 's/> / /' | sort | sed -e "s/\//self.add('AUTH', '/" -e "s/$$/'\)/" -e "s/\/:id\//', '/g" ; \ - echo "Deprecated:" ; \ - egrep '; deprecated' < $$tmp.2 | while read cmd x deprecated deprecated_date ; do egrep "$$cmd" $$tmp.4 | sed -e "s/$$/ ; deprecated $$deprecated_date/" ; done | sort | uniq ; \ - rm $$tmp.? - openapi: @tmp=/tmp/_$$$$_ ; \ $(PYTHON) -m cli4 --dump | sort > $$tmp.1 ; \ diff --git a/README.md b/README.md index 0a4c20d..3feedb6 100644 --- a/README.md +++ b/README.md @@ -561,7 +561,7 @@ All API calls can be called from the command line. The command will convert domain names prefixed with a colon (`:`) into zone_identifiers: e.g. to view `example.com` you must use `cli4 /zones/:example.com` (the zone ID cannot be used). ```bash -$ cli4 [-V|--version] [-h|--help] [-v|--verbose] [-q|--quiet] [-j|--json] [-y|--yaml] [-r|--raw] [-d|--dump] [--get|--patch|--post|--put|--delete] [item=value ...] /command... +$ cli4 [-V|--version] [-h|--help] [-v|--verbose] [-q|--quiet] [-j|--json] [-y|--yaml] [-n|ndjson] [-r|--raw] [-d|--dump] [-A|--openapi url] [-b|--binary] [-p|--profile profile-name] [--get|--patch|--post|--put|--delete] [item=value|item=@filename|@filename ...] /command ... ``` diff --git a/cli4/cli4.py b/cli4/cli4.py index 291bbf1..3ee3e09 100644 --- a/cli4/cli4.py +++ b/cli4/cli4.py @@ -367,7 +367,6 @@ def do_it(args): output = 'json' raw = False dump = False - dump_from_web = False openapi_url = None binary_file = False profile = None @@ -378,7 +377,6 @@ def do_it(args): + '[-j|--json] [-y|--yaml] [-n|ndjson] ' + '[-r|--raw] ' + '[-d|--dump] ' - + '[-a|--api] ' + '[-A|--openapi url] ' + '[-b|--binary] ' + '[-p|--profile profile-name] ' @@ -388,12 +386,12 @@ def do_it(args): try: opts, args = getopt.getopt(args, - 'VhvqjyrdaA:bp:GPOUD', + 'VhvqjyrdA:bp:GPOUD', [ 'version', 'help', 'verbose', 'quiet', 'json', 'yaml', 'ndjson', 'raw', - 'dump', 'api', 'openapi=', + 'dump', 'openapi=', 'binary', 'profile=', 'get', 'patch', 'post', 'put', 'delete' @@ -427,8 +425,6 @@ def do_it(args): profile = arg elif opt in ('-d', '--dump'): dump = True - elif opt in ('-a', '--api'): - dump_from_web = True elif opt in ('-A', '--openapi'): openapi_url = arg elif opt in ('-b', '--binary'): @@ -454,11 +450,6 @@ def do_it(args): sys.stdout.write(a) sys.exit(0) - if dump_from_web: - a = dump_commands_from_web(cf) - sys.stdout.write(a) - sys.exit(0) - if openapi_url: a = dump_commands_from_web(cf, openapi_url) sys.stdout.write(a) diff --git a/cli4/dump.py b/cli4/dump.py index dc68b3e..c94d243 100644 --- a/cli4/dump.py +++ b/cli4/dump.py @@ -5,12 +5,9 @@ def dump_commands(cf): w = cf.api_list() return '\n'.join(w) + '\n' -def dump_commands_from_web(cf, url=None): +def dump_commands_from_web(cf, url): """dump a tree of all the known API commands - from web""" - if url: - w = cf.api_from_openapi(url) - else: - w = cf.api_from_web() + w = cf.api_from_openapi(url) a = [] for r in w: