Bunnyx.DnsRecord (Bunnyx v0.3.0)

Copy Markdown View Source

DNS records within a zone. Records are nested under a Bunnyx.DnsZone — all operations require the parent zone's ID.

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

Record types

The :type field is an integer matching bunny.net's record type constants: 0 = A, 1 = AAAA, 2 = CNAME, 3 = TXT, 4 = MX, 5 = Redirect, 6 = Flatten, 7 = Pull Zone, 8 = SRV, 9 = CAA, 10 = PTR, 11 = Script, 12 = NS.

Usage

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

{:ok, record} = Bunnyx.DnsRecord.add(client, zone_id,
  type: 0,
  name: "www",
  value: "1.2.3.4",
  ttl: 300
)

{:ok, record} = Bunnyx.DnsRecord.update(client, zone_id, record.id, ttl: 600)
{:ok, nil} = Bunnyx.DnsRecord.delete(client, zone_id, record.id)

Summary

Functions

Adds a DNS record to a zone.

Deletes a DNS record from a zone.

Updates a DNS record.

Types

t()

@type t() :: %Bunnyx.DnsRecord{
  accelerated: boolean() | nil,
  comment: String.t() | nil,
  disabled: boolean() | nil,
  flags: integer() | nil,
  id: pos_integer() | nil,
  name: String.t() | nil,
  port: integer() | nil,
  priority: integer() | nil,
  tag: String.t() | nil,
  ttl: integer() | nil,
  type: integer() | nil,
  value: String.t() | nil,
  weight: integer() | nil
}

Functions

add(client, zone_id, attrs)

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

Adds a DNS record to a zone.

delete(client, zone_id, id)

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

Deletes a DNS record from a zone.

update(client, zone_id, id, attrs)

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

Updates a DNS record.