Sha256: 9a49582da1cf6d219ab14f2cb9ceb441cc7881e47b29c158944faba47c0e1068

Contents?: true

Size: 1.82 KB

Versions: 30

Compression:

Stored size: 1.82 KB

Contents

module Fog
  module DNS
    class DNSimple
      class Real
        # Create a new host in the specified zone
        #
        # ==== Parameters
        # * domain<~String> - domain name or numeric ID
        # * name<~String>
        # * type<~String>
        # * content<~String>
        # * options<~Hash> - optional
        #   * priority<~Integer>
        #   * ttl<~Integer>
        #
        # ==== Returns
        # * response<~Excon::Response>:
        #   * body<~Hash>:
        #     * 'record'<~Hash> The representation of the record.
        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 = {})
          body = {
            "record" => {
              "id" => Fog::Mock.random_numbers(1).to_i,
              "domain_id" => domain,
              "name" => name,
              "content" => content,
              "ttl" => 3600,
              "prio" => nil,
              "record_type" => type,
              "system_record" => nil,
              "created_at" => Time.now.iso8601,
              "updated_at" => Time.now.iso8601,
            }.merge(options)
          }
          self.data[:records][domain] ||= []
          self.data[:records][domain] << body

          response = Excon::Response.new
          response.status = 201
          response.body = body
          response
        end
      end
    end
  end
end

Version data entries

30 entries across 30 versions & 4 rubygems

Version Path
fog-1.38.0 lib/fog/dnsimple/requests/dns/create_record.rb
fog-1.37.0 lib/fog/dnsimple/requests/dns/create_record.rb
fog-1.36.0 lib/fog/dnsimple/requests/dns/create_record.rb
fog-1.35.0 lib/fog/dnsimple/requests/dns/create_record.rb
fog-2.0.0.pre.0 lib/fog/dnsimple/requests/dns/create_record.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-1.32.0/lib/fog/dnsimple/requests/dns/create_record.rb
fog-1.34.0 lib/fog/dnsimple/requests/dns/create_record.rb
fog-1.33.0 lib/fog/dnsimple/requests/dns/create_record.rb
fog-1.32.0 lib/fog/dnsimple/requests/dns/create_record.rb
fog-1.31.0 lib/fog/dnsimple/requests/dns/create_record.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/fog-1.22.1/lib/fog/dnsimple/requests/dns/create_record.rb
fog-1.30.0 lib/fog/dnsimple/requests/dns/create_record.rb
fog-1.29.0 lib/fog/dnsimple/requests/dns/create_record.rb
fog-1.28.0 lib/fog/dnsimple/requests/dns/create_record.rb
fog-1.27.0 lib/fog/dnsimple/requests/dns/create_record.rb
fog-1.26.0 lib/fog/dnsimple/requests/dns/create_record.rb
fog-1.25.0 lib/fog/dnsimple/requests/dns/create_record.rb
nsidc-fog-1.24.1 lib/fog/dnsimple/requests/dns/create_record.rb
fog-1.24.0 lib/fog/dnsimple/requests/dns/create_record.rb
ns-fog-1.22.11 lib/fog/dnsimple/requests/dns/create_record.rb