Class: Zonomi::API::Adapter

Inherits:
Object
  • Object
show all
Defined in:
lib/zonomi/api/adapter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Adapter

Returns a new instance of Adapter.



7
8
9
10
11
12
13
14
# File 'lib/zonomi/api/adapter.rb', line 7

def initialize(client)
  @client    = client
  @actions   = []
  @requests  = []
  @responses = []
  @results   = []
  self
end

Instance Attribute Details

#actionsObject (readonly)

Returns the value of attribute actions.



5
6
7
# File 'lib/zonomi/api/adapter.rb', line 5

def actions
  @actions
end

#clientObject (readonly)

Returns the value of attribute client.



5
6
7
# File 'lib/zonomi/api/adapter.rb', line 5

def client
  @client
end

#requestsObject (readonly)

Returns the value of attribute requests.



5
6
7
# File 'lib/zonomi/api/adapter.rb', line 5

def requests
  @requests
end

#responsesObject (readonly)

Returns the value of attribute responses.



5
6
7
# File 'lib/zonomi/api/adapter.rb', line 5

def responses
  @responses
end

#resultsObject (readonly)

Returns the value of attribute results.



5
6
7
# File 'lib/zonomi/api/adapter.rb', line 5

def results
  @results
end

Instance Method Details

#add_zone(name) ⇒ Object



72
73
74
# File 'lib/zonomi/api/adapter.rb', line 72

def add_zone(name)
  query!(:add_zone, name: name)
end

#change_ip(old_ip, new_ip) ⇒ Object



110
111
112
# File 'lib/zonomi/api/adapter.rb', line 110

def change_ip(old_ip, new_ip)
  query!(:change_ip, old_ip: old_ip, new_ip: new_ip)
end

#convert_zone_to_master(name) ⇒ Object

Convert a zone from a slave zone back to a ‘regular’ zone (where you manage your DNS records via our web pages and API). zonomi.com/app/dns/converttomaster.jsp?name=some-test-domain.com&api_key=api_key_hash



103
104
105
# File 'lib/zonomi/api/adapter.rb', line 103

def convert_zone_to_master(name)
  query!(:convert_zone_to_master, name: name)
end

#convert_zone_to_slave(name, master) ⇒ Object

Convert a zone to a slave zone with the specified master name server IP address. zonomi.com/app/dns/converttosecondary.jsp?name=some-test-domain.com&master=0.0.0.0&api_key=api_key_hash



96
97
98
# File 'lib/zonomi/api/adapter.rb', line 96

def convert_zone_to_slave(name, master)
  query!(:convert_zone_to_slave, name: name, master: master)
end

#delete_ipaddress_for_a_record_for(name) ⇒ Object



33
34
35
# File 'lib/zonomi/api/adapter.rb', line 33

def delete_ipaddress_for_a_record_for(name)
  query!(:delete_ipaddress_for_a_record_for, name: name)
end

#delete_zone(name) ⇒ Object



79
80
81
# File 'lib/zonomi/api/adapter.rb', line 79

def delete_zone(name)
  query!(:delete_zone, name: name)
end

#records_by_name(name, options = {}) ⇒ Object

Retrieve all records ending in some-test-domain.com. e.g. letting you fetch all records in a DNS zone. zonomi.com/app/dns/dyndns.jsp?action=QUERY&name=**.some-test-domain.com&api_key=api_key_hash



50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/zonomi/api/adapter.rb', line 50

def records_by_name(name, options = {})
  all_records = options.delete(:all_records) || false
  if all_records
    name.gsub!(%r{^\W+}, '')
    name = '**.' + name
  end

  query!(:records_by_name, name: name)
  respond_value_for(results.last, :records_by_name).map do |record_hash|
    Record.new(record_hash)
  end
end

#set_current_ipaddress_to_host(host) ⇒ Object

Set the IP Address for ‘some-test-domain.com’ to your PC’s address. Right now that is 176.52.37.118. zonomi.com/app/dns/dyndns.jsp?host=some-test-domain.com&api_key=api_key_hash



19
20
21
# File 'lib/zonomi/api/adapter.rb', line 19

def set_current_ipaddress_to_host(host)
  query!(:set_current_ipaddress_to_host, host: host)
end

#set_ipaddress_for_a_record_for(name, value) ⇒ Object



26
27
28
# File 'lib/zonomi/api/adapter.rb', line 26

def set_ipaddress_for_a_record_for(name, value)
  query!(:set_ipaddress_for_a_record_for, name: name, value: value)
end

#set_mx_record_for(name, value, prio = 5) ⇒ Object



40
41
42
# File 'lib/zonomi/api/adapter.rb', line 40

def set_mx_record_for(name, value, prio = 5)
  query!(:set_mx_record_for, name: name, value: value, prio: prio)
end

#zonesObject



86
87
88
89
90
91
# File 'lib/zonomi/api/adapter.rb', line 86

def zones
  query!(:zones)
  respond_value_for(results.last, :zones).map do |zone_hash|
    Zone.new(zone_hash)
  end
end