Sha256: 319157695f27e98b1527c7c37f58945e34941a6c3a44bed0d5908b8598e163fe

Contents?: true

Size: 1.54 KB

Versions: 1

Compression:

Stored size: 1.54 KB

Contents

module Fog
  module DNS
    class Bluebox
      class Real

        require 'rackspace-fog/bluebox/parsers/dns/create_record'

        # 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
        def create_record(zone_id, type, name, content, options={})
          body = %Q{<?xml version="1.0" encoding="UTF-8"?><record><type>#{type}</type><name>#{name}</name><content>#{content}</content>}
          options.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

      end

      class Mock

        def create_record(zone_id, type, name, content)
          Fog::Mock.not_implemented
        end

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rackspace-fog-1.4.2 lib/rackspace-fog/bluebox/requests/dns/create_record.rb