Skip to content

Commit

Permalink
remove --api option and leave --openapi in place
Browse files Browse the repository at this point in the history
  • Loading branch information
mahtin committed May 21, 2023
1 parent 6d6dd33 commit 74f1999
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 37 deletions.
7 changes: 0 additions & 7 deletions CloudFlare/cloudflare.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""

Expand Down
13 changes: 0 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 ; \
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 ...

```

Expand Down
13 changes: 2 additions & 11 deletions cli4/cli4.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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] '
Expand All @@ -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'
Expand Down Expand Up @@ -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'):
Expand All @@ -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)
Expand Down
7 changes: 2 additions & 5 deletions cli4/dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 74f1999

Please sign in to comment.