Class: Rubber::Dns::Zone
- Inherits:
-
Object
- Object
- Rubber::Dns::Zone
- Includes:
- HTTParty
- Defined in:
- lib/rubber/dns/zerigo.rb
Instance Method Summary collapse
- #create_host(host) ⇒ Object
- #data ⇒ Object
- #delete_host(hostname) ⇒ Object
- #host(hostname) ⇒ Object
- #hosts ⇒ Object
-
#initialize(customer_id, email, token, domain) ⇒ Zone
constructor
A new instance of Zone.
- #new_host ⇒ Object
- #refresh ⇒ Object
- #update_host(host) ⇒ Object
Constructor Details
#initialize(customer_id, email, token, domain) ⇒ Zone
Returns a new instance of Zone.
12 13 14 15 16 17 |
# File 'lib/rubber/dns/zerigo.rb', line 12 def initialize(customer_id, email, token, domain) self.class.basic_auth email, token self.class.base_uri "https://ns.zerigo.com/accounts/#{customer_id}" @domain = domain refresh() end |
Instance Method Details
#create_host(host) ⇒ Object
33 34 35 |
# File 'lib/rubber/dns/zerigo.rb', line 33 def create_host(host) self.class.post("/zones/#{@zone['id']}/hosts.xml", :body => {:host => host}) end |
#data ⇒ Object
57 58 59 |
# File 'lib/rubber/dns/zerigo.rb', line 57 def data return @zone end |
#delete_host(hostname) ⇒ Object
42 43 44 45 |
# File 'lib/rubber/dns/zerigo.rb', line 42 def delete_host(hostname) host_id = host(hostname)['id'] self.class.delete("/zones/#{@zone['id']}/hosts/#{host_id}.xml") end |
#host(hostname) ⇒ Object
24 25 26 27 |
# File 'lib/rubber/dns/zerigo.rb', line 24 def host(hostname) hosts = self.class.get("/zones/#{@zone['id']}/hosts.xml?fqdn=#{hostname}.#{@domain}") return (hosts['hosts'] || []).first end |
#hosts ⇒ Object
19 20 21 22 |
# File 'lib/rubber/dns/zerigo.rb', line 19 def hosts hosts = self.class.get("/zones/#{@zone['id']}/hosts.xml") return hosts['hosts'] end |
#new_host ⇒ Object
29 30 31 |
# File 'lib/rubber/dns/zerigo.rb', line 29 def new_host self.class.get("/zones/#{@zone['id']}/hosts/new.xml")['host'] end |
#refresh ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/rubber/dns/zerigo.rb', line 47 def refresh zone_id = @zone['id'] rescue nil if zone_id @zone = self.class.get("/zones/#{zone_id}.xml") else zones = self.class.get('/zones.xml') @zone = zones["zones"].find {|z| z["domain"] == @domain } end end |
#update_host(host) ⇒ Object
37 38 39 40 |
# File 'lib/rubber/dns/zerigo.rb', line 37 def update_host(host) host_id = host['id'] self.class.put("/zones/#{@zone['id']}/hosts/#{host_id}.xml", :body => {:host => host}) end |