Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 111 additions & 0 deletions rust/domains-client/openapi/domains.oas3.json
Original file line number Diff line number Diff line change
Expand Up @@ -4069,6 +4069,117 @@
"tags": [
"Records"
]
},
"put": {
"description": "Fully replaces an existing DNS resource record identified by\nrecordId within the zone. All writable fields applicable to the\nrecord type must be supplied; partial updates are not supported\non this endpoint. Changes are applied synchronously.\n\nGoDaddy-managed system records (SOA and NS) are read-only. When\nrecordId refers to such a record, the request fails with\n`409 Conflict` — the record exists but cannot be modified.\n",
"operationId": "replaceDNSRecord",
"parameters": [
{
"description": "Optional client-generated request correlation identifier, propagated across services and returned in the response X-Request-Id header.\n",
"in": "header",
"name": "X-Request-Id",
"required": false,
"schema": {
"$ref": "#/components/schemas/uuid"
}
},
{
"description": "Reseller acting on behalf of a shopper account. When present, all domain operations are scoped to the specified shopper. Absent, the authenticated entity's own account is used. Only valid for reseller OAuth tokens.\n",
"example": "shopper_123",
"in": "header",
"name": "X-Shopper-Id",
"required": false,
"schema": {
"type": "string"
}
},
{
"description": "The domain name in punycode A-label form (e.g., example.com). For IDNs, use the punycode representation.\n",
"example": "example.com",
"in": "path",
"name": "zone",
"required": true,
"schema": {
"type": "string"
}
},
{
"description": "Server-assigned DNS record identifier within the zone.",
"example": "Aad7oqdXCms9mlJvm_m6UFYqmwjyP20H2KBmQHgttK9kGbF_TuI3knsocArQqIv5I0Kq5C0",
"in": "path",
"name": "recordId",
"required": true,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"examples": {
"apexARecord": {
"summary": "Replace apex A record",
"value": {
"data": "192.0.2.1",
"name": "@",
"ttl": 3600,
"type": "A"
}
},
"tlsaRecord": {
"summary": "Replace a TLSA record (rotate to new SPKI pin)",
"value": {
"certificateData": "a3b4c5d6e7f8091a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a",
"matchingType": 1,
"name": "www",
"port": 443,
"protocol": "_tcp",
"selector": 1,
"ttl": 3600,
"type": "TLSA",
"usage": 3
}
}
},
"schema": {
"$ref": "#/components/schemas/DNSRecord"
}
}
},
"required": true
},
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/DNSRecord"
}
}
},
"description": "DNS record replaced.",
"headers": {
"X-Request-Id": {
"description": "Request correlation identifier echoed from the request or server-generated.",
"schema": {
"$ref": "#/components/schemas/uuid"
}
}
}
}
},
"security": [
{
"oauth2": [
"domains.dns:update"
]
}
],
"summary": "Replace a DNS record",
"tags": [
"Records"
]
}
}
},
Expand Down
14 changes: 4 additions & 10 deletions rust/domains-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -716,21 +716,15 @@ mod tests {
}

#[test]
fn replace_dns_record_stays_removed() {
// See https://github.com/godaddy/cli/issues/136 and the `NOTE:`
// comment above `/zones/{zone}/dns-records/{recordId}` in the
// vendored v3 yaml: this PUT returns 200 but silently replaces the
// entire dns-records collection instead of the one record. A spec
// sync that copies the upstream shape verbatim would reintroduce it.
fn replace_dns_record_is_exposed() {
// `dns set` replaces a retained record in place with this PUT.
let spec = vendored_spec();
let methods = spec["paths"]["/v3/domains/zones/{zone}/dns-records/{recordId}"]
.as_object()
.expect("dns-records/{recordId} path exists");
assert!(
!methods.contains_key("put"),
"replaceDNSRecord (PUT) must stay excluded until a confirmed \
server-side fix and a fresh live check against a real zone with \
unrelated records — see godaddy/cli#136"
methods.contains_key("put"),
"replaceDNSRecord (PUT) missing"
);
}
}
20 changes: 11 additions & 9 deletions rust/src/dns/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use crate::scopes::DOMAINS_DNS_UPDATE;

use super::conflicts::{WriteErrorContext, describe_write_error};
use super::records::{
RecordOptions, RecordWriteArgs, v3_records, validate_caa_fields, validate_svcb_fields,
validate_tlsa_fields, verified_result,
RecordOptions, RecordWriteArgs, v3_records, validate_caa_fields, validate_record_name,
validate_svcb_fields, validate_tlsa_fields, verified_result,
};

