Class: Fog::DNS::Bluebox::Real
- Inherits:
-
Object
- Object
- Fog::DNS::Bluebox::Real
- Defined in:
- lib/fog/bluebox/dns.rb,
lib/fog/bluebox/requests/dns/get_zone.rb,
lib/fog/bluebox/requests/dns/get_zones.rb,
lib/fog/bluebox/requests/dns/get_record.rb,
lib/fog/bluebox/requests/dns/create_zone.rb,
lib/fog/bluebox/requests/dns/delete_zone.rb,
lib/fog/bluebox/requests/dns/get_records.rb,
lib/fog/bluebox/requests/dns/update_zone.rb,
lib/fog/bluebox/requests/dns/create_record.rb,
lib/fog/bluebox/requests/dns/delete_record.rb
Instance Method Summary collapse
-
#create_record(zone_id, type, name, content, options = {}) ⇒ Object
Create a new record in a DNS zone ==== Parameters * type<~String> - type of DNS record to create (A, CNAME, etc) * name<~String> - host name this DNS record is for * content<~String> - data for the DNS record (ie for an A record, the IP address) ==== Returns * response<~Excon::Response>: * body<~Hash>: * ‘name’<~String> - as above * ‘id’<~Integer> - Id of zone/domain - used in future API calls for this zone * ‘ttl’<~Integer> - as above * ‘data’<~String> - as above * ‘active’<~String> - as above * ‘aux’<~String> - as above.
-
#create_zone(options) ⇒ Object
Create a new DNS zone ==== Parameters * ‘name’<~String> - The name of the zone * ‘ttl’<~Integer> - TimeToLive (ttl) for the domain, in seconds * ‘retry’<~Integer> - Retry interval for the domain, in seconds * ‘refresh’<~Integer> - Refresh interval for the zone * ‘minimum’<~Integer> - Minimum refresh interval for the zone ==== Returns * response<~Excon::Response>: * body<~Hash>: * ‘name’<~String> - The name of the zone * ‘serial’<~Integer> - Serial number of the zone * ‘ttl’<~Integer> - TimeToLive (ttl) for the domain, in seconds * ‘retry’<~Integer> - Retry interval for the domain, in seconds * ‘record-count’<~Integer> - Number of records in the zone * ‘id’<~String> - Id for the zone * ‘refresh’<~Integer> - Refresh interval for the zone * ‘minimum’<~Integer> - Minimum refresh interval for the zone.
-
#delete_record(zone_id, record_id) ⇒ Object
Delete a record from the specified DNS zone ==== Parameters * record_id<~Integer> - Id of DNS record to delete.
-
#delete_zone(zone_id) ⇒ Object
Delete a zone from DNS ==== Parameters * zone_id<~Integer> - Id of zone to delete.
-
#get_record(zone_id, record_id) ⇒ Object
Get an individual DNS record from the specified zone.
-
#get_records(zone_id) ⇒ Object
Get all the DNS records across all the DNS zones for this account.
-
#get_zone(zone_id) ⇒ Object
Get details of a DNS zone.
-
#get_zones ⇒ Object
Get list of all DNS zones hosted on Bluebox (for this account).
-
#initialize(options = {}) ⇒ Real
constructor
A new instance of Real.
- #reload ⇒ Object
- #request(params) ⇒ Object
-
#update_zone(zone_id, options) ⇒ Object
Updates an existing DNS zone.
Constructor Details
#initialize(options = {}) ⇒ Real
Returns a new instance of Real.
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/fog/bluebox/dns.rb', line 55 def initialize( ={}) @bluebox_customer_id = [:bluebox_customer_id] @bluebox_api_key = [:bluebox_api_key] @connection_options = [:connection_options] || {} @host = [:bluebox_host] || "boxpanel.bluebox.net" @persistent = [:persistent] || false @port = [:bluebox_port] || 443 @scheme = [:bluebox_scheme] || 'https' @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options) end |
Instance Method Details
#create_record(zone_id, type, name, content, options = {}) ⇒ Object
Create a new record in a DNS zone
Parameters
-
type<~String> - type of DNS record to create (A, CNAME, etc)
-
name<~String> - host name this DNS record is for
-
content<~String> - data for the DNS record (ie for an A record, the IP address)
Returns
-
response<~Excon::Response>:
-
body<~Hash>:
-
‘name’<~String> - as above
-
‘id’<~Integer> - Id of zone/domain - used in future API calls for this zone
-
‘ttl’<~Integer> - as above
-
‘data’<~String> - as above
-
‘active’<~String> - as above
-
‘aux’<~String> - as above
-
-
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/fog/bluebox/requests/dns/create_record.rb', line 22 def create_record(zone_id, type, name, content, ={}) body = %Q{<?xml version="1.0" encoding="UTF-8"?><record><type>#{type}</type><name>#{name}</name><content>#{content}</content>} .each do |k,v| body += %Q{<#{k}>#{v}</#{k}>} end body += %Q{</record>} request( :body => body, :expects => 202, :method => 'POST', :parser => Fog::Parsers::DNS::Bluebox::CreateRecord.new, :path => "/api/domains/#{zone_id}/records.xml" ) end |
#create_zone(options) ⇒ Object
Create a new DNS zone
Parameters
* 'name'<~String> - The name of the zone
* 'ttl'<~Integer> - TimeToLive (ttl) for the domain, in seconds
* 'retry'<~Integer> - Retry interval for the domain, in seconds
* 'refresh'<~Integer> - Refresh interval for the zone
* 'minimum'<~Integer> - Minimum refresh interval for the zone
Returns
-
response<~Excon::Response>:
-
body<~Hash>:
-
‘name’<~String> - The name of the zone
-
‘serial’<~Integer> - Serial number of the zone
-
‘ttl’<~Integer> - TimeToLive (ttl) for the domain, in seconds
-
‘retry’<~Integer> - Retry interval for the domain, in seconds
-
‘record-count’<~Integer> - Number of records in the zone
-
‘id’<~String> - Id for the zone
-
‘refresh’<~Integer> - Refresh interval for the zone
-
‘minimum’<~Integer> - Minimum refresh interval for the zone
-
-
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/fog/bluebox/requests/dns/create_zone.rb', line 26 def create_zone() body = %Q{<?xml version="1.0" encoding="UTF-8"?><domain><name>#{[:name]}</name><ttl>#{[:ttl]}</ttl>} body += %Q{<retry>#{[:retry]}</retry>} if [:retry] body += %Q{<refresh>#{[:retry]}</refresh>} if [:refresh] body += %Q{<minimum>#{[:minimum]}</minimum>} if [:minimum] body += %Q{</domain>} request( :body => body, :expects => 202, :method => 'POST', :parser => Fog::Parsers::DNS::Bluebox::CreateZone.new, :path => "/api/domains.xml" ) end |
#delete_record(zone_id, record_id) ⇒ Object
Delete a record from the specified DNS zone
Parameters
-
record_id<~Integer> - Id of DNS record to delete
Returns
-
response<~Excon::Response>: - HTTP status code will be result
12 13 14 15 16 17 18 |
# File 'lib/fog/bluebox/requests/dns/delete_record.rb', line 12 def delete_record(zone_id, record_id) request( :expects => 200, :method => 'DELETE', :path => "/api/domains/#{zone_id}/records/#{record_id}.xml" ) end |
#delete_zone(zone_id) ⇒ Object
Delete a zone from DNS
Parameters
-
zone_id<~Integer> - Id of zone to delete
Returns
-
response<~Excon::Response>: - HTTP status code will be result
12 13 14 15 16 17 18 |
# File 'lib/fog/bluebox/requests/dns/delete_zone.rb', line 12 def delete_zone(zone_id) request( :expects => 200, :method => 'DELETE', :path => "/api/domains/#{zone_id}.xml" ) end |
#get_record(zone_id, record_id) ⇒ Object
Get an individual DNS record from the specified zone
Returns
-
response<~Excon::Response>:
-
hash<~Hash>:
-
‘id’<~String> - The id of this record
-
‘type’<~String> - type of DNS record to create (A, CNAME, etc)
-
‘domain-id’<~Integer> - ID of the zone
-
‘name’<~String> - empty?
-
‘domain’<~String> - The domain name
-
‘type’<~String> - The type of DNS record (e.g. A, MX, NS, etc.)
-
‘content’<~String> - data for the DNS record (ie for an A record, the IP address)
-
-
20 21 22 23 24 25 26 27 |
# File 'lib/fog/bluebox/requests/dns/get_record.rb', line 20 def get_record(zone_id, record_id) request( :expects => 200, :method => 'GET', :parser => Fog::Parsers::DNS::Bluebox::GetRecord.new, :path => "/api/domains/#{zone_id}/records/#{record_id}.xml" ) end |
#get_records(zone_id) ⇒ Object
Get all the DNS records across all the DNS zones for this account
Returns
-
response<~Excon::Response>:
-
body<~Array>:
-
‘addresses’<~Array> - Ip addresses for the slice
-
‘backup-id’<~Integer> - Id of backup slice was booted from
-
‘flavor_id’<~Integer> - Id of flavor slice was booted from
-
‘id’<~Integer> - Id of the slice
-
‘image-id’<~Integer> - Id of image slice was booted from
-
‘name’<~String> - Name of the slice
-
‘progress’<~Integer> - Progress of current action, in percentage
-
‘status’<~String> - Current status of the slice
-
-
21 22 23 24 25 26 27 28 |
# File 'lib/fog/bluebox/requests/dns/get_records.rb', line 21 def get_records(zone_id) request( :expects => 200, :method => 'GET', :parser => Fog::Parsers::DNS::Bluebox::GetRecords.new, :path => "/api/domains/#{zone_id}/records.xml" ) end |
#get_zone(zone_id) ⇒ Object
Get details of a DNS zone
Parameters
-
zone_id<~Integer> - Id of zone to lookup
Returns
-
response<~Excon::Response>:
-
hash<~Hash>:
-
‘name’<~String> - The name of the zone
-
‘serial’<~Integer> - Serial number of the zone
-
‘ttl’<~Integer> - TimeToLive (ttl) for the domain, in seconds
-
‘retry’<~Integer> - Retry interval for the domain, in seconds
-
‘record-count’<~Integer> - Number of records in the zone
-
‘id’<~String> - Id for the zone
-
‘refresh’<~Integer> - Refresh interval for the zone
-
‘minimum’<~Integer> - Minimum refresh interval for the zone
-
-
24 25 26 27 28 29 30 31 |
# File 'lib/fog/bluebox/requests/dns/get_zone.rb', line 24 def get_zone(zone_id) request( :expects => 200, :method => 'GET', :parser => Fog::Parsers::DNS::Bluebox::GetZone.new, :path => "/api/domains/#{zone_id}.xml" ) end |
#get_zones ⇒ Object
Get list of all DNS zones hosted on Bluebox (for this account)
Returns
-
response<~Excon::Response>:
-
‘records’<~Array>
-
‘record’
-
‘name’<~String> - name of the zone
-
‘serial’<~Integer> - Serial # for the zone
-
‘ttl’<~Integer> - TTL for the zone record in seconds
-
‘retry’<~Integer> - Retry interval for the zone record in seconds
-
‘expires’<~Integer> - Expiration interval for the zone record in seconds
-
‘record-count’<~Integer> - # of records in this zone
-
‘id’<~String> - Id for the zone record
-
‘refresh’<~Integer> - default refresh interval for this zone, in seconds
-
‘minimum’<~Integer> - minimum value for intervals for this zone, in seconds
-
-
-
23 24 25 26 27 28 29 30 |
# File 'lib/fog/bluebox/requests/dns/get_zones.rb', line 23 def get_zones request( :expects => 200, :method => 'GET', :parser => Fog::Parsers::DNS::Bluebox::GetZones.new, :path => '/api/domains.xml' ) end |
#reload ⇒ Object
66 67 68 |
# File 'lib/fog/bluebox/dns.rb', line 66 def reload @connection.reset end |
#request(params) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/fog/bluebox/dns.rb', line 70 def request(params) params[:headers] ||= {} params[:headers]['Authorization'] = "Basic #{auth_header}" params[:headers]['Accept'] = 'application/xml' case params[:method] when 'POST', 'PUT' params[:headers]['Content-Type'] = 'application/xml' end begin response = @connection.request(params.merge!({:host => @host})) rescue Excon::Errors::HTTPStatusError => error raise case error when Excon::Errors::NotFound Fog::DNS::Bluebox::NotFound.slurp(error) else error end end response end |
#update_zone(zone_id, options) ⇒ Object
Updates an existing DNS zone
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/fog/bluebox/requests/dns/update_zone.rb', line 7 def update_zone(zone_id, ) body = %Q{<?xml version="1.0" encoding="UTF-8"?><domain>} .each {|k,v| body += "<#{k}>#{v}</#{k}>"} body += "</domain>" request( :body => body, :expects => 202, :method => 'PUT', :path => "/api/domains/#{zone_id}.xml" ) end |