feat: add nameserver management#8
Conversation
Add support for setting and querying custom nameservers for domains. Library API: - nc.dns.set_custom_nameservers(domain, nameservers) - switch to custom NS - nc.dns.set_default_nameservers(domain) - reset to Namecheap BasicDNS - nc.dns.get_nameserver_info(domain) - get current NS configuration CLI commands: - namecheap-cli dns set-nameservers <domain> <ns1> <ns2> ... - namecheap-cli dns reset-nameservers <domain> - namecheap-cli dns nameservers <domain>
398d38d to
9148850
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds support for managing custom nameservers for domains through both the library API and CLI commands. The implementation allows users to switch between Namecheap's default BasicDNS and custom nameservers (e.g., Route 53, Cloudflare).
Changes:
- Added three new DNS API methods:
set_custom_nameservers(),set_default_nameservers(), andget_nameserver_info() - Added three new CLI commands:
nameservers,set-nameservers, andreset-nameservers - Updated pending.md to document the newly implemented nameserver management features
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/namecheap/_api/dns.py | Adds three API methods for managing domain nameservers - setting custom nameservers, resetting to defaults, and querying current configuration |
| src/namecheap_cli/main.py | Implements three CLI commands for nameserver management with confirmation prompts, progress indicators, and formatted output |
| pending.md | Documents the implemented nameserver management functionality and marks it as complete |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/namecheap/_api/dns.py
Outdated
| if isinstance(ns_data, str): | ||
| nameservers = [ns_data] | ||
| elif isinstance(ns_data, list): | ||
| nameservers = ns_data |
There was a problem hiding this comment.
The handling of ns_data does not account for all possible types returned by the API. While the code handles string and list types, if ns_data is a dict or another type (which can occur with certain XML parsing edge cases), nameservers will remain an empty list without any indication of the issue. Consider adding an else clause to handle unexpected types or log a warning, for example: else: logger.warning(f"Unexpected nameserver data type: {type(ns_data)}")
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- get_nameserver_info() → get_nameservers() returning Nameservers model - Replace defensive code with asserts - Add Nameservers Pydantic model (is_default, nameservers) - Add nameserver management docs to README - Clarify Domain NS API (glue records) vs nameserver switching in pending.md - Sync version to 1.1.0 across pyproject.toml and __init__.py
|
Hey @cosmin, thanks for the contribution! I pushed a cleanup commit on top of your branch. Here's what I changed:
Tested against live domains, everything works. Appreciate the PR! |
Add support for setting and querying custom nameservers for domains.
Library API:
CLI commands: