Class: Fog::AWS::Compute::Volumes

Inherits:
Collection
  • Object
show all
Defined in:
lib/fog/aws/models/compute/volumes.rb

Instance Attribute Summary

Attributes inherited from Collection

#connection

Instance Method Summary collapse

Methods inherited from Collection

#clear, #create, #inspect, #load, model, #model, #reload, #table, #to_json

Methods included from Fog::Attributes::ClassMethods

#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes

Methods included from Fog::Attributes::InstanceMethods

#_dump, #attributes, #identity, #identity=, #merge_attributes, #new_record?, #requires

Constructor Details

#initialize(attributes) ⇒ Volumes

Returns a new instance of Volumes.



15
16
17
18
# File 'lib/fog/aws/models/compute/volumes.rb', line 15

def initialize(attributes)
  @filters ||= {}
  super
end

Instance Method Details

#all(filters = @filters) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/fog/aws/models/compute/volumes.rb', line 20

def all(filters = @filters)
  unless filters.is_a?(Hash)
    Formatador.display_line("[yellow][WARN] all with #{filters.class} param is deprecated, use all('volume-id' => []) instead[/] [light_black](#{caller.first})[/]")
    filters = {'volume-id' => [*filters]}
  end
  @filters = filters
  data = connection.describe_volumes(@filters).body
  load(data['volumeSet'])
  if server
    self.replace(self.select {|volume| volume.server_id == server.id})
  end
  self
end

#get(volume_id) ⇒ Object



34
35
36
37
38
# File 'lib/fog/aws/models/compute/volumes.rb', line 34

def get(volume_id)
  if volume_id
    self.class.new(:connection => connection).all('volume-id' => volume_id).first
  end
end

#new(attributes = {}) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/fog/aws/models/compute/volumes.rb', line 40

def new(attributes = {})
  if server
    super({ :server => server }.merge!(attributes))
  else
    super
  end
end