Parent

Class/Module Index [+]

Quicksearch

Fog::DNS::DNSimple::Real

Public Class Methods

new(options={}) click to toggle source
# File lib/fog/dnsimple/dns.rb, line 57
def initialize(options={})
  @dnsimple_email = options[:dnsimple_email]
  @dnsimple_password  = options[:dnsimple_password]
  @connection_options = options[:connection_options] || {}
  if options[:dnsimple_url]
    uri = URI.parse(options[:dnsimple_url])
    options[:host]    = uri.host
    options[:port]    = uri.port
    options[:scheme]  = uri.scheme
  end
  @host       = options[:host]        || "dnsimple.com"
  @persistent = options[:persistent]  || false
  @port       = options[:port]        || 443
  @scheme     = options[:scheme]      || 'https'
  @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end

Public Instance Methods

create_domain(name) click to toggle source

Create a single domain in DNSimple in your account.

Parameters

  • name<~String> - domain name to host (ie example.com)

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • 'name'<~String>

# File lib/fog/dnsimple/requests/dns/create_domain.rb, line 14
def create_domain(name)
  body = { "domain" => { "name" => name } }
  request(
          :body     => Fog::JSON.encode(body),
          :expects  => 201,
          :method   => 'POST',
          :path     => '/domains'
          )
end
create_record(domain, name, type, content, options = {}) click to toggle source

Create a new host in the specified zone

Parameters

  • domain<~String>

  • name<~String>

  • type<~String>

  • content<~String>

  • options<~Hash> - optional

    • priority<~Integer>

    • ttl<~Integer>

Returns

  • response<~Excon::Response>:

    • body<~Hash>

      • name<~String>

      • ttl<~Integer>

      • created_at<~String>

      • special_type<~String>

      • updated_at<~String>

      • domain_id<~Integer>

      • id<~Integer>

      • content<~String>

      • record_type<~String>

      • prio<~Integer>

# File lib/fog/dnsimple/requests/dns/create_record.rb, line 29
def create_record(domain, name, type, content, options = {})

  body = {
    "record" => {
      "name" => name,
      "record_type" => type,
      "content" => content } }

  body["record"].merge!(options)

  request( :body     => Fog::JSON.encode(body),
           :expects  => 201,
           :method   => 'POST',
           :path     => "/domains/#{domain}/records" )
end
delete_domain(name) click to toggle source

Delete the given domain from your account. You may use either the domain ID or the domain name.

Please note that for domains which are registered with DNSimple this will not delete the domain from the registry.

Parameters

  • name<~String> - domain name or numeric ID

# File lib/fog/dnsimple/requests/dns/delete_domain.rb, line 15
def delete_domain(name)
  request(
          :expects  => 200,
          :method   => 'DELETE',
          :path     => "/domains/#{name}"
          )
end
delete_record(domain, record_id) click to toggle source

Delete the record with the given ID for the given domain.

Parameters

  • domain<~String>

  • record_id<~String>

# File lib/fog/dnsimple/requests/dns/delete_record.rb, line 11
def delete_record(domain, record_id)

  request( :expects  => 200,
           :method   => "DELETE",
           :path     => "/domains/#{domain}/records/#{record_id}" )
end
get_domain(id) click to toggle source

Get the details for a specific domain in your account. You may pass either the domain numeric ID or the domain name itself.

Parameters

  • id<~String> - domain name or numeric ID

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • 'domain'<~Hash>

        • 'name'<~String>

        • 'expires_at'<~String>

        • 'created_at'<~String>

        • 'registration_status'<~String>

        • 'updated_at'<~String>

        • 'registrant_id'<~Integer>

        • 'id'<~Integer>

        • 'user_id'<~Integer>

        • 'name_server_status'<~String>

# File lib/fog/dnsimple/requests/dns/get_domain.rb, line 26
def get_domain(id)
  request(
          :expects  => 200,
          :method   => "GET",
          :path     => "/domains/#{id}"
          )
end
get_record(domain, record_id) click to toggle source

Gets record from given domain.

Parameters

  • domain<~String>

  • record_id<~String>

Returns

  • response<~Excon::Response>:

    • record<~Hash>

      • name<~String>

      • ttl<~Integer>

      • created_at<~String>

      • special_type<~String>

      • updated_at<~String>

      • domain_id<~Integer>

      • id<~Integer>

      • content<~String>

      • record_type<~String>

      • prio<~Integer>

# File lib/fog/dnsimple/requests/dns/get_record.rb, line 24
def get_record(domain, record_id)

  request( :expects  => 200,
           :method   => "GET",
           :path     => "/domains/#{domain}/records/#{record_id}" )
end
list_domains() click to toggle source

Get the details for a specific domain in your account. You may pass either the domain numeric ID or the domain name itself.

Parameters

  • id<~String> - domain name or numeric ID

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • 'domains'<~Array>

        • 'name'<~String>

        • 'expires_at'<~String>

        • 'created_at'<~String>

        • 'registration_status'<~String>

        • 'updated_at'<~String>

        • 'registrant_id'<~Integer>

        • 'id'<~Integer>

        • 'user_id'<~Integer>

        • 'name_server_status'<~String>

# File lib/fog/dnsimple/requests/dns/list_domains.rb, line 24
def list_domains
  request(
          :expects  => 200,
          :method   => 'GET',
          :path     => '/domains'
          )
end
list_records(domain) click to toggle source

Get the list of records for the specific domain.

Parameters

  • domain<~String>

Returns

  • response<~Excon::Response>:

    • records<Array~>

      • name<~String>

      • ttl<~Integer>

      • created_at<~String>

      • special_type<~String>

      • updated_at<~String>

      • domain_id<~Integer>

      • id<~Integer>

      • content<~String>

      • record_type<~String>

      • prio<~Integer>

# File lib/fog/dnsimple/requests/dns/list_records.rb, line 23
def list_records(domain)
  request( :expects  => 200,
           :method   => "GET",
           :path     => "/domains/#{domain}/records" )
end
reload() click to toggle source
# File lib/fog/dnsimple/dns.rb, line 74
def reload
  @connection.reset
end
request(params) click to toggle source
# File lib/fog/dnsimple/dns.rb, line 78
def request(params)
  params[:headers] ||= {}
  key = "#{@dnsimple_email}:#{@dnsimple_password}"
  params[:headers].merge!({ "Authorization" => "Basic " + Base64.encode64(key).gsub("\n",''),
                            "Accept" => "application/json",
                            "Content-Type" => "application/json" })

  response = @connection.request(params.merge!({:host => @host}))

  unless response.body.empty?
    response.body = Fog::JSON.decode(response.body)
  end
  response
end
update_record(domain, record_id, options) click to toggle source

Update the given record for the given domain.

Parameters

  • domain<~String>

  • record_id<~String>

  • options<~Hash> - optional

    • type<~String>

    • content<~String>

    • priority<~Integer>

    • ttl<~Integer>

Returns

  • response<~Excon::Response>:

    • record<~Hash>

      • name<~String>

      • ttl<~Integer>

      • created_at<~String>

      • special_type<~String>

      • updated_at<~String>

      • domain_id<~Integer>

      • id<~Integer>

      • content<~String>

      • record_type<~String>

      • prio<~Integer>

# File lib/fog/dnsimple/requests/dns/update_record.rb, line 29
def update_record(domain, record_id, options)

  body = { "record" => options }

  request( :body     => Fog::JSON.encode(body),
           :expects  => 200,
           :method   => "PUT",
           :path     => "/domains/#{domain}/records/#{record_id}" )
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.