Sha256: 20378d8c7ac4943df56e72071034fc91d1bcb40a32069d4750962882d4112faf

Contents?: true

Size: 1.83 KB

Versions: 17

Compression:

Stored size: 1.83 KB

Contents

module Fog
  module Compute
    class Google
      class Snapshot < Fog::Model
        identity :name

        attribute :creation_timestamp, :aliases => "creationTimestamp"
        attribute :description
        attribute :disk_size_gb, :aliases => "diskSizeGb"
        attribute :id
        attribute :kind
        attribute :label_fingerprint, :aliases => "labelFingerprint"
        attribute :labels
        attribute :licenses
        attribute :self_link, :aliases => "selfLink"
        attribute :snapshot_encryption_key, :aliases => "snapshotEncryptionKey"
        attribute :source_disk, :aliases => "sourceDisk"
        attribute :source_disk_encryption_key, :aliases => "sourceDiskEncryptionKey"
        attribute :source_disk_id, :aliases => "sourceDiskId"
        attribute :status
        attribute :storage_bytes, :aliases => "storageBytes"
        attribute :storage_bytes_status, :aliases => "storageBytesStatus"

        CREATING_STATE  = "CREATING".freeze
        DELETING_STATE  = "DELETING".freeze
        FAILED_STATE    = "FAILED".freeze
        READY_STATE     = "READY".freeze
        UPLOADING_STATE = "UPLOADING".freeze

        def destroy(async = true)
          requires :identity

          data = service.delete_snapshot(identity)
          operation = Fog::Compute::Google::Operations.new(:service => service)
                                                      .get(data.name)
          operation.wait_for { ready? } unless async
          operation
        end

        def set_labels(new_labels)
          requires :identity, :label_fingerprint
          service.set_snapshot_labels(identity, label_fingerprint, new_labels)
          reload
        end

        def ready?
          status == READY_STATE
        end

        def resource_url
          "#{service.project}/global/snapshots/#{name}"
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

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