Sha256: b0a85f640d632c91179a05d6500f18d13dd6f555f2983b2ea575f8b539e6bbb5

Contents?: true

Size: 1.63 KB

Versions: 15

Compression:

Stored size: 1.63 KB

Contents

module Fog
  module Compute
    class Google
      class Disks < Fog::Collection
        model Fog::Compute::Google::Disk

        def all(zone: nil, filter: nil, max_results: nil, order_by: nil,
                page_token: nil)
          opts = {
            :filter => filter,
            :max_results => max_results,
            :order_by => order_by,
            :page_token => page_token
          }
          if zone
            data = service.list_disks(zone, opts).items || []
          else
            data = []
            service.list_aggregated_disks(opts).items.each_value do |scoped_list|
              data.concat(scoped_list.disks) if scoped_list.disks
            end
          end
          load(data.map(&:to_h))
        end

        def get(identity, zone)
          response = service.get_disk(identity, zone)
          return nil if response.nil?
          new(response.to_h)
        rescue ::Google::Apis::ClientError => e
          raise e unless e.status_code == 404
          nil
        end

        def attached_disk_obj(source,
                              writable: true,
                              boot: false,
                              device_name: nil,
                              encryption_key: nil,
                              auto_delete: false)
          {
            :auto_delete => auto_delete,
            :boot => boot,
            :device_name => device_name,
            :disk_encryption_key => encryption_key,
            :mode => writable ? "READ_WRITE" : "READ_ONLY",
            :source => source,
            :type => "PERSISTENT"
          }.reject { |_k, v| v.nil? }
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
fog-google-1.7.1 lib/fog/compute/google/models/disks.rb
fog-google-1.7.0 lib/fog/compute/google/models/disks.rb
fog-google-1.6.0 lib/fog/compute/google/models/disks.rb
fog-google-1.5.0 lib/fog/compute/google/models/disks.rb
fog-google-1.4.0 lib/fog/compute/google/models/disks.rb
fog-google-1.3.3 lib/fog/compute/google/models/disks.rb
fog-google-1.3.2 lib/fog/compute/google/models/disks.rb
fog-google-1.3.1 lib/fog/compute/google/models/disks.rb
fog-google-1.3.0 lib/fog/compute/google/models/disks.rb
fog-google-1.2.2 lib/fog/compute/google/models/disks.rb
fog-google-1.2.1 lib/fog/compute/google/models/disks.rb
fog-google-1.2.0 lib/fog/compute/google/models/disks.rb
fog-google-1.1.0 lib/fog/compute/google/models/disks.rb
fog-google-1.0.1 lib/fog/compute/google/models/disks.rb
fog-google-1.0.0 lib/fog/compute/google/models/disks.rb