mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Add initial support for pulling in >100 zones via Zones.each.
Uses the hypermedia links returned by the response body to determine whether or not there are more results available.
This commit is contained in:
parent
148cb14c19
commit
ca7d6f61c8
1 changed files with 22 additions and 0 deletions
|
@ -22,6 +22,28 @@ module Fog
|
||||||
data = service.list_domains(:name => substring).body['domains']
|
data = service.list_domains(:name => substring).body['domains']
|
||||||
load(data)
|
load(data)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
alias :each_zone_this_page :each
|
||||||
|
def each
|
||||||
|
if !block_given?
|
||||||
|
self
|
||||||
|
else
|
||||||
|
body = service.list_domains.body
|
||||||
|
subset = load(body['domains'])
|
||||||
|
|
||||||
|
subset.each_zone_this_page {|f| yield f}
|
||||||
|
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 = load(body['domains'])
|
||||||
|
subset.each_zone_this_page {|f| yield f}
|
||||||
|
end
|
||||||
|
self
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def get(zone_id)
|
def get(zone_id)
|
||||||
if zone_id.nil? or zone_id.to_s.empty?
|
if zone_id.nil? or zone_id.to_s.empty?
|
||||||
|
|
Loading…
Add table
Reference in a new issue