Class/Module Index [+]

Quicksearch

Fog::DNS::Rackspace::Real

Public Class Methods

new(options={}) click to toggle source
# File lib/fog/rackspace/dns.rb, line 86
def initialize(options={})
  @rackspace_api_key = options[:rackspace_api_key]
  @rackspace_username = options[:rackspace_username]
  @rackspace_auth_url = options[:rackspace_auth_url]
  @connection_options = options[:connection_options] || {}
  @rackspace_endpoint = Fog::Rackspace.normalize_url(options[:rackspace_dns_url] || options[:rackspace_dns_endpoint])
  @rackspace_region = options[:rackspace_region]

  authenticate

  deprecation_warnings(options)

  @connection_options[:headers] ||= {}
  @connection_options[:headers].merge!({ 'Content-Type' => 'application/json', 'X-Auth-Token' => auth_token })

  @persistent = options[:persistent] || false
  @connection = Fog::Connection.new(endpoint_uri.to_s, @persistent, @connection_options)
end

Public Instance Methods

add_records(domain_id, records) click to toggle source
# File lib/fog/rackspace/requests/dns/add_records.rb, line 5
def add_records(domain_id, records)

  validate_path_fragment :domain_id, domain_id

  data = {
    'records' => records.collect do |record|
      record_data = {
        'name' => record[:name],
        'type' => record[:type],
        'data' => record[:data]
      }
      
      if record.has_key? :ttl
        record_data['ttl'] = record[:ttl]
      end
      
      if record.has_key? :priority
        record_data['priority'] = record[:priority]
      end
      record_data
    end
  }

  request(
    :expects  => 202,
    :method   => 'POST',
    :path     => "domains/#{domain_id}/records",
    :body     => Fog::JSON.encode(data)
  )
end
callback(job_id, show_details=true) click to toggle source
# File lib/fog/rackspace/requests/dns/callback.rb, line 5
def callback(job_id, show_details=true)

  validate_path_fragment :job_id, job_id

  request(
    :expects  => [200, 202, 204],
    :method   => 'GET',
    :path     => "status/#{job_id}",
    :query    => "showDetails=#{show_details}"
  )
end
create_domains(domains) click to toggle source
# File lib/fog/rackspace/requests/dns/create_domains.rb, line 5
def create_domains(domains)
  data = {
    'domains' => []
  }

  domains.each do |domain|
    domain_data =
      {
        'name' => domain[:name],
        'emailAddress' => domain[:email]
      }

    if domain.has_key? :records
      domain_data['recordsList'] = {
        'records' => domain[:records].collect do |record|
          record_data = {
            'ttl' => record[:ttl],
            'data' => record[:data],
            'name' => record[:name],
            'type' => record[:type],
          }

          if record.has_key? :priority
            record_data.merge!({'priority' => record[:priority]})
          else
            record_data
          end
        end
      }
    end
    data['domains'] << domain_data
  end

  request(
    :expects  => 202,
    :method   => 'POST',
    :path     => 'domains',
    :body     => Fog::JSON.encode(data)
  )
end
endpoint_uri(service_endpoint_url=nil) click to toggle source
# File lib/fog/rackspace/dns.rb, line 105
def endpoint_uri(service_endpoint_url=nil)
  @uri = super(@rackspace_endpoint || service_endpoint_url, :rackspace_dns_url)
end
list_domain_details(domain_id, options={}) click to toggle source
# File lib/fog/rackspace/requests/dns/list_domain_details.rb, line 5
def list_domain_details(domain_id, options={})

  validate_path_fragment :domain_id, domain_id

  path = "domains/#{domain_id}"
  query_data = {}

  if options.has_key? :show_records
    query_data['showRecords'] = options[:show_records]
  end
  if options.has_key? :show_subdomains
    query_data['showSubdomains'] = options[:show_subdomains]
  end

  if !query_data.empty?
    path = path + '?' + array_to_query_string(query_data)
  end

  request(
    :expects  => 200,
    :method   => 'GET',
    :path     => path
  )
end
list_domains(options={}) click to toggle source
# File lib/fog/rackspace/requests/dns/list_domains.rb, line 5
def list_domains(options={})

  path = 'domains'
  if !options.empty?
    path = path + '?' + array_to_query_string(options)
  end

  request(
    :expects  => 200,
    :method   => 'GET',
    :path     => path
  )
end
list_record_details(domain_id, record_id) click to toggle source
# File lib/fog/rackspace/requests/dns/list_record_details.rb, line 5
def list_record_details(domain_id, record_id)

  validate_path_fragment :domain_id, domain_id
  validate_path_fragment :record_id, record_id

  path = "domains/#{domain_id}/records/#{record_id}"

  request(
    :expects  => 200,
    :method   => 'GET',
    :path     => path
  )
