Sha256: 1a6c6c4b7eecfe5c7b58f842f90713164fad4407536d2c799687bd546c0e9850

Contents?: true

Size: 1.22 KB

Versions: 12

Compression:

Stored size: 1.22 KB

Contents

require 'fog/core/collection'
require 'fog/aws/models/rds/snapshot'

module Fog
  module AWS
    class RDS

      class Snapshots < Fog::Collection
        attribute :server
        attribute :filters
        model Fog::AWS::RDS::Snapshot

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

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

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

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

      end
    end
  end
end

Version data entries

12 entries across 12 versions & 5 rubygems

Version Path
hpfog-0.0.20 lib/fog/aws/models/rds/snapshots.rb
vagrant-shell-0.2.6 vendor/bundle/gems/fog-1.10.1/lib/fog/aws/models/rds/snapshots.rb
vagrant-shell-0.2.5 vendor/bundle/gems/fog-1.10.1/lib/fog/aws/models/rds/snapshots.rb
fog-1.11.1 lib/fog/aws/models/rds/snapshots.rb
fog-1.11.0 lib/fog/aws/models/rds/snapshots.rb
fog-1.10.1 lib/fog/aws/models/rds/snapshots.rb
fog-test-me-1.10.0 lib/fog/aws/models/rds/snapshots.rb
fog-1.10.0 lib/fog/aws/models/rds/snapshots.rb
fog-1.9.0 lib/fog/aws/models/rds/snapshots.rb
fog-maestrodev-1.8.0.20130114204828 lib/fog/aws/models/rds/snapshots.rb
fog-maestrodev-1.8.0.20130111070250 lib/fog/aws/models/rds/snapshots.rb
fog-maestrodev-1.8.0.20130109172219 lib/fog/aws/models/rds/snapshots.rb