Sha256: 794ed3a6b8fd0d0aa93395a68778e345a02194a8ee3a7280206043ecdefff43b

Contents?: true

Size: 1.58 KB

Versions: 22

Compression:

Stored size: 1.58 KB

Contents

# frozen_string_literal: true

require 'fog/core/model'
module Fog
  module Compute
    class Aliyun
      class Snapshot < Fog::Model
        identity :id, aliases: 'SnapshotId'
        attribute :name, aliases: 'SnapshotName'
        attribute :description, aliases: 'Description'
        attribute :progress, aliases: 'Progress'
        attribute :volume_id, aliases: 'SourceDiskId'
        attribute :volume_size, aliases: 'SourceDiskSize'
        attribute :volume_type, aliases: 'SourceDiskType'
        attribute :product_code, aliases: 'ProductCode'
        attribute :created_at, aliases: 'CreationTime'
        attribute :state, aliases: 'Status'
        attribute :usage, aliases: 'Usage'
        attribute :tags, aliases: 'Tags'

        def destroy
          requires :id
          service.delete_snapshot(id)
          true
        end

        def ready?
          state == 'accomplished'
        end

        def save(options = {})
          # raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted?
          requires :volume_id
          options[:name] = name if name
          options[:description] = description if description
          data = Fog::JSON.decode(service.create_snapshot(volume_id, options).body)
          merge_attributes(data)
          true
        end

        def volume
          requires :volume_id
          Fog::Compute::Aliyun::Volumes.new(service: service).all(diskIds: [volume_id])[0]
        end

        private

        def volume=(new_volume)
          self.volume_id = new_volume.id
        end
      end
    end
  end
end

Version data entries

22 entries across 20 versions & 2 rubygems

Version Path
fog-aliyun-0.4.0 lib/fog/aliyun/models/compute/snapshot.rb
fog-aliyun-0.3.19 lib/fog/aliyun/models/compute/snapshot.rb
fog-aliyun-0.3.18 lib/fog/aliyun/models/compute/snapshot.rb
fog-aliyun-0.3.17 lib/fog/aliyun/models/compute/snapshot.rb
fog-aliyun-0.3.16 lib/fog/aliyun/models/compute/snapshot.rb
fog-aliyun-0.3.15 lib/fog/aliyun/models/compute/snapshot.rb
fog-aliyun-0.3.13 lib/fog/aliyun/models/compute/snapshot.rb
fog-aliyun-0.3.12 lib/fog/aliyun/models/compute/snapshot.rb
fog-aliyun-0.3.11 lib/fog/aliyun/models/compute/snapshot.rb
fog-aliyun-0.3.10 lib/fog/aliyun/models/compute/snapshot.rb
fog-aliyun-0.3.9 lib/fog/aliyun/models/compute/snapshot.rb
fog-aliyun-0.3.8 lib/fog/aliyun/models/compute/snapshot.rb
fog-aliyun-0.3.7 lib/fog/aliyun/models/compute/snapshot.rb
fog-aliyun-0.3.6 lib/fog/aliyun/models/compute/snapshot.rb
fog-aliyun-0.3.5 lib/fog/aliyun/models/compute/snapshot.rb
fog-aliyun-0.3.4 lib/fog/aliyun/models/compute/snapshot.rb
fog-aliyun-0.3.3 lib/fog/aliyun/models/compute/snapshot.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-aliyun-0.3.2/lib/fog/aliyun/models/compute/snapshot.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-aliyun-0.3.2/lib/fog/aliyun/models/compute/snapshot.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-aliyun-0.3.2/lib/fog/aliyun/models/compute/snapshot.rb