CloudflareApi.DnsRecord (cloudflare_api v0.6.0)
View SourceMakes a struct and convenience functions around A Cloudflare DNS record.
See Cloudflare docs: https://api.cloudflare.com/#dns-records-for-a-zone-properties
Summary
Functions
Build the Cloudflare DNS records URL for a given record.
Build a CloudflareApi.DnsRecord struct from a Cloudflare-style map.
Convert a CloudflareApi.DnsRecord struct into the JSON body Cloudflare
expects when creating or updating a record.
Types
@type record_type() ::
:A
| :AAAA
| :CNAME
| :HTTPS
| :TXT
| :SRV
| :LOC
| :MX
| :NS
| :CERT
| :DNSKEY
| :DS
| :NAPTR
| :SMIMEA
| :SSHFP
| :SVCB
| :TLSA
| :URI
@type t() :: %CloudflareApi.DnsRecord{ created_on: String.t() | nil, hostname: String.t(), id: String.t() | nil, ip: String.t(), locked: boolean() | nil, proxiable: boolean() | nil, proxied: boolean() | nil, ttl: non_neg_integer(), type: record_type(), zone_id: String.t(), zone_name: String.t() | nil }
@type ttl() :: record_type()
Functions
Build the Cloudflare DNS records URL for a given record.
This is primarily useful for debugging or when you need to reason about the REST endpoint for a specific record.
Build a CloudflareApi.DnsRecord struct from a Cloudflare-style map.
The input may use either atom keys (for example :zone_id) or string keys
(for example "zone_id"); keys are normalized before the struct is built.
Examples
iex> source = %{
...> "id" => "id",
...> "zone_id" => "zone-id",
...> "zone_name" => "example.com",
...> "name" => "www.example.com",
...> "content" => "1.2.3.4",
...> "created_on" => "now",
...> "type" => "A",
...> "ttl" => 120,
...> "proxied" => true,
...> "proxiable" => true,
...> "locked" => false
...> }
iex> record = CloudflareApi.DnsRecord.from_cf_json(source)
iex> {record.id, record.zone_id, record.hostname, record.ip}
{"id", "zone-id", "www.example.com", "1.2.3.4"}
Convert a CloudflareApi.DnsRecord struct into the JSON body Cloudflare
expects when creating or updating a record.