Class: DNSimple::Domain
Instance Attribute Summary collapse
-
#auto_renew ⇒ Object
Is the domain set to autorenew.
-
#created_at ⇒ Object
When the domain was created in DNSimple.
-
#expires_on ⇒ Object
When the domain is due to expire.
-
#id ⇒ Object
The domain ID in DNSimple.
-
#lockable ⇒ Object
Is the domain lockable.
-
#name ⇒ Object
The domain name.
-
#name_server_status ⇒ Object
The current known name server status.
-
#registrant_id ⇒ Object
ID of the registrant in DNSimple.
-
#state ⇒ Object
The state of the domain in DNSimple.
-
#updated_at ⇒ Object
When the domain was last update in DNSimple.
-
#user_id ⇒ Object
User ID in DNSimple.
-
#whois_protected ⇒ Object
Is the whois information protected.
Class Method Summary collapse
-
.all(options = {}) ⇒ Object
Get all domains for the account.
-
.check(name, options = {}) ⇒ Object
Check the availability of a name.
-
.create(name, options = {}) ⇒ Object
Create the domain with the given name in DNSimple.
-
.find(id, options = {}) ⇒ Object
Find a specific domain in the account either by the numeric ID or by the fully-qualified domain name.
-
.register(name, registrant = {}, extended_attributes = {}, options = {}) ⇒ Object
Purchase a domain name.
Instance Method Summary collapse
- #add_service(id_or_short_name, options = {}) ⇒ Object
- #applied_services(options = {}) ⇒ Object
-
#apply(template, options = {}) ⇒ Object
Apply the given named template to the domain.
- #available_services(options = {}) ⇒ Object
-
#delete(options = {}) ⇒ Object
(also: #destroy)
Delete the domain from DNSimple.
-
#disable_auto_renew ⇒ Object
Disable auto_renew on the domain.
-
#enable_auto_renew ⇒ Object
Enable auto_renew on the domain.
- #remove_service(id, options = {}) ⇒ Object
- #resolve_template(template) ⇒ Object
Methods inherited from Base
Constructor Details
This class inherits a constructor from DNSimple::Base
Instance Attribute Details
#auto_renew ⇒ Object
Is the domain set to autorenew
35 36 37 |
# File 'lib/dnsimple/domain.rb', line 35 def auto_renew @auto_renew end |
#created_at ⇒ Object
When the domain was created in DNSimple
11 12 13 |
# File 'lib/dnsimple/domain.rb', line 11 def created_at @created_at end |
#expires_on ⇒ Object
When the domain is due to expire
20 21 22 |
# File 'lib/dnsimple/domain.rb', line 20 def expires_on @expires_on end |
#id ⇒ Object
The domain ID in DNSimple
5 6 7 |
# File 'lib/dnsimple/domain.rb', line 5 def id @id end |
#lockable ⇒ Object
Is the domain lockable
32 33 34 |
# File 'lib/dnsimple/domain.rb', line 32 def lockable @lockable end |
#name ⇒ Object
The domain name
8 9 10 |
# File 'lib/dnsimple/domain.rb', line 8 def name @name end |
#name_server_status ⇒ Object
The current known name server status
17 18 19 |
# File 'lib/dnsimple/domain.rb', line 17 def name_server_status @name_server_status end |
#registrant_id ⇒ Object
ID of the registrant in DNSimple
26 27 28 |
# File 'lib/dnsimple/domain.rb', line 26 def registrant_id @registrant_id end |
#state ⇒ Object
The state of the domain in DNSimple
23 24 25 |
# File 'lib/dnsimple/domain.rb', line 23 def state @state end |
#updated_at ⇒ Object
When the domain was last update in DNSimple
14 15 16 |
# File 'lib/dnsimple/domain.rb', line 14 def updated_at @updated_at end |
#user_id ⇒ Object
User ID in DNSimple
29 30 31 |
# File 'lib/dnsimple/domain.rb', line 29 def user_id @user_id end |
#whois_protected ⇒ Object
Is the whois information protected
38 39 40 |
# File 'lib/dnsimple/domain.rb', line 38 def whois_protected @whois_protected end |
Class Method Details
.all(options = {}) ⇒ Object
Get all domains for the account.
110 111 112 113 114 115 116 117 118 119 |
# File 'lib/dnsimple/domain.rb', line 110 def self.all(={}) response = DNSimple::Client.get("/v1/domains", ) case response.code when 200 response.map { |r| new(r["domain"]) } else raise RequestError.new("Error listing domains", response) end end |
.check(name, options = {}) ⇒ Object
Check the availability of a name
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/dnsimple/domain.rb', line 42 def self.check(name, ={}) response = DNSimple::Client.get("/v1/domains/#{name}/check", ) case response.code when 200 "registered" when 404 "available" else raise RequestError.new("Error checking availability", response) end end |
.create(name, options = {}) ⇒ Object
Create the domain with the given name in DNSimple. This method returns a Domain instance if the name is created and raises an error otherwise.
58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/dnsimple/domain.rb', line 58 def self.create(name, ={}) .merge!({:body => {:domain => {:name => name}}}) response = DNSimple::Client.post("/v1/domains", ) case response.code when 201 new(response["domain"]) else raise RequestError.new("Error creating domain", response) end end |
.find(id, options = {}) ⇒ Object
Find a specific domain in the account either by the numeric ID or by the fully-qualified domain name.
96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/dnsimple/domain.rb', line 96 def self.find(id, ={}) response = DNSimple::Client.get("/v1/domains/#{id}", ) case response.code when 200 new(response["domain"]) when 404 raise RecordNotFound, "Could not find domain #{id}" else raise RequestError.new("Error finding domain", response) end end |
.register(name, registrant = {}, extended_attributes = {}, options = {}) ⇒ Object
Purchase a domain name.
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/dnsimple/domain.rb', line 72 def self.register(name, registrant={}, extended_attributes={}, ={}) body = {:domain => {:name => name}} if registrant if registrant[:id] body[:domain][:registrant_id] = registrant[:id] else body.merge!(:contact => DNSimple::Contact.resolve_attributes(registrant)) end end body.merge!(:extended_attribute => extended_attributes) .merge!({:body => body}) response = DNSimple::Client.post("/v1/domain_registrations", ) case response.code when 201 return DNSimple::Domain.new(response["domain"]) else raise RequestError.new("Error registering domain", response) end end |
Instance Method Details
#add_service(id_or_short_name, options = {}) ⇒ Object
180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/dnsimple/domain.rb', line 180 def add_service(id_or_short_name, ={}) .merge!(:body => {:service => {:id => id_or_short_name}}) response = DNSimple::Client.post("/v1/domains/#{name}/applied_services", ) case response.code when 200 true else raise RequestError.new("Error adding service", response) end end |
#applied_services(options = {}) ⇒ Object
158 159 160 161 162 163 164 165 166 167 |
# File 'lib/dnsimple/domain.rb', line 158 def applied_services(={}) response = DNSimple::Client.get("/v1/domains/#{name}/applied_services", ) case response.code when 200 response.map { |r| DNSimple::Service.new(r["service"]) } else raise RequestError.new("Error listing applied services", response) end end |
#apply(template, options = {}) ⇒ Object
Apply the given named template to the domain. This will add all of the records in the template to the domain.
142 143 144 145 146 147 |
# File 'lib/dnsimple/domain.rb', line 142 def apply(template, ={}) .merge!(:body => {}) template = resolve_template(template) DNSimple::Client.post("/v1/domains/#{name}/templates/#{template.id}/apply", ) end |
#available_services(options = {}) ⇒ Object
169 170 171 172 173 174 175 176 177 178 |
# File 'lib/dnsimple/domain.rb', line 169 def available_services(={}) response = DNSimple::Client.get("/v1/domains/#{name}/available_services", ) case response.code when 200 response.map { |r| DNSimple::Service.new(r["service"]) } else raise RequestError.new("Error listing available services", response) end end |
#delete(options = {}) ⇒ Object Also known as: destroy
Delete the domain from DNSimple. WARNING: this cannot be undone.
135 136 137 |
# File 'lib/dnsimple/domain.rb', line 135 def delete(={}) DNSimple::Client.delete("/v1/domains/#{name}", ) end |
#disable_auto_renew ⇒ Object
Disable auto_renew on the domain
128 129 130 131 |
# File 'lib/dnsimple/domain.rb', line 128 def disable_auto_renew return unless auto_renew auto_renew!(:delete) end |
#enable_auto_renew ⇒ Object
Enable auto_renew on the domain
122 123 124 125 |
# File 'lib/dnsimple/domain.rb', line 122 def enable_auto_renew return if auto_renew auto_renew!(:post) end |
#remove_service(id, options = {}) ⇒ Object
192 193 194 195 196 197 198 199 200 201 |
# File 'lib/dnsimple/domain.rb', line 192 def remove_service(id, ={}) response = DNSimple::Client.delete("/v1/domains/#{name}/applied_services/#{id}", ) case response.code when 200 true else raise RequestError.new("Error removing service", response) end end |