Skip to content

Commit

Permalink
do something useful with api listing
Browse files Browse the repository at this point in the history
  • Loading branch information
mahtin committed Sep 15, 2022
1 parent 4d7962d commit 4f63908
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions examples/example_list_api_from_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,32 @@ def main():

cf = CloudFlare.CloudFlare()
try:
r = cf.api_from_web()
found_comands= cf.api_from_web()
except Exception as e:
exit('api_from_web: - %s - api call connection failed' % (e))

print(json.dumps(r))
exit(0)
cmds = {}
for r in found_comands:
if r['deprecated'] or r['deprecated_already']:
continue
cmd = r['cmd']
action = r['action']
if cmd not in cmds:
cmds[cmd] = {}
cmds[cmd][action] = action

# This produces something like this ...
# GET - - PATCH - /zones/:zone_identifier/settings/always_online
# GET - PUT PATCH DELETE /zones/:zone_identifier/waiting_rooms/:waiting_room_id

for cmd in cmds.keys():
p = ''
for method in ['GET', 'POST', 'PUT', 'PATCH', 'DELETE']:
if method in cmds[cmd]:
p += '%-7s' % method
else:
p += '%-7s' % '-'
print("%s %s" % (p, cmd))

if __name__ == '__main__':
main()
Expand Down

0 comments on commit 4f63908

Please sign in to comment.