mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Merge pull request #1808 from harryw/rds_snapshot_pagination
Include all snapshots in Fog::AWS::RDS::Snapshots#all
This commit is contained in:
commit
80724ac8d7
1 changed files with 19 additions and 3 deletions
|
@ -21,10 +21,26 @@ module Fog
|
|||
super
|
||||
end
|
||||
|
||||
# This will return a single page based on the current or provided filters,
|
||||
# updating the filters with the marker for the next page. Calling this repeatedly
|
||||
# will iterate through pages.
|
||||
def all(filters = filters)
|
||||
self.filters = filters
|
||||
data = service.describe_db_snapshots(filters).body['DescribeDBSnapshotsResult']['DBSnapshots']
|
||||
load(data) # data is an array of attribute hashes
|
||||
self.filters.merge!(filters)
|
||||
|
||||
snapshots = service.describe_db_snapshots(filters)
|
||||
self.filters[:marker] = snapshots.body['DescribeDBSnapshotsResult']['Marker']
|
||||
data = snapshots.body['DescribeDBSnapshotsResult']['DBSnapshots']
|
||||
load(data)
|
||||
end
|
||||
|
||||
# This will execute a block for each snapshot, fetching new pages of snapshots as required.
|
||||
def each(filters = filters)
|
||||
begin
|
||||
page = self.all(filters)
|
||||
# We need to explicitly use the base 'each' method here on the page, otherwise we get infinite recursion
|
||||
base_each = Fog::Collection.instance_method(:each)
|
||||
base_each.bind(page).call {|snapshot| yield snapshot}
|
||||
end while self.filters[:marker]
|
||||
end
|
||||
|
||||
def get(identity)
|
||||
|
|
Loading…
Reference in a new issue