Sha256: a6e9bf0961e1b46350a010ed74198b0e95737f8d30e11fafd1394b68fbbdc720

Contents?: true

Size: 1.14 KB

Versions: 12

Compression:

Stored size: 1.14 KB

Contents

require 'fog/core/collection'
require 'fog/aws/models/cloud_watch/alarm'

module Fog
  module AWS
    class CloudWatch

      class Alarms < Fog::Collection
        model Fog::AWS::CloudWatch::Alarm

        def all
          data = []
          next_token = nil
          loop do
            result = connection.describe_alarms('NextToken' => next_token).body['DescribeAlarmsResult']
            data += result['MetricAlarms']
            next_token = result['NextToken']
            break if next_token.nil?
          end
          load(data)
        end

        def get(identity)
          data = connection.describe_alarms('AlarmNames' => identity).body['DescribeAlarmsResult']['MetricAlarms'].first
          new(data) unless data.nil?
        end

        #alarm_names is an array of alarm names
        def delete(alarm_names)
          connection.delete_alarms(alarm_names)
          true
        end

        def disable(alarm_names)
          connection.disable_alarm_actions(alarm_names)
          true
        end

        def enable(alarm_names)
          connection.enable_alarm_actions(alarm_names)
          true
        end

      end
    end
  end
end

Version data entries

12 entries across 12 versions & 7 rubygems

Version Path
fog-nirvanix-1.8.2 lib/fog/aws/models/cloud_watch/alarms.rb
fog-nirvanix-1.8.1 lib/fog/aws/models/cloud_watch/alarms.rb
fog-parser-fix-1.6.1 lib/fog/aws/models/cloud_watch/alarms.rb
fog-test-again-1.6.0 lib/fog/aws/models/cloud_watch/alarms.rb
fog-parser-fix-1.6.0 lib/fog/aws/models/cloud_watch/alarms.rb
ey-vendored-backup-3.0.27 vendor/gems/fog/lib/fog/aws/models/cloud_watch/alarms.rb
fog-sgonyea-1.8.1 lib/fog/aws/models/cloud_watch/alarms.rb
fog-1.8.0 lib/fog/aws/models/cloud_watch/alarms.rb
fog-maestrodev-1.7.0.20121114190951 lib/fog/aws/models/cloud_watch/alarms.rb
fog-1.7.0 lib/fog/aws/models/cloud_watch/alarms.rb
fog-1.6.0 lib/fog/aws/models/cloud_watch/alarms.rb
fog-1.5.0 lib/fog/aws/models/cloud_watch/alarms.rb