Method: Fog::DNS::Slicehost::Real#create_zone

Defined in:
lib/fog/slicehost/requests/dns/create_zone.rb

#create_zone(origin, options = {}) ⇒ Object

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



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/fog/slicehost/requests/dns/create_zone.rb', line 22

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::DNS::Slicehost::CreateZone.new,
    :path     => 'zones.xml'
  )
end