Skip to contents

Retrieves DNS records from Netlify for the specified domain using the getDnsRecords endpoint of Netlify's RESTful API.

Usage

netlify_dns_records_get(
  domain,
  token = funky::config_val("netlify_token"),
  max_tries = 3L
)

Arguments

domain

Domain name to retrieve DNS records for. This is translated into the corresponding Netlify DNS Zone. A character scalar.

token

Netlify personal access token used for authentication. A character scalar.

max_tries

Maximum number of request attempts in case of an HTTP error. An integerish scalar. Retries are performed using exponential backoff and jitter, see httr2::req_retry() for details.

Value

A tibble with the columns type, hostname, value, ttl, priority, weight, port, flag, tag, id, dns_zone_id, site_id, and managed.

See also

Examples

if (FALSE) { # \dontrun{
yay::netlify_dns_records_get(domain = "my.site")

# to write "portable" record keys to a TOML file `dns_records.toml` with a `records` table
# NOTE that the CLI tool `jsontoml` is required for this: https://github.com/pelletier/go-toml/
yay::netlify_dns_records_get(domain = "my.site") |>
  # remove records which can't be handled via API
  dplyr::filter(!managed) |>
  # remove Netlify-specific cols
  dplyr::select(any_of(colnames(yay:::ptype_dns_records))) |>
  # convert to target list structure
  list(records = _) |>
  # convert to JSON
  jsonlite::toJSON(auto_unbox = TRUE,
                   pretty = TRUE) |>
  # convert JSON to TOML via external CLI
  system2(input = _,
          stdout = TRUE,
          command = "jsontoml") |>
  # remove leading newline
  _[-1L] |>
  # write TOML to file
  brio::write_lines(path = "dns_records.toml")} # }