Class: Fog::Compute::Google::DiskTypes
- Inherits:
-
Fog::Collection
- Object
- Fog::Collection
- Fog::Compute::Google::DiskTypes
- Defined in:
- lib/fog/google/models/compute/disk_types.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/disk_types.rb', line 10 def all(filters = {}) if filters['zone'] data = service.list_disk_types(filters['zone']).body['items'] || [] else data = [] service.list_aggregated_disk_types.body['items'].each_value do |zone| data.concat(zone['diskTypes']) if zone['diskTypes'] 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 |
# File 'lib/fog/google/models/compute/disk_types.rb', line 22 def get(identity, zone = nil) response = nil if zone response = service.get_disk_type(identity, zone).body else disk_types = service.list_aggregated_disk_types(:filter => "name eq .*#{identity}").body['items'] || {} disk_type = disk_types.each_value.detect { |zone| zone.key?('diskTypes') } || {} response = disk_type['diskTypes'].first unless disk_type.empty? end return nil if response.nil? new(response) rescue Fog::Errors::NotFound nil end |