Forked from alfredocambera/cloudflare-list-zones-and-records.py
Created
August 28, 2023 19:10
-
-
Save ssstonebraker/6b00a6bb182ffd2c76774cae05ef768d to your computer and use it in GitHub Desktop.
Revisions
-
alfredocambera revised this gist
Jul 26, 2023 . 1 changed file with 9 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -10,15 +10,21 @@ per_page = 10 zones = cf.zones.get(params={'per_page': per_page, 'page': 0}) print(separator.join(["zone_id", "zone_name", "record_name", "record_type", "record_value", "record_id" ])) for zone_page in range(zones['result_info']['total_pages']): zones = cf.zones.get(params={'per_page': per_page, 'page': zone_page}) for zone in zones['result']: zone_id = zone['id'] zone_name = zone['name'] records = cf.zones.dns_records.get(zone['id'], params={'per_page': per_page, 'page': 1}) for record_page in range(1, records['result_info']['total_pages']+1): records = cf.zones.dns_records.get(zone['id'], params={'per_page': per_page, 'page': record_page})['result'] for record in records: print(separator.join([zone_id, zone_name, -
alfredocambera revised this gist
Jul 26, 2023 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,7 @@ #!/usr/bin/env python # prints all the records in all the zones in colums separated by ','. # It uses raw mode to handle pagination to iterate over zones and records import CloudFlare -
alfredocambera revised this gist
Jul 26, 2023 . 1 changed file with 23 additions and 16 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,22 +1,29 @@ #!/usr/bin/env python # prints all the records in all the zones in colums separated by ',' import CloudFlare separator="," cf = CloudFlare.CloudFlare(token='REPLACE_WITH_YOUR_OWN_CF_TOKEN', raw=True) per_page = 10 zones = cf.zones.get(params={'per_page': per_page, 'page': 0}) for zone_page in range(zones['result_info']['total_pages']): zones = cf.zones.get(params={'per_page': per_page, 'page': zone_page}) for zone in zones['result']: zone_id = zone['id'] zone_name = zone['name'] records = cf.zones.dns_records.get(zone['id'], params={'per_page': per_page, 'page': 1}) print(separator.join(["zone_id", "zone_name", "record_name", "record_type", "record_value", "record_id"])) for record_page in range(records['result_info']['total_pages']): records = cf.zones.dns_records.get(zone['id'], params={'per_page': per_page, 'page': record_page+1})['result'] for record in records: print(separator.join([zone_id, zone_name, record['name'], record['type'], record['content'], record['id'] ])) -
alfredocambera revised this gist
Jul 21, 2023 . 2 changed files with 22 additions and 12 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,12 +0,0 @@ This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ #!/usr/bin/env python # prints all the records in all the zones in colums separated by ~ so it can be easy imported into an .csv viewer import CloudFlare separator="~" cf = CloudFlare.CloudFlare(token='REPLACE_WITH_YOUR_OWN_TOKEN') zones = cf.zones.get() for zone in zones: zone_id = zone['id'] zone_name = zone['name'] print(separator.join(["zone_id", "zone_name", "record_name", "record_type", "record_value", "record_id"])) for record in cf.zones.dns_records.get(zone['id'], params={'per_page':50}): print(separator.join([zone_id, zone_name, record['name'], record['type'], record['content'], record['id'] ])) -
alfredocambera revised this gist
Jul 20, 2023 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -5,8 +5,8 @@ cf = CloudFlare.CloudFlare(token='REPLACE_WITH_YOUR_OWN_TOKEN') zones = cf.zones.get() for zone in zones: zone_id = zone['id'] zone_name = zone['name'] print(f"zone_id: {zone_id}, zone_name: {zone_name}") for record in cf.zones.dns_records.get(zone['id'], params={'per_page':100}): print(f"name: {record['name']}, type: {record['type']}, value: {record['content']}, id: {record['id']}") -
alfredocambera created this gist
Jul 12, 2023 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,12 @@ #!/usr/bin/env python import CloudFlare cf = CloudFlare.CloudFlare(token='REPLACE_WITH_YOUR_OWN_TOKEN') zones = cf.zones.get() for zone in zones: zone_id = zone['id'] zone_name = zone['name'] print(f"zone_id: {zone_id}, zone_name: {zone_name}") for record in cf.zones.dns_records.get(zone['id'], params={'per_page':100}): print(f"name: {record['name']}, type: {record['type']}, value: {record['content']}, id: {record['id']}")