Class: Fog::DNS::Rackspace::Zones

Inherits:
Collection
  • Object
show all
Defined in:
lib/fog/rackspace/models/dns/zones.rb

Instance Method Summary collapse

Instance Method Details

#all(options = {}) ⇒ Object

List all domains. Return by default a maximum of 100 items

Parameters:

  • options (Hash) (defaults to: {})

    Options to pass to the underlying API call

Options Hash (options):

  • :name (String)

    search for domains containing the given substring

  • :limit (Integer)

    number of records to return

  • :offset (Integer)

    starting offset of records to return



17
18
19
20
21
22
23
# File 'lib/fog/rackspace/models/dns/zones.rb', line 17

def all(options={})
  clear
  body = service.list_domains(options).body
  merge_attributes(body)

  load(body['domains'])
end

#eachObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/fog/rackspace/models/dns/zones.rb', line 26

def each
  return self unless block_given?

  params = { :limit => 100} # prime loop (100 Records is default page size for Rackspace Cloud)
  while params
    body = service.list_domains(params).body
    subset = dup.load(body["domains"])
    self.merge_attributes(body)

    params = next_params(body)

    subset.each_zone_this_page {|zone| yield zone}
  end
  self
end

#each_zone_this_pageObject



25
# File 'lib/fog/rackspace/models/dns/zones.rb', line 25

alias_method :each_zone_this_page, :each

#get(zone_id) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/fog/rackspace/models/dns/zones.rb', line 42

def get(zone_id)
  if zone_id.nil? or zone_id.to_s.empty?
    return nil
  end

  data = service.list_domain_details(zone_id).body
  new(data)
rescue Fog::DNS::Rackspace::NotFound
  # if we can't find it by id, go back and find it via domain
  find{|z| z.domain == zone_id}
#Accessing a valid (but other customer's) id returns a 503 error
rescue Fog::Rackspace::Errors::ServiceUnavailable
  nil
end