Bunnyx.DnsZone (Bunnyx v0.4.0)

Copy Markdown View Source

DNS zones. bunny.net can host your domain's DNS alongside its CDN. A zone represents a domain and contains DNS records managed through Bunnyx.DnsRecord.

Uses the main API client created with Bunnyx.new/1.

Usage

client = Bunnyx.new(api_key: "sk-...")

{:ok, zone} = Bunnyx.DnsZone.create(client, domain: "example.com")
{:ok, zone} = Bunnyx.DnsZone.get(client, zone.id)
{:ok, page} = Bunnyx.DnsZone.list(client)
{:ok, zone} = Bunnyx.DnsZone.update(client, zone.id, logging_enabled: true)
{:ok, nil} = Bunnyx.DnsZone.delete(client, zone.id)

Fetching a zone with get/2 includes its records as a list of %Bunnyx.DnsRecord{} structs in the :records field.

Summary

Functions

Checks if a DNS zone name is available.

Creates a DNS zone with the given attributes.

Deletes a DNS zone.

Disables DNSSEC for a DNS zone.

Enables DNSSEC for a DNS zone.

Exports a DNS zone as a BIND-format zone file.

Fetches a DNS zone by ID, including its records.

Imports DNS records from a BIND-format zone file.

Issues a wildcard certificate for a DNS zone.

Lists DNS zones.

Returns DNS zone query statistics.

Updates a DNS zone.

Types

t()

@type t() :: %Bunnyx.DnsZone{
  certificate_key_type: integer() | nil,
  custom_nameservers_enabled: boolean() | nil,
  date_created: String.t() | nil,
  date_modified: String.t() | nil,
  dns_sec_enabled: boolean() | nil,
  domain: String.t() | nil,
  id: pos_integer() | nil,
  log_anonymization_type: integer() | nil,
  logging_enabled: boolean() | nil,
  logging_ip_anonymization_enabled: boolean() | nil,
  nameserver1: String.t() | nil,
  nameserver2: String.t() | nil,
  nameservers_detected: boolean() | nil,
  nameservers_next_check: String.t() | nil,
  records: [Bunnyx.DnsRecord.t()] | nil,
  soa_email: String.t() | nil
}

Functions

check_availability(client, name)

@spec check_availability(Bunnyx.t() | keyword(), String.t()) ::
  {:ok, boolean()} | {:error, Bunnyx.Error.t()}

Checks if a DNS zone name is available.

create(client, attrs)

@spec create(Bunnyx.t() | keyword(), Bunnyx.Params.attrs()) ::
  {:ok, t()} | {:error, Bunnyx.Error.t()}

Creates a DNS zone with the given attributes.

delete(client, id)

@spec delete(Bunnyx.t() | keyword(), pos_integer()) ::
  {:ok, nil} | {:error, Bunnyx.Error.t()}

Deletes a DNS zone.

disable_dnssec(client, id)

@spec disable_dnssec(Bunnyx.t() | keyword(), pos_integer()) ::
  {:ok, nil} | {:error, Bunnyx.Error.t()}

Disables DNSSEC for a DNS zone.

enable_dnssec(client, id)

@spec enable_dnssec(Bunnyx.t() | keyword(), pos_integer()) ::
  {:ok, nil} | {:error, Bunnyx.Error.t()}

Enables DNSSEC for a DNS zone.

export(client, id)

@spec export(Bunnyx.t() | keyword(), pos_integer()) ::
  {:ok, String.t()} | {:error, Bunnyx.Error.t()}

Exports a DNS zone as a BIND-format zone file.

get(client, id)

@spec get(Bunnyx.t() | keyword(), pos_integer()) ::
  {:ok, t()} | {:error, Bunnyx.Error.t()}

Fetches a DNS zone by ID, including its records.

import_records(client, id, zone_data)

@spec import_records(Bunnyx.t() | keyword(), pos_integer(), String.t()) ::
  {:ok,
   %{
     records_successful: integer(),
     records_failed: integer(),
     records_skipped: integer()
   }}
  | {:error, Bunnyx.Error.t()}

Imports DNS records from a BIND-format zone file.

issue_certificate(client, id)

@spec issue_certificate(Bunnyx.t() | keyword(), pos_integer()) ::
  {:ok, nil} | {:error, Bunnyx.Error.t()}

Issues a wildcard certificate for a DNS zone.

list(client, opts \\ [])

@spec list(
  Bunnyx.t() | keyword(),
  keyword()
) ::
  {:ok,
   %{
     items: [t()],
     current_page: integer(),
     total_items: integer(),
     has_more_items: boolean()
   }}
  | {:error, Bunnyx.Error.t()}

Lists DNS zones.

Options

  • :page — page number
  • :per_page — items per page
  • :search — search term

statistics(client, id, opts \\ [])

@spec statistics(Bunnyx.t() | keyword(), pos_integer(), keyword()) ::
  {:ok,
   %{
     total_queries_served: integer(),
     queries_served_chart: map(),
     normal_queries_served_chart: map(),
     smart_queries_served_chart: map(),
     queries_by_type_chart: map()
   }}
  | {:error, Bunnyx.Error.t()}

Returns DNS zone query statistics.

Options

  • :date_from — start date (ISO 8601 string)
  • :date_to — end date (ISO 8601 string)

update(client, id, attrs)

@spec update(Bunnyx.t() | keyword(), pos_integer(), Bunnyx.Params.attrs()) ::
  {:ok, t()} | {:error, Bunnyx.Error.t()}

Updates a DNS zone.