Sha256: ca97b8681c85b9ae9af733be920501b2498cfd0f08548db8e7df7bb721310535
Contents?: true
Size: 1.11 KB
Versions: 14
Compression:
Stored size: 1.11 KB
Contents
module Fog module Compute class Google class Disks < Fog::Collection model Fog::Compute::Google::Disk 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 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 end end end end
Version data entries
14 entries across 14 versions & 1 rubygems