Skip to content

feat: add nameserver management#8

Merged
adriangalilea merged 5 commits intoadriangalilea:mainfrom
cosmin:feature/custom-nameservers
Feb 3, 2026
Merged

feat: add nameserver management#8
adriangalilea merged 5 commits intoadriangalilea:mainfrom
cosmin:feature/custom-nameservers

Conversation

@cosmin
Copy link
Contributor

@cosmin cosmin commented Feb 2, 2026

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 ...
  • namecheap-cli dns reset-nameservers
  • namecheap-cli dns nameservers

Copilot AI review requested due to automatic review settings February 2, 2026 16:57
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>
@cosmin cosmin force-pushed the feature/custom-nameservers branch from 398d38d to 9148850 Compare February 2, 2026 17:02
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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(), and get_nameserver_info()
  • Added three new CLI commands: nameservers, set-nameservers, and reset-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.

Comment on lines 502 to 505
if isinstance(ns_data, str):
nameservers = [ns_data]
elif isinstance(ns_data, list):
nameservers = ns_data
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)}")

Copilot uses AI. Check for mistakes.
cosmin and others added 3 commits February 2, 2026 23:17
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
@adriangalilea
Copy link
Owner

Hey @cosmin, thanks for the contribution!

I pushed a cleanup commit on top of your branch. Here's what I changed:

  • get_nameserver_info()get_nameservers() — shorter, return type already says it's info
  • Returns a Nameservers Pydantic model (is_default: bool, nameservers: list[str]) instead of dict[str, Any] — consistent with how every other method in the SDK uses models
  • Replaced the silent fallback (if not result: return {…}) with an assert — if the API returns nothing, that's unexpected and we want to know
  • Replaced isinstance branching with assert + ternary
  • Replaced ValueError with assert for nameserver count/emptiness validation in set_custom_nameservers
  • Removed noise comments (# Parse domain, # Extract nameservers)
  • Added nameserver management section to README
  • Version bump to 1.1.0

Tested against live domains, everything works. Appreciate the PR!

@adriangalilea adriangalilea merged commit e308005 into adriangalilea:main Feb 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants