forked from cloudflare/python-cloudflare
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
32 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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env python | ||
"""Cloudflare API code - example""" | ||
|
||
import os | ||
import sys | ||
|
||
sys.path.insert(0, os.path.abspath('..')) | ||
import CloudFlare | ||
|
||
def main(): | ||
"""Cloudflare API code - example""" | ||
|
||
# Grab the first argument, if there is one | ||
try: | ||
zone_name = sys.argv[1] | ||
params = {'name':zone_name, 'per_page':1} | ||
except IndexError: | ||
params = {'per_page':50} | ||
|
||
# | ||
# Show how 'with' statement works | ||
# | ||
with CloudFlare.CloudFlare() as cf: | ||
zones = cf.zones(params=params) | ||
for zone in sorted(zones, key=lambda v: v['name']): | ||
print zone['id'], zone['name'] | ||
|
||
exit(0) | ||
|
||
if __name__ == '__main__': | ||
main() | ||
|