Sha256: f78d4b9f210a20de1ad51f7b367694f4fef876006d2ee9379d243815a27c01af

Contents?: true

Size: 1.94 KB

Versions: 39

Compression:

Stored size: 1.94 KB

Contents

module Fog
  module DNS
    class DNSimple
      class Real

        # 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>
        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

      end

      class Mock

        def create_record(domain, name, type, content, options = {})
          response = Excon::Response.new
          response.status = 201
          body = {
            "record" => {
              "name" => name,
              "record_type" => type,
              "content" => content,
              "created_at" => Time.now.iso8601,
              "updated_at" => Time.now.iso8601,
              "id" => Fog::Mock.random_numbers(1).to_i,
              "domain_id" => domain
            }.merge(options)
          }

          self.data[:records][domain] ||= []
          self.data[:records][domain] << body

          response.body = body
          response
        end

      end

    end
  end
end

Version data entries

39 entries across 39 versions & 3 rubygems

Version Path
fog-maestrodev-1.18.0.20131126122111 lib/fog/dnsimple/requests/dns/create_record.rb
fog-maestrodev-1.18.0.20131125111730 lib/fog/dnsimple/requests/dns/create_record.rb
fog-maestrodev-1.18.0.20131125083406 lib/fog/dnsimple/requests/dns/create_record.rb
fog-maestrodev-1.18.0.20131123105121 lib/fog/dnsimple/requests/dns/create_record.rb
fog-maestrodev-1.18.0.20131122203507 lib/fog/dnsimple/requests/dns/create_record.rb
fog-maestrodev-1.18.0.20131121075022 lib/fog/dnsimple/requests/dns/create_record.rb
fog-maestrodev-1.18.0.20131118164830 lib/fog/dnsimple/requests/dns/create_record.rb
fog-maestrodev-1.18.0.20131115184302 lib/fog/dnsimple/requests/dns/create_record.rb
fog-maestrodev-1.18.0.20131114200144 lib/fog/dnsimple/requests/dns/create_record.rb
fog-maestrodev-1.18.0.20131112185232 lib/fog/dnsimple/requests/dns/create_record.rb
fog-maestrodev-1.18.0.20131111203459 lib/fog/dnsimple/requests/dns/create_record.rb
fog-1.18.0 lib/fog/dnsimple/requests/dns/create_record.rb
fog-1.17.0 lib/fog/dnsimple/requests/dns/create_record.rb
fog-1.16.0 lib/fog/dnsimple/requests/dns/create_record.rb
fog-maestrodev-1.15.0.20130927082724 lib/fog/dnsimple/requests/dns/create_record.rb
fog-maestrodev-1.15.0.20130829165835 lib/fog/dnsimple/requests/dns/create_record.rb
fog-1.15.0 lib/fog/dnsimple/requests/dns/create_record.rb
gapinc-fog-1.14.0 lib/fog/dnsimple/requests/dns/create_record.rb
fog-maestrodev-1.14.0.20130806165225 lib/fog/dnsimple/requests/dns/create_record.rb