Class: Dynect
- Inherits:
-
Object
- Object
- Dynect
- Defined in:
- lib/dynect.rb
Instance Method Summary collapse
- #add_a_record(zone, address, options = {}) ⇒ Object
-
#add_cname_record(zone, hostname, options = {}) ⇒ Object
Adds a CNAME record for the specified zone.
- #add_node(node, zone, options = {}) ⇒ Object
-
#create_zone(zone, type, options = {}) ⇒ Object
Create a new zone.
-
#delete_a_record(id) ⇒ Object
Deletes an A record identified by the ID.
- #delete_cname_record(id) ⇒ Object
- #delete_node(node, zone, options = {}) ⇒ Object
-
#initialize(customer, user, password, driver = nil) ⇒ Dynect
constructor
Provide the customer, user, and password information to intiate the SOAP connection.
-
#list_a_records(zone, options = {}) ⇒ Object
Lists all the A records associated with the account.
-
#list_cname_records(zone, options = {}) ⇒ Object
Lists the CNAME records associated with an account.
- #list_nodes(zone, options = {}) ⇒ Object
- #list_soa(zone, options = {}) ⇒ Object
-
#list_zones(zone = nil) ⇒ Object
Lists the zones associated with the accout.
-
#update_a_record(id, options = {}) ⇒ Object
Updates A records identified by the ID.
- #update_cname_record(id, options = {}) ⇒ Object
- #update_soa(id, options = {}) ⇒ Object
Constructor Details
#initialize(customer, user, password, driver = nil) ⇒ Dynect
Provide the customer, user, and password information to intiate the SOAP connection. If desired, an alternate driver can be supplied to enable mocking or the use of different protocols.
9 10 11 12 13 14 |
# File 'lib/dynect.rb', line 9 def initialize(customer, user, password, driver = nil) @driver = driver || setup_driver @creds = {"cust" => customer, "user" => user, "pass" => password } add_methods end |
Instance Method Details
#add_a_record(zone, address, options = {}) ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/dynect.rb', line 55 def add_a_record(zone, address, = {}) args = @creds.merge("type" => "A", "zone" => zone, "rdata" => {"address" => address}) args.merge!() response = @driver.RecordAdd args check_for_errors("when adding an A record", response) end |
#add_cname_record(zone, hostname, options = {}) ⇒ Object
Adds a CNAME record for the specified zone
89 90 91 92 93 94 95 |
# File 'lib/dynect.rb', line 89 def add_cname_record(zone, hostname, = {} ) args = @creds.merge("type" => "CNAME", "zone" => zone, "rdata" => {"cname" => hostname}) args.merge!() response = @driver.RecordAdd args check_for_errors("when adding a CNAME record", response) end |
#add_node(node, zone, options = {}) ⇒ Object
135 136 137 138 139 140 141 |
# File 'lib/dynect.rb', line 135 def add_node(node, zone, ={}) args = @creds.merge("zone" => zone, "node" => "#{node}.#{zone}") args.merge!() response = @driver.NodeAdd args check_for_errors("when adding a node", response) end |
#create_zone(zone, type, options = {}) ⇒ Object
Create a new zone
27 28 29 30 31 32 33 |
# File 'lib/dynect.rb', line 27 def create_zone(zone, type, ={}) args = @creds.merge("zone" => zone, "type" => type) args.merge!() response = @driver.ZoneAdd args check_for_errors("when creating a zone", response) end |
#delete_a_record(id) ⇒ Object
Deletes an A record identified by the ID
73 74 75 76 |
# File 'lib/dynect.rb', line 73 def delete_a_record(id) response = @driver.RecordDelete @creds.merge("record_id" => id) check_for_errors("when removing an A record", response) end |
#delete_cname_record(id) ⇒ Object
105 106 107 108 |
# File 'lib/dynect.rb', line 105 def delete_cname_record(id) response = @driver.RecordDelete @creds.merge("record_id" => id) check_for_errors("when removing a CNAME record", response) end |
#delete_node(node, zone, options = {}) ⇒ Object
143 144 145 146 147 148 149 |
# File 'lib/dynect.rb', line 143 def delete_node(node, zone, ={}) args = @creds.merge("zone" => zone, "node" => "#{node}.#{zone}") args.merge!() response = @driver.NodeDelete args check_for_errors("when deleting a node", response) end |
#list_a_records(zone, options = {}) ⇒ Object
Lists all the A records associated with the account.
Options
-
node
– The fully qualified domain name of the node to retreive records from. Omit or enter an empty string to get the records of the root node -
record_id
– The ID of the record to retreive information of
Useage
d = Dynect.new("customer", "username", "password")
d.list_a_records("myzone.domain.com")
46 47 48 49 50 51 52 53 |
# File 'lib/dynect.rb', line 46 def list_a_records(zone, ={}) args = @creds.merge("type" => "A", "zone" => zone) args.merge!() response = @driver.RecordGet args check_for_errors("when listing records", response) response.records end |
#list_cname_records(zone, options = {}) ⇒ Object
Lists the CNAME records associated with an account
79 80 81 82 83 84 85 86 |
# File 'lib/dynect.rb', line 79 def list_cname_records(zone, ={}) args = @creds.merge("type" => "CNAME", "zone" => zone) args.merge!() response = @driver.RecordGet args check_for_errors("when listing CNAME records", response) response.records end |
#list_nodes(zone, options = {}) ⇒ Object
127 128 129 130 131 132 133 |
# File 'lib/dynect.rb', line 127 def list_nodes(zone, = {}) args = @creds.merge("zone" => zone) args.merge!() response = @driver.NodeGet args check_for_errors("when listing nodes", response) end |
#list_soa(zone, options = {}) ⇒ Object
118 119 120 121 122 123 124 125 |
# File 'lib/dynect.rb', line 118 def list_soa(zone, = {}) args = @creds.merge("type" => "SOA", "zone" => zone) args.merge!() response = @driver.RecordGet args check_for_errors("when listing SOA records", response) response.records.first end |
#list_zones(zone = nil) ⇒ Object
Lists the zones associated with the accout. Specify a zone to get information on a specific one
17 18 19 20 21 22 23 24 |
# File 'lib/dynect.rb', line 17 def list_zones(zone = nil) args = @creds args["zone"] = zone if zone response = @driver.ZoneGet args check_for_errors("when listing zone(s)", response) response.zones end |
#update_a_record(id, options = {}) ⇒ Object
Updates A records identified by the ID
64 65 66 67 68 69 70 |
# File 'lib/dynect.rb', line 64 def update_a_record(id, = {}) args = @creds.merge("record_id" => id) args.merge!() response = @driver.RecordUpdate args check_for_errors("when updating an A record", response) end |
#update_cname_record(id, options = {}) ⇒ Object
97 98 99 100 101 102 103 |
# File 'lib/dynect.rb', line 97 def update_cname_record(id, = {}) args = @creds.merge("id" => id) args.merge!() response = @driver.RecordUpdate args check_for_errors("when updating a CNAME record", response) end |
#update_soa(id, options = {}) ⇒ Object
110 111 112 113 114 115 116 |
# File 'lib/dynect.rb', line 110 def update_soa(id, = {}) args = @creds.merge("record_id" => id) args.merge!() response = @driver.RecordUpdate args check_for_errors("when updating a SOA record", response) end |