Sha256: ce894438a18a3ce4077796b1e188c4c25d586e59e785f193a260df80eda1d7b8

Contents?: true

Size: 965 Bytes

Versions: 1

Compression:

Stored size: 965 Bytes

Contents

require File.expand_path('../volume', __FILE__)
require File.expand_path('../../helpers/compute/data_helper', __dir__)

module Fog
  module Compute
    class ProfitBricks
      class Volumes < Fog::Collection
        include Fog::Helpers::ProfitBricks::DataHelper
        model Fog::Compute::ProfitBricks::Volume

        def all(datacenter_id)
          result = service.get_all_volumes(datacenter_id)

          volumes = result.body['items'].each {|volume| volume['datacenter_id'] = datacenter_id}
          result.body['items'] = volumes

          load(result.body['items'].each {|volume| flatten(volume)})
        end

        def get(datacenter_id, volume_id)
          response = service.get_volume(datacenter_id, volume_id)
          volume = response.body

          Excon::Errors
          volume['datacenter_id'] = datacenter_id
          new(flatten(volume))
        rescue Excon::Errors::NotFound
          nil
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fog-profitbricks-2.0.1 lib/fog/profitbricks/models/compute/volumes.rb