Class: Fog::DNS::Dreamhost::Real
- Inherits:
-
Object
- Object
- Fog::DNS::Dreamhost::Real
- Defined in:
- lib/fog/dreamhost/dns.rb,
lib/fog/dreamhost/requests/dns/list_records.rb,
lib/fog/dreamhost/requests/dns/create_record.rb,
lib/fog/dreamhost/requests/dns/delete_record.rb
Instance Method Summary collapse
- #create_record(record, type, value, comment = "") ⇒ Object
- #delete_record(name, type, value) ⇒ Object
-
#initialize(options = {}) ⇒ Real
constructor
A new instance of Real.
- #list_records ⇒ Object
- #reload ⇒ Object
- #request(params) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Real
Returns a new instance of Real.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/fog/dreamhost/dns.rb', line 44 def initialize(={}) @dreamhost_api_key = [:dreamhost_api_key] if [:dreamhost_url] uri = URI.parse([:dreamhost_url]) [:host] = uri.host [:port] = uri.port [:scheme] = uri.scheme end @host = [:host] || "api.dreamhost.com" @persistent = [:persistent] || false @port = [:port] || 443 @scheme = [:scheme] || 'https' @connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent) end |
Instance Method Details
#create_record(record, type, value, comment = "") ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/fog/dreamhost/requests/dns/create_record.rb', line 11 def create_record(record, type, value, comment = "") request( :expects => 200, :method => 'GET', :path => "/", :query => { :record => record, :type => type, :value => value, :cmd => 'dns-add_record', :comment => comment } ) end |
#delete_record(name, type, value) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/fog/dreamhost/requests/dns/delete_record.rb', line 11 def delete_record(name, type, value) request( :expects => 200, :method => "GET", :path => "/", :query => { :cmd => 'dns-remove_record', :type => type, :record => name, :value => value, } ) end |
#list_records ⇒ Object
11 12 13 14 15 16 |
# File 'lib/fog/dreamhost/requests/dns/list_records.rb', line 11 def list_records request( :expects => 200, :method => "GET", :path => "/", :query => { :cmd => 'dns-list_records' } ) end |
#reload ⇒ Object
59 60 61 |
# File 'lib/fog/dreamhost/dns.rb', line 59 def reload @connection.reset end |
#request(params) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/fog/dreamhost/dns.rb', line 63 def request(params) params[:query].merge!( { :key => @dreamhost_api_key, :format => 'json' } ) response = @connection.request(params) unless response.body.empty? response.body = Fog::JSON.decode(response.body) end if response.body['result'] != 'success' raise response.body['data'] end response end |