Class: Fog::Compute::Google::Snapshots

Inherits:
Fog::Collection
  • Object
show all
Defined in:
lib/fog/compute/google/models/snapshots.rb

Instance Method Summary collapse

Instance Method Details

#allObject



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/fog/compute/google/models/snapshots.rb', line 7

def all
  items = []
  next_page_token = nil
  loop do
    data = service.list_snapshots(nil, next_page_token)
    items.concat(data.body["items"]) unless data.body["items"].nil?
    next_page_token = data.body["nextPageToken"]
    break if next_page_token.nil? || next_page_token.empty?
  end
  load(items)
end

#get(snap_id) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/fog/compute/google/models/snapshots.rb', line 19

def get(snap_id)
  response = service.get_snapshot(snap_id)
  return nil if response.nil?
  new(response.body)
rescue Fog::Errors::NotFound
  nil
end