forked from cloudflare-api/python-cloudflare-v4
-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add openapi support, added tuna for testing
- Loading branch information
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,8 @@ TWINE = twine | |
EMAIL = "[email protected]" | ||
NAME = "cloudflare" | ||
|
||
OPENAPI_URL = "https://github.com/cloudflare/api-schemas/raw/main/openapi.json" | ||
|
||
#all: README.rst CHANGELOG.md build | ||
all: CHANGELOG.md build | ||
|
||
|
@@ -103,6 +105,33 @@ api: | |
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 ; \ | ||
$(PYTHON) -m cli4 --openapi $(OPENAPI_URL) | 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.? | ||
|
||
TUNA_CLI4_TEST_COMMAND = "/ips" | ||
TUNA_CLI4_TEST_COMMAND = "--openapi http://localhost/~martin/openapi.json" | ||
TUNA_CLI4_TEST_COMMAND = "--api" | ||
TUNA_CLI4_TEST_COMMAND = "--openapi $(OPENAPI_URL)" | ||
|
||
tuna: | ||
@tmp=/tmp/_$$$$_ ; \ | ||
$(PYTHON) -X importtime -m cli4 $(TUNA_CLI4_TEST_COMMAND) > /dev/null 2> $$tmp.1 ; \ | ||
tuna $$tmp.1 2> /dev/null & \ | ||
tunapid=$$! ; \ | ||
sleep 1 ; \ | ||
kill $$tunapid ; \ | ||
rm $$tmp.? | ||
|
||
clean: | ||
rm -rf build | ||
rm -rf dist | ||
|