Skip to content

feat: migrate domain & dns commands to the v3 Domains API - #76

Merged
jpage-godaddy merged 25 commits into
rust-portfrom
v3-apis
Jul 6, 2026
Merged

jpage-godaddy merged 25 commits into
rust-portfrom
v3-apis

Conversation

@jpage-godaddy

@jpage-godaddy jpage-godaddy commented Jul 1, 2026 •

Copy link
Copy Markdown
Collaborator

What

Migrates the domain and dns command groups from the v1/v2 Domains API to the v3 Domain Lifecycle Management API, keeping v1 only for the two operations v3 still doesn't serve (domain list, agreements).

Highlights

  • domains-client: single generated client over one host, built from a merged OAS3 spec — the vendored v3 bundle plus the retained v1 operations (prefixed V1) — via merge-spec.py + trim-spec.py. build.rs stays hermetic.
  • domain: available / suggest / get / quote / purchase / nameservers set on v3. Each subcommand lives in its own module under src/domain/, with shared helpers in common.rs.
  • Strict two-step registration: domain quote locks a price and caches the quote locally (src/quote_cache.rs); domain purchase --quote-token <tok> --agree --confirm accepts that exact quote (no re-quote → charges the reviewed price), records consent, registers, and polls the async operation. A single idempotency key is minted at quote time and reused across purchase retries.
  • dns fully on v3: list (paginated GET with type/name filters), add (create), set, and delete all use /v3/domains/zones/{zone}/dns-records. v3 keys replace/delete on a server recordId, so set reconciles in place (reuse ids, delete surplus, create shortfall) and delete lists-then-deletes each — both report per record (non-atomic). This also unlocks CAA (new --flag/--tag) and ALIAS across the DNS commands. The retained v1 DNS record ops were dropped.
  • OAuth-only: removed the sso-key dual-mode auth entirely (API keys are deprecated at launch) — GoDaddyAuthProvider is the sole provider.
  • Central OAuth scope registry (src/scopes.rs), drawn from by every command. Read scopes (apps.app-registry:read, domains.domain:read) are granted at login; write scopes are declared per-command and requested on demand (OAuth step-up) — e.g. the app-registry mutations declare apps.app-registry:write themselves rather than defaulting it into every login.
  • ISO-4217 minor-unit money formatting (via iso_currency); contacts.toml mapped to the v3 Contact shape.
  • cli-engine 0.3.5: next_actions now render as a "Next steps" footer in human output.

Notes

  • Re-vendoring the v3 spec for the DNS work also picked up an upstream Suggestion schema change (listPrice/renewalPrice → prices[]); domain suggest was adapted to surface the headline term price (unchanged output field).

Testing

  • cargo fmt --check, cargo clippy --workspace --all-targets -- -D warnings (clean), cargo test --workspace (all pass).
  • Verified live (test env): domain quote → purchase registers a domain (status: ACTIVE). Live DNS-v3 checks (dns add --type CAA …, list/set/delete) are pending an authenticated test-env run.

🤖 Generated with Claude Code

Migrate the `domain` and `dns` command groups from the v1/v2 Domains API to
the v3 Domain Lifecycle Management API, keeping v1 only where v3 has no
equivalent yet.

- domains-client: regenerate from a merged OAS3 spec (vendored v3 bundle +
  retained v1 ops, V1-prefixed) via new merge-spec.py / reworked trim-spec.py.
- domain: available/suggest/get/quote/purchase/nameservers on v3; list +
  agreements stay on v1. Split each subcommand into its own module under
  src/domain/, with shared helpers in common.rs.
- Strict two-step registration: `domain quote` locks a price + caches the quote
  (src/quote_cache.rs); `domain purchase --quote-token` accepts it, records
  consent, registers, and polls the async operation.
- Central OAuth scope registry (src/scopes.rs) the client must mirror.
- ISO-4217 minor-unit money formatting (iso_currency); contacts.toml mapped to
  the v3 Contact shape.
