Sha256: a129ca5142242423e632501f21ce0defcf05b03ccfa2fa7ea205a76e67f4683b

Contents?: true

Size: 1.24 KB

Versions: 22

Compression:

Stored size: 1.24 KB

Contents

# frozen_string_literal: true

require 'fog/core/collection'
require 'fog/aliyun/models/compute/snapshot'

module Fog
  module Compute
    class Aliyun
      class Snapshots < Fog::Collection
        # attribute :filters
        model Fog::Compute::Aliyun::Snapshot

        # def initialize(attributes)
        #   self.filters ||= {}
        #   super
        # end

        def all(filters_arg = {})
          unless filters_arg.is_a?(Hash)
            Fog::Logger.deprecation("all with #{filters_arg.class} param is deprecated, use all('snapshotIds' => []) instead [light_black](#{caller.first})[/]")
            filters_arg = { 'snapshotIds' => [*filters_arg] }
          end
          volume_id = filters_arg[:volume_id]
          volume_type = filters_arg[:volume_type]
          filters_arg[:diskId] = volume_id if volume_id
          filters_arg[:sourseDiskType] = volume_type if volume_type
          data = Fog::JSON.decode(service.list_snapshots(filters_arg).body)['Snapshots']['Snapshot']
          load(data)
        end

        def get(snapshot_id)
          if snapshot_id
            snapshotIds = Array.new(1, snapshot_id)
            self.class.new(service: service).all(snapshotIds: snapshotIds)[0]
          end
        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/snapshots.rb
fog-aliyun-0.3.19 lib/fog/aliyun/models/compute/snapshots.rb
fog-aliyun-0.3.18 lib/fog/aliyun/models/compute/snapshots.rb
fog-aliyun-0.3.17 lib/fog/aliyun/models/compute/snapshots.rb
fog-aliyun-0.3.16 lib/fog/aliyun/models/compute/snapshots.rb
fog-aliyun-0.3.15 lib/fog/aliyun/models/compute/snapshots.rb
fog-aliyun-0.3.13 lib/fog/aliyun/models/compute/snapshots.rb
fog-aliyun-0.3.12 lib/fog/aliyun/models/compute/snapshots.rb
fog-aliyun-0.3.11 lib/fog/aliyun/models/compute/snapshots.rb
fog-aliyun-0.3.10 lib/fog/aliyun/models/compute/snapshots.rb
fog-aliyun-0.3.9 lib/fog/aliyun/models/compute/snapshots.rb
fog-aliyun-0.3.8 lib/fog/aliyun/models/compute/snapshots.rb
fog-aliyun-0.3.7 lib/fog/aliyun/models/compute/snapshots.rb
fog-aliyun-0.3.6 lib/fog/aliyun/models/compute/snapshots.rb
fog-aliyun-0.3.5 lib/fog/aliyun/models/compute/snapshots.rb
fog-aliyun-0.3.4 lib/fog/aliyun/models/compute/snapshots.rb
fog-aliyun-0.3.3 lib/fog/aliyun/models/compute/snapshots.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-aliyun-0.3.2/lib/fog/aliyun/models/compute/snapshots.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-aliyun-0.3.2/lib/fog/aliyun/models/compute/snapshots.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-aliyun-0.3.2/lib/fog/aliyun/models/compute/snapshots.rb