Class: Fog::DNS::Rackspace::Zones
- Inherits:
-
Collection
- Object
- Array
- Collection
- Fog::DNS::Rackspace::Zones
- Defined in:
- lib/fog/rackspace/models/dns/zones.rb
Instance Attribute Summary
Attributes inherited from Collection
Instance Method Summary collapse
- #all(options = {}) ⇒ Object
- #each ⇒ Object
- #each_zone_this_page ⇒ Object
-
#find(substring) ⇒ Object
Returns all domains containing the given substring.
- #get(zone_id) ⇒ Object
Methods inherited from Collection
#clear, #create, #destroy, #initialize, #inspect, #load, model, #model, #new, #reload, #table, #to_json
Methods included from Attributes::ClassMethods
#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes
Methods included from Core::DeprecatedConnectionAccessors
#connection, #connection=, #prepare_service_value
Methods included from Attributes::InstanceMethods
#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #persisted?, #requires, #requires_one
Constructor Details
This class inherits a constructor from Fog::Collection
Instance Method Details
#all(options = {}) ⇒ Object
11 12 13 14 15 |
# File 'lib/fog/rackspace/models/dns/zones.rb', line 11 def all(={}) clear data = service.list_domains().body['domains'] load(data) end |
#each ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/fog/rackspace/models/dns/zones.rb', line 27 def each if !block_given? self else body = service.list_domains.body subset = dup.all subset.each_zone_this_page {|f| yield f} if body.has_key?('links') while !body['links'].select{|l| l['rel'] == 'next'}.empty? url = body['links'].select{|l| l['rel'] == 'next'}.first['href'] query = url.match(/\?(.+)/) parsed = CGI.parse($1) body = service.list_domains(:offset => parsed['offset'], :limit => parsed['limit']).body subset = dup.all(:offset => parsed['offset'], :limit => parsed['limit']) subset.each_zone_this_page {|f| yield f} end end self end end |
#each_zone_this_page ⇒ Object
26 |
# File 'lib/fog/rackspace/models/dns/zones.rb', line 26 alias :each_zone_this_page :each |
#find(substring) ⇒ Object
Returns all domains containing the given substring. Still limited by the 100-domain pagination limit. Returns an empty array if no matches.
20 21 22 23 24 |
# File 'lib/fog/rackspace/models/dns/zones.rb', line 20 def find(substring) clear data = service.list_domains(:name => substring).body['domains'] load(data) end |
#get(zone_id) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/fog/rackspace/models/dns/zones.rb', line 50 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::Rackspace::Errors::NotFound nil #Accessing a valid (but other customer's) id returns a 503 error rescue Fog::Rackspace::Errors::ServiceUnavailable nil end |