Class: TortoiseLabs::DNS::Zone
- Inherits:
-
Object
- Object
- TortoiseLabs::DNS::Zone
- Defined in:
- lib/tortoiselabs/dns.rb
Overview
DNS zone class
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#records ⇒ Object
readonly
Returns the value of attribute records.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Class Method Summary collapse
- .create(domain) ⇒ Object
-
.list ⇒ Object
Class Methods.
Instance Method Summary collapse
-
#delete ⇒ Object
Instance Methods.
-
#initialize(zhash) ⇒ Zone
constructor
A new instance of Zone.
- #new_record(subdomain, type, content, ttl = 3600, prio = 0) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(zhash) ⇒ Zone
Returns a new instance of Zone.
10 11 12 13 14 15 16 17 18 19 |
# 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 |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
8 9 10 |
# File 'lib/tortoiselabs/dns.rb', line 8 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/tortoiselabs/dns.rb', line 8 def name @name end |
#records ⇒ Object (readonly)
Returns the value of attribute records.
8 9 10 |
# File 'lib/tortoiselabs/dns.rb', line 8 def records @records end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
8 9 10 |
# File 'lib/tortoiselabs/dns.rb', line 8 def user @user end |
Class Method Details
.create(domain) ⇒ Object
54 55 56 57 58 59 60 61 62 |
# 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 ⇒ Object
Class Methods
41 42 43 44 45 46 47 48 49 50 51 52 |
# 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 |
Instance Method Details
#delete ⇒ Object
Instance Methods
23 24 25 26 |
# 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) ⇒ Object
28 29 30 31 32 33 |
# 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 ⇒ Object
35 36 37 |
# File 'lib/tortoiselabs/dns.rb', line 35 def to_s @name end |