netlify_dns_records_get: Get Netlify DNS records

netlify_dns_records_getR Documentation

Get Netlify DNS records

Description

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 = pal::pkg_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 attempts to retry in case of an HTTP error. An integerish scalar.

Value

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

See Also

Other Netlify functions: netlify_dns_records_delete(), netlify_dns_records_set()

Examples

## Not run: 
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(yay:::cols_dns_records$key)) |>
  # 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")
## End(Not run)

salim-b/yay documentation built on Oct. 25, 2024, 9:42 p.m.