end
list_records(domain_id, options={}) click to toggle source
# File lib/fog/rackspace/requests/dns/list_records.rb, line 5
def list_records(domain_id, options={})

  validate_path_fragment :domain_id, domain_id

  path = "domains/#{domain_id}/records"
  if !options.empty?
    path = path + '?' + array_to_query_string(options)
  end

  request(
    :expects  => 200,
    :method   => 'GET',
    :path     => path
  )
end
list_subdomains(domain_id, options={}) click to toggle source
# File lib/fog/rackspace/requests/dns/list_subdomains.rb, line 5
def list_subdomains(domain_id, options={})

  validate_path_fragment :domain_id, domain_id

  path = "domains/#{domain_id}/subdomains"
  if !options.empty?
    path = path + '?' + array_to_query_string(options)
  end

  request(
    :expects  => 200,
    :method   => 'GET',
    :path     => path
  )
end
modify_domain(domain_id, options={}) click to toggle source
# File lib/fog/rackspace/requests/dns/modify_domain.rb, line 5
def modify_domain(domain_id, options={})

  validate_path_fragment :domain_id, domain_id

  path = "domains/#{domain_id}"
  data = {}

  if options.has_key? :ttl
    data['ttl'] = options[:ttl]
  end
  if options.has_key? :comment
    data['comment'] = options[:comment]
  end
  if options.has_key? :email
    data['emailAddress'] = options[:email]
  end

  if data.empty?
    return
  end

  request(
    :expects  => [202, 204],
    :method   => 'PUT',
    :path     => path,
    :body     => Fog::JSON.encode(data)
  )
end
modify_record(domain_id, record_id, options={}) click to toggle source
# File lib/fog/rackspace/requests/dns/modify_record.rb, line 5
def modify_record(domain_id, record_id, options={})

  validate_path_fragment :domain_id, domain_id
  validate_path_fragment :record_id, record_id

  path = "domains/#{domain_id}/records/#{record_id}"
  data = {}

  if options.has_key? :ttl
    data['ttl'] = options[:ttl]
  end
  if options.has_key? :name
    data['name'] = options[:name]
  end
  if options.has_key? :data
    data['data'] = options[:data]
  end

  if data.empty?
    return
  end

  request(
    :expects  => [202, 204],
    :method   => 'PUT',
    :path     => path,
    :body     => Fog::JSON.encode(data)
  )
end
region() click to toggle source
# File lib/fog/rackspace/dns.rb, line 81
def region
  #Note: DNS does not currently support multiple regions
  @rackspace_region
end
remove_domain(domain_id, options={}) click to toggle source
# File lib/fog/rackspace/requests/dns/remove_domain.rb, line 5
def remove_domain(domain_id, options={})

  validate_path_fragment :domain_id, domain_id

  path = "domains/#{domain_id}"
  query_data = {}

  if options.has_key? :delete_subdomains
    query_data['deleteSubdomains'] = options[:delete_subdomains].to_s
  end

  if !query_data.empty?
    path = path + '?' + array_to_query_string(query_data)
  end

  request(
    :expects  => [202, 204],
    :method   => 'DELETE',
    :path     => path
  )
end
remove_domains(domain_ids, options={}) click to toggle source
# File lib/fog/rackspace/requests/dns/remove_domains.rb, line 5
def remove_domains(domain_ids, options={})

  path = "domains?" + domain_ids.collect { |domain_id| "id=#{domain_id}" }.join('&')
  query_data = {}

  if options.has_key? :delete_subdomains
    query_data['deleteSubdomains'] = options[:delete_subdomains]
  end

  if !query_data.empty?
    path = path + '&' + array_to_query_string(query_data)
  end

  request(
    :expects  => [202, 204],
    :method   => 'DELETE',
    :path     => path
  )
end
remove_record(domain_id, record_id) click to toggle source
# File lib/fog/rackspace/requests/dns/remove_record.rb, line 5
def remove_record(domain_id, record_id)

  validate_path_fragment :domain_id, domain_id
  validate_path_fragment :record_id, record_id

  path = "domains/#{domain_id}/records/#{record_id}"

  request(
    :expects  => [202, 204],
    :method   => 'DELETE',
    :path     => path
  )
end
remove_records(domain_id, record_ids) click to toggle source
# File lib/fog/rackspace/requests/dns/remove_records.rb, line 5
def remove_records(domain_id, record_ids)

  validate_path_fragment :domain_id, domain_id

  path = "domains/#{domain_id}/records?" + record_ids.collect { |record_id| "id=#{record_id}" }.join('&')

  request(
    :expects  => [202, 204],
    :method   => 'DELETE',
    :path     => path
  )
end
service_name() click to toggle source
# File lib/fog/rackspace/dns.rb, line 77
def service_name
  :cloudDNS
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.