Class: Zonomi::API::Adapter
- Inherits:
-
Object
- Object
- Zonomi::API::Adapter
- Defined in:
- lib/zonomi/api/adapter.rb
Instance Attribute Summary collapse
-
#actions ⇒ Object
readonly
Returns the value of attribute actions.
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#requests ⇒ Object
readonly
Returns the value of attribute requests.
-
#responses ⇒ Object
readonly
Returns the value of attribute responses.
-
#results ⇒ Object
readonly
Returns the value of attribute results.
Instance Method Summary collapse
-
#add_zone(name) ⇒ Object
Setup a new DNS zone.
-
#change_ip(old_ip, new_ip) ⇒ Object
Change an IP across all your zones.
-
#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).
-
#convert_zone_to_slave(name, master) ⇒ Object
Convert a zone to a slave zone with the specified master name server IP address.
-
#delete_ipaddress_for_a_record_for(name) ⇒ Object
Delete an IP Address (A) record zonomi.com/app/dns/dyndns.jsp?action=DELETE&name=some-test-domain.com&type=A&api_key=api_key_hash.
-
#delete_zone(name) ⇒ Object
Delete a DNS zone.
-
#initialize(client) ⇒ Adapter
constructor
A new instance of Adapter.
-
#records_by_name(name, options = {}) ⇒ Object
Retrieve all records ending in some-test-domain.com.
-
#set_current_ipaddress_to_host(host) ⇒ Object
Set the IP Address for ‘some-test-domain.com’ to your PC’s address.
-
#set_ipaddress_for_a_record_for(name, value) ⇒ Object
Set an IP Address (A) record zonomi.com/app/dns/dyndns.jsp?action=SET&name=some-test-domain.com&value=10.0.0.1&type=A&api_key=api_key_hash.
- #set_mx_record_for(name, value, prio = 5) ⇒ Object
-
#zones ⇒ Object
Return a list of zones on your account.
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
#actions ⇒ Object (readonly)
Returns the value of attribute actions.
5 6 7 |
# File 'lib/zonomi/api/adapter.rb', line 5 def actions @actions end |
#client ⇒ Object (readonly)
Returns the value of attribute client.
5 6 7 |
# File 'lib/zonomi/api/adapter.rb', line 5 def client @client end |
#requests ⇒ Object (readonly)
Returns the value of attribute requests.
5 6 7 |
# File 'lib/zonomi/api/adapter.rb', line 5 def requests @requests end |
#responses ⇒ Object (readonly)
Returns the value of attribute responses.
5 6 7 |
# File 'lib/zonomi/api/adapter.rb', line 5 def responses @responses end |
#results ⇒ Object (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
Setup a new DNS zone. zonomi.com/app/dns/addzone.jsp?name=some-test-domain.com&api_key=api_key_hash
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
Change an IP across all your zones. zonomi.com/app/dns/ipchange.jsp?old_ip=0.0.0.0&new_ip=0.0.0.0&api_key=api_key_hash
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
Delete an IP Address (A) record zonomi.com/app/dns/dyndns.jsp?action=DELETE&name=some-test-domain.com&type=A&api_key=api_key_hash
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, = {}) all_records = .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
Set an IP Address (A) record zonomi.com/app/dns/dyndns.jsp?action=SET&name=some-test-domain.com&value=10.0.0.1&type=A&api_key=api_key_hash
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 |
#zones ⇒ Object
Return a list of zones on your account. zonomi.com/app/dns/dyndns.jsp?action=QUERYZONES&api_key=api_key_hash
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 |