// `dns add` creates one v3 record per `--data` value; it reports each outcome
Expand Down Expand Up @@ -105,13 +105,13 @@ pub(super) fn command() -> RuntimeCommandSpec {
)
.with_long(
"Appends one or more DNS records to a domain without modifying any \
existing records. Pass `--data` once per record value to add \
multiple records for the same type+name (each is a separate v3 \
create call). `--ttl` defaults to 3600 when omitted. DNS only \
allows a CNAME or other record types at a name, never both — \
adding into a name that already has the other kind fails with a \
specific error naming the conflicting record. Use `dns set` to \
replace the full record set for a type+name.",
existing records. Pass `--data` once per record value to add \
multiple records for the same type+name (each is a separate v3 \
create call). `--ttl` is 600 to 86400 seconds and defaults to 3600 \
when omitted. DNS only allows a CNAME or other record types at a \
name, never both — adding into a name that already has the other \
kind fails with a specific error naming the conflicting record. Use \
`dns set` to replace the full record set for a type+name.",
)
.with_system("domain")
.with_tier(Tier::Mutate)
Expand All @@ -125,6 +125,8 @@ pub(super) fn command() -> RuntimeCommandSpec {
let record_type = args.record_type;
let name = args.name;
let domain_format = args.domain_format.form(&ctx)?;
validate_record_name(&record_type, &name)
.map_err(crate::error::GddyError::validation)?;
validate_caa_fields(&record_type, &opts)
.map_err(crate::error::GddyError::validation)?;
validate_tlsa_fields(&record_type, &opts)
Expand Down
36 changes: 27 additions & 9 deletions rust/src/dns/guides/dns.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ Without filters, `list` returns every record. `--type` narrows to one record typ
gddy dns add example.com --type A --name www --data 192.0.2.1 --ttl 3600
```

Pass `--data` more than once to add several records for the same type+name in one call — each becomes a separate record, and a failure on one doesn't stop the rest (the result reports created/failed counts with a per-value breakdown). `--ttl` defaults to 3600 seconds when omitted.
Pass `--data` more than once to add several records for the same type+name in one call — each becomes a separate record. `--ttl` is in seconds, from 600 (10 minutes) to 86400 (24 hours), and defaults to 3600 when omitted.

A name can hold a CNAME or other record types, never both. Adding into a name that already has the other kind fails with an error naming the conflict — see `set --replace-conflicting-types` below if you actually want to replace it.

## Replacing records (`set`, destructive)

`set` replaces every record matching a type+name pair with exactly the `--data` value(s) you give it. It reconciles rather than deleting and recreating everything: existing records are paired with your `--data` values, whatever's no longer in your list is deleted, and whatever's new is created. There's no atomic in-place replace in v3, so each paired value is written as a new record before the old one it's replacing is deleted — record IDs are not reused across a replace.
`set` replaces every record matching a type+name pair with exactly the `--data` value(s) you give it.

```
gddy dns set example.com --type TXT --name @ --data "v=spf1 -all"
Expand All @@ -51,9 +51,9 @@ Preview the plan before writing:
gddy dns set example.com --type TXT --name @ --data "v=spf1 -all" --dry-run
```

The dry-run preview lists the planned action (replace/create/delete) per record so you can confirm it before it runs for real. `set` is not atomic — a partial failure reports how many records were replaced, created, and deleted before it happened.
The dry-run preview lists the planned action per record so you can confirm it before it runs for real.

To also remove a conflicting CNAME (or, when setting a CNAME, any other type) at that name, add `--replace-conflicting-types`.
For `SRV` and `TLSA` records, give `add` and `set` the record's own name and the service and protocol (or port and protocol) as separate flags, e.g. `--name chat --service sip --protocol tcp`.

## Deleting records

Expand All @@ -73,10 +73,28 @@ Domain names and record names can be typed either as Unicode (`münchen.de`) or

## Type-specific flags

Most of these only apply to certain record types — set them only when the type calls for it:
Some record types need extra flags:

| Flag | Applies to | Notes |
| Record type | Required flags | Optional |
|---|---|---|
| `--priority` | `MX`, `SRV` | |
| `--port`, `--weight`, `--protocol`, `--service` | `SRV` | |
| `--flag`, `--tag` | `CAA` | `--tag` is required for CAA (e.g. `issue`, `issuewild`, `iodef`); `--data` carries the CA domain/value |
| `MX` | `--priority` | |
| `SRV` | `--priority`, `--weight`, `--port`, `--service`, `--protocol` | |
| `HTTPS`, `SVCB` | `--priority` (`0` means AliasMode) | `--parameters` |
| `TLSA` | `--usage`, `--selector`, `--matching-type`, `--port`, `--protocol` | |
| `CAA` | `--tag` (`issue`, `issuewild` or `iodef`); `--data` carries the CA domain or value | `--flag` (defaults to `0`) |

`--service` and `--protocol` take the plain name, e.g. `--service sip --protocol tcp`. GoDaddy stores them with a leading underscore (`_sip._tcp`), which `gddy` adds for you; `--service _sip` works too. Any name made of letters, digits, `-` and `_` (up to 62 characters before the underscore) is accepted, so custom services work. Where they are shown (`--fields service,protocol`, or JSON), they appear in the underscore form, since that is the DNS name.

Example SRV record:

```
gddy dns add example.com \
--type SRV \
--name chat \
--data chat-server.example.com. \
--priority 10 \
--weight 5 \
--port 5222 \
--service xmpp \
--protocol tcp
```
4 changes: 3 additions & 1 deletion rust/src/dns/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ pub(super) fn command() -> RuntimeCommandSpec {
/// The original `certificateData`/`usage`/`selector`/`matchingType` fields
/// are left in place alongside it. Pure so the merge is unit-testable
/// without a mock server.
fn build_list_output(records: &[types::DnsRecord]) -> Result<Vec<Value>, serde_json::Error> {
pub(super) fn build_list_output(
records: &[types::DnsRecord],
) -> Result<Vec<Value>, serde_json::Error> {
records
.iter()
.map(|rec| {
Expand Down
Loading
Loading