Sha256: 8c21961772c6f349515a04389774bd21c53b944fb8be81a94b9ed55403e2228c

Contents?: true

Size: 1.11 KB

Versions: 14

Compression:

Stored size: 1.11 KB

Contents

module Fog
  module Compute
    class Google
      class DiskTypes < Fog::Collection
        model Fog::Compute::Google::DiskType

        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

        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
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
fog-google-0.6.0 lib/fog/compute/google/models/disk_types.rb
fog-google-0.5.5 lib/fog/compute/google/models/disk_types.rb
fog-google-0.5.4 lib/fog/compute/google/models/disk_types.rb
fog-google-0.5.3 lib/fog/compute/google/models/disk_types.rb
fog-google-0.5.2 lib/fog/compute/google/models/disk_types.rb
fog-google-0.5.1 lib/fog/compute/google/models/disk_types.rb
fog-google-0.5.0 lib/fog/compute/google/models/disk_types.rb
fog-google-0.4.2 lib/fog/compute/google/models/disk_types.rb
fog-google-0.4.1 lib/fog/compute/google/models/disk_types.rb
fog-google-0.4.0 lib/fog/compute/google/models/disk_types.rb
fog-google-0.3.2 lib/fog/compute/google/models/disk_types.rb
fog-google-0.3.1 lib/fog/compute/google/models/disk_types.rb
fog-google-0.3.0 lib/fog/compute/google/models/disk_types.rb
fog-google-0.2.0 lib/fog/compute/google/models/disk_types.rb