Sha256: 1f802a7dcbf26d14430e0c3701dc0cc6e7f5e883dbea38f8ba56c6a1b48a6f02

Contents?: true

Size: 1.3 KB

Versions: 4

Compression:

Stored size: 1.3 KB

Contents

module Fog
  module AWS
    class EC2

      def volumes
        Fog::AWS::EC2::Volumes.new(:connection => self)
      end

      class Volumes < Fog::Collection

        attribute :volume_id

        def initialize(attributes)
          @volume_id ||= []
          super
        end

        def all(volume_id = [])
          data = connection.describe_volumes(volume_id).body
          volumes = Fog::AWS::EC2::Volumes.new({
            :connection => connection,
            :volume_id  => volume_id
          }.merge!(attributes))
          data['volumeSet'].each do |volume|
            volumes << Fog::AWS::EC2::Volume.new({
              :connection => connection,
              :volumes    => self
            }.merge!(volume))
          end
          volumes
        end

        def create(attributes = {})
          volume = new(attributes)
          volume.save
          volume
        end

        def get(volume_id)
          all(volume_id).first
        rescue Fog::Errors::BadRequest
          nil
        end

        def new(attributes = {})
          Fog::AWS::EC2::Volume.new(
            attributes.merge!(
              :connection => connection,
              :volumes    => self
            )
          )
        end

        def reload
          all(volume_id)
        end

      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fog-0.0.13 lib/fog/aws/models/ec2/volumes.rb
fog-0.0.12 lib/fog/aws/models/ec2/volumes.rb
fog-0.0.11 lib/fog/aws/models/ec2/volumes.rb
fog-0.0.10 lib/fog/aws/models/ec2/volumes.rb