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.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/fog/dreamhost/dns.rb', line 49 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::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent) end |
Instance Method Details
#create_record(record, type, value, comment = "") ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/fog/dreamhost/requests/dns/create_record.rb', line 15 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
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/fog/dreamhost/requests/dns/delete_record.rb', line 15 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
15 16 17 18 19 20 |
# File 'lib/fog/dreamhost/requests/dns/list_records.rb', line 15 def list_records request( :expects => 200, :method => "GET", :path => "/", :query => { :cmd => 'dns-list_records' } ) end |
#reload ⇒ Object
64 65 66 |
# File 'lib/fog/dreamhost/dns.rb', line 64 def reload @connection.reset end |
#request(params) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/fog/dreamhost/dns.rb', line 68 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 |