Class: Fog::Compute::Google::Disks
- Inherits:
-
Fog::Collection
- Object
- Fog::Collection
- Fog::Compute::Google::Disks
- Defined in:
- lib/fog/google/models/compute/disks.rb
Instance Method Summary collapse
Instance Method Details
#all(filters = {}) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/fog/google/models/compute/disks.rb', line 10 def all(filters={}) if filters['zone'] data = service.list_disks(filters['zone']).body['items'] || [] else data = [] service.list_aggregated_disks.body['items'].each_value do |zone| data.concat(zone['disks']) if zone['disks'] end end load(data) end |
#get(identity, zone = nil) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/fog/google/models/compute/disks.rb', line 22 def get(identity, zone=nil) response = nil if zone response = service.get_disk(identity, zone).body else disks = service.list_aggregated_disks(:filter => "name eq .*#{identity}").body['items'] disk = disks.each_value.select { |zone| zone.key?('disks') } # It can only be 1 disk with the same name across all regions response = disk.first['disks'].first unless disk.empty? end return nil if response.nil? new(response) rescue Fog::Errors::NotFound nil end |