- Fixes: suggest --limit panic, register response parsing (writeOnly quoteToken),
  QUOTE_MISMATCH from not re-sending the quoted profile.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot wasn't able to review this pull request because it exceeds the maximum number of lines (20,000). Try reducing the number of changed lines and requesting a review from Copilot again.

@jpage-godaddy
jpage-godaddy changed the base branch from main to rust-port July 1, 2026 23:05
@jpage-godaddy
jpage-godaddy requested a review from Copilot July 1, 2026 23:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 24 out of 26 changed files in this pull request and generated 2 comments.

Comment thread rust/src/environments/mod.rs Resolved
Comment thread rust/src/domain/quote.rs Resolved
…ofile

Address Copilot review on #76:

- application commands: the 7 app-registry-mutating commands (init, update,
  enable, disable, archive, release, deploy) now declare
  [apps.app-registry:read, apps.app-registry:write] via with_scopes, so the
  write scope is requested on demand (OAuth step-up) rather than granted at
  every login. DEFAULT_OAUTH_SCOPES stays read-only — app-registry writes are
  a rarely-used operation for most customers.
- domain quote: build_profile now returns InlineRegistrationProfile directly
  (it always produced Some(..)); dropped the misleading Option and corrected
  the doc comment.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 25 out of 27 changed files in this pull request and generated 5 comments.

Comment thread rust/src/quote_cache.rs Resolved
Comment thread rust/src/quote_cache.rs Resolved
Comment thread rust/src/dns/mod.rs Resolved
Comment thread rust/domains-client/src/lib.rs Resolved
Comment thread rust/domains-client/src/lib.rs Resolved
Address Copilot re-review on #76 (all doc/test clarity, no behavior change):

- quote_cache: module + Lookup::Found docs referenced a 'take' that consumes;
  the API is read-only get() + remove()-after-success. Reworded to match.
- dns v3_records: doc said SRV/MX fields are 'clamped' to u16; they're converted
  via u16::try_from (out-of-range -> None), and clap already bounds them.
- domains-client tests: availability/quote mock 'value's used the v1 micro-unit
  scale (11_990_000 / 23_980_000); v3 money is ISO-4217 minor units, so use
  1199 / 2398 to match format_money and keep the contract clear.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 25 out of 27 changed files in this pull request and generated 5 comments.

Comment thread rust/src/scopes.rs Resolved
Comment thread rust/src/dns/mod.rs Resolved
Comment thread rust/domains-client/src/lib.rs Resolved
Comment thread rust/domains-client/src/lib.rs Resolved
Comment thread rust/domains-client/src/lib.rs Resolved
…o spec

Address Copilot re-review round 2 on #76 (docs/tests, no behavior change):

- scopes: APP_REGISTRY_WRITE docstring still said 'requested at login by
  default'; corrected to describe the on-demand step-up (declared per-command
  by the application mutations), matching the round-1 default-scope change.
- domains-client tests: the register fixtures used consent actor type SHOPPER,
  which isn't a documented ConsentActorType; switched to DIRECT to match what
  production (domain purchase) sends and the spec's documented values.

Not changed: adding CAA to the DNS record-type allowlist. The pre-migration
allowlist was A/AAAA/CNAME/MX/NS/SOA/SRV/TXT (no CAA), so this migration
preserves parity; proper CAA support also needs --flag/--tag plumbing that's
out of scope here. Tracked as a follow-up.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 25 out of 27 changed files in this pull request and generated 5 comments.

Comment thread rust/src/domain/purchase.rs Resolved
Comment thread rust/src/domain/purchase.rs Resolved
Comment thread rust/src/contacts/mod.rs Resolved
Comment thread rust/src/domain/available.rs Resolved
Comment thread rust/src/domain/suggest.rs Resolved
…e/suggest

Address Copilot re-review round 3 on #76:

- purchase: fail fast when a cached quote's profile can't be deserialized
  (was silently dropped -> confusing server-side QUOTE_MISMATCH); clear
  re-quote message instead.
- purchase: check the cached quote's agreement types are non-empty *before*
  the --agree gate, so a corrupt/empty cache yields one accurate 're-quote'
  error rather than a 'requires agreeing…' prompt with an empty list that a
  rerun can't satisfy. Regression test added.
- domain available / suggest: replace with_json_schema::<Availability/Suggestion>
  (raw API types) with explicit output_schema! matching the transformed JSON
  the handlers actually emit (formatted price/currency strings, headline term,
  listPrice), so --schema/help field metadata is accurate.
- contacts: validate_country doc clarified — it checks the ISO-3166 alpha-2
  *shape* (e.g. ZZ passes), not list membership; the API validates the code.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 25 out of 27 changed files in this pull request and generated 7 comments.

Comment thread rust/src/domain/available.rs Resolved
Comment thread rust/src/domain/available.rs Resolved
Comment thread rust/src/domain/suggest.rs Resolved
Comment thread rust/src/domain/quote.rs Resolved
Comment thread rust/src/domain/quote.rs Resolved
Comment thread rust/src/domain/purchase.rs Resolved
Comment thread rust/src/domain/purchase.rs Resolved
…rchase/available/suggest)

Address Copilot re-review round 4 on #76 (--schema/help accuracy, no runtime change):

- available: price/currency/renewalPrice/period marked optional (emitted only
  when the API returns a headline price).
- suggest: listPrice marked optional.
- quote: DomainQuoteResult completed to mirror quote_to_json (added
  renewalPrice/expiresAt/irreversible/agreements/requiredAgreements/resolved)
  with the conditional fields marked optional.
- purchase: operationId/price/currency marked optional.

Deliberately not changing the runtime JSON to omit null keys: whether the CLI
should emit explicit null vs. omit absent keys is a CLI-wide output-convention
decision (it affects every command's json! output, not just these four), so it
belongs in a dedicated change rather than this migration. Marking the schema
fields optional already makes --schema/help accurate for both shapes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 25 out of 27 changed files in this pull request and generated 3 comments.

Comment thread rust/src/domain/contacts.rs Resolved
Comment thread rust/src/domain/mod.rs Resolved
Comment thread rust/src/domain/nameservers.rs Resolved
…ema optionality

Address Copilot re-review round 5 on #76 (help/schema accuracy, no runtime change):

- domain contacts: group help said contacts.toml is for 'domain purchase' only;
  the two-step flow reads it at quote time and binds it into the token, so the
  help now says edit-and-re-quote to change contacts.
- domain group help: noted that 'nameservers set' needs domains.nameserver:update
  (previously only read + create scopes were mentioned).
- nameservers: operationId/status marked optional in NameserversResult (they're
  serialized from Option values from the async operation).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@jpage-godaddy
jpage-godaddy requested a review from Copilot July 2, 2026 00:33
Address Copilot review on 7bff139: the module doc read 'ttl required; defaults
to 3600' which is contradictory — clarify that --ttl is optional on the CLI
(defaults to 3600) while the v3 record payload itself requires a ttl. (Also
refreshed the PR description: DNS is now fully on v3, not v1.)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 25 out of 28 changed files in this pull request and generated 4 comments.

Comment thread rust/src/dns/mod.rs Resolved
Comment thread rust/src/dns/mod.rs Resolved
Address Copilot review on 8e4877f:

- dns set: bail before mutating if any matching existing record lacks a
  recordId (v3 mutations are keyed by id) — silently dropping it would leave it
  behind and turn 'set' into an append. Mirrors the delete-side guard.
- dns --ttl help: no longer says the 3600 default is add-only (set defaults too).
- regenerate-spec.sh / merge-spec.py: header/docstring no longer claim v1 serves
  DNS record list/set/delete — v1 now retains only list + agreements.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 25 out of 28 changed files in this pull request and generated 2 comments.

Comment thread rust/src/dns/mod.rs Resolved
Comment thread rust/src/scopes.rs Resolved
jpage-godaddy and others added 2 commits July 6, 2026 10:24
Address Copilot review on 0d4c726: the doc said 'each --data value' but
`dns delete` takes no --data — outcomes are keyed by each matched record's
data value. Reworded.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Comment thread rust/src/dns/mod.rs Resolved
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.

4 participants