File: log_files.rb

package info (click to toggle)
ruby-fog-aws 3.18.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,140 kB
  • sloc: ruby: 73,328; javascript: 14; makefile: 9; sh: 4
file content (47 lines) | stat: -rw-r--r-- 1,404 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
require 'fog/aws/models/rds/log_file'

module Fog
  module AWS
    class RDS
      class LogFiles < Fog::Collection
        attribute :filters
        attribute :rds_id
        model Fog::AWS::RDS::LogFile

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

        # This method deliberately returns only a single page of results
        def all(filters_arg = filters)
          filters.merge!(filters_arg)

          result = service.describe_db_log_files(rds_id, filters).body['DescribeDBLogFilesResult']
          filters[:marker] = result['Marker']
          load(result['DBLogFiles'])
        end

        def each(filters_arg = filters)
          if block_given?
            begin
              page = self.all(filters_arg)
              # We need to explicitly use the base 'each' method here on the page, otherwise we get infinite recursion
              base_each = Fog::Collection.instance_method(:each)
              base_each.bind(page).call { |log_file| yield log_file }
            end while self.filters[:marker]
          end
          self
        end

        def get(file_name=nil)
          if file_name
            matches = self.select {|log_file| log_file.name.upcase == file_name.upcase}
            return matches.first unless matches.empty?
          end
        rescue Fog::AWS::RDS::NotFound
        end
      end
    end
  end
end