-
Notifications
You must be signed in to change notification settings - Fork 26
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
Draft
soniafrancisNS1
wants to merge
16
commits into
master
Choose a base branch
from
PENG-7708-python-sdk-zoneexport
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
9d7c48b
Add zone export functionality
soniafrancisNS1 12d4ad1
zone name
soniafrancisNS1 9d1500d
ruff formatting
soniafrancisNS1 f0d21b1
Fix black formatting for zone export code
soniafrancisNS1 c2b75da
Add put and get endpoints in sdk
soniafrancisNS1 2e7ecac
Address PR review feedback - rename methods, consolidate export logic…
soniafrancisNS1 ccb6000
Fix black formatting for zones.py
soniafrancisNS1 ca1896b
Update unit tests to use renamed zone export methods
soniafrancisNS1 c04cadf
add error handling, update status check to COMPLETED, update copyright
soniafrancisNS1 8cb5012
fixed the api endpoint
soniafrancisNS1 421d382
lint format
soniafrancisNS1 f371731
black format
soniafrancisNS1 5161c1d
fix err messages
soniafrancisNS1 f7d7251
copyright update
soniafrancisNS1 477bb68
err handling
soniafrancisNS1 f411f8b
Removed unused ResourceException import
soniafrancisNS1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 characters
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 characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| # | ||
| # 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 | ||
| output_file = f"{zone_name}.txt" | ||
| with open(output_file, "w") as f: | ||
| f.write(zone_file) | ||
| print(f"Zone file saved to {output_file}") | ||
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 characters
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 characters
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 characters
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 characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add more to the example? This example just assumes the other endpoints have been called.
It needs to initiate the export; then poll the status until it gets a complete status; then to download the file.