Sha256: a0912fb9ccf6a3f6c5279390c1d4a0e2f686bb4ff83ddfd3922355d505052741

Contents?: true

Size: 1.5 KB

Versions: 9

Compression:

Stored size: 1.5 KB

Contents

module Fog
  module Slicehost
    class DNS
      class Real

        require 'fog/dns/parsers/slicehost/create_zone'

        # Create a new zone for Slicehost's DNS servers to serve/host
        # ==== Parameters
        # * origin<~String> - domain name to host (ie example.com)
        # * options<~Hash> - optional paramaters
        #   * ttl<~Integer> - TimeToLive (ttl) for the domain, in seconds (> 60)
        #   * active<~String> - whether zone is active in Slicehost DNS server - 'Y' or 'N'
        #
        # ==== Returns
        # * response<~Excon::Response>:
        #   * body<~Hash>:
        #     * 'origin'<~String> - as above
        #     * 'id'<~Integer> - Id of zone/domain - used in future API calls
        #     * 'ttl'<~Integer> - as above
        #     * 'active'<~String> - as above
        def create_zone(origin, options = {})

          optional_tags= ''
          options.each { |option, value|
            case option
            when :ttl
              optional_tags+= "<ttl type='interger'>#{value}</ttl>"
            when :active
              optional_tags+= "<active>#{value}</active>"
            end
          }
          
          request(
            :body     => %Q{<?xml version="1.0" encoding="UTF-8"?><zone><origin>#{origin}</origin>#{optional_tags}</zone>},
            :expects  => 201,
            :method   => 'POST',
            :parser   => Fog::Parsers::Slicehost::DNS::CreateZone.new,
            :path     => 'zones.xml'
          )
        end

      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
fog-0.8.2 lib/fog/dns/requests/slicehost/create_zone.rb
fog-0.8.1 lib/fog/dns/requests/slicehost/create_zone.rb
fog-0.8.0 lib/fog/dns/requests/slicehost/create_zone.rb
fog-0.7.2 lib/fog/dns/requests/slicehost/create_zone.rb
fog-0.7.1 lib/fog/dns/requests/slicehost/create_zone.rb
fog-0.7.0 lib/fog/dns/requests/slicehost/create_zone.rb
fog-0.6.0 lib/fog/dns/requests/slicehost/create_zone.rb
fog-0.5.3 lib/fog/dns/requests/slicehost/create_zone.rb
fog-0.5.2 lib/fog/dns/requests/slicehost/create_zone.rb