Sha256: f59873e4abef5e15c5c7abbe8b99fdb706e9519c9544d3e56a12a4be80c121ff

Contents?: true

Size: 1.17 KB

Versions: 4

Compression:

Stored size: 1.17 KB

Contents

require 'fog/huaweicloud/models/collection'
require 'fog/compute/huaweicloud/models/snapshot'

module Fog
  module Compute
    class HuaweiCloud
      class Snapshots < Fog::HuaweiCloud::Collection
        model Fog::Compute::HuaweiCloud::Snapshot

        def all(options = {})
          if !options.kind_of?(Hash)
            if options
              Fog::Logger.deprecation('Calling HuaweiCloud[:compute].snapshots.all(true) is deprecated, use .snapshots.all')
            else
              Fog::Logger.deprecation('Calling HuaweiCloud[:compute].snapshots.all(false) is deprecated, use .snapshots.summary')
            end
            load_response(service.list_snapshots(options), 'snapshots')
          else
            load_response(service.list_snapshots_detail(options), 'snapshots')
          end
        end

        def summary(options = {})
          load_response(service.list_snapshots(options), 'snapshots')
        end

        def get(snapshot_id)
          if snapshot = service.get_snapshot_details(snapshot_id).body['snapshot']
            new(snapshot)
          end
        rescue Fog::Compute::HuaweiCloud::NotFound
          nil
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fog-huaweicloud-0.0.3 lib/fog/compute/huaweicloud/models/snapshots.rb
fog-huaweicloud-0.0.2 lib/fog/compute/huaweicloud/models/snapshots.rb
fog-huaweicloud-0.1.3 lib/fog/compute/huaweicloud/models/snapshots.rb
fog-huaweicloud-0.1.2 lib/fog/compute/huaweicloud/models/snapshots.rb