Class: Fog::AWS::RDS::Snapshots

Inherits:
Collection
  • Object
show all
Defined in:
lib/fog/aws/rds/models/snapshots.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) ⇒ Snapshots

Returns a new instance of Snapshots.



13
14
15
16
17
18
19
# File 'lib/fog/aws/rds/models/snapshots.rb', line 13

def initialize(attributes)
  self.filters ||= {}
  if attributes[:server]
    filters[:identifier] = attributes[:server].id
  end
  super
end

Instance Method Details

#all(filters = filters) ⇒ Object



21
22
23
24
25
# File 'lib/fog/aws/rds/models/snapshots.rb', line 21

def all(filters = filters)
  self.filters = filters
  data = connection.describe_db_snapshots(filters).body['DescribeDBSnapshotsResult']['DBSnapshots']
  load(data) # data is an array of attribute hashes
end

#get(identity) ⇒ Object



27
28
29
30
31
32
# File 'lib/fog/aws/rds/models/snapshots.rb', line 27

def get(identity)
  data = connection.describe_db_snapshots(:snapshot_id => identity).body['DescribeDBSnapshotsResult']['DBSnapshots'].first
  new(data) # data is an attribute hash
rescue Fog::AWS::RDS::NotFound
  nil
end

#new(attributes = {}) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/fog/aws/rds/models/snapshots.rb', line 34

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