-
Notifications
You must be signed in to change notification settings - Fork 27
PENG-7708-python-sdk-zoneexport #145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
9d7c48b
12d4ad1
9d1500d
f0d21b1
c2b75da
2e7ecac
ccb6000
ca1896b
c04cadf
8cb5012
421d382
f371731
5161c1d
f7d7251
477bb68
f411f8b
ee5a7c9
b0c9c5c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| # | ||
| # Copyright IBM Corp. 2026 | ||
| # | ||
| # License under The MIT License (MIT). See LICENSE in project root. | ||
| # | ||
|
|
||
| from ns1 import NS1 | ||
|
|
||
| # NS1 will use config in ~/.nsone by default | ||
| api = NS1() | ||
|
|
||
| # to specify an apikey here instead, use: | ||
| # api = NS1(apiKey='<<CLEARTEXT API KEY>>') | ||
|
|
||
| # to load an alternate configuration file: | ||
| # api = NS1(configFile='/etc/ns1/api.json') | ||
|
|
||
| # Define the zone to export | ||
| zone_name = "example.com" | ||
|
|
||
| # Export a zone to BIND format | ||
| # The export() method will: | ||
| # 1. Initiate the export job | ||
| # 2. Poll the status until complete or failed | ||
| # 3. Download and return the zone file content | ||
| zone = api.loadZone(zone_name) | ||
|
|
||
| print(f"Exporting zone {zone_name}...") | ||
| zone_file = zone.export() | ||
| print("Export complete!") | ||
| print(zone_file) | ||
|
|
||
| # Save to a file | ||
| with open("example.com.txt", "w") as f: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, too late 😞 Thanks for catching that; I thought the file had been renamed too. Let's fix it in the next release. |
||
| f.write(zone_file) | ||
| print("Zone file saved to example.com.txt") | ||
Uh oh!
There was an error while loading. Please reload this page.