Class: DNSimple::Template
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#short_name ⇒ Object
Returns the value of attribute short_name.
Class Method Summary collapse
- .all(options = {}) ⇒ Object
- .create(name, short_name, description = nil, options = {}) ⇒ Object
- .find(id_or_short_name, options = {}) ⇒ Object
Instance Method Summary collapse
-
#delete(options = {}) ⇒ Object
(also: #destroy)
Delete the template from DNSimple.
Methods inherited from Base
Constructor Details
This class inherits a constructor from DNSimple::Base
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
7 8 9 |
# File 'lib/dnsimple/template.rb', line 7 def description @description end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/dnsimple/template.rb', line 4 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/dnsimple/template.rb', line 5 def name @name end |
#short_name ⇒ Object
Returns the value of attribute short_name.
6 7 8 |
# File 'lib/dnsimple/template.rb', line 6 def short_name @short_name end |
Class Method Details
.all(options = {}) ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/dnsimple/template.rb', line 43 def self.all(={}) response = DNSimple::Client.get("/v1/templates", ) case response.code when 200 response.map { |r| new(r["dns_template"]) } else raise RequestError.new("Error listing templates", response) end end |
.create(name, short_name, description = nil, options = {}) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/dnsimple/template.rb', line 10 def self.create(name, short_name, description=nil, ={}) template_hash = { :name => name, :short_name => short_name, :description => description } .merge!(:body => {:dns_template => template_hash}) response = DNSimple::Client.post("/v1/templates", ) case response.code when 201 new(response["dns_template"]) else raise RequestError.new("Error creating template", response) end end |
.find(id_or_short_name, options = {}) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/dnsimple/template.rb', line 29 def self.find(id_or_short_name, ={}) id = id_or_short_name response = DNSimple::Client.get("/v1/templates/#{id}", ) case response.code when 200 new(response["dns_template"]) when 404 raise RecordNotFound, "Could not find template #{id}" else raise RequestError.new("Error finding template", response) end end |