class TortoiseLabs::DNS::Zone

DNS zone class

Attributes

id[R]
name[R]
records[R]
user[R]

Public Class Methods

create(domain) click to toggle source
# File lib/tortoiselabs/dns.rb, line 54
def self.create(domain)
  TortoiseLabs::Client.post("/dns/zone/new", {:domain_name => domain})
  list = self.list
  if list.keys.include?(domain)
    return list[domain]
  else
    return false
  end
end
list() click to toggle source

Class Methods

# File lib/tortoiselabs/dns.rb, line 41
def self.list
  response = TortoiseLabs::Client.get("/dns/zones").parsed_response
  json = JSON.parse(response)
  zones = Hash.new
  
  json["zones"].each do |zone|
    obj = self.new(zone)
    zones[obj.name] = obj
  end
  
  zones
end
new(zhash) click to toggle source
# File lib/tortoiselabs/dns.rb, line 10
def initialize(zhash)
  @id, @name, @user = zhash["id"], zhash["name"], zhash["user"]
  @records = Array.new
  
  zhash["records"].each do |record|
    obj = Record.new(record)
    obj.zoneid = @id
    @records << obj
  end
end

Public Instance Methods

delete() click to toggle source

Instance Methods

# File lib/tortoiselabs/dns.rb, line 23
def delete
  resp = TortoiseLabs::Client.get("/dns/zone/#{@id}/delete")
  Zone.list
end
new_record(subdomain, type, content, ttl = 3600, prio = 0) click to toggle source
# File lib/tortoiselabs/dns.rb, line 28
def new_record(subdomain, type, content, ttl = 3600, prio = 0)
  resp = TortoiseLabs::Client.post("/dns/zone/#{@id}/record/new", 
     {:subdomain => subdomain, :type => type, :ttl => ttl,
      :prio => prio, :content => content})
  Zone.list[@name]
end
to_s() click to toggle source
# File lib/tortoiselabs/dns.rb, line 35
def to_s
  @name
end