Class: DnsServices::DigitalOcean

Inherits:
Dnsign::DnsService show all
Defined in:
lib/dnsign/dns_services/digital_ocean.rb

Instance Method Summary collapse

Methods inherited from Dnsign::DnsService

create_from_name

Constructor Details

#initialize(opts = {}) ⇒ DigitalOcean

Returns a new instance of DigitalOcean.


10
11
12
# File 'lib/dnsign/dns_services/digital_ocean.rb', line 10

def initialize(opts={})
  @access_token = opts.fetch :access_token
end

Instance Method Details

#retrieve_ip(fqdn) ⇒ Object


24
25
26
27
28
29
30
# File 'lib/dnsign/dns_services/digital_ocean.rb', line 24

def retrieve_ip(fqdn)
  name, domain = split_fqdn fqdn

  if record = fetch_record_by_name(domain, name)
    record.data
  end
end

#update_ip(fqdn, ip) ⇒ Object


14
15
16
17
18
19
20
21
22
# File 'lib/dnsign/dns_services/digital_ocean.rb', line 14

def update_ip(fqdn, ip)
  name, domain = split_fqdn fqdn

  if existing = fetch_record_by_name(domain, name)
    handle_record_response update_record(existing.id, domain, name, ip)
  else
    handle_record_response create_record(domain, name, ip)
  